Jump to content
  • Advertisement
Sign in to follow this  
nerditup

Rendering 3D Meshes and... Objects that Aren't Meshes At the Same Time

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

You know those cube's you draw in many tutorials by setting the vertices, and the meshes you import as .x files. I was wondering, how would I go about and do somethign like this, would I need to create a second d3d Device for the two, or just use the same one? How would I set the two FVF's at the same time? I haven't attempted this yet but I have been going through it on paper first, and wondering how it would work. Does anyone have any tutorials?

Share this post


Link to post
Share on other sites
Advertisement
You need only a single device. There really are not very many circumstances where you ever need more than one.

You cannot "set two FVF's at the same time." What you can do, is set up the state (FVF, textures, et cetera) for one mesh and then draw it. Then, you set up the state for the second mesh (different FVF, textures, et cetera) and draw that. You can extend this to an arbitrary number of different meshes.

There are plenty of tutorials available if you Google. While some of them may address some of the critical misunderstandings you seem to have, I doubt any of them will address your specific question. By their nature, tutorials are generally quite simplistic (which is one of the reasons they can actually be very poor learning aids); actual application or extension of the presented topic is left "as an exercise for the reader" (you). Since rendering multiple meshes in a scene is a trivial extension of rendering a single mesh (in the simple case), you're unlikely to find a tutorial geared specifically at "rendering two meshes." However there are some tutorials out there that do render two meshes (though that's not their main goal). Once again, Google should help you out; just search for DirectX tutorials.

Share this post


Link to post
Share on other sites
It should not be very difficoult.
We will suppose g_pVertexBuffer is our vertex buffer for a quad.
g_pMesh is our mesh to render.
Look at this scheme of render function


1. Clear of the scene device->Clear(...);
2. Begin Scene device->BeginScene();
3. Set FVF device->SetFVF(...);
4 Set Vertex Buffer to draw device->setstreamsource(...);
5. Set the WorldMatrix in an x position (Use D3DXMatrixTranslation);
6. Set Matrix into current device device->setMatrix(D3DTS_WORLD,...);
7. Call DrawPrimitive device->drawprimitive(...);
8. Set new world matrix for mesh device->setmatrix(D3DTS_WORLD,...);
9. Draw the mesh with subsets


In this mode you should see a primitive and a mesh rendered togheter!

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!