Sign in to follow this  
luckyyyyyy

calculate the time... traslation of object 5mm in 1 sec..

Recommended Posts

luckyyyyyy    145
Hi guys..

I am stuck at this point... I couldn't figure it out how to calculate the feedrate and how can I impliment. I have tried alot but now don't know what to do..

Actually the problem is .. I want to translate one object that will cover 5.555 mm in 1 sec.. so it means that 100mm in 18 sec..
I have obtained the results that is 100mm in 18sec but when the fps is 59...

but when I start my simulation, the fps goes to 14... then the object moves very slowly, it does not covers 100mm in 18 sec.. it takes too much time..

my code is..





[code]
void ModelRotation_IdleFunc(void)
{
CurrentTime = clock();
float timeInterval = CurrentTime - PreviousTime;

C_TOOL_X += (5.5555f/(1000.0*3.24*timeInterval*0.001f));

if(C_TOOL_X > 100.0)
C_TOOL_X = C_TOOL_X - 100.0;

PreviousTime = CurrentTime;

glutPostRedisplay();
}
[/code]


kindly guide me how can i do this... I think fps must be considered in my code.. but how ?

Share this post


Link to post
Share on other sites
the_visualist    188
A basic fps independent movementspeed example:
[code]float stepsize = elapsedTimeSinceLastFrame * speed;
position += stepsize;
[/code]
This example does work, just try to adjust it so it fits your x meter / second.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this