Fix #325; Blender UV unwrap issue

The BMesh converter might be missing more details, but this should get basic UVs working for now.
pull/352/head
Adam Petrone 2014-08-30 00:39:03 -04:00
parent 201807f733
commit 625d2b7c4a
2 changed files with 21 additions and 0 deletions

View File

@ -143,9 +143,13 @@ void BlenderBMeshConverter::DestroyTriMesh( )
void BlenderBMeshConverter::ConvertPolyToFaces( const MPoly& poly )
{
const MLoop* polyLoop = &BMesh->mloop[ poly.loopstart ];
const MLoopUV* loopUV = &BMesh->mloopuv[ poly.loopstart ];
if ( poly.totloop == 3 || poly.totloop == 4 )
{
AddFace( polyLoop[ 0 ].v, polyLoop[ 1 ].v, polyLoop[ 2 ].v, poly.totloop == 4 ? polyLoop[ 3 ].v : 0 );
AddTFace( loopUV[ 0 ].uv, loopUV[ 1 ].uv, loopUV[ 2 ].uv, poly.totloop == 4 ? loopUV[ 3 ].uv : 0 );
}
else if ( poly.totloop > 4 )
{
@ -173,4 +177,20 @@ void BlenderBMeshConverter::AddFace( int v1, int v2, int v3, int v4 )
triMesh->totface = triMesh->mface.size( );
}
// ------------------------------------------------------------------------------------------------
void BlenderBMeshConverter::AddTFace( const float* uv1, const float *uv2, const float *uv3, const float* uv4 )
{
MTFace mtface;
memcpy( &mtface.uv[ 0 ], uv1, sizeof(float) * 2 );
memcpy( &mtface.uv[ 1 ], uv2, sizeof(float) * 2 );
memcpy( &mtface.uv[ 2 ], uv3, sizeof(float) * 2 );
if ( uv4 )
{
memcpy( &mtface.uv[ 3 ], uv4, sizeof(float) * 2 );
}
triMesh->mtface.push_back( mtface );
}
#endif // ASSIMP_BUILD_NO_BLEND_IMPORTER

View File

@ -80,6 +80,7 @@ namespace Assimp
void DestroyTriMesh( );
void ConvertPolyToFaces( const Blender::MPoly& poly );
void AddFace( int v1, int v2, int v3, int v4 = 0 );
void AddTFace( const float* uv1, const float* uv2, const float *uv3, const float* uv4 = 0 );
const Blender::Mesh* BMesh;
Blender::Mesh* triMesh;