# extracting vertex data from a pod-scene

**URL:** <https://forums.imgtec.com/t/extracting-vertex-data-from-a-pod-scene/808>\
**Category:** PowerVR Insider\
**Created:** [August 19, 2010, 11:37am UTC](https://forums.imgtec.com/t/extracting-vertex-data-from-a-pod-scene/808 "2010-08-19T11:37:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kellogs](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/kellogs/32/83_2.png) [@kellogs](https://forums.imgtec.com/u/kellogs)\
**Post date:** [August 19, 2010, 11:37am UTC](https://forums.imgtec.com/t/extracting-vertex-data-from-a-pod-scene/808/1 "2010-08-19T11:37:29Z")

</div>

Hello,  
  
While attempting to retrieve the 3 vertices for each polygon in a scene I always get a SIGSEGV on the indicated line. How does one correctly retrievev such information ?

Code:

  
VERTTYPE vtPlane[4];&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // 4 coefs in a\*x +b\*y +c\*z + d = 0  
&nbsp;&nbsp;&nbsp; VERTTYPE vtFace[3][3];&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // 3 points each having 3 coords  
&nbsp;&nbsp;&nbsp; unsigned short usI[3];&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // indices in the vertices array for one point  
&nbsp;&nbsp;&nbsp; bool bExistentPlane = false;  
&nbsp;&nbsp;&nbsp; short i = 0;  
  
&nbsp;&nbsp;&nbsp; \_\_bInterleaved = scene.pMesh[0].pInterleaved != NULL;  
  
&nbsp;&nbsp;&nbsp; for (unsigned int nm = 0; nm \< scene.nNumMesh; nm++)&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // each mesh in the scene  
&nbsp;&nbsp;&nbsp; {  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SPODMesh& currentMesh = scene.pMesh[nm];  
  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (currentMesh.ePrimitiveType == ePODLines)  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; continue;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // we do not fear intersection with .. lines  
  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (unsigned int nf = 0; nf \< currentMesh.nNumFaces; nf++)&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // each poly in the mesh  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; CPODData& currentFaces = currentMesh.sFaces;  
  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // assuming nStride = 2 and the type is indeed unsigned short;  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (currentFaces.eType != EPODDataUnsignedShort)  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return false;  
  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // same for the vertex array - assume floats  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (currentMesh.sVertex.eType != EPODDataFloat)  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return false;  
  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (char nv = 0; nv \< 3; nv++)&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // for all 3 vertices of this face  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; usI[0] = ((unsigned short\*) currentFaces.pData)[nf + nv\*3 + 0];  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; usI[1] = ((unsigned short\*) currentFaces.pData)[nf + nv\*3 + 1];  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; usI[2] = ((unsigned short\*) currentFaces.pData)[nf + nv\*3 + 2];  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // line below fails with SIGSEGV as the usI[] contains trash  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtFace[nv][0] = \_\_bInterleaved ? ((float\*) currentMesh.pInterleaved)[usI[0]] : ((float\*) currentMesh.sVertex.pData)[usI[0]];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // I have noticed it fails for the same nv = 2 (3rd vertex), nf = 0 (first face) but nm can be anything (?). Noticed this behaviour for the 10th, 9th and 7th meshes (nm = mesh number). Never worked for all meshes without error.  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtFace[nv][1] = \_\_bInterleaved ? ((float\*) currentMesh.pInterleaved)[usI[1]] : ((float\*) currentMesh.sVertex.pData)[usI[1]];  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtFace[nv][2] = \_\_bInterleaved ? ((float\*) currentMesh.pInterleaved)[usI[2]] : ((float\*) currentMesh.sVertex.pData)[usI[2]];  
  
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }  
  
...  
...  

  
  
Thank you

---

<div class="post-metadata">

**Author:** ![kellogs](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/kellogs/32/83_2.png) [@kellogs](https://forums.imgtec.com/u/kellogs)\
**Post date:** [August 20, 2010, 8:48pm UTC](https://forums.imgtec.com/t/extracting-vertex-data-from-a-pod-scene/808/2 "2010-08-20T20:48:37Z")

</div>

I have been staring at PVRTModelPOD.cpp for hints but no luck … ☹

---

<div class="post-metadata">

**Author:** ![kellogs](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/kellogs/32/83_2.png) [@kellogs](https://forums.imgtec.com/u/kellogs)\
**Post date:** [August 21, 2010, 9:55am UTC](https://forums.imgtec.com/t/extracting-vertex-data-from-a-pod-scene/808/3 "2010-08-21T09:55:39Z")

</div>

aleluia   
  
[https://www.imgtec.com/forum/forum\_posts.asp?TID=653&KW=interleaved](https://www.imgtec.com/forum/forum_posts.asp?TID=653&KW=interleaved)

---

<div class="post-metadata">

**Author:** ![jman](https://avatars.discourse-cdn.com/v4/letter/j/b487fb/32.png) [@jman](https://forums.imgtec.com/u/jman)\
**Post date:** [August 21, 2010, 4:31pm UTC](https://forums.imgtec.com/t/extracting-vertex-data-from-a-pod-scene/808/4 "2010-08-21T16:31:08Z")

</div>

You might also want to take a look at the **PVRTVertexRead** functions (used by a couple of functions in PVRTModelPOD.cpp as well) stored in PVRTVertex.cpp. I used it for reading vertex info [here](https://www.imgtec.com/forum/forum_posts.asp?TID=594&PN=2).

---

<div class="post-metadata">

**Author:** ![kellogs](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/kellogs/32/83_2.png) [@kellogs](https://forums.imgtec.com/u/kellogs)\
**Post date:** [August 22, 2010, 12:17am UTC](https://forums.imgtec.com/t/extracting-vertex-data-from-a-pod-scene/808/5 "2010-08-22T00:17:57Z")

</div>

I managed that part,  
  
Cheers
