IndexArrayToken,
MaterialToken,
ColorToken,
- Paramtype,
+ ParamToken,
TextureToken,
};
return CameraNodeToken;
} else if ( LightNodeType == tokenType ) {
return LightNodeToken;
- } else if( GeometryObjectType == tokenType ) {
+ }
+ else if ( GeometryObjectType == tokenType ) {
return GeometryObjectToken;
+ } else if ( CameraObjectType == tokenType ) {
+ return CameraObjectToken;
+ } else if ( LightObjectType == tokenType ) {
+ return LightObjectToken;
} else if( TransformType == tokenType ) {
return TransformToken;
} else if( MeshType == tokenType ) {
return IndexArrayToken;
} else if( MaterialType == tokenType ) {
return MaterialToken;
- } else if( ColorType == tokenType ) {
+ } else if ( ColorType == tokenType ) {
return ColorToken;
+ } else if ( ParamType == tokenType ) {
+ return ParamToken;
} else if( TextureType == tokenType ) {
return TextureToken;
}
}
copyMeshes( pScene );
+ copyCameras( pScene );
+ copyLights( pScene );
resolveReferences();
createNodeTree( pScene );
}
break;
case Grammar::LightObjectToken:
- handleCameraObject( *it, pScene );
+ handleLightObject( *it, pScene );
break;
case Grammar::TransformToken:
case Grammar::ColorToken:
handleColorNode( *it, pScene );
break;
+
+ case Grammar::ParamToken:
+ handleParamNode( *it, pScene );
+ break;
case Grammar::TextureToken:
handleTextureNode( *it, pScene );
std::vector<std::string> objRefNames;
getRefNames( node, objRefNames );
- m_currentNode->mNumMeshes = objRefNames.size();
- m_currentNode->mMeshes = new unsigned int[ objRefNames.size() ];
- if( !objRefNames.empty() ) {
- m_unresolvedRefStack.push_back( new RefInfo( m_currentNode, RefInfo::MeshRef, objRefNames ) );
+
+ // when we are dealing with a geometry node prepare the mesh cache
+ if ( m_tokenType == Grammar::GeometryNodeToken ) {
+ m_currentNode->mNumMeshes = objRefNames.size();
+ m_currentNode->mMeshes = new unsigned int[ objRefNames.size() ];
+ if ( !objRefNames.empty() ) {
+ m_unresolvedRefStack.push_back( new RefInfo( m_currentNode, RefInfo::MeshRef, objRefNames ) );
+ }
}
}
m_currentCamera = camera;
aiNode *newNode = new aiNode;
+ pushNode( newNode, pScene );
m_tokenType = Grammar::CameraNodeToken;
m_currentNode = newNode;
- pushNode( newNode, pScene );
handleNodes( node, pScene );
//------------------------------------------------------------------------------------------------
void OpenGEXImporter::handleCameraObject( ODDLParser::DDLNode *node, aiScene *pScene ) {
// parameters will be parsed normally in the tree, so just go for it
+
handleNodes( node, pScene );
-
}
//------------------------------------------------------------------------------------------------
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() ) {
-
+ const float floatVal( val->getFloat() );
+ if ( NULL != val && prop->m_value != NULL ) {
+ if ( "fov" == prop->m_value->getString() ) {
+ m_currentCamera->mHorizontalFOV = floatVal;
+ } else if ( "near" == prop->m_value->getString() ) {
+ m_currentCamera->mClipPlaneNear = floatVal;
+ } else if ( "far" == prop->m_value->getString() ) {
+ m_currentCamera->mClipPlaneFar = floatVal;
}
}
}
//------------------------------------------------------------------------------------------------
void OpenGEXImporter::copyMeshes( aiScene *pScene ) {
+ ai_assert( nullptr != pScene );
+
if( m_meshCache.empty() ) {
return;
}
}
//------------------------------------------------------------------------------------------------
+void OpenGEXImporter::copyCameras( aiScene *pScene ) {
+ ai_assert( nullptr != pScene );
+
+ if ( m_cameraCache.empty() ) {
+ return;
+ }
+
+ pScene->mNumCameras = m_cameraCache.size();
+ pScene->mCameras = new aiCamera*[ pScene->mNumCameras ];
+ std::copy( m_cameraCache.begin(), m_cameraCache.end(), pScene->mCameras );
+}
+
+//------------------------------------------------------------------------------------------------
+void OpenGEXImporter::copyLights( aiScene *pScene ) {
+ ai_assert( nullptr != pScene );
+
+ if ( m_lightCache.empty() ) {
+ return;
+ }
+
+ pScene->mNumLights = m_lightCache.size();
+ pScene->mLights = new aiLight*[ pScene->mNumLights ];
+ std::copy( m_lightCache.begin(), m_lightCache.end(), pScene->mLights );
+}
+
+//------------------------------------------------------------------------------------------------
void OpenGEXImporter::resolveReferences() {
if( m_unresolvedRefStack.empty() ) {
return;
aiNode *node( currentRefInfo->m_node );
if( RefInfo::MeshRef == currentRefInfo->m_type ) {
for( size_t i = 0; i < currentRefInfo->m_Names.size(); i++ ) {
- const std::string &name(currentRefInfo->m_Names[ i ] );
+ const std::string &name( currentRefInfo->m_Names[ i ] );
ReferenceMap::const_iterator it( m_mesh2refMap.find( name ) );
if( m_mesh2refMap.end() != it ) {
unsigned int meshIdx = m_mesh2refMap[ name ];
void OpenGEXImporter::pushNode( aiNode *node, aiScene *pScene ) {
ai_assert( NULL != pScene );
- if( NULL != node ) {
- ChildInfo *info( NULL );
- if( m_nodeStack.empty() ) {
- node->mParent = pScene->mRootNode;
- NodeChildMap::iterator it( m_nodeChildMap.find( node->mParent ) );
- if( m_nodeChildMap.end() == it ) {
- info = new ChildInfo;
- m_root = info;
- m_nodeChildMap[ node->mParent ] = info;
- } else {
- info = it->second;
- }
- info->m_children.push_back( node );
+ if ( NULL == node ) {
+ return;
+ }
+
+ ChildInfo *info( NULL );
+ if( m_nodeStack.empty() ) {
+ node->mParent = pScene->mRootNode;
+ NodeChildMap::iterator it( m_nodeChildMap.find( node->mParent ) );
+ if( m_nodeChildMap.end() == it ) {
+ info = new ChildInfo;
+ m_root = info;
+ m_nodeChildMap[ node->mParent ] = info;
} else {
- aiNode *parent( m_nodeStack.back() );
- ai_assert( NULL != parent );
- node->mParent = parent;
- NodeChildMap::iterator it( m_nodeChildMap.find( node->mParent ) );
- if( m_nodeChildMap.end() == it ) {
- info = new ChildInfo;
- m_nodeChildMap[ node->mParent ] = info;
- } else {
- info = it->second;
- }
- info->m_children.push_back( node );
+ info = it->second;
+ }
+ info->m_children.push_back( node );
+ } else {
+ aiNode *parent( m_nodeStack.back() );
+ ai_assert( NULL != parent );
+ node->mParent = parent;
+ NodeChildMap::iterator it( m_nodeChildMap.find( node->mParent ) );
+ if( m_nodeChildMap.end() == it ) {
+ info = new ChildInfo;
+ m_nodeChildMap[ node->mParent ] = info;
+ } else {
+ info = it->second;
}
- m_nodeStack.push_back( node );
+ info->m_children.push_back( node );
}
+ m_nodeStack.push_back( node );
}
//------------------------------------------------------------------------------------------------