D3DXMatrix questions
Hi,
I got simple questions. In the SDK samples (DX8), to demonstrate the way to use D3DXMatrixRotation, they use it with TimeGetTime() / 1000.0f.. This is the rotation angle (in radian); but why is it needed to use timeGetTime(). Can''t we just give an angle (in degrees used with D3DXToRadian()) ?
Indeed, I made a simple model viewer. I would like to rotate the model by pressing a key, and, when the user stops pressing, the rotation stops. I tried with various angles, but, either it''s much too fast, either it never stops... Could anyone give me the way to do this correctly ?
And in a first person view game, what does really move? Is it just the camera or the character and the camera (which is located about character''s head)?
Thank you
NONO
By using timeGetTime() /1000.0f you get an absolute time refernce. This means the object will spin at the same rate on all computers, at all framerates.
Instead of feeding radians to the the rotate functions, you take your angular rotation velocity and multiple by the time to get the current orientation.
So if you wanted something to spin at 2 rpm:
//dps: degrees per second
//w dps = 2rpm * 60 rev/sec * 360 degree/rev
float w_dps = 2.0f / 60.0f * 360.0f;
float t_sec = timeGetTime() / 1000.0f;
float theta_d = w_dps * t_sec;
Now, instead of change the theta with the arrow keys, you can incrementally change w_dps.
It depends on the particulars of the game, but generally you need to move the camera & the character.
Magmai Kai Holmlor
- The disgruntled & disillusioned
Instead of feeding radians to the the rotate functions, you take your angular rotation velocity and multiple by the time to get the current orientation.
So if you wanted something to spin at 2 rpm:
//dps: degrees per second
//w dps = 2rpm * 60 rev/sec * 360 degree/rev
float w_dps = 2.0f / 60.0f * 360.0f;
float t_sec = timeGetTime() / 1000.0f;
float theta_d = w_dps * t_sec;
Now, instead of change the theta with the arrow keys, you can incrementally change w_dps.
It depends on the particulars of the game, but generally you need to move the camera & the character.
Magmai Kai Holmlor
- The disgruntled & disillusioned
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement