Advertisement

What is the need to increase/decrease the rotation variable?

Started by March 13, 2003 01:35 AM
4 comments, last by inrecovery 21 years, 11 months ago
Call me stupid here, but I am unable to comprehend why one needs to increase/decrease the rotation angle to make the triangle/quad spin about the desired axis! Why can''t we just set the variables once? Drawing an analogy here, a fan runs at the speed you set it to, no matter how many times, its switched on or off. Once I comment out the lines to increase/decrease the variables,I get a static object.why is that? The code mandates that the triangle/quad be rotated...but they aren''t!!! Why? Am I missing something here? "Recovering Thinker" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I''ve learned that you can get by on charm for about fifteen minutes. After that, you''d better have a big willie or huge boobs. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
What's happening is that the object itself does not "remember" where you have rotated it. Each frame, the object is back to it's original position. So if you need the fan to rotate, you must tell it that it is at a different angle each frame.

Doing a rotate only determines how an object is drawn on the screen for the current frame only. (Or as long as the current transform is in effect)

That's the short explanation.

[edited by - Nypyren on March 13, 2003 4:06:28 AM]
Advertisement
I get that now.. but I need to ask another question and I am sure that this is very stupid of me BUT I am a learner:
when you say: current frame, what do you mean>?

quote:

Doing a rotate only determines how an object is drawn on the screen for the current frame only. (Or as long as the current transform is in effect)


1)How long does the *current frame* last?I mean how many times is a frame drawn?Is there a rate?
2)Does this depend on the refresh rate of the monitor?
As I understand(very little, I must admit),DrawGLScene() will be called by WinMain() till the time that the *active* variable is set to true.But teh question is how many times?The number of times will determine the number of times the frame has to be redrawn? Is that correct?
3)How many times is the DrawGLScene() actually called?






[edited by - inrecovery on March 13, 2003 5:19:19 AM]
In OpenGL you specify the rotation by calling glRotatef or glRotated or by multiplying a matrix. Normally render code consists of this

(global render)
Clear screen and depth buffer
Clear matrices
Set Camera
Render Objects
Swap buffers if neccesary

(object render)
Push matrix
Set object matrix
Draw Object
Pop matrix

If you managed to follow that, you probably didn''t. You''ll see that every tiem you get to render object the matrix has been cleared. This means that you have to put the old rotation in AND also any additional rotation. I think Nypyren failed in his explanation, no offense, when he said frame. You see the rotation, the matrix, that is in effect just before you render the object is what effects the position and rotation of the object. If you clear the matrix then you no longer remember the old rotation/translation/scaling etc. Think of it like this

Clear matrix //matrix is currently empty
Set object rotation to 0,1,0 //we now have a rotation matrix
Render object

Every time this is called the object is cleared and rotation set to 0,1,0. So EVERY time the matrix that is used to render the object is the same.


If you didn''t understand a word I just said then just ignore it and go to www.gametutorials and do all the OpenGL tutorials there. You''ll get it after that.
I think I get it now....
But I think I raised another question in my post and now I am really interested in knowing the answer to that one...
The time to render a frame is referred to as ''frametime''. Using this you can calculate frames per second(FPS), but there are alternate ways to do it(no multiplication). This depends on the speed of your computer, what video card you have, ect. Of course to get either of these values, you must have a timer based system; there are plenty of posts about that.

If VSync is on, yes frametime is directly related to the refresh rate of your monitor. That is why you see your FPS capped at 60, 85, or whatever your monitor refresh rate is at. Most people disable VSync so you can''t count on that for timing.

To compensate for this fluncuation in the framerate/time, most people multiply their translation/rotations by the framerate, this causes the scene to update at the same speed no matter what system it is running on. Of course when you get into more complex effects, you must devise more complicated schemes.

DrawScene is called once per frame. Basically as often and fast as it can be. BTW, a ''frame'' is an update to the screen. Whenever anything is drawn, it is a frame. Think about VHS movies.

This topic is closed to new replies.

Advertisement