add copy op for positions, normals and texture coordinates.
Signed-off-by: Kim Kulling <kim.kulling@googlemail.com>pull/521/head
parent
20ad00b5e5
commit
0e11cfbe6f
|
@ -562,6 +562,51 @@ static MeshAttribute getAttributeByName( const char *attribName ) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------------------
|
||||||
|
static void fillVector3( aiVector3D *vec3, Value *vals ) {
|
||||||
|
ai_assert( NULL != vec3 );
|
||||||
|
ai_assert( NULL != vals );
|
||||||
|
|
||||||
|
float x( 0.0f ), y( 0.0f ), z( 0.0f );
|
||||||
|
Value *next( vals );
|
||||||
|
x = next->getFloat();
|
||||||
|
next = next->m_next;
|
||||||
|
y = next->getFloat();
|
||||||
|
next = next->m_next;
|
||||||
|
if( NULL != next ) {
|
||||||
|
z = next->getFloat();
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3->Set( x, y, z );
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------------------
|
||||||
|
static size_t countDataArrayListItems( DataArrayList *vaList ) {
|
||||||
|
size_t numItems( 0 );
|
||||||
|
if( NULL == vaList ) {
|
||||||
|
return numItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataArrayList *next( vaList );
|
||||||
|
while( NULL != next ) {
|
||||||
|
if( NULL != vaList->m_dataList ) {
|
||||||
|
numItems++;
|
||||||
|
}
|
||||||
|
next = next->m_next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return numItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------------------
|
||||||
|
static void copyVectorArray( size_t numItems, DataArrayList *vaList, aiVector3D *vectorArray ) {
|
||||||
|
for( size_t i = 0; i < numItems; i++ ) {
|
||||||
|
Value *next( vaList->m_dataList );
|
||||||
|
fillVector3( &vectorArray[ i ], next );
|
||||||
|
vaList = vaList->m_next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
void OpenGEXImporter::handleVertexArrayNode( ODDLParser::DDLNode *node, aiScene *pScene ) {
|
void OpenGEXImporter::handleVertexArrayNode( ODDLParser::DDLNode *node, aiScene *pScene ) {
|
||||||
if( NULL == node ) {
|
if( NULL == node ) {
|
||||||
|
@ -583,16 +628,17 @@ void OpenGEXImporter::handleVertexArrayNode( ODDLParser::DDLNode *node, aiScene
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( Position == attribType ) {
|
const size_t numItems( countDataArrayListItems( vaList ) );
|
||||||
aiVector3D *pos = new aiVector3D[ vaList->m_numItems ];
|
|
||||||
Value *next( vaList->m_dataList );
|
Value *next( vaList->m_dataList );
|
||||||
for( size_t i = 0; i < vaList->m_numItems; i++ ) {
|
if( Position == attribType ) {
|
||||||
|
m_currentMesh->mVertices = new aiVector3D[ numItems ];
|
||||||
}
|
copyVectorArray( numItems, vaList, m_currentMesh->mVertices );
|
||||||
} else if( Normal == attribType ) {
|
} else if( Normal == attribType ) {
|
||||||
aiVector3D *normal = new aiVector3D[ vaList->m_numItems ];
|
m_currentMesh->mNormals = new aiVector3D[ numItems ];
|
||||||
|
copyVectorArray( numItems, vaList, m_currentMesh->mNormals );
|
||||||
} else if( TexCoord == attribType ) {
|
} else if( TexCoord == attribType ) {
|
||||||
aiVector3D *tex = new aiVector3D[ vaList->m_numItems ];
|
m_currentMesh->mTextureCoords[0] = new aiVector3D[ numItems ];
|
||||||
|
copyVectorArray( numItems, vaList, m_currentMesh->mTextureCoords[0] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue