Code segment for exporting vertex data with 3dxi

Source: Internet
Author: User

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 );
}
}
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.