Advertisement

Making rotations more smooth?

Started by April 24, 2001 09:16 PM
3 comments, last by Jackthemeangiant 23 years, 9 months ago
Hi, I have created a small little 3D engine, based on tutorials 9, and 23. It so far seems fine, except that it isn''t very smooth, unless I update input 100 times a second, and even then it seems a little edgy. My origninal plan was to make it update input 40, or 60 times a second, but everything was not very smooth rotation wasn''t smooth when i did that. The only time i get it fully smooth, is when i set the input to 60+ times a second, and enable vsync. If anyone has any suggestions, please let me know Thanks, Jack
This is how im roughly doing mine in delphi using the windows api:

while GetMessage(Msg,0,0,0) do begin
..TranslateMessage(Msg);
..DispatchMessage(Msg);
..CheckKey;
..DrawScene;
..SwapBuffers(glDC);
end;

This way, the program checks for keypresses every chance it gets, no this doesnt overload the system. CheckKey is a procedure which moves the player according to which keys are being held down, and drawscene, as the name suggests, is a procedure which draws everything in my engine.

of course there is the WndProc function which checks for keypresses:

WM_KEYDOWN: Keys[wParam]:=True;
WM_KEYUP: Keys[wParam]:=False;

not sure why the way you''re doing it doesnt work correctly..

Advertisement
Thanks for replying,

I could make it update every chance that it gets, but the problem with that is, i have to set the movement speed in accordence with the update speed, so it dosn''t move to quickly, or to slow. The problem is, I have to have a timer on the keyboard, so if you run the program on a slower machine, it will run at the same speed as a faster one.


Jack
If you haven''t already read it, you probably should look through the ''constant velocity problem'' posted by broTspinne. He posed a question on a very similar topic.
If I understand you correctly, then the reason why you''re engine is not running smoothly is that you''re only updating positions/rotations several times a second based on when you check the input. For movement, what you can do is specify a velocity, and then update the position every frame based on the simple equation.
x'' = x + v * t
This way, the object will move at the same speed on all computers regardless of the computers speed, because the new position of the object is dependant only on the time between frames.

Hope that helps.
use glut, if you dont know how, go here.

http://home.clara.net/paulyg/ogl.htm
www.EberKain.comThere it is, Television, Look Listen Kneel Pray.

This topic is closed to new replies.

Advertisement