Camera/model rotation help !

Started by
2 comments, last by Tenshi_rdk 17 years, 6 months ago
I just cannot get my camera to point the way to the model as i want... At the moment my camera is UNDER my character and if i adjust the up , eye and look at values it just does weird stuff... i want to rotate my model and look at it from the side and upright.like a platform game walking char. this is my matrixes..help me please / Sets up the camera 1000 units back looking at the origin. D3DXMATRIX V; D3DXMatrixIdentity(&V); D3DXVECTOR3 pos(0.0f, 0.0f, -1000.0f); D3DXVECTOR3 up(0.0f, 1.0f, 0.0f); //to rotate VIEW ANGLE D3DXVECTOR3 target(0.0f, 0.0f, 0.0f); D3DXMatrixLookAtLH( &V, &pos, &target, &up ); //FOR SOME REASON THIS DOES NOT WORK ??? //This makes the model rotate Y //D3DXMatrixRotationY( &V, D3DXToRadian(fAngle)); //This makes the model rotate X //D3DXMatrixRotationX( &V, D3DXToRadian(fAngle2)); //This makes the model rotate Z //D3DXMatrixRotationZ( &V, D3DXToRadian(fAngle3)); HR(gd3dDevice->SetTransform(D3DTS_WORLD, &V)); HR(gd3dDevice->SetTransform(D3DTS_VIEW, &V)); The middel part of code has no response what so ever.. any clues ?? even id i adjust the angles...
Advertisement
Quote:The middel part of code has no response what so ever.. any clues ??


Could it be because the middle part is completely commented out? Or is that post-op?
http://blog.protonovus.com/
D3DXMatrixRotationY(), D3DXMatrixRotationX(), and D3DXMatrixRotationZ() replace the contents of the matrix you pass to them.

You need to multiply/concatenate the matrices:

D3DXMATRIX v;D3DXMatrixLookAtLH( &v, &pos, &target, &up );D3DXMATRIX temp;D3DXMatrixRotationY( &temp, D3DXToRadian(fAngle));D3DXMatrixMultiply( &v, &v, &temp );D3DXMatrixRotationX( &temp, D3DXToRadian(fAngle2));D3DXMatrixMultiply( &v, &v, &temp );D3DXMatrixRotationZ( &temp, D3DXToRadian(fAngle3));D3DXMatrixMultiply( &v, &v, &temp );


Beware that matrix multiplication isn't commutative (A*B will give a different result to B*A) so you may need to reverse the order of the last two arguments for each D3DXMatrixMultiply() depending on what you're trying to achieve.

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

EXCELLENT ! thanks , i had NO IDEA the matrix was being replaced , thanks a million ! works like a charm now ! :)

This topic is closed to new replies.

Advertisement