Please help me

Started by
15 comments, last by Sam Gamgee 23 years ago
I don''t have a clue of how direct3d does the transformation stuff, but if it''s like opengl (glRotate*(), glTranslate*())
Check to see that you do rotate the scene BEFORE translating it, the symptom described seems like you translate the scene first, and then rotate it. wich will not work very good, since when you rotate the scene you will rotate around an axis that is positioned behind/before to the left/right of you.


return 1;
Advertisement
Hi,

Here is the code that rotates and transforms the matrix:

...
D3DXMATRIX matWorld,matWorld2;

D3DXMatrixRotationX( &matWorld, W.WorldAngle.x);
D3DXMatrixRotationY( &matWorld2, W.WorldAngle.y);

// now multiply the two matricies together:
D3DXMatrixMultiply(&matWorld,&matWorld,&matWorld2);

D3DXMatrixRotationZ( &matWorld2, W.WorldAngle.z);

// then multiply again:
D3DXMatrixMultiply(&matWorld,&matWorld,&matWorld2);

// Now that we have the rotations, we need to get the position
D3DXMatrixTranslation(&matWorld2,W.WorldPos.x,W.WorldPos.y,W.WorldPos.z);

D3DXMatrixMultiply(&matWorld,&matWorld2,&matWorld);

g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
...

Then the code goes on to actually rendering the world. Is this what you wanted?

I still don''t understand what could be wrong!

I also checked out NeXe, but he''s not up to the tutorial that I need...but I''ll keep checking.


-Sam.
No, I don''t need to know what you do with your world matrix, just what you do with your view matrix. The view matrix defines the camera''s position. You do move the camera, don''t you? Or do you move the entire world instead? Meaning, when the user presses a key, do you change World.x or Camera.x?

~CGameProgrammer( );

~CGameProgrammer( );Developer Image Exchange -- New Features: Upload screenshots of your games (size is unlimited) and upload the game itself (up to 10MB). Free. No registration needed.
Sorry ''bout that. Actually I don''t change the view matrix at all...I move the whole world around.

However, while I was looking through flipcode.com, I saw another post about someone else having a similar problem. I read throught the post, and modified some code that someone else posted as a solution. So anyway I modified it, then put it in my engine, and everything works now!

The below code works...maybe it will help someone:

Level1.Level.MeshPos.x += (float)sin(Level1.Level.MeshAngle.y)*0.005f;
Level1.Level.MeshPos.z -= (float)cos(Level1.Level.MeshAngle.y)*0.005f;


That works fine for moving forward, and it''s the opposite for moving backward!

Thanks again for all the help you''ve given me!

-Sam.
Good to hear you''ve fixed it... I didn''t get a chance to help or I would''ve hehe.

Oh, By the way, For anyone learning DirectX, the nexe site is at http://nexe.gamedev.net

They don''t actually have lesson 10 ported yet, but its a site worth keeping your eye on.

~Cobra~
"Build a man a fire, and he will be warm for a day. Set a man on fire, and he will have warmth for the rest of his life"
hi
i have a similar problem.
the following code works (its of one of nehe''s tutorials)

xpos+=(float)cos(zrotate*0.0174532925)*0.05;
ypos+=(float)sin(zrotate*0.0174532925)*0.05;

but this code doesn''t work:

xpos+=(float)cos(zrotate)*0.05;
ypos+=(float)sin(zrotate)*0.05;

if i use this code the cube i''m controling does not move in the right angle.
i really don''t have any idea why it does not work.

cu ][nika][

I think (I may be wrong) the answer to your problem is as follows. The sin() and cos() functions take there inputs in radians. However OpenGL uses degrees. So when you times your degrees by 0.0174532925f, you convert the degrees into radians.

However DX8 takes radians...that''s why I don''t have to do this is the code I gave in my last post.

I could be wrong.

-Sam.

This topic is closed to new replies.

Advertisement