Panda3D
|
00001 // Filename: eggNode.h 00002 // Created by: drose (16Jan99) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef EGGNODE_H 00016 #define EGGNODE_H 00017 00018 #include "pandabase.h" 00019 00020 #include "eggNamedObject.h" 00021 00022 #include "typedObject.h" 00023 #include "lmatrix.h" 00024 #include "pointerTo.h" 00025 #include "referenceCount.h" 00026 00027 class EggGroupNode; 00028 class EggRenderMode; 00029 class EggTextureCollection; 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Class : EggNode 00033 // Description : A base class for things that may be directly added 00034 // into the egg hierarchy. This includes groups, 00035 // joints, polygons, vertex pools, etc., but does not 00036 // include things like vertices. 00037 //////////////////////////////////////////////////////////////////// 00038 class EXPCL_PANDAEGG EggNode : public EggNamedObject { 00039 PUBLISHED: 00040 INLINE EggNode(const string &name = ""); 00041 INLINE EggNode(const EggNode ©); 00042 INLINE EggNode &operator = (const EggNode ©); 00043 00044 INLINE EggGroupNode *get_parent() const; 00045 INLINE int get_depth() const; 00046 INLINE bool is_under_instance() const; 00047 INLINE bool is_under_transform() const; 00048 INLINE bool is_local_coord() const; 00049 00050 INLINE const LMatrix4d &get_vertex_frame() const; 00051 INLINE const LMatrix4d &get_node_frame() const; 00052 INLINE const LMatrix4d &get_vertex_frame_inv() const; 00053 INLINE const LMatrix4d &get_node_frame_inv() const; 00054 INLINE const LMatrix4d &get_vertex_to_node() const; 00055 INLINE const LMatrix4d &get_node_to_vertex() const; 00056 00057 INLINE const LMatrix4d *get_vertex_frame_ptr()const; 00058 INLINE const LMatrix4d *get_node_frame_ptr()const; 00059 INLINE const LMatrix4d *get_vertex_frame_inv_ptr()const; 00060 INLINE const LMatrix4d *get_node_frame_inv_ptr()const; 00061 INLINE const LMatrix4d *get_vertex_to_node_ptr()const; 00062 INLINE const LMatrix4d *get_node_to_vertex_ptr()const; 00063 00064 INLINE void transform(const LMatrix4d &mat); 00065 INLINE void transform_vertices_only(const LMatrix4d &mat); 00066 INLINE void flatten_transforms(); 00067 void apply_texmats(); 00068 00069 int rename_node(vector_string strip_prefix); 00070 00071 virtual bool is_joint() const; 00072 virtual bool is_anim_matrix() const; 00073 00074 virtual EggRenderMode *determine_alpha_mode(); 00075 virtual EggRenderMode *determine_depth_write_mode(); 00076 virtual EggRenderMode *determine_depth_test_mode(); 00077 virtual EggRenderMode *determine_visibility_mode(); 00078 virtual EggRenderMode *determine_depth_offset(); 00079 virtual EggRenderMode *determine_draw_order(); 00080 virtual EggRenderMode *determine_bin(); 00081 virtual bool determine_indexed(); 00082 virtual bool determine_decal(); 00083 00084 virtual void write(ostream &out, int indent_level) const=0; 00085 bool parse_egg(const string &egg_syntax); 00086 00087 #ifdef _DEBUG 00088 void test_under_integrity() const; 00089 #else 00090 void test_under_integrity() const { } 00091 #endif // _DEBUG 00092 00093 00094 protected: 00095 enum UnderFlags { 00096 UF_under_instance = 0x001, 00097 UF_under_transform = 0x002, 00098 UF_local_coord = 0x004, 00099 }; 00100 00101 virtual bool egg_start_parse_body(); 00102 00103 virtual void update_under(int depth_offset); 00104 virtual void adjust_under(); 00105 virtual bool has_primitives() const; 00106 virtual bool joint_has_primitives() const; 00107 virtual bool has_normals() const; 00108 00109 virtual void r_transform(const LMatrix4d &mat, const LMatrix4d &inv, 00110 CoordinateSystem to_cs); 00111 virtual void r_transform_vertices(const LMatrix4d &mat); 00112 virtual void r_mark_coordsys(CoordinateSystem cs); 00113 virtual void r_flatten_transforms(); 00114 virtual void r_apply_texmats(EggTextureCollection &textures); 00115 00116 // These members are updated automatically by prepare_add_child(), 00117 // prepare_remove_child(), and update_under(). Other functions 00118 // shouldn't be fiddling with them. 00119 00120 EggGroupNode *_parent; 00121 int _depth; 00122 int _under_flags; 00123 00124 typedef RefCountObj<LMatrix4d> MatrixFrame; 00125 00126 PT(MatrixFrame) _vertex_frame; 00127 PT(MatrixFrame) _node_frame; 00128 PT(MatrixFrame) _vertex_frame_inv; 00129 PT(MatrixFrame) _node_frame_inv; 00130 PT(MatrixFrame) _vertex_to_node; 00131 PT(MatrixFrame) _node_to_vertex; 00132 00133 00134 public: 00135 00136 static TypeHandle get_class_type() { 00137 return _type_handle; 00138 } 00139 static void init_type() { 00140 EggNamedObject::init_type(); 00141 register_type(_type_handle, "EggNode", 00142 EggNamedObject::get_class_type()); 00143 MatrixFrame::init_type(); 00144 } 00145 virtual TypeHandle get_type() const { 00146 return get_class_type(); 00147 } 00148 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00149 00150 private: 00151 static TypeHandle _type_handle; 00152 00153 friend class EggGroupNode; 00154 friend class EggTable; 00155 }; 00156 00157 #include "eggNode.I" 00158 00159 #endif