Jump to content
  • Advertisement
Sign in to follow this  
nananya

world rotation question...

This topic is 2891 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

D3DXMatrixRotationY( &matTrans2, rotX );
D3DXMatrixMultiply(&matWorld2,&matWorld2,&matTrans2 );
D3DXMatrixTranslation(&matTrans2,transX,transY,transZ );
D3DXMatrixMultiply(&matWorld2,&matWorld2,&matTrans2 );
pd3dDevice->SetTransform(D3DTS_WORLD, &matWorld2);
//player x file


Before rotation:
game1.jpg

After Rotation:
game2.jpg
just as the above picture show...i wan to keep direction Z is same as the direction my character facing to...
but using the code above i only can rotate my character,cannot rotate the world coordinate...so i wan to ask is there anyone can help me to solve this question?

Share this post


Link to post
Share on other sites
Advertisement
It's not clear exactly what you want to do, I'm afraid. You can't "rotate" the world. You must rotate objects (such as the camera, your player, etc.) within the world.

Can you explain a little more about what you want to do?

Share this post


Link to post
Share on other sites
actually u get what i want to do...i want to rotate the world coordinate system...making direction X and Z to change every time i rotate my character.
I want to make a game use up arrow key to move in front...
and when my character rotate, i wish to make it walk in front to the direction where it facing to.
That mean the character can only walk in front to where it is facing...
If cannot rotate the world coordinate system is there any other choice to make it?

Share this post


Link to post
Share on other sites
You need variables for the character's position and direction. When you press the up arrow key, the character's new position will be:

// speed is a float for how far you want the character to move when you press the arrow key
character_position += speed * character_direction;

When you rotate your character, change the character_direction and normalize it. You need to normalize it ( like D3DXVec3Normalize(&character_direction,&character_direction) ) so the equation above will move the character consistently.

Share this post


Link to post
Share on other sites
Thank you for reply...but i still got 1 question to ask...
how to set the character_direction?i didnt learn it before...is it any tutorial?

Share this post


Link to post
Share on other sites

Thank you for reply...but i still got 1 question to ask...
how to set the character_direction?i didnt learn it before...is it any tutorial?

Generally speaking, if you have a transform matrix for an object, you have the direction vectors as well (they will be the first three rows of the matrix, assuming row-vector convention).

There can be situations where you need a direction vector other than those encoded in the transform matrix, such as for typical FPS-style movement; in those cases, the required direction vector can computed using simple trigonometry.

Share this post


Link to post
Share on other sites
hmm...tat means the Direction Matrix is transX,transY and transZ in the code i given above?
or is the &matWorld2 will be the Direction Matrix?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!