Skip to main content
gamedev.net
🔒 Locked

simple question, simple answer

Started by malyskolacek Oct 6, 2001 at 8:54 AM 2 replies 150+ views
Original Post
malyskolacek
malyskolacek
How can I get a polygon from a mesh? I thought I take vertexbuffer for it and every 3 vertices make up a polygon: //FVF is (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1) //m3dData is of type VERTEX3D {D3DXVECTOR3 position,normal; D3DXVECTOR2 texture;} //ppData is VOID* m_pMesh->LockVertexBuffer(0,(BYTE**)&ppData); memcpy(m3dData,ppData,mMesh->sizeOfVertex); m_pMesh->UnlockVertexBuffer(); for (DWORD counter=0;counterGetNumVertices();counter+=3) { m3dData[counter].position; //first vertex of polygon m3dData[counter+1].position; //second one m3dData[counter+2].position; //third one } But I''m not sure if this is right. Can anybody validate or refute this? Thanks
Tessellator
Tessellator
Hi,

Thats ok as long as the entire mesh is made up individual triangles. In other words it does not have a set of indices to draw the tris.

T
malyskolacek
malyskolacek
Another question: how to get perpendicular vector to face(normal)defined with three vertices?

Edited by - malyskolacek on October 6, 2001 11:34:38 AM
AndyTX
AndyTX
Cross product. You only need two vectors to define the face.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.