Work in progress: WRL2 to SGNODE translation
This commit is contained in:
parent
b426740195
commit
d68418d613
|
@ -346,3 +346,10 @@ bool WRL2APPEARANCE::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
SGNODE* WRL2APPEARANCE::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
// XXX - TO IMPLEMENT
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "vrml2_node.h"
|
||||
|
||||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* Class WRL2APPEARANCE
|
||||
|
@ -63,6 +64,7 @@ public:
|
|||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
bool AddRefNode( WRL2NODE* aNode );
|
||||
bool AddChildNode( WRL2NODE* aNode );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent );
|
||||
};
|
||||
|
||||
#endif // VRML2_APPEARANCE_H
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "vrml2_coords.h"
|
||||
#include "vrml2_norms.h"
|
||||
#include "vrml2_color.h"
|
||||
#include "plugins/3dapi/ifsg_all.h"
|
||||
|
||||
|
||||
WRL2BASE::WRL2BASE() : WRL2NODE()
|
||||
|
@ -762,3 +763,68 @@ bool WRL2BASE::readColor( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
SGNODE* WRL2BASE::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
if( m_Children.empty() )
|
||||
return NULL;
|
||||
|
||||
if( m_topNode )
|
||||
return m_topNode;
|
||||
|
||||
IFSG_TRANSFORM topNode( aParent );
|
||||
|
||||
std::list< WRL2NODE* >::iterator sC = m_Children.begin();
|
||||
std::list< WRL2NODE* >::iterator eC = m_Children.end();
|
||||
WRL2NODES type;
|
||||
|
||||
// Include only Shape and Transform nodes in the top node
|
||||
bool test = false; // set to true if there are any subnodes for display
|
||||
|
||||
while( sC != eC )
|
||||
{
|
||||
type = (*sC)->GetNodeType();
|
||||
|
||||
switch( type )
|
||||
{
|
||||
case WRL2_SHAPE:
|
||||
// wrap the shape in a transform
|
||||
do
|
||||
{
|
||||
IFSG_TRANSFORM wrapper( topNode.GetRawPtr() );
|
||||
SGNODE* pshape = (*sC)->TranslateToSG( wrapper.GetRawPtr() );
|
||||
|
||||
if( NULL != pshape )
|
||||
test = true;
|
||||
else
|
||||
wrapper.Destroy();
|
||||
|
||||
} while( 0 );
|
||||
|
||||
break;
|
||||
|
||||
case WRL2_TRANSFORM:
|
||||
|
||||
if( NULL != (*sC)->TranslateToSG( topNode.GetRawPtr() ) )
|
||||
test = true;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
++ sC;
|
||||
}
|
||||
|
||||
if( false == test )
|
||||
{
|
||||
topNode.Destroy();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
m_topNode = topNode.GetRawPtr();
|
||||
|
||||
return m_topNode;
|
||||
}
|
||||
|
|
|
@ -91,6 +91,7 @@ public:
|
|||
// functions inherited from WRL2NODE
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
bool SetParent( WRL2NODE* aParent );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent );
|
||||
};
|
||||
|
||||
#endif // VRML2_BASE_H
|
||||
|
|
|
@ -187,3 +187,10 @@ bool WRL2COLOR::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
SGNODE* WRL2COLOR::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
// XXX - TO IMPLEMENT
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "vrml2_node.h"
|
||||
|
||||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* Class WRL2COLOR
|
||||
|
@ -57,6 +58,7 @@ public:
|
|||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
bool AddRefNode( WRL2NODE* aNode );
|
||||
bool AddChildNode( WRL2NODE* aNode );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent );
|
||||
};
|
||||
|
||||
#endif // VRML2_COLOR_H
|
||||
|
|
|
@ -187,3 +187,10 @@ bool WRL2COORDS::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
SGNODE* WRL2COORDS::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
// XXX - TO IMPLEMENT
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "vrml2_node.h"
|
||||
|
||||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* Class WRL2COORDS
|
||||
|
@ -57,6 +58,7 @@ public:
|
|||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
bool AddRefNode( WRL2NODE* aNode );
|
||||
bool AddChildNode( WRL2NODE* aNode );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent );
|
||||
};
|
||||
|
||||
#endif // VRML2_COORDS_H
|
||||
|
|
|
@ -558,3 +558,10 @@ bool WRL2FACESET::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
SGNODE* WRL2FACESET::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
// XXX - TO IMPLEMENT
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "vrml2_node.h"
|
||||
|
||||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* Class WRL2FACESET
|
||||
|
@ -81,6 +82,7 @@ public:
|
|||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
bool AddRefNode( WRL2NODE* aNode );
|
||||
bool AddChildNode( WRL2NODE* aNode );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent );
|
||||
};
|
||||
|
||||
#endif // VRML2_FACESET_H
|
||||
|
|
|
@ -285,3 +285,10 @@ bool WRL2MATERIAL::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
SGNODE* WRL2MATERIAL::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
// XXX - TO IMPLEMENT
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "vrml2_node.h"
|
||||
|
||||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* Class WRL2MATERIAL
|
||||
|
@ -62,6 +63,7 @@ public:
|
|||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
bool AddRefNode( WRL2NODE* aNode );
|
||||
bool AddChildNode( WRL2NODE* aNode );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent );
|
||||
};
|
||||
|
||||
#endif // VRML2_MATERIAL_H
|
||||
|
|
|
@ -42,6 +42,7 @@ static NODEMAP nodenames;
|
|||
|
||||
WRL2NODE::WRL2NODE()
|
||||
{
|
||||
m_topNode = NULL;
|
||||
m_Parent = NULL;
|
||||
m_Type = WRL2_END;
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "wrlproc.h"
|
||||
|
||||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* Class WRL2NODE
|
||||
|
@ -66,6 +67,8 @@ protected:
|
|||
std::list< WRL2NODE* > m_Refs; // nodes referenced by this node
|
||||
std::string m_error;
|
||||
|
||||
SGNODE* m_topNode; // the SGNODE representation of the display data
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
|
@ -173,6 +176,16 @@ public:
|
|||
virtual bool AddRefNode( WRL2NODE* aNode );
|
||||
|
||||
std::string GetError( void );
|
||||
|
||||
/**
|
||||
* Function TranslateToSG
|
||||
* produces a representation of the data using the intermediate
|
||||
* scenegraph structures of the kicad_3dsg library.
|
||||
*
|
||||
* @param aParent is a pointer to the parent SG node
|
||||
* @return is non-NULL on success
|
||||
*/
|
||||
virtual SGNODE* TranslateToSG( SGNODE* aParent ) = 0;
|
||||
};
|
||||
|
||||
#endif // VRML2_NODE_H
|
||||
|
|
|
@ -187,3 +187,10 @@ bool WRL2NORMS::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
SGNODE* WRL2NORMS::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
// XXX - TO IMPLEMENT
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "vrml2_node.h"
|
||||
|
||||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* Class WRL2NORMS
|
||||
|
@ -57,6 +58,7 @@ public:
|
|||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
bool AddRefNode( WRL2NODE* aNode );
|
||||
bool AddChildNode( WRL2NODE* aNode );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent );
|
||||
};
|
||||
|
||||
#endif // VRML2_NORMS_H
|
||||
|
|
|
@ -309,3 +309,10 @@ bool WRL2SHAPE::Read( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
SGNODE* WRL2SHAPE::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
// XXX - TO IMPLEMENT
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "vrml2_node.h"
|
||||
|
||||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* Class WRL2SHAPE
|
||||
|
@ -62,6 +63,7 @@ public:
|
|||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
bool AddRefNode( WRL2NODE* aNode );
|
||||
bool AddChildNode( WRL2NODE* aNode );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent );
|
||||
};
|
||||
|
||||
#endif // VRML2_SHAPE_H
|
||||
|
|
|
@ -333,3 +333,10 @@ bool WRL2TRANSFORM::readChildren( WRLPROC& proc, WRL2BASE* aTopNode )
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
SGNODE* WRL2TRANSFORM::TranslateToSG( SGNODE* aParent )
|
||||
{
|
||||
// XXX - TO IMPLEMENT
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "vrml2_node.h"
|
||||
|
||||
class WRL2BASE;
|
||||
class SGNODE;
|
||||
|
||||
/**
|
||||
* Class WRL2TRANSFORM
|
||||
|
@ -62,6 +63,7 @@ public:
|
|||
// functions inherited from WRL2NODE
|
||||
bool Read( WRLPROC& proc, WRL2BASE* aTopNode );
|
||||
bool AddRefNode( WRL2NODE* aNode );
|
||||
SGNODE* TranslateToSG( SGNODE* aParent );
|
||||
};
|
||||
|
||||
#endif // VRML2_TRANSFORM_H
|
||||
|
|
|
@ -176,6 +176,7 @@ SCENEGRAPH* Load( char const* aFileName )
|
|||
return NULL;
|
||||
|
||||
LOCALESWITCH switcher;
|
||||
SCENEGRAPH* scene = NULL;
|
||||
|
||||
// VRML file processor
|
||||
WRLPROC proc;
|
||||
|
@ -207,10 +208,12 @@ SCENEGRAPH* Load( char const* aFileName )
|
|||
#ifdef DEBUG
|
||||
std::cout << " * [INFO] load completed\n";
|
||||
#endif
|
||||
|
||||
scene = (SCENEGRAPH*)bp->TranslateToSG( NULL );
|
||||
}
|
||||
|
||||
delete bp;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return scene;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue