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