Jump to content
  • Advertisement


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


Drawing a triangle on a x-file face

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

Hi, OK, I wrote the next code to extract the vertex data from my x-file: #define Maxfaces 100 // I know my mesh has 100 faces D3DXVECTOR3 v1[Maxfaces], v2[Maxfaces], v3[Maxfaces]; . . . // Get the buffers pMesh->GetIndexBuffer(&pIB); pMesh->GetVertexBuffer(&pVB); // Get face and vertex count numFaces = pMesh->GetNumFaces(); numVertices = pMesh->GetNumVertices(); CUSTOMVERTEX *pVertices; WORD* pIndices; pMesh->LockIndexBuffer(0L, (VOID**)&pIndices); pMesh->LockVertexBuffer(D3DLOCK_DISCARD,(VOID**)&pVertices); for (DWORD face=0; faceUnlockVertexBuffer(); pMesh->UnlockIndexBuffer(); . . . I don''t have experience in D3D (normally I use OpenGL), so I thought to store the position data in 3 arrays (v1, v2 and v3). Please, I would like to have your opnions about a better way to make this. My question is very simple: How to draw the triangle (face) composed, for example, by v1[10], v2[10] and v3[10]? In OGL it is very easy to make this, but in DX the process seems be more complicated... Another question: Is it a good idea to lock/unlock buffer in the render process? Thanks for your attention... and patience

Share this post

Link to post
Share on other sites
in OGL triangles are usually drawn 1by1.. in DX we use these vertex&index buffers.

I guess you only want to draw some of the triangles in your mesh and not the whole mesh?

!!! Use the same vertexbuffer you allready have. no point duplicating/extracting vertices from your mesh. they are allready in memory.

1. create a second index buffer
2. fill this second index buffer with triangles you want to draw
3. call SetStreamSource(yourvertexbuffer)
4. call SetIndices(the second indexbuffer)
5. call DrawIndexedPrimitive

in DX it is very slow to render one triangle at time. use those buffers.. read this Terrain Tutorial

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.

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

Sign me up!