This toturial was written for me by Imran Khan (firstname.lastname@example.org,
3D Rotation :
we will use ' glRotatef ' method for rotation. 'glRotatef ' got 4 arguments , 1 st is the angle of rotation , 2nd is x-axis , 3rd is y-axis,4th is z-axis.
here is the code...
We have just add one line " glRotatef(rtri,0.0f,1.0f,0.0f); " . rtri is an float type variable.We will use this variable so that the pyramid will be in rotation all the time.We only want rotation on Y-axis thats why we pass " 1.0f " in the 3rd argument.
Same as above we add one line for Cube rotation.
We want rotation on X and on Z-axis as well thats why we pass "1.0f" in 2nd and 4th argument.
Now here is the increament and decrement for the 2 variable , " rtri" & "rquad", so that both object remain in rotation.
Simple we increament,decrement everytime when the method run. You can change its value to check the effent.Higer the value more fast it wil rotate.
Here will be the Output.
|Correspondence about this page|
Book Shop - Further reading.
Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.
Commercial Software Shop
Where I can, I have put links to Amazon for commercial software, not directly related to this site, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.
This site may have errors. Don't use for critical systems.