first parsing of references and geometry objects.
Signed-off-by: Kim Kulling <kim.kulling@googlemail.com>pull/502/head
parent
d9d7dd31ea
commit
207906f039
|
@ -164,7 +164,9 @@ USE_ODDLPARSER_NS
|
|||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
OpenGEXImporter::OpenGEXImporter()
|
||||
: m_ctx( NULL )
|
||||
: m_meshCache()
|
||||
, m_mesh2refMap()
|
||||
, m_ctx( NULL )
|
||||
, m_currentNode( NULL ) {
|
||||
// empty
|
||||
}
|
||||
|
@ -205,6 +207,8 @@ void OpenGEXImporter::InternReadFile( const std::string &filename, aiScene *pSce
|
|||
m_ctx = myParser.getContext();
|
||||
handleNodes( m_ctx->m_root, pScene );
|
||||
}
|
||||
|
||||
resolveReferences();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
@ -238,6 +242,9 @@ void OpenGEXImporter::handleNodes( DDLNode *node, aiScene *pScene ) {
|
|||
break;
|
||||
|
||||
case Grammar::ObjectRefToken:
|
||||
handleObjectRefNode( *it, pScene );
|
||||
break;
|
||||
|
||||
case Grammar::MaterialRefToken:
|
||||
case Grammar::MetricKeyToken:
|
||||
case Grammar::GeometryNodeToken:
|
||||
|
@ -245,6 +252,9 @@ void OpenGEXImporter::handleNodes( DDLNode *node, aiScene *pScene ) {
|
|||
break;
|
||||
|
||||
case Grammar::GeometryObjectToken:
|
||||
handleGeometryObject( *it, pScene );
|
||||
break;
|
||||
|
||||
case Grammar::TransformToken:
|
||||
case Grammar::MeshToken:
|
||||
case Grammar::VertexArrayToken:
|
||||
|
@ -295,7 +305,7 @@ void OpenGEXImporter::handleMetricNode( DDLNode *node, aiScene *pScene ) {
|
|||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
void OpenGEXImporter::handleNameNode( ODDLParser::DDLNode *node, aiScene *pScene ) {
|
||||
void OpenGEXImporter::handleNameNode( DDLNode *node, aiScene *pScene ) {
|
||||
if( NULL == m_currentNode ) {
|
||||
throw DeadlyImportError( "No parent node for name." );
|
||||
return;
|
||||
|
@ -313,11 +323,42 @@ void OpenGEXImporter::handleNameNode( ODDLParser::DDLNode *node, aiScene *pScene
|
|||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
void OpenGEXImporter::handleGeometryNode( ODDLParser::DDLNode *node, aiScene *pScene ) {
|
||||
void OpenGEXImporter::handleObjectRefNode( DDLNode *node, aiScene *pScene ) {
|
||||
if( NULL == m_currentNode ) {
|
||||
throw DeadlyImportError( "No parent node for name." );
|
||||
return;
|
||||
}
|
||||
|
||||
Reference *ref = node->getReferences();
|
||||
if( NULL != ref ) {
|
||||
for( size_t i = 0; i < ref->m_numRefs; i++ ) {
|
||||
Name *currentName( ref->m_referencedName[ i ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
void OpenGEXImporter::handleGeometryNode( DDLNode *node, aiScene *pScene ) {
|
||||
m_currentNode = new aiNode;
|
||||
handleNodes( node, pScene );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
void OpenGEXImporter::handleGeometryObject( DDLNode *node, aiScene *pScene ) {
|
||||
aiMesh *currentMesh( new aiMesh );
|
||||
const size_t idx( m_meshCache.size() );
|
||||
m_meshCache.push_back( currentMesh );
|
||||
|
||||
// store name to reference relation
|
||||
m_mesh2refMap[ node->getName() ] = idx;
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
void OpenGEXImporter::resolveReferences() {
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
} // Namespace OpenGEX
|
||||
|
|
|
@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "BaseImporter.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace ODDLParser {
|
||||
class DDLNode;
|
||||
|
@ -100,9 +101,14 @@ protected:
|
|||
void handleNodes( ODDLParser::DDLNode *node, aiScene *pScene );
|
||||
void handleMetricNode( ODDLParser::DDLNode *node, aiScene *pScene );
|
||||
void handleNameNode( ODDLParser::DDLNode *node, aiScene *pScene );
|
||||
void handleObjectRefNode( ODDLParser::DDLNode *node, aiScene *pScene );
|
||||
void handleGeometryNode( ODDLParser::DDLNode *node, aiScene *pScene );
|
||||
void handleGeometryObject( ODDLParser::DDLNode *node, aiScene *pScene );
|
||||
void resolveReferences();
|
||||
|
||||
private:
|
||||
std::vector<aiMesh*> m_meshCache;
|
||||
std::map<std::string, size_t> m_mesh2refMap;
|
||||
ODDLParser::Context *m_ctx;
|
||||
MetricInfo m_metrics[ MetricInfo::Max ];
|
||||
aiNode *m_currentNode;
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace Grammar {
|
|||
} // Namespace Grammar
|
||||
|
||||
|
||||
static void logInvalidTokenError( char *in, char *exp, OpenDDLParser::logCallback callback ) {
|
||||
static void logInvalidTokenError( char *in, const std::string &exp, OpenDDLParser::logCallback callback ) {
|
||||
std::stringstream stream;
|
||||
stream << "Invalid token " << *in << ", " << exp << " expected." << std::endl;
|
||||
callback( ddl_error_msg, stream.str() );
|
||||
|
@ -297,7 +297,7 @@ char *OpenDDLParser::parseStructure( char *in, char *end ) {
|
|||
}
|
||||
else {
|
||||
in++;
|
||||
logInvalidTokenError( in, "{", m_logCallback );
|
||||
logInvalidTokenError( in, std::string( Grammar::OpenBracketToken ), m_logCallback );
|
||||
error = true;
|
||||
return in;
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ char *OpenDDLParser::parseStructureBody( char *in, char *end, bool &error ) {
|
|||
|
||||
in = getNextToken( in, end );
|
||||
if( *in != '}' ) {
|
||||
logInvalidTokenError( in, "}", m_logCallback );
|
||||
logInvalidTokenError( in, std::string( Grammar::CloseBracketToken ), m_logCallback );
|
||||
} else {
|
||||
//in++;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
# ifdef OPENDDLPARSER_BUILD
|
||||
# define DLL_ODDLPARSER_EXPORT TAG_DLL_EXPORT
|
||||
# else
|
||||
# define DLL_ODDLPARSER_EXPORT TAG_DLL_IMPORT
|
||||
# define DLL_ODDLPARSER_EXPORT TAG_DLL_IMPORT
|
||||
# endif // OPENDDLPARSER_BUILD
|
||||
# pragma warning( disable : 4251 )
|
||||
#else
|
||||
|
@ -52,7 +52,7 @@ BEGIN_ODDLPARSER_NS
|
|||
# define ddl_nullptr nullptr
|
||||
#else
|
||||
# define ddl_nullptr NULL
|
||||
#endif
|
||||
#endif // OPENDDL_NO_USE_CPP11
|
||||
|
||||
class DDLNode;
|
||||
class Value;
|
||||
|
|
|
@ -202,7 +202,9 @@ bool isReference( T *in, T *end ) {
|
|||
if( *in == 'r' ) {
|
||||
if( *(in+1) == 'e' ) {
|
||||
if( *(in+2) == 'f' ) {
|
||||
return true;
|
||||
if( ( in + 2 ) != end ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue