Jump to content
• Advertisement

Archived

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

How do I render 2 meshes?

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

From the D3D tutorial on the documentation it would seem that I would need 2 devices in order to render 2 different meshes. I think I am wrong, but how else would I do transformation on a single object without it affecting the other? In the code it shows on the tutorial it says that I would do a transformation by calling the D3d device like so: g_pd3dDevice->setTransform( D3DTS_WORLD, &matWorld); because the matrix is named matworld it would seem logical that the code would perform a transformation on the entire world. Would somebody please explain this to me? Also would somebody tell me how I would create a bounding box around a mesh so I can do collisions? Edited by - ManaStone on December 31, 2001 1:03:33 PM

Share this post

Share on other sites
Advertisement
  D3DUtil_SetRotateXMatrix(matRotateX,anglex);D3DUtil_SetRotateYMatrix(matRotateY,angley);D3DUtil_SetRotateZMatrix(matRotateZ,anglez);D3DUtil_SetTranslateMatrix(world, 0.0, 0.0 , 0.0);D3DMath_MatrixMultiply(world,matRotateY,world);D3DMath_MatrixMultiply(world,matRotateZ,world);D3DMath_MatrixMultiply(world,matRotateX,world);D3DUtil_SetTranslateMatrix(matTrans, xpos, ypos , zpos);D3DMath_MatrixMultiply(world,matTrans,world);g_pd3dDevice->SetTransform(D3DTRANSFORMSTATE_WORLD,&world);Mesh->Render(g_pd3dDevice);

Where anglex,angley,anglez are the angles you want your mesh rotated. x,y, and zpos are is the position you want it. Mesh is the mesh you''re rendering. You don''t need more than one device.

Ben

Share this post

Share on other sites
I got an error saying that "Render is not a member of ID3DXMESH"

Share this post

Share on other sites
First, the world matrix isn''t really moving the world. It moves the rendering position. Let''s say you have a cube a 0, 0, 0. You move the world matrix to 1, 1, 1 and the cube will be rendered at 1, 1, 1.

Now if you set the world matrix to the identity matrix(anything times it will equal itself), you won''t move the object. This will solve the problem for rendering other objects.

Create three matrixes. The first will be the world matrix for the first mesh. The second will be the world matrix for the second mesh. The third will be the identity matrix. Fill in the first two and use the D3DXMatrixIdentity function to make an identity matrix for the third. Before you render the first mesh, set the world matrix to the first matrix. Then render. Set the world matrix for the second matrix. Render the second mesh. Then set the world matrix to the third matrix(the identity one). You can now render other objects at their real location.

just set multiple matrixes.

Share this post

Share on other sites
How do I set the first two matrixes to the meshes?

Share this post

Share on other sites
D3DXMatrix meshmatrix1;
D3DXMatrix meshmatrix2;

//set the matrix''s up, like multiply and transform then

device->SetTransform(D3DTS_WORLD, meshmatrix1;
//render the first mesh here

device->SetTransform(D3DTS_WORLD, meshmatrix2;
//render the second mesh here

something like that.

Share this post

Share on other sites
But how do you assign a mesh to a matrix?
Do you typecast it like this:
D3DXMatrix meshmatrix1= Mesh1(*D3DXMatrix);
D3DXMatrix meshmatrix2= Mesh2 (*D3DXMatrix);

Or does it automaticly assign it in the order you load the meshes?

Share this post

Share on other sites
After you set the matrix where you want to position it and everything else, you don''t need to assign anything. Anything drawn after you set the world matrix will be at that position. That is why you must set multiple matrixes, maybe one per object even. If you set an identity matrix, the object won''t move from its original position, usually 0, 0, 0.

Share this post

Share on other sites
OK, thank you very much. When you said render I didn''t think you literally meant render it. I thought you were talking about using

device->SetTransform(D3DTS_WORLD,&worldmesh1);

Thanks again. I don''t know what I''d do without this board.

Share this post

Share on other sites

• Advertisement
• Advertisement

• Popular Contributors

1. 1
2. 2
Rutin
23
3. 3
JoeJ
20
4. 4
5. 5
• Advertisement

• 29
• 40
• 23
• 13
• 13
• Forum Statistics

• Total Topics
631740
• Total Posts
3001962
×

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!