Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/pgraph/sceneGraphReducer.h

Go to the documentation of this file.
00001 // Filename: sceneGraphReducer.h
00002 // Created by:  drose (14Mar02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef SCENEGRAPHREDUCER_H
00020 #define SCENEGRAPHREDUCER_H
00021 
00022 #include "pandabase.h"
00023 #include "transformState.h"
00024 #include "renderAttrib.h"
00025 #include "renderState.h"
00026 #include "accumulatedAttribs.h"
00027 #include "geomTransformer.h"
00028 
00029 #include "typedObject.h"
00030 #include "pointerTo.h"
00031 
00032 class PandaNode;
00033 
00034 ///////////////////////////////////////////////////////////////////
00035 //       Class : SceneGraphReducer
00036 // Description : An interface for simplifying ("flattening") scene
00037 //               graphs by eliminating unneeded nodes and collapsing
00038 //               out unneeded state changes and transforms.
00039 //
00040 //               This class is designed so that it may be inherited
00041 //               from and specialized, if needed, to fine-tune the
00042 //               flattening behavior, but normally the default
00043 //               behavior is sufficient.
00044 ////////////////////////////////////////////////////////////////////
00045 class EXPCL_PANDA SceneGraphReducer {
00046 PUBLISHED:
00047   INLINE SceneGraphReducer();
00048   INLINE ~SceneGraphReducer();
00049 
00050   enum AttribTypes {
00051     TT_transform       = 0x001,
00052     TT_color           = 0x002,
00053     TT_color_scale     = 0x004,
00054     TT_tex_matrix      = 0x008,
00055     TT_other           = 0x010,
00056   };
00057 
00058   INLINE void apply_attribs(PandaNode *node, int attrib_types = ~0);
00059   INLINE void apply_attribs(PandaNode *node, const AccumulatedAttribs &attribs,
00060                             int attrib_types, GeomTransformer &transformer);
00061 
00062   int flatten(PandaNode *root, bool combine_siblings);
00063 
00064 protected:
00065   void r_apply_attribs(PandaNode *node, const AccumulatedAttribs &attribs,
00066                        int attrib_types, GeomTransformer &transformer);
00067 
00068   int r_flatten(PandaNode *grandparent_node, PandaNode *parent_node,
00069                 bool combine_siblings);
00070   int flatten_siblings(PandaNode *parent_node);
00071 
00072   bool consider_child(PandaNode *grandparent_node,
00073                       PandaNode *parent_node, PandaNode *child_node);
00074   bool consider_siblings(PandaNode *parent_node, PandaNode *child1,
00075                          PandaNode *child2);
00076 
00077   bool do_flatten_child(PandaNode *grandparent_node, 
00078                         PandaNode *parent_node, PandaNode *child_node);
00079 
00080   PandaNode *do_flatten_siblings(PandaNode *parent_node, 
00081                                  PandaNode *child1, PandaNode *child2);
00082 
00083   PT(PandaNode) collapse_nodes(PandaNode *node1, PandaNode *node2, 
00084                                bool siblings);
00085   void choose_name(PandaNode *preserve, PandaNode *source1, 
00086                    PandaNode *source2);
00087 
00088 private:
00089   GeomTransformer _transformer;
00090 };
00091 
00092 #include "sceneGraphReducer.I"
00093 
00094 #endif

Generated on Fri May 2 00:42:20 2003 for Panda by doxygen1.3