Panda3D
daeCharacter.h
1 // Filename: daeCharacter.h
2 // Created by: pro-rsoft (24Nov08)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef DAECHARACTER_H
16 #define DAECHARACTER_H
17 
18 #include "pandatoolbase.h"
19 #include "typedReferenceCount.h"
20 #include "typeHandle.h"
21 #include "eggTable.h"
22 #include "epvector.h"
23 
24 #include "pre_fcollada_include.h"
25 #include "FCollada.h"
26 #include "FCDocument/FCDSceneNode.h"
27 #include "FCDocument/FCDControllerInstance.h"
28 #include "FCDocument/FCDSkinController.h"
29 #include "FCDocument/FCDGeometryMesh.h"
30 
31 class DAEToEggConverter;
32 
33 ////////////////////////////////////////////////////////////////////
34 // Class : DaeCharacter
35 // Description : Class representing an animated character.
36 ////////////////////////////////////////////////////////////////////
38 public:
39  DaeCharacter(EggGroup *node_group, const FCDControllerInstance* controller_instance);
40 
41  struct Joint {
42  INLINE Joint(EggGroup *group, const FCDSceneNode *scene_node) :
43  _group(group),
44  _scene_node(scene_node),
45  _character(NULL),
46  _bind_pose(LMatrix4d::ident_mat()) {}
47 
48  LMatrix4d _bind_pose;
49  PT(EggGroup) _group;
50  const FCDSceneNode *_scene_node;
51  DaeCharacter *_character;
52  };
53  typedef epvector<Joint> Joints;
55 
56  void bind_joints(JointMap &joint_map);
57  void adjust_joints(FCDSceneNode *node, const JointMap &joint_map,
58  const LMatrix4d &transform = LMatrix4d::ident_mat());
59 
60  void influence_vertex(int index, EggVertex *vertex);
61 
62  void collect_keys(pset<float> &keys);
63  void r_collect_keys(FCDSceneNode *node, pset<float> &keys);
64 
65  void build_table(EggTable *parent, FCDSceneNode* node, const pset<float> &keys);
66 
67 public:
68  PT(EggGroup) _node_group;
69  const FCDGeometryMesh *_skin_mesh;
70  const FCDControllerInstance *_instance;
71  LMatrix4d _bind_shape_mat;
72 
73 private:
74  string _name;
75  const FCDSkinController *_skin_controller;
76  Joints _joints;
77  JointMap _bound_joints;
78 
79 public:
80  virtual TypeHandle get_type() const {
81  return get_class_type();
82  }
83  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
84  static TypeHandle get_class_type() {
85  return _type_handle;
86  }
87  static void init_type() {
88  TypedReferenceCount::init_type();
89  register_type(_type_handle, "DaeCharacter",
90  TypedReferenceCount::get_class_type());
91  }
92 
93 private:
94  static TypeHandle _type_handle;
95 };
96 
97 #endif
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:4716
void r_collect_keys(FCDSceneNode *node, pset< float > &keys)
Collects all animation keys found for the given node tree.
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
Class representing an animated character.
Definition: daeCharacter.h:37
This class supervises the construction of an EggData structure from a DAE file.
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
Definition: eggGroup.h:36
void influence_vertex(int index, EggVertex *vertex)
Adds the influences for the given vertex.
static const LMatrix4d & ident_mat()
Returns an identity matrix.
Definition: lmatrix.h:5168
Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal...
Definition: eggVertex.h:41
void bind_joints(JointMap &joint_map)
Binds the joints to the character.
This corresponds to a.
Definition: eggTable.h:31
This is our own Panda specialization on the default STL set.
Definition: pset.h:52
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
void build_table(EggTable *parent, FCDSceneNode *node, const pset< float > &keys)
Processes a joint node and its transforms.
void collect_keys(pset< float > &keys)
Collects all animation keys of animations applied to this character.
void adjust_joints(FCDSceneNode *node, const JointMap &joint_map, const LMatrix4d &transform=LMatrix4d::ident_mat())
Traverses through the character hierarchy in order to bind the mesh to the character.