add copy op for positions, normals and texture coordinates.

Signed-off-by: Kim Kulling <kim.kulling@googlemail.com>
pull/521/head
Kim Kulling 2015-03-29 18:53:23 +02:00
parent 20ad00b5e5
commit 0e11cfbe6f
1 changed files with 53 additions and 7 deletions

View File

@ -562,6 +562,51 @@ static MeshAttribute getAttributeByName( const char *attribName ) {
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 ) {
if( NULL == node ) {
@ -583,16 +628,17 @@ void OpenGEXImporter::handleVertexArrayNode( ODDLParser::DDLNode *node, aiScene
return;
}
if( Position == attribType ) {
aiVector3D *pos = new aiVector3D[ vaList->m_numItems ];
const size_t numItems( countDataArrayListItems( vaList ) );
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 ) {
aiVector3D *normal = new aiVector3D[ vaList->m_numItems ];
m_currentMesh->mNormals = new aiVector3D[ numItems ];
copyVectorArray( numItems, vaList, m_currentMesh->mNormals );
} 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] );
}
}
}