# Easy question about SPODMesh and sFaces

**URL:** <https://forums.imgtec.com/t/easy-question-about-spodmesh-and-sfaces/615>\
**Category:** PowerVR Insider\
**Created:** [February 18, 2010, 1:43am UTC](https://forums.imgtec.com/t/easy-question-about-spodmesh-and-sfaces/615 "2010-02-18T01:43:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fwalker](https://avatars.discourse-cdn.com/v4/letter/f/3bc359/32.png) [@fwalker](https://forums.imgtec.com/u/fwalker)\
**Post date:** [February 18, 2010, 1:43am UTC](https://forums.imgtec.com/t/easy-question-about-spodmesh-and-sfaces/615/1 "2010-02-18T01:43:48Z")

</div>

How can I obtain the faces that make up a mesh?  
  
  
I know I have to use sFaces. This is a list on indexes to sVertex ?..  
  
  
Is there an example on how I can get these faces?  
  
  
Are the face normals calculated and stored by any chance?  
  
  
  
  
  
I need this for collision detection.  
  
  
  
  
  
Thank you.

---

<div class="post-metadata">

**Author:** ![Scott](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/scott/32/256_2.png) [@Scott](https://forums.imgtec.com/u/Scott)\
**Post date:** [February 22, 2010, 9:03am UTC](https://forums.imgtec.com/t/easy-question-about-spodmesh-and-sfaces/615/2 "2010-02-22T09:03:36Z")

</div>

Hi,
  

&nbsp;
  

fwalker wrote:

  

How can I obtain the faces that make up a mesh?   
I know I have to use sFaces. This is a list on indexes to sVertex ?...   
Is there an example on how I can get these faces?
  

  

&nbsp;
  

Assuming your data is indexed then as you say you need to use sFaces which is a list of indices into pInterleaved or sVertex etc.
  

&nbsp;
  

The only example I can find in the SDK is the PVRTModelPODDeIndex function in the tools code which takes an interleaved indexed mesh and removes the indices. The important part to look at is 
  

Code:

(char\*)mesh.pInterleaved + ((unsigned short\*)mesh.sFaces.pData)[i] \* mesh.sVertex.nStride

  

which calculates the start of vertex&nbsp;_ **i** _ in pInterleaved. To get a particular element of the vertex e.g. normal just add onto this the sVertex, sNormal etc. offset (pData).
  

&nbsp;
  

fwalker wrote:

  
Are the face normals calculated and stored by any chance?   

  

&nbsp;
  

I'm afraid the POD format stores normals per-vertex not per-face so these will need to be calculated.
  

&nbsp;
  

Thanks,
  

&nbsp;
  

Scott

---

<div class="post-metadata">

**Author:** ![fwalker](https://avatars.discourse-cdn.com/v4/letter/f/3bc359/32.png) [@fwalker](https://forums.imgtec.com/u/fwalker)\
**Post date:** [February 25, 2010, 11:01pm UTC](https://forums.imgtec.com/t/easy-question-about-spodmesh-and-sfaces/615/3 "2010-02-25T23:01:48Z")

</div>

Scott,  
  
  
  
  
  
Thank you very much for your help. I am still trying to figure this out. Please forgive my rookie question I am obviously missing something here. Please enlighten me. How is it that the following line from OGLESIntroducingPOD in the “void OGLESIntroducingPOD::DrawMesh(unsigned int ui32MeshID)” function works?  
  
  
  
  
  
// Setup pointers  
  
  
glVertexPointer(Mesh.sVertex.n, VERTTYPEENUM, Mesh.sVertex.nStride, Mesh.sVertex.pData);  
  
  
  
  
  
According to my debugger Mesh.sVertex.pData is nil !!!  
  
  
  
  
  
How is this possible? I am confused. Please help.

---

<div class="post-metadata">

**Author:** ![Scott](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/scott/32/256_2.png) [@Scott](https://forums.imgtec.com/u/Scott)\
**Post date:** [February 26, 2010, 12:18pm UTC](https://forums.imgtec.com/t/easy-question-about-spodmesh-and-sfaces/615/4 "2010-02-26T12:18:01Z")

</div>

fwalker wrote:

  

According to my debugger Mesh.sVertex.pData is nil !!!!   
  
How is this possible? I am confused. Please help.
  

  

&nbsp;
  

When the mesh data is interleaved Mesh.sVertex.pData becomes an offset to the start of the first vertex position in Mesh.pInterleaved. For IntroducingPOD the&nbsp;position is the first part of the vertex so pData is 0 (i.e. no offset). The normals are the second part so have an offset of 12 (3 x sizeof(float) i.e. the size of the position). The UVs are the third part so their offset is 24 (6 x sizeof(float) i.e. the size of the position and normal).

---

<div class="post-metadata">

**Author:** ![fwalker](https://avatars.discourse-cdn.com/v4/letter/f/3bc359/32.png) [@fwalker](https://forums.imgtec.com/u/fwalker)\
**Post date:** [March 2, 2010, 7:01pm UTC](https://forums.imgtec.com/t/easy-question-about-spodmesh-and-sfaces/615/5 "2010-03-02T19:01:00Z")

</div>

Thanks so much Scott, that all makes sense. Right after I got it working, by coincidence, I found that you guys have a file in your SDK that does BoundingBox calculations. You do not use it in your demos that I can tell. But its exactly what i needed.  
  
  
  
  
  
PVRTTrans.cpp  
  
  
PVRTBoundingBoxComputeInterleaved  
  
  
  
  
  
So I verified my code and things look good.  
  
  
  
  
  
I am mentioning this in case this helps someone else.  
  
  
  
  
  
Thanks so much ! fwalker2010-03-02 20:02:15
