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

panda/src/egg/eggNode.h

Go to the documentation of this file.
00001 // Filename: eggNode.h
00002 // Created by:  drose (16Jan99)
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 EGGNODE_H
00020 #define EGGNODE_H
00021 
00022 #include <pandabase.h>
00023 
00024 #include "eggNamedObject.h"
00025 
00026 #include <typedObject.h>
00027 #include <lmatrix.h>
00028 #include <pointerTo.h>
00029 #include <referenceCount.h>
00030 
00031 class EggGroupNode;
00032 class EggRenderMode;
00033 class EggTextureCollection;
00034 
00035 ////////////////////////////////////////////////////////////////////
00036 //       Class : EggNode
00037 // Description : A base class for things that may be directly added
00038 //               into the egg hierarchy.  This includes groups,
00039 //               joints, polygons, vertex pools, etc., but does not
00040 //               include things like vertices.
00041 ////////////////////////////////////////////////////////////////////
00042 class EXPCL_PANDAEGG EggNode : public EggNamedObject {
00043 public:
00044   INLINE EggNode(const string &name = "");
00045   INLINE EggNode(const EggNode &copy);
00046   INLINE EggNode &operator = (const EggNode &copy);
00047 
00048   INLINE EggGroupNode *get_parent() const;
00049   INLINE int get_depth() const;
00050   INLINE bool is_under_instance() const;
00051   INLINE bool is_under_transform() const;
00052   INLINE bool is_local_coord() const;
00053 
00054   INLINE const LMatrix4d &get_vertex_frame() const;
00055   INLINE const LMatrix4d &get_node_frame() const;
00056   INLINE const LMatrix4d &get_vertex_frame_inv() const;
00057   INLINE const LMatrix4d &get_node_frame_inv() const;
00058   INLINE const LMatrix4d &get_vertex_to_node() const;
00059   INLINE const LMatrix4d &get_node_to_vertex() const;
00060 
00061   INLINE void transform(const LMatrix4d &mat);
00062   INLINE void transform_vertices_only(const LMatrix4d &mat);
00063   INLINE void flatten_transforms();
00064   void apply_texmats();
00065 
00066   virtual EggRenderMode *determine_alpha_mode();
00067   virtual EggRenderMode *determine_depth_write_mode();
00068   virtual EggRenderMode *determine_depth_test_mode();
00069   virtual EggRenderMode *determine_draw_order();
00070   virtual EggRenderMode *determine_bin();
00071 
00072   virtual void write(ostream &out, int indent_level) const=0;
00073   bool parse_egg(const string &egg_syntax);
00074 
00075 #ifndef NDEBUG
00076   void test_under_integrity() const;
00077 #else
00078   void test_under_integrity() const { }
00079 #endif  // NDEBUG
00080 
00081 
00082 protected:
00083   enum UnderFlags {
00084     UF_under_instance  = 0x001,
00085     UF_under_transform = 0x002,
00086     UF_local_coord     = 0x004,
00087   };
00088 
00089   virtual bool egg_start_parse_body();
00090 
00091   virtual void update_under(int depth_offset);
00092   virtual void adjust_under();
00093 
00094   virtual void r_transform(const LMatrix4d &mat, const LMatrix4d &inv,
00095                            CoordinateSystem to_cs);
00096   virtual void r_transform_vertices(const LMatrix4d &mat);
00097   virtual void r_mark_coordsys(CoordinateSystem cs);
00098   virtual void r_flatten_transforms();
00099   virtual void r_apply_texmats(EggTextureCollection &textures);
00100 
00101   // These members are updated automatically by prepare_add_child(),
00102   // prepare_remove_child(), and update_under().  Other functions
00103   // shouldn't be fiddling with them.
00104 
00105   EggGroupNode *_parent;
00106   int _depth;
00107   int _under_flags;
00108 
00109   typedef RefCountObj<LMatrix4d> MatrixFrame;
00110 
00111   PT(MatrixFrame) _vertex_frame;
00112   PT(MatrixFrame) _node_frame;
00113   PT(MatrixFrame) _vertex_frame_inv;
00114   PT(MatrixFrame) _node_frame_inv;
00115   PT(MatrixFrame) _vertex_to_node;
00116   PT(MatrixFrame) _node_to_vertex;
00117 
00118 
00119 public:
00120 
00121   static TypeHandle get_class_type() {
00122     return _type_handle;
00123   }
00124   static void init_type() {
00125     EggNamedObject::init_type();
00126     register_type(_type_handle, "EggNode",
00127                   EggNamedObject::get_class_type());
00128   }
00129   virtual TypeHandle get_type() const {
00130     return get_class_type();
00131   }
00132   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00133 
00134 private:
00135   static TypeHandle _type_handle;
00136 
00137 friend class EggGroupNode;
00138 };
00139 
00140 #include "eggNode.I"
00141 
00142 #endif

Generated on Fri May 2 00:37:45 2003 for Panda by doxygen1.3