eng_graph_maker.hh

Go to the documentation of this file.
00001 /*
00008  * LEGAL:   COPYRIGHT (C) 2007 JIM E. BROOKS
00009  *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
00010  *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
00011  *****************************************************************************/
00012 
00013 #ifndef ENG_GRAPH_MAKER_HH
00014 #define ENG_GRAPH_MAKER_HH 1
00015 
00016 namespace eng {
00017 
00068 class GraphMaker
00069 {
00070 
00071 public:
00075     class NodePredecessors
00076     {
00077     
00078     friend class GraphMaker;
00079     public:
00080                 NodePredecessors( void );
00081                 ~NodePredecessors();
00082         void    Clear( void );
00083         // Subset of Nodes is intentional.
00084         void    Assign( const ModesNode::Value&       value );
00085         void    Assign( const MaterialNode::Value&    value );
00086         void    Assign( const TextureNode::Value&     value );
00087         void    Assign( const ColorsNode::Value&      value );
00088         void    Assign( const PolygonNode::Value&     value );
00089         void    Assign( const PolygonNode_Tex::Value& value );
00090     private:
00091         struct NodeValues
00092         {
00093             NodeValues( void );
00094                  ModesNode::Value mModes;
00095               MaterialNode::Value mMaterial;
00096                TextureNode::Value mTexture;
00097                 ColorsNode::Value mColors;
00098                PolygonNode::Value mPolygon;
00099            PolygonNode_Tex::Value mPolygonTex;
00100         };
00101 
00102     private:
00103         NodeValues      mNodeValues;
00104     };
00105 
00106 public:
00110     class Partition : public Shared
00111     {
00112     friend class SharedPtr<Partition>;
00113     friend class GraphMaker;
00114     private:
00115                             Partition( Node::Ptr parentNode, const string& name );
00116                             ~Partition();
00117     public:
00118         void                SetVertexsNode( SharedPtr<LocalVertexs> vertexs );
00119         void                SetPivotVertex( const LocalVertex& pivotVertex );
00120 
00121     private:
00122         PartitionNode::Ptr  GetRootNode( void ) const;
00123         Node::Ptr           GetParentNode( void ) const;
00124 
00125     private:
00127         struct UniqueNodes
00128         {
00129             //UniqueNodes( void );  // unnecesssary, Node::Ptr is shptr0 which initially nullifies
00130 
00131             PartitionNode::Ptr mPartitionNode;     // root
00132             TransformNode::Ptr mTransformNode;
00133               VertexsNode::Ptr   mVertexsNode;
00134               NormalsNode::Ptr   mNormalsNode;
00135         };
00136 
00138         struct DefaultNodes
00139         {
00140                 ModesNode::Ptr     mModesNode;
00141              MaterialNode::Ptr  mMaterialNode;
00142               TextureNode::Ptr   mTextureNode;
00143         };
00144 
00145         // Color/polygon values are omitted since there are no reasonable defaults,
00146         // rather, the client is expected to define them.
00147         UniqueNodes     mUniqueNodes;
00148         DefaultNodes    mDefaultNodes;
00149     };
00150 
00151 // Public interface:
00152 public:
00153                         GraphMaker( void );
00154                         ~GraphMaker();
00155     SharedPtr<Graph>        Commit( void );
00156 
00157     SharedPtr<Partition>    GetPartition( void );
00158     void                SelectPartition( SharedPtr<Partition> partition );
00159     SharedPtr<Partition>    MakeChildPartition( SharedPtr<Partition> parentPartition, const string& name );
00160     SharedPtr<Partition>    MakeSiblingPartition( SharedPtr<Partition> prevSiblingPartition, const string& name );
00161 
00162     ModesNode::Ptr       AttachNode( const       ModesNode::Value& nodeValue, const NodePredecessors& nodePredecessors );
00163     MaterialNode::Ptr    AttachNode( const    MaterialNode::Value& nodeValue, const NodePredecessors& nodePredecessors );
00164     TextureNode::Ptr     AttachNode( const     TextureNode::Value& nodeValue, const NodePredecessors& nodePredecessors );
00165     ColorsNode::Ptr      AttachNode( const      ColorsNode::Value& nodeValue, const NodePredecessors& nodePredecessors );
00166     PolygonNode::Ptr     AttachNode( const     PolygonNode::Value& nodeValue, const NodePredecessors& nodePredecessors );
00167     PolygonNode_Tex::Ptr AttachNode( const PolygonNode_Tex::Value& nodeValue, const NodePredecessors& nodePredecessors );
00168     void                 SetConstantNormals( SharedPtr<NormalVertexs> polygonNormals, SharedPtr<NormalVertexs> vertexNormals );
00169 
00170 private:
00171     template<typename POLYGON_NODE>
00172     typename POLYGON_NODE::Ptr
00173     AttachPolygonNode2( const typename POLYGON_NODE::Value& nodeValue, const NodePredecessors& nodePredecessors );
00174 
00175     template<typename POLYGON_NODE,
00176              typename POLYGON_NODE_TRI_COLOR1,
00177              typename POLYGON_NODE_QUAD_COLOR1,
00178              typename POLYGON_NODE_TRI_COLOR3,
00179              typename POLYGON_NODE_QUAD_COLOR4>
00180     typename POLYGON_NODE::Ptr
00181     AttachPolygonNode( const typename POLYGON_NODE::Value& nodeValue, const NodePredecessors& nodePredecessors );
00182 
00183 // Data:
00184 private:
00185     shptr<Graph>        mGraph;         // ORDER-DEPENDENT
00186     shptr<Partition>    mPartition;     // ORDER-DEPENDENT
00187 };
00188 
00189 } // namespace eng
00190 
00191 #endif // ENG_GRAPH_MAKER_HH
Palomino 3D Engine documents generated by doxygen 1.5.3 on Fri Nov 23 11:26:08 2007