USE_ODDLPARSER_NS
//------------------------------------------------------------------------------------------------
+static void propId2StdString( Property *prop, std::string &name, std::string &key ) {
+ name = key = "";
+ if ( NULL == prop ) {
+ return;
+ }
+
+ if ( NULL != prop->m_key ) {
+ name = prop->m_key->m_buffer;
+ if ( Value::ddl_string == prop->m_value->m_type ) {
+ key = prop->m_value->getString();
+ }
+ }
+}
+
+//------------------------------------------------------------------------------------------------
OpenGEXImporter::VertexContainer::VertexContainer()
: m_numVerts( 0 )
, m_vertices(NULL)
, m_currentVertices()
, m_currentMesh( NULL )
, m_currentMaterial( NULL )
+, m_currentLight( NULL )
+, m_currentCamera( nullptr )
, m_tokenType( Grammar::NoneType )
, m_materialCache()
, m_cameraCache()
handleGeometryObject( *it, pScene );
break;
+ case Grammar::CameraObjectToken:
+ handleCameraObject( *it, pScene );
+ break;
+
+ case Grammar::LightObjectToken:
+ handleCameraObject( *it, pScene );
+ break;
+
case Grammar::TransformToken:
handleTransformNode( *it, pScene );
break;
aiCamera *camera( new aiCamera );
const size_t camIdx( m_cameraCache.size() );
m_cameraCache.push_back( camera );
+ m_currentCamera = camera;
+
+ aiNode *newNode = new aiNode;
+ m_tokenType = Grammar::CameraNodeToken;
+ m_currentNode = newNode;
+ pushNode( newNode, pScene );
+
+ handleNodes( node, pScene );
+ popNode();
+
+ m_currentCamera->mName.Set( newNode->mName.C_Str() );
}
//------------------------------------------------------------------------------------------------
aiLight *light( new aiLight );
const size_t lightIdx( m_lightCache.size() );
m_lightCache.push_back( light );
+ m_currentLight = light;
aiNode *newNode = new aiNode;
m_tokenType = Grammar::LightNodeToken;
popNode();
- light->mName.Set( newNode->mName.C_Str() );
+ m_currentLight->mName.Set( newNode->mName.C_Str() );
}
//------------------------------------------------------------------------------------------------
}
//------------------------------------------------------------------------------------------------
-static void propId2StdString( Property *prop, std::string &name, std::string &key ) {
- name = key = "";
- if( NULL == prop ) {
- return;
- }
-
- if( NULL != prop->m_key ) {
- name = prop->m_key->m_buffer;
- if( Value::ddl_string == prop->m_value->m_type ) {
- key = prop->m_value->getString();
- }
- }
-}
-
-//------------------------------------------------------------------------------------------------
void OpenGEXImporter::handleMeshNode( ODDLParser::DDLNode *node, aiScene *pScene ) {
m_currentMesh = new aiMesh;
const size_t meshidx( m_meshCache.size() );
m_currentMesh->mFaces = new aiFace[ numItems ];
m_currentMesh->mNumVertices = numItems * 3;
m_currentMesh->mVertices = new aiVector3D[ m_currentMesh->mNumVertices ];
- m_currentMesh->mNormals = new aiVector3D[ m_currentMesh->mNumVertices ];
- m_currentMesh->mNumUVComponents[ 0 ] = 3;
- m_currentMesh->mTextureCoords[ 0 ] = new aiVector3D[ m_currentMesh->mNumVertices ];
+ bool hasNormalCoords( false );
+ if ( m_currentVertices.m_numNormals > 0 ) {
+ m_currentMesh->mNormals = new aiVector3D[ m_currentMesh->mNumVertices ];
+ hasNormalCoords = true;
+ }
+ bool hasTexCoords( false );
+ if ( m_currentVertices.m_numUVComps[ 0 ] > 0 ) {
+ m_currentMesh->mTextureCoords[ 0 ] = new aiVector3D[ m_currentMesh->mNumVertices ];
+ hasTexCoords = true;
+ }
unsigned int index( 0 );
for( size_t i = 0; i < m_currentMesh->mNumFaces; i++ ) {
for( size_t indices = 0; indices < current.mNumIndices; indices++ ) {
const int idx( next->getUnsignedInt32() );
ai_assert( static_cast<size_t>( idx ) <= m_currentVertices.m_numVerts );
-
- aiVector3D &pos = ( m_currentVertices.m_vertices[ idx ] );
- aiVector3D &normal = ( m_currentVertices.m_normals[ idx ] );
- aiVector3D &tex = ( m_currentVertices.m_textureCoords[ 0 ][ idx ] );
-
ai_assert( index < m_currentMesh->mNumVertices );
+ aiVector3D &pos = ( m_currentVertices.m_vertices[ idx ] );
m_currentMesh->mVertices[ index ].Set( pos.x, pos.y, pos.z );
- m_currentMesh->mNormals[ index ].Set( normal.x, normal.y, normal.z );
- m_currentMesh->mTextureCoords[0][ index ].Set( tex.x, tex.y, tex.z );
+ if ( hasNormalCoords ) {
+ aiVector3D &normal = ( m_currentVertices.m_normals[ idx ] );
+ m_currentMesh->mNormals[ index ].Set( normal.x, normal.y, normal.z );
+ }
+ if ( hasTexCoords ) {
+ aiVector3D &tex = ( m_currentVertices.m_textureCoords[ 0 ][ idx ] );
+ m_currentMesh->mTextureCoords[ 0 ][ index ].Set( tex.x, tex.y, tex.z );
+ }
current.mIndices[ indices ] = index;
index++;
}
//------------------------------------------------------------------------------------------------
+void OpenGEXImporter::handleParamNode( ODDLParser::DDLNode *node, aiScene *pScene ) {
+ if ( NULL == node ) {
+ return;
+ }
+
+ Property *prop = node->findPropertyByName( "attrib" );
+
+ if ( nullptr != prop ) {
+ if ( NULL != prop->m_value ) {
+ Value *val( node->getValue() );
+ if ( NULL != val ) {
+ if ( "fov" == val->getString() ) {
+
+ } else if ( "near" == val->getString() ) {
+
+ }else if ( "far" == val->getString() ) {
+
+ }
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------------------------------
void OpenGEXImporter::copyMeshes( aiScene *pScene ) {
if( m_meshCache.empty() ) {
return;