Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

phatslug

2 Mesh Questions

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

1. How do I make the vertex shading of a Mesh work?? This: device->SetVertexShader( mesh->GetFVF() ); doesn''t seem to work. 2. I use this code to Render a mesh to a certain location D3DXMATRIX transMX; D3DXMatrixTranslation(&transMX,x,y,z); device->SetTransform(D3DTS_WORLD,&worldMX); Now... how do I make that mesh rotate? All the code I''ve tried seems pretty good at making the whole world rotate, but I actually want just that mesh, and to have it stay in place. thanks

Share this post


Link to post
Share on other sites
Advertisement
probably it would be better if you would clone the mesh after loading it, this way, you could specify the fvf,

remember the rule in d3d8, when you set something on the device, that state would remain until you change it again, so maybe this is the reason why everything rotates, you forgot to reset/set the matrix for the other objects/models,

Share this post


Link to post
Share on other sites
quote:
1. How do I make the vertex shading of a Mesh work?? This: device->SetVertexShader( mesh->GetFVF() );
doesn''t seem to work.


Assuming you meant using a vertex shader, you need to assemble and create one first. Then you pass the handle recieved from creating it to SetVertexShader, not the fvf of your mesh. When your done, you destroy the shader. You cannot render our mesh using the default DrawSubset. You need to gain access to the vertex and index buffer and render manually.

quote:
2. I use this code to Render a mesh to a certain location
D3DXMATRIX transMX;
D3DXMatrixTranslation(&transMX,x,y,z);
device->SetTransform(D3DTS_WORLD,&worldMX);
Now... how do I make that mesh rotate? All the code I''ve tried seems pretty good at making the whole world rotate, but I actually want just that mesh, and to have it stay in place.

thanks


When setting transforms, whatever you set is used for all objects drawn after it. In order to stop using a transform, create an identity matrix and set it as the transform. Then objects drawn after you set the identity matrix will not be transformed.

---
My Site
Come join us on IRC in #directxdev @ irc.afternet.org

Share this post


Link to post
Share on other sites
hmm... Perhaps Ill hold off on vertex shading for a while if I need to add a bunch more code to render meshes...

but about the rotation, heres the code I use before rendering every mesh

  void CMesh::Render(float x, float y, float z,
float rx, float ry, float rz)
{
HRESULT hr;

D3DXMATRIX transMX, rotMX, worldMX;
D3DXMatrixRotationYawPitchRoll(&rotMX,rx,ry,rz);
D3DXMatrixTranslation(&transMX,x,y,z);
D3DXMatrixMultiply(&worldMX,&transMX,&rotMX);

hr = d3dDevice->SetTransform(D3DTS_WORLD,&worldMX);


The effect that I get is that say when I input a number for say rx, the mesh will rotate so many degrees around the X-Axis. What I want is for it to stay in place and rotate around on its own.

Share this post


Link to post
Share on other sites
I believe it has to do something with the center of the mesh being in the origin of its local coordinate system. But i had the same problem often enough.

Im Anfang war die Tat...
Faust

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!