Advertisement

Jerky Movement

Started by January 10, 2003 10:07 AM
6 comments, last by CharletMoser 22 years, 1 month ago
Hi there, I made a small GL engine based upon NeHe''s #10 lesson. Nothing special, just moving over a terrain which is constructed by 8000+ polys and one texture. I also included Y axis movement just like a chopper for fun. I used glTranslate/glRotate, a display list, and made a simple fps counter. My "machine" is a 435 Mhz PII with an GeForce card with 32Mb, hardware accel. My problem is when rotating the scene, the movement is jerky. I can decrease the rotation step angle then it''s not so jerky but rather slow. I changed the WM_KEYDOWN/WM_KEYUP thing to GetKeyState (...) && ... but not much better. The fps shows 80-150. I did the whole thing in Win32Asm. How can I get rid of this jerky rotation? All comments would be highly appreciated. Thx CM High in the sky, what do you see? Come down to Earth, a cup of tea Flying saucer, flying teacup From outer space, Flying Teapot
;---------------------------------High in the sky, what do you see? Come down to Earth, a cup of tea Flying saucer, flying teacup From outer space, Flying Teapot;-----------------------------------
Question have you multiplied the movement/rotation distance with the frame time(1/fps).

if not then do so, then it will move/turn the specified distance/angle per second over the second, and not the whole lump sum in one chunk, thus making the movement/rotation smoother.

Well that''s the theory anyway.
It works well for me, sometimes i go from 5Kp to 30Kp and it''s still smooth(sorta).
Advertisement
Maybe you''re only rotating when the key is pressed or when you get key messages (i.e. the hardware "repeats" the key for you while the key is held down). I''m not sure how you''re using GetKeyState, but make sure you do the rotation every frame. For example, have a boolean for LeftKeyDown, RightKeyDown, etc. Set it true when the key is pressed down and false when the key is released. Then you can rotate every frame depending on if the key is pressed. Hope this helps.

Firebird Entertainment
“[The clergy] believe that any portion of power confided to me, will be exerted in opposition to their schemes. And they believe rightly: for I have sworn upon the altar of God, eternal hostility against every form of tyranny over the mind of man” - Thomas Jefferson
Um maybe it is just lag. 8000 polys all at once is kinda a bit. Maybe you would benefit from some more culling sechniques.
80-150 in FPS produces no lag.

i sometime run my engine with over 30000 polygons and i still get 99 FPS(currently i only have two digit''s so it maxes out on 99)
Do u just rotate by n degrees per second everytime u press the turn key???

Sometimes animation appears jerky because ur animation is idle, then suddenly when u press the turn key ur scene starts rotating suddenly at a fix rate. How about implementing some acceleration in ur turning. So when u press ur turn key start u rotating slowly, but increase the rotation speed the longer u hold down ur turn key. I think this will trick the brains of ur game players and make ''em think ur animation is soooooooooooooooooo smooth.
:)
Advertisement
A big thank you to all for the help!

Unfortunately, I haven''t been able to do anything useful coz of my exams. However, there some points which aren''t quite clear enough for me. I''m just a beginner in this engine stuff and I''m not so familiar with the expressions around it.

lc_overlord: what does it mean ''multiplied the movement/rotation distance with the frame time(1/fps)''? You mentioned ''the theory'' where can I find anything on it?

The Keyboard procedure is in the WndProc, checks the keyboard if there is no WM_... to process. The DrawScene proc is also in the WndProc. If the key is pressed then it adds/subtracts a value from a variable used by the glRotate function in the DrawScene.

;the keyboard bit
.
.
.

invoke GetKeyState (VK_RIGHT)
and eax,80h
.if (eax);if pressed
fld RotAngle
fadd Step ;this is the value,global variable
fstp RotAngle
.endif

invoke GetKeyState (VK_LEFT)
and eax,80h
.if (eax);if pressed
fld RotAngle
fsub Step
fstp RotAngle
.endif

.
.
.
ret

;the drawscene bit
invoke glRotatef,RotAngle,Fnull,Fone,Fnull ;Fnull:global floats
...

I tried it with a simple textured box and it was swimming around smoothly.

I thought I should draw only the necessary polys on screen which I could see from that point (maybe this is the thing called culling). But no idea how to do it.Any advice?

Yau: I will try to increase rotation angle gradually.Thx for the advice.

Thx

CM

;---------------------------------
High in the sky, what do you see?
Come down to Earth, a cup of tea
Flying saucer, flying teacup
From outer space, Flying Teapot
;-----------------------------------
;---------------------------------High in the sky, what do you see? Come down to Earth, a cup of tea Flying saucer, flying teacup From outer space, Flying Teapot;-----------------------------------
Well, lets say your running at 80 fps and you want to rotate in around 90 degrees per second whatever the load is.

then the RotAngle +=90/80;
that would make 1,125 degrees per frame

This topic is closed to new replies.

Advertisement