Imagination PowerVR SDK Blog

POD triangle Indice


#1

Dear Team



When the type of export is indexed triangle list or indexed triangle strips ,i wish to get the indice to be able to feed directly my physics engine (build a custom meshes directly from POD) .

i need the indice and the position of each vertex

The section 4.2 of the documentation is quite obscure for me now expcept the default value to set :wink:



for(unsigned int i = 0; i < mesh.nNumFaces * 3; i += 3)

{

unsigned char *pData = mesh.sFaces.pData + i * mesh.sFaces.nStride;

…??

}



in The Shaman Tools all this data are displayed when of course you select the right type during the pod creation

do you have piece of code that build a pod from scratch by an easy way…?



any answer are welcom,



Kind regards

david


#2

One solution is on the old code of the extra package

bool Mesh::ConvertToLines() show the technic



#3

Hi,



In your example code if you change pData to be an unsigned short pointer or unsigned int pointer, depending on whether your POD is using 16-bit or 32-bit indices, will give you your indices ([0],[1],[2]) for face i / 3.



Then, with these indices you can index into mesh.sVertices.pdata or mesh. pInterleaved depending on if your data is non-interleaved or interleaved in a similar way to get your vertex positions.


do you have piece of code that build a pod from scratch by an easy way......?

We provide helper functions for converting the data, interleaving, deinterleaving the vertex data, deindexing as well as other things. Could you elaborate more on what you're trying to achieve?

Thanks,

Scott

#4

Hello Scott



i use obj format to get indice and vertex but to avoid duplication i would to use only POD,be able to create my dynamic mesh from POD only, witch could be a nice connector for external physic engine .Sure there is other format but i am only interested by POD.



The Context :

to create a kind of dynamic shape in bullet you do :

int totalVerts = 633;<br />
btVector3* m_vertices = new btVector3[totalVerts];<br />
int*	gIndices = new int[totalTriangles*3];<br />
btTriangleMesh* trimesh = new btTriangleMesh();<br />
trimesh->addTriangle(<b>btVector3 (-322.567,72.5652,133.36),</b><b>btVector3 (-291.543,73.1621,133.401)</b>,<b>btVector3 (-291.929,72.2013,114.977)</b>); 
```<br />
<br />
etc etc<br />
<br />
<b>The Problem:</b><br />
you must then access to the faces and extract the 3 points sort by indice.the Shaman is displaying this data in the databiewver when you export in index mode of course but getting this data is hot.<br />
<br />
<br />
<b>solution ?<br />
</b><br />
// Triangles a have 3 corners on the whole<br />

unsigned int u32IndexCount = m_psMesh->nNumFaces*3;
unsigned char* pNewIndices = (unsigned char*)malloc(u32IndexCount*sizeof(unsigned char)*2);
unsigned short* pSrcPointer = (unsigned short*)m_psMesh->sFaces.pData,
*pDstPointer = (unsigned short*)pNewIndices;

for(unsigned int i=0;inNumFaces;i++)
{ // tri ABC lines ABBCCA

} ```

how can get the position of A B C ????

regards
david

#5

hi,

everyhting is fine