248 lines
7.7 KiB
C++
248 lines
7.7 KiB
C++
// Filename: eggGroup.h
|
|
// Created by: drose (16Jan99)
|
|
//
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef EGGGROUP_H
|
|
#define EGGGROUP_H
|
|
|
|
#include <pandabase.h>
|
|
|
|
#include "eggGroupNode.h"
|
|
#include "eggAlphaMode.h"
|
|
#include "eggVertex.h"
|
|
#include "eggSwitchCondition.h"
|
|
|
|
#include <luse.h>
|
|
#include <collideMask.h>
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
// Class : EggGroup
|
|
// Description : The main glue of the egg hierarchy, this corresponds
|
|
// to the <Group>, <Instance>, and <Joint> type nodes.
|
|
////////////////////////////////////////////////////////////////////
|
|
class EXPCL_PANDAEGG EggGroup : public EggGroupNode, public EggAlphaMode {
|
|
public:
|
|
typedef map<PT(EggVertex), double> VertexRef;
|
|
|
|
// These bits are all stored somewhere in _flags.
|
|
enum GroupType {
|
|
// The bits here must correspond to those in Flags, below.
|
|
GT_invalid = -1,
|
|
GT_group = 0x00000000,
|
|
GT_instance = 0x00000001,
|
|
GT_joint = 0x00000002,
|
|
};
|
|
enum DartType {
|
|
// The bits here must correspond to those in Flags, below.
|
|
DT_none = 0x00000000,
|
|
DT_sync = 0x00000004,
|
|
DT_nosync = 0x00000008,
|
|
DT_default = 0x0000000c,
|
|
};
|
|
enum BillboardType {
|
|
// The bits here must correspond to those in Flags, below.
|
|
BT_none = 0x00000000,
|
|
BT_axis = 0x00000020,
|
|
BT_point_camera_relative = 0x00000040,
|
|
BT_point_world_relative = 0x00000080,
|
|
};
|
|
enum CollisionSolidType {
|
|
// The bits here must correspond to those in Flags, below.
|
|
CST_none = 0x00000000,
|
|
CST_plane = 0x00010000,
|
|
CST_polygon = 0x00020000,
|
|
CST_polyset = 0x00030000,
|
|
CST_sphere = 0x00040000,
|
|
CST_inverse_sphere = 0x00050000,
|
|
CST_geode = 0x00060000,
|
|
};
|
|
enum CollideFlags {
|
|
// The bits here must correspond to those in Flags, below.
|
|
CF_none = 0x00000000,
|
|
CF_intangible = 0x00080000,
|
|
CF_descend = 0x00100000,
|
|
CF_event = 0x00200000,
|
|
CF_keep = 0x00400000,
|
|
CF_solid = 0x00800000,
|
|
CF_center = 0x01000000,
|
|
CF_turnstile = 0x02000000,
|
|
};
|
|
|
|
EggGroup(const string &name = "");
|
|
EggGroup(const EggGroup ©);
|
|
EggGroup &operator = (const EggGroup ©);
|
|
~EggGroup();
|
|
|
|
virtual void write(ostream &out, int indent_level) const;
|
|
bool parse_egg(const string &egg_syntax);
|
|
|
|
void set_group_type(GroupType type);
|
|
INLINE GroupType get_group_type() const;
|
|
|
|
INLINE void set_billboard_type(BillboardType type);
|
|
INLINE BillboardType get_billboard_type() const;
|
|
|
|
INLINE void set_cs_type(CollisionSolidType type);
|
|
INLINE CollisionSolidType get_cs_type() const;
|
|
|
|
INLINE void set_collide_flags(int flags);
|
|
INLINE CollideFlags get_collide_flags() const;
|
|
|
|
INLINE void set_collision_name(const string &collision_name);
|
|
INLINE void clear_collision_name();
|
|
INLINE bool has_collision_name() const;
|
|
INLINE const string &get_collision_name() const;
|
|
|
|
INLINE void set_dcs_flag(bool flag);
|
|
INLINE bool get_dcs_flag() const;
|
|
|
|
INLINE void set_dart_type(DartType type);
|
|
INLINE DartType get_dart_type() const;
|
|
|
|
INLINE void set_switch_flag(bool flag);
|
|
INLINE bool get_switch_flag() const;
|
|
|
|
INLINE void set_switch_fps(double fps);
|
|
INLINE double get_switch_fps() const;
|
|
|
|
void set_transform(const LMatrix4d &transform);
|
|
void clear_transform();
|
|
INLINE bool has_transform() const;
|
|
INLINE LMatrix4d get_transform() const;
|
|
INLINE bool transform_is_identity() const;
|
|
|
|
INLINE void set_objecttype(const string &objecttype);
|
|
INLINE void clear_objecttype();
|
|
INLINE bool has_objecttype() const;
|
|
INLINE const string &get_objecttype() const;
|
|
|
|
INLINE void set_model_flag(bool flag);
|
|
INLINE bool get_model_flag() const;
|
|
|
|
INLINE void set_texlist_flag(bool flag);
|
|
INLINE bool get_texlist_flag() const;
|
|
|
|
INLINE void set_nofog_flag(bool flag);
|
|
INLINE bool get_nofog_flag() const;
|
|
|
|
INLINE void set_decal_flag(bool flag);
|
|
INLINE bool get_decal_flag() const;
|
|
|
|
INLINE void set_direct_flag(bool flag);
|
|
INLINE bool get_direct_flag() const;
|
|
|
|
INLINE void set_collide_mask(CollideMask mask);
|
|
INLINE void clear_collide_mask();
|
|
INLINE bool has_collide_mask() const;
|
|
INLINE CollideMask get_collide_mask() const;
|
|
|
|
INLINE void set_from_collide_mask(CollideMask mask);
|
|
INLINE void clear_from_collide_mask();
|
|
INLINE bool has_from_collide_mask() const;
|
|
INLINE CollideMask get_from_collide_mask() const;
|
|
|
|
INLINE void set_into_collide_mask(CollideMask mask);
|
|
INLINE void clear_into_collide_mask();
|
|
INLINE bool has_into_collide_mask() const;
|
|
INLINE CollideMask get_into_collide_mask() const;
|
|
|
|
INLINE void set_lod(const EggSwitchCondition &lod);
|
|
INLINE bool has_lod() const;
|
|
INLINE const EggSwitchCondition &get_lod() const;
|
|
|
|
void ref_vertex(EggVertex *vert, double membership = 1.0);
|
|
void unref_vertex(EggVertex *vert);
|
|
void unref_all_vertices();
|
|
double get_vertex_membership(const EggVertex *vert) const;
|
|
|
|
INLINE VertexRef::const_iterator vref_begin() const;
|
|
INLINE VertexRef::const_iterator vref_end() const;
|
|
INLINE VertexRef::size_type vref_size() const;
|
|
|
|
#ifndef NDEBUG
|
|
void test_vref_integrity() const;
|
|
#else
|
|
void test_vref_integrity() const { }
|
|
#endif // NDEBUG
|
|
|
|
static GroupType string_group_type(const string &string);
|
|
static DartType string_dart_type(const string &string);
|
|
static BillboardType string_billboard_type(const string &string);
|
|
static CollisionSolidType string_cs_type(const string &string);
|
|
static CollideFlags string_collide_flags(const string &string);
|
|
|
|
protected:
|
|
void write_vertex_ref(ostream &out, int indent_level) const;
|
|
virtual void adjust_under();
|
|
|
|
virtual void r_transform(const LMatrix4d &mat, const LMatrix4d &inv,
|
|
CoordinateSystem to_cs);
|
|
|
|
private:
|
|
|
|
enum Flags {
|
|
F_group_type = 0x00000003,
|
|
F_dart_type = 0x0000000c,
|
|
F_dcs_flag = 0x00000010,
|
|
F_billboard_type = 0x000000e0,
|
|
F_switch_flag = 0x00000100,
|
|
F_has_transform = 0x00000200,
|
|
F_model_flag = 0x00000400,
|
|
F_texlist_flag = 0x00000800,
|
|
F_nofog_flag = 0x00001000,
|
|
F_decal_flag = 0x00002000,
|
|
F_direct_flag = 0x00004000,
|
|
F_cs_type = 0x00070000,
|
|
F_collide_flags = 0x03f80000,
|
|
};
|
|
enum Flags2 {
|
|
F2_collide_mask = 0x00000001,
|
|
F2_from_collide_mask = 0x00000002,
|
|
F2_into_collide_mask = 0x00000004,
|
|
};
|
|
|
|
int _flags;
|
|
int _flags2;
|
|
LMatrix4d _transform;
|
|
CollideMask _collide_mask, _from_collide_mask, _into_collide_mask;
|
|
string _objecttype;
|
|
string _collision_name;
|
|
double _fps;
|
|
PT(EggSwitchCondition) _lod;
|
|
VertexRef _vref;
|
|
|
|
|
|
public:
|
|
|
|
static TypeHandle get_class_type() {
|
|
return _type_handle;
|
|
}
|
|
static void init_type() {
|
|
EggGroupNode::init_type();
|
|
EggAlphaMode::init_type();
|
|
register_type(_type_handle, "EggGroup",
|
|
EggGroupNode::get_class_type(),
|
|
EggAlphaMode::get_class_type());
|
|
}
|
|
virtual TypeHandle get_type() const {
|
|
return get_class_type();
|
|
}
|
|
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
|
|
|
|
private:
|
|
static TypeHandle _type_handle;
|
|
};
|
|
|
|
ostream &operator << (ostream &out, EggGroup::GroupType t);
|
|
ostream &operator << (ostream &out, EggGroup::DartType t);
|
|
ostream &operator << (ostream &out, EggGroup::BillboardType t);
|
|
ostream &operator << (ostream &out, EggGroup::CollisionSolidType t);
|
|
ostream &operator << (ostream &out, EggGroup::CollideFlags t);
|
|
|
|
|
|
#include "eggGroup.I"
|
|
|
|
#endif
|
|
|