For each face ....
Faceex * pfaceex = pgamemesh-> getface (faceid );
// Obtain the location
Int vertexid = pfaceex-> vert [facevertexid];
Point3 vertex;
If (pgamemesh-> getvertex (vertexid, vertex ))
Pvertexdata-> m_position = vertex;
// Obtain the normal vector
Int normid = pfaceex-> norm [facevertexid];
Point3 normal;
If (pgamemesh-> getnormal (normid, normal ))
Pvertexdata-> m_normal = normal;
// Obtain the texture coordinate
// Mapchannel indicates the texture coordinate of a layer. If mapchannel number is 1, use the gettexvertex () function directly.
// Otherwise, all texturemaps will be traversed to calculate the texture coordinates of the current texturemap.
If (pgamemesh-> getactivemapchannelnum (). Count () = 1)
{
Int texcoordid = pfaceex-> texcoord [facevertexid];
Point2 texcoord;
If (pgamemesh-> gettexvertex (texcoordid, texcoord ))
Pvertexdata-> addtexturecoordinate (texcoord. X, 1.f-texcoord. y );
}
Else
{
Igamematerial * pgamematerial = pgamemesh-> getmaterialfromface (pfaceex );
Int inumtexture = pgamematerial-> getnumberoftexturemaps ();
For (INT I = 0; I <inumtexture; ++ I)
{
Igametexturemap * ptexture = pgamematerial-> getigametexturemap (I );
Tchar * tcname = ptexture-> getbitmapfilename ();
Int ichannel = ptexture-> getmaxtexmap ()-> getmapchannel ();
DWORD vertexid [3];
Point3 uvvert;
If (pgamemesh-> getmapfaceindex (ichannel, faceid, vertexid ))
{
If (pgamemesh-> getmapvertex (ichannel, vertexid [facevertexid], uvvert ))
{
Igameuvgen * pgameuvgen = ptexture-> getigameuvgen ();
Gmatrix gmuv = pgameuvgen-> getuvtransform ();
Uvvert = uvvert * gmuv;
Pvertexdata-> addtexturecoordinate (uvvert. X, 1.f-uvvert. y );
}
}
}
}
// Obtain the skin Information
If (pgamemesh-> isobjectskinned ())
{
Igameskin * pgameskin = NULL;
Pgameskin = pgamemesh-> getigameskin ();
Int iboneid;
Float fweight;
Int type = pgameskin-> getvertextype (vertexid );
If (type = igameskin: igame_rigid)
{
Iboneid = pgameskin-> getboneid (vertexid, 0 );
Igamenode * pbonenode = g_exporter.getigamescene ()-> getigamenode (ulong (iboneid ));
Tchar * chbonename = pbonenode-> getname ();
Fweight = 1.f;
Pvertexdata-> addinfluence (iboneid, fweight );
}
Else // blended
{
For (INT B = 0; B <pgameskin-> getnumberofbones (vertexid); ++ B)
{
Iboneid = pgameskin-> getboneid (vertexid, B );
Igamenode * pbonenode = g_exporter.getigamescene ()-> getigamenode (ulong (iboneid ));
Tchar * chbonename = pbonenode-> getname ();
Fweight = pgameskin-> getweight (vertexid, B );
Pvertexdata-> addinfluence (iboneid, fweight );
}
}
}