Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Free Up CPU Time, Custom Render Rate, Time Based Movement

Author
Message
Todd Riggins
20
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 12th Feb 2008 07:30
Hopefully, I got it right this time.

Code below demostrates calling dbSync() at a user specific rendering rate( Note: can set anything at or lower then the moniter refresh rate ) and movement based on time itself. Hopefully, this will show smooth 3d movement and also frees up CPU time when expected.

I don't just check how long a single frame takes to then multiply that by movement. Instead, in general, when a movement action takes place, save the current time at start of movement and also save the current position and/or rotation state. Then as the movement action is taken place, we add or subtract the time difference from the saved "timestart", multiply the camera/object's speed to that. Add that result to the saved "starting position/rotation" and then apply that result to the dbPositionObject() and/or dbRotateObject ( or camera equivalent or whatever else equivalent... ). Do that until the movememt action stops. Once a movement action starts again, we do all of above again.

Ok, mabie I cant explain things well...

Code below should show ya what I did to abtain "smoother" 3d movement. I still think there is a slight "jittering" of movement. Though my eyes are getting tired right now... I could be seeing things.

If you indeed see annoying jittering, please do tell. IF you can make this any smoother, please do share.

Hopefully you likes, enjoy


Inspirational Music: Descent ][ Redbook Audio CD Soundtrack
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 12th Feb 2008 12:20
As this doesn't actually free up CPU time (the loop will still execute as fast as it can) I'd recommend using Sleep to free up unused CPU time when possible.

Todd Riggins
20
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 12th Feb 2008 21:27
Your absolutely right Benjamin. That is what I meant instead as like you said, the looping will execute as fast as it can instead of locking at a given refresh rate. Somehow I wrongly equated that with freeing of CPU time in which has nothing to do with what Im trying to achieve. sorry.

I guess if I could change the title of the post... it would be:
"Free Up Loop Time, Custom Render Rate, Time Based Movement"

Inspirational Music: Descent ][ Redbook Audio CD Soundtrack

Login to post a reply

Server time is: 2024-11-20 01:22:05
Your offset time is: 2024-11-20 01:22:05