Jump to content
  • Advertisement
Sign in to follow this  
zenidon

Rotating an ".x" mesh

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

Hello, I am new to directx programming and have a basic program that loads a .x mesh, moves it around the screen and rotates (a screen saver). My problem is when it rotates, the back half of the mesh doesn't appear to exist. The front side rotates and displays correctly, but when the object starts to go toward the back side the object gets slimmer and slimmer, disappears for a microseconds and starts to display again. I am doing the rotation though the simple RotationY matrix in the world transform. Any thoughs? Thank you! --Gavin

Share this post


Link to post
Share on other sites
Advertisement
My first guess is that your model is quite big and the far-plane value you
entered in your projection matrix is relativly small to your model,meaning that there are vertices in your model that exceed the far-plane so they are clipped out of sight.

Try increasing the Z value of your far-plane :
if you're using D3DXMatrixPerspectiveFovLH , its the last value;

Share this post


Link to post
Share on other sites
roty is a float that goes between 0.0 and 6.28. That value goes up and down on every iteration.

D3DXMatrixRotationY(&ypr_mat,roty);
D3DXMatrixTranslation(&smarty_mat,0,0,50.0f);
m_pd3dDevice->SetTransform(D3DTS_WORLD, &(smarty_mat + ypr_mat));

Is this what you are looking for?

Thanks!

Share this post


Link to post
Share on other sites
Quote:
Original post by Xsy
My first guess is that your model is quite big and the far-plane value you
entered in your projection matrix is relativly small to your model,meaning that there are vertices in your model that exceed the far-plane so they are clipped out of sight.

Try increasing the Z value of your far-plane :
if you're using D3DXMatrixPerspectiveFovLH , its the last value;


My Z value is 1000, and the model sits at -100, so I don't think that's it.

--Gavin

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
You can't add matrices like that and get the effect you want. You probably want to multiply the two matrices instead.


That was it...I know I am supposed to multiply the matrix's. I just ended up fat-fingering the plus.

Thanks for the quick response!

--Gavin

Share this post


Link to post
Share on other sites
One last question, and I think it's been addressed before. How do I rotate the mesh, then place it on the world space? when I run it now, because the Y placement moves, the rotation actually moves the model on the Z access as well.

Thanks!

--Gavin

Share this post


Link to post
Share on other sites
Quote:
Original post by zenidon
One last question, and I think it's been addressed before. How do I rotate the mesh, then place it on the world space? when I run it now, because the Y placement moves, the rotation actually moves the model on the Z access as well.

Thanks!

--Gavin
Multiply the matrices in the inverse order:
m_pd3dDevice->SetTransform(D3DTS_WORLD, &(ypr_mat * smarty_mat));

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Quote:
Original post by zenidon
One last question, and I think it's been addressed before. How do I rotate the mesh, then place it on the world space? when I run it now, because the Y placement moves, the rotation actually moves the model on the Z access as well.

Thanks!

--Gavin
Multiply the matrices in the inverse order:
m_pd3dDevice->SetTransform(D3DTS_WORLD, &(ypr_mat * smarty_mat));


That's the trick! Thanks all!

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!