00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
00037
00038
00039
00040
00041
00042 class EXPCL_PANDAEGG EggNode : public EggNamedObject {
00043 public:
00044 INLINE EggNode(const string &name = "");
00045 INLINE EggNode(const EggNode ©);
00046 INLINE EggNode &operator = (const EggNode ©);
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
00102
00103
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