00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef EGGGROUP_H
00020 #define EGGGROUP_H
00021
00022 #include "pandabase.h"
00023
00024 #include "eggGroupNode.h"
00025 #include "eggRenderMode.h"
00026 #include "eggTransform3d.h"
00027 #include "eggVertex.h"
00028 #include "eggSwitchCondition.h"
00029 #include "pt_EggVertex.h"
00030
00031 #include "luse.h"
00032 #include "collideMask.h"
00033 #include "vector_string.h"
00034
00035
00036
00037
00038
00039
00040 class EXPCL_PANDAEGG EggGroup : public EggGroupNode, public EggRenderMode, public EggTransform3d {
00041 public:
00042 typedef pmap<PT_EggVertex, double> VertexRef;
00043
00044
00045 enum GroupType {
00046
00047 GT_invalid = -1,
00048 GT_group = 0x00000000,
00049 GT_instance = 0x00000001,
00050 GT_joint = 0x00000002,
00051 };
00052 enum DartType {
00053
00054 DT_none = 0x00000000,
00055 DT_sync = 0x00000004,
00056 DT_nosync = 0x00000008,
00057 DT_default = 0x0000000c,
00058 };
00059 enum DCSType {
00060
00061 DC_none = 0x00000000,
00062 DC_local = 0x00000010,
00063 DC_net = 0x00000020,
00064 DC_default = 0x00000030,
00065 };
00066 enum BillboardType {
00067
00068 BT_none = 0x00000000,
00069 BT_axis = 0x00000020,
00070 BT_point_camera_relative = 0x00000040,
00071 BT_point_world_relative = 0x00000080,
00072 };
00073 enum CollisionSolidType {
00074
00075 CST_none = 0x00000000,
00076 CST_plane = 0x00010000,
00077 CST_polygon = 0x00020000,
00078 CST_polyset = 0x00030000,
00079 CST_sphere = 0x00040000,
00080 CST_inverse_sphere = 0x00050000,
00081 CST_geode = 0x00060000,
00082 };
00083 enum CollideFlags {
00084
00085 CF_none = 0x00000000,
00086 CF_intangible = 0x00080000,
00087 CF_descend = 0x00100000,
00088 CF_event = 0x00200000,
00089 CF_keep = 0x00400000,
00090 CF_solid = 0x00800000,
00091 CF_center = 0x01000000,
00092 CF_turnstile = 0x02000000,
00093 };
00094
00095 EggGroup(const string &name = "");
00096 EggGroup(const EggGroup ©);
00097 EggGroup &operator = (const EggGroup ©);
00098 ~EggGroup();
00099
00100 virtual void write(ostream &out, int indent_level) const;
00101
00102 virtual EggRenderMode *determine_alpha_mode();
00103 virtual EggRenderMode *determine_depth_write_mode();
00104 virtual EggRenderMode *determine_depth_test_mode();
00105 virtual EggRenderMode *determine_draw_order();
00106 virtual EggRenderMode *determine_bin();
00107
00108 void set_group_type(GroupType type);
00109 INLINE GroupType get_group_type() const;
00110 INLINE bool is_instance_type() const;
00111
00112 INLINE void set_billboard_type(BillboardType type);
00113 INLINE BillboardType get_billboard_type() const;
00114
00115 INLINE void set_billboard_center(const LPoint3d &billboard_center);
00116 INLINE void clear_billboard_center();
00117 INLINE bool has_billboard_center() const;
00118 INLINE const LPoint3d &get_billboard_center() const;
00119
00120 INLINE void set_cs_type(CollisionSolidType type);
00121 INLINE CollisionSolidType get_cs_type() const;
00122
00123 INLINE void set_collide_flags(int flags);
00124 INLINE CollideFlags get_collide_flags() const;
00125
00126 INLINE void set_collision_name(const string &collision_name);
00127 INLINE void clear_collision_name();
00128 INLINE bool has_collision_name() const;
00129 INLINE const string &get_collision_name() const;
00130
00131 INLINE void set_dcs_type(DCSType type);
00132 INLINE DCSType get_dcs_type() const;
00133
00134 INLINE void set_dart_type(DartType type);
00135 INLINE DartType get_dart_type() const;
00136
00137 INLINE void set_switch_flag(bool flag);
00138 INLINE bool get_switch_flag() const;
00139
00140 INLINE void set_switch_fps(double fps);
00141 INLINE double get_switch_fps() const;
00142
00143 INLINE void add_object_type(const string &object_type);
00144 INLINE void clear_object_types();
00145 INLINE int get_num_object_types() const;
00146 INLINE string get_object_type(int index) const;
00147 bool has_object_type(const string &object_type) const;
00148 bool remove_object_type(const string &object_type);
00149
00150 INLINE void set_model_flag(bool flag);
00151 INLINE bool get_model_flag() const;
00152
00153 INLINE void set_texlist_flag(bool flag);
00154 INLINE bool get_texlist_flag() const;
00155
00156 INLINE void set_nofog_flag(bool flag);
00157 INLINE bool get_nofog_flag() const;
00158
00159 INLINE void set_decal_flag(bool flag);
00160 INLINE bool get_decal_flag() const;
00161
00162 INLINE void set_direct_flag(bool flag);
00163 INLINE bool get_direct_flag() const;
00164
00165 INLINE void set_collide_mask(CollideMask mask);
00166 INLINE void clear_collide_mask();
00167 INLINE bool has_collide_mask() const;
00168 INLINE CollideMask get_collide_mask() const;
00169
00170 INLINE void set_from_collide_mask(CollideMask mask);
00171 INLINE void clear_from_collide_mask();
00172 INLINE bool has_from_collide_mask() const;
00173 INLINE CollideMask get_from_collide_mask() const;
00174
00175 INLINE void set_into_collide_mask(CollideMask mask);
00176 INLINE void clear_into_collide_mask();
00177 INLINE bool has_into_collide_mask() const;
00178 INLINE CollideMask get_into_collide_mask() const;
00179
00180 INLINE void set_lod(const EggSwitchCondition &lod);
00181 INLINE void clear_lod();
00182 INLINE bool has_lod() const;
00183 INLINE const EggSwitchCondition &get_lod() const;
00184
00185 void ref_vertex(EggVertex *vert, double membership = 1.0);
00186 void unref_vertex(EggVertex *vert);
00187 void unref_all_vertices();
00188 double get_vertex_membership(const EggVertex *vert) const;
00189
00190 INLINE VertexRef::const_iterator vref_begin() const;
00191 INLINE VertexRef::const_iterator vref_end() const;
00192 INLINE VertexRef::size_type vref_size() const;
00193
00194 #ifndef NDEBUG
00195 void test_vref_integrity() const;
00196 #else
00197 void test_vref_integrity() const { }
00198 #endif // NDEBUG
00199
00200 static GroupType string_group_type(const string &string);
00201 static DartType string_dart_type(const string &string);
00202 static DCSType string_dcs_type(const string &string);
00203 static BillboardType string_billboard_type(const string &string);
00204 static CollisionSolidType string_cs_type(const string &string);
00205 static CollideFlags string_collide_flags(const string &string);
00206
00207 protected:
00208 void write_vertex_ref(ostream &out, int indent_level) const;
00209 virtual bool egg_start_parse_body();
00210 virtual void adjust_under();
00211 virtual void r_transform(const LMatrix4d &mat, const LMatrix4d &inv,
00212 CoordinateSystem to_cs);
00213 virtual void r_flatten_transforms();
00214
00215 virtual void transform_changed();
00216
00217 private:
00218
00219 enum Flags {
00220 F_group_type = 0x00000003,
00221 F_dart_type = 0x0000000c,
00222
00223 F_billboard_type = 0x000000e0,
00224 F_switch_flag = 0x00000100,
00225 F_model_flag = 0x00000400,
00226 F_texlist_flag = 0x00000800,
00227 F_nofog_flag = 0x00001000,
00228 F_decal_flag = 0x00002000,
00229 F_direct_flag = 0x00004000,
00230 F_cs_type = 0x00070000,
00231 F_collide_flags = 0x03f80000,
00232 };
00233 enum Flags2 {
00234 F2_collide_mask = 0x00000001,
00235 F2_from_collide_mask = 0x00000002,
00236 F2_into_collide_mask = 0x00000004,
00237 F2_billboard_center = 0x00000008,
00238
00239 F2_dcs_type = 0x00000030,
00240 };
00241
00242 int _flags;
00243 int _flags2;
00244 CollideMask _collide_mask, _from_collide_mask, _into_collide_mask;
00245 LPoint3d _billboard_center;
00246 vector_string _object_types;
00247 string _collision_name;
00248 double _fps;
00249 PT(EggSwitchCondition) _lod;
00250 VertexRef _vref;
00251
00252
00253 public:
00254
00255 static TypeHandle get_class_type() {
00256 return _type_handle;
00257 }
00258 static void init_type() {
00259 EggGroupNode::init_type();
00260 EggRenderMode::init_type();
00261 register_type(_type_handle, "EggGroup",
00262 EggGroupNode::get_class_type(),
00263 EggRenderMode::get_class_type());
00264 }
00265 virtual TypeHandle get_type() const {
00266 return get_class_type();
00267 }
00268 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00269
00270 private:
00271 static TypeHandle _type_handle;
00272 };
00273
00274 ostream &operator << (ostream &out, EggGroup::GroupType t);
00275 ostream &operator << (ostream &out, EggGroup::DartType t);
00276 ostream &operator << (ostream &out, EggGroup::DCSType t);
00277 ostream &operator << (ostream &out, EggGroup::BillboardType t);
00278 ostream &operator << (ostream &out, EggGroup::CollisionSolidType t);
00279 ostream &operator << (ostream &out, EggGroup::CollideFlags t);
00280
00281
00282 #include "eggGroup.I"
00283
00284 #endif
00285