Sign in to follow this  

Ticking movement

This topic is 3580 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I'm trying to get an accurate account of the time passed rendering each frame - so that I can scale my translations. I currently have, as a timer, this:
class pixieTimer
{
protected:
//---Vars----------------------------------------------------------------------------------------------------------
	LARGE_INTEGER m_iFrequency;
	LARGE_INTEGER m_iLastQuery;
	LARGE_INTEGER m_iDelta;
public:
	pixieTimer()
	{
	}

	~pixieTimer()
	{
	}
//-----------------------------------------------------------------------------------------------------------------

	void Init() 
	{
		QueryPerformanceFrequency(&m_iFrequency);
		Update();
	}

	void Update() 
	{
		LARGE_INTEGER kTempTimer;
		QueryPerformanceCounter(&kTempTimer);
		m_iDelta.QuadPart = kTempTimer.QuadPart - m_iLastQuery.QuadPart;
		m_iLastQuery.QuadPart = kTempTimer.QuadPart;
	}

	double GetDeltaSeconds() 
	{
		return (double)(m_iDelta.QuadPart) / (double)(m_iFrequency.QuadPart);
	}

	double GetDeltaMillis() 
	{
		return (double)(m_iDelta.QuadPart) / (double)(m_iFrequency.QuadPart) * 1000;
	}
      

};


Then, if I run the code:
		static float index = 0; 
		index += 1 * (float)PD->GetDelta(); //PD->GetDelta() equates to pixieTimer->GetDeltaMillis()
		D3DXMATRIX matRotateY;    
		D3DXMatrixRotationY(&matRotateY, index);
		PD->GetDirectXDevice()->SetTransform(D3DTS_WORLD, &(matRotateY));


The result is not a steady rotation, rather the rotation appears static. I am updating the timer once every frame, just before BeginScene. I should mention that the mesh is rotated when it is first rendered( when, it should face entirely forward ), but it doesn't appear to rotate after that. I used this as a reference: http://www.gamedev.net/community/forums/topic.asp?topic_id=113457&whichpage=1򕌅 I did try before hand to do something with GetTickCount(), but after reading around it seems that this is the most appropriate way to do it. I just can't seem to get it to work correctly. Thanks.

Share this post


Link to post
Share on other sites
if your only drawing 1 quad on the screen, your frame time might be so small it's truncating it when you cast it as a float, so it's not signficant enough to cause movement.

also why do you have index += 1 * (the 1 isn't doing anything)

also if you are trying to get a rotation amount, your setting index=0 every frame and just adding the time difference, your not actually increase the actual rotation of the object. You need to store the heading/rotation of the object and keep adding to it every frame, so make it a global or make a class etc.

only other thing I can recommend is write it to the screen, or artificially increase the amount (*100x fold, etc to make sure it does infact have a value already)

Share this post


Link to post
Share on other sites

This topic is 3580 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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