00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CHARACTERJOINT_H
00016 #define CHARACTERJOINT_H
00017
00018 #include "pandabase.h"
00019 #include "transformState.h"
00020
00021 #include "movingPartMatrix.h"
00022 #include "pandaNode.h"
00023 #include "nodePathCollection.h"
00024 #include "ordered_vector.h"
00025
00026 class JointVertexTransform;
00027 class Character;
00028
00029
00030
00031
00032
00033
00034 class EXPCL_PANDA_CHAR CharacterJoint : public MovingPartMatrix {
00035 protected:
00036 CharacterJoint();
00037 CharacterJoint(const CharacterJoint ©);
00038
00039 PUBLISHED:
00040 CharacterJoint(Character *character,
00041 PartBundle *root, PartGroup *parent, const string &name,
00042 const LMatrix4 &default_value);
00043 virtual ~CharacterJoint();
00044
00045 public:
00046 virtual bool is_character_joint() const;
00047 virtual PartGroup *make_copy() const;
00048
00049 virtual bool update_internals(PartBundle *root, PartGroup *parent,
00050 bool self_changed, bool parent_changed,
00051 Thread *current_thread);
00052 virtual void do_xform(const LMatrix4 &mat, const LMatrix4 &inv_mat);
00053
00054 PUBLISHED:
00055 bool add_net_transform(PandaNode *node);
00056 bool remove_net_transform(PandaNode *node);
00057 bool has_net_transform(PandaNode *node) const;
00058 void clear_net_transforms();
00059 NodePathCollection get_net_transforms();
00060
00061 bool add_local_transform(PandaNode *node);
00062 bool remove_local_transform(PandaNode *node);
00063 bool has_local_transform(PandaNode *node) const;
00064 void clear_local_transforms();
00065 NodePathCollection get_local_transforms();
00066
00067 void get_transform(LMatrix4 &transform) const;
00068 INLINE const LMatrix4 &get_transform() const;
00069 CPT(TransformState) get_transform_state() const;
00070
00071 void get_net_transform(LMatrix4 &transform) const;
00072
00073 Character *get_character() const;
00074
00075 private:
00076 void set_character(Character *character);
00077
00078 private:
00079
00080 Character *_character;
00081
00082 typedef ov_set< PT(PandaNode) > NodeList;
00083 NodeList _net_transform_nodes;
00084 NodeList _local_transform_nodes;
00085
00086 typedef ov_set<JointVertexTransform *> VertexTransforms;
00087 VertexTransforms _vertex_transforms;
00088
00089 public:
00090 static void register_with_read_factory();
00091 virtual void write_datagram(BamWriter* manager, Datagram &me);
00092 virtual int complete_pointers(TypedWritable **p_list,
00093 BamReader *manager);
00094
00095 static TypedWritable *make_CharacterJoint(const FactoryParams ¶ms);
00096
00097 protected:
00098 void fillin(DatagramIterator& scan, BamReader* manager);
00099
00100 private:
00101 int _num_net_nodes, _num_local_nodes;
00102
00103 public:
00104
00105
00106
00107
00108 PT(PandaNode) _geom_node;
00109
00110
00111 LMatrix4 _net_transform;
00112 LMatrix4 _initial_net_transform_inverse;
00113
00114 public:
00115 virtual TypeHandle get_type() const {
00116 return get_class_type();
00117 }
00118 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00119 static TypeHandle get_class_type() {
00120 return _type_handle;
00121 }
00122 static void init_type() {
00123 MovingPartMatrix::init_type();
00124 register_type(_type_handle, "CharacterJoint",
00125 MovingPartMatrix::get_class_type());
00126 }
00127
00128 private:
00129 static TypeHandle _type_handle;
00130
00131 friend class Character;
00132 friend class CharacterJointBundle;
00133 friend class JointVertexTransform;
00134 };
00135
00136 #include "characterJoint.I"
00137
00138 #endif
00139
00140