Panda3D
eggCharacterData.I
1 // Filename: eggCharacterData.I
2 // Created by: drose (23Feb01)
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 
16 
17 ////////////////////////////////////////////////////////////////////
18 // Function: EggCharacterData::get_num_models
19 // Access: Public
20 // Description: Returns the total number of models associated with
21 // this character.
22 //
23 // A "model" here is either a character model (or one
24 // LOD of a character model), or a character animation
25 // file: in either case, a hierarchy of joints.
26 ////////////////////////////////////////////////////////////////////
27 INLINE int EggCharacterData::
28 get_num_models() const {
29  return _models.size();
30 }
31 
32 ////////////////////////////////////////////////////////////////////
33 // Function: EggCharacterData::get_model_index
34 // Access: Public
35 // Description: Returns the model_index of the nth model associated
36 // with this character. This model_index may be used to
37 // ask questions about the particular model from the
38 // EggCharacterCollection object, or from the individual
39 // EggJointData and EggSliderData objects.
40 //
41 // A "model" here is either a character model (or one
42 // LOD of a character model), or a character animation
43 // file: in either case, a hierarchy of joints.
44 ////////////////////////////////////////////////////////////////////
45 INLINE int EggCharacterData::
46 get_model_index(int n) const {
47  nassertr(n >= 0 && n < (int)_models.size(), 0);
48  return _models[n]._model_index;
49 }
50 
51 ////////////////////////////////////////////////////////////////////
52 // Function: EggCharacterData::get_model_root
53 // Access: Public
54 // Description: Returns the model_root of the nth model associated
55 // with this character.
56 //
57 // This is the node at which the character, animation
58 // bundle, or LOD officially began within its particular
59 // egg file.
60 ////////////////////////////////////////////////////////////////////
62 get_model_root(int n) const {
63  nassertr(n >= 0 && n < (int)_models.size(), (EggNode *)NULL);
64  return _models[n]._model_root;
65 }
66 
67 ////////////////////////////////////////////////////////////////////
68 // Function: EggCharacterData::get_egg_data
69 // Access: Public
70 // Description: Returns the EggData representing the egg file that
71 // defined this particular model. Note that one egg
72 // file might contain multiple models.
73 ////////////////////////////////////////////////////////////////////
75 get_egg_data(int n) const {
76  nassertr(n >= 0 && n < (int)_models.size(), (EggData *)NULL);
77  return _models[n]._egg_data;
78 }
79 
80 ////////////////////////////////////////////////////////////////////
81 // Function: EggCharacterData::get_root_joint
82 // Access: Public
83 // Description: Returns the root joint of the character hierarchy.
84 // This root joint does not represent an actual joint in
85 // the hierarchy, but instead is a fictitious joint that
86 // is the parent of all the top joints in the hierarchy
87 // (since the hierarchy may actually contain zero or
88 // more top joints).
89 ////////////////////////////////////////////////////////////////////
91 get_root_joint() const {
92  return _root_joint;
93 }
94 
95 ////////////////////////////////////////////////////////////////////
96 // Function: EggCharacterData::find_joint
97 // Access: Public
98 // Description: Returns the first joint found with the indicated
99 // name, or NULL if no joint has that name.
100 ////////////////////////////////////////////////////////////////////
102 find_joint(const string &name) const {
103  return _root_joint->find_joint(name);
104 }
105 
106 ////////////////////////////////////////////////////////////////////
107 // Function: EggCharacterData::make_new_joint
108 // Access: Public
109 // Description: Creates a new joint as a child of the indicated joint
110 // and returns it. The new joint will be initialized to
111 // the identity transform, so that in inherits the
112 // net transform of the indicated parent joint.
113 ////////////////////////////////////////////////////////////////////
115 make_new_joint(const string &name, EggJointData *parent) {
116  EggJointData *joint = parent->make_new_joint(name);
117  _joints.push_back(joint);
118  _components.push_back(joint);
119  return joint;
120 }
121 
122 ////////////////////////////////////////////////////////////////////
123 // Function: EggCharacterData::get_num_joints
124 // Access: Public
125 // Description: Returns the total number of joints in the character
126 // joint hierarchy.
127 ////////////////////////////////////////////////////////////////////
128 INLINE int EggCharacterData::
129 get_num_joints() const {
130  return _joints.size();
131 }
132 
133 ////////////////////////////////////////////////////////////////////
134 // Function: EggCharacterData::get_joint
135 // Access: Public
136 // Description: Returns the nth joint in the character joint
137 // hierarchy. This returns all of the joints in the
138 // hierarchy in an arbitrary ordering.
139 ////////////////////////////////////////////////////////////////////
141 get_joint(int n) const {
142  nassertr(n >= 0 && n < (int)_joints.size(), NULL);
143  return _joints[n];
144 }
145 
146 ////////////////////////////////////////////////////////////////////
147 // Function: EggCharacterData::get_num_sliders
148 // Access: Public
149 // Description: Returns the number of sliders in the character
150 // slider list.
151 ////////////////////////////////////////////////////////////////////
152 INLINE int EggCharacterData::
154  return _sliders.size();
155 }
156 
157 ////////////////////////////////////////////////////////////////////
158 // Function: EggCharacterData::get_slider
159 // Access: Public
160 // Description: Returns the nth slider in the character slider list.
161 ////////////////////////////////////////////////////////////////////
163 get_slider(int n) const {
164  nassertr(n >= 0 && n < (int)_sliders.size(), NULL);
165  return _sliders[n];
166 }
167 
168 ////////////////////////////////////////////////////////////////////
169 // Function: EggCharacterData::get_num_components
170 // Access: Public
171 // Description: Returns the total number of joints and sliders in
172 // the character.
173 ////////////////////////////////////////////////////////////////////
174 INLINE int EggCharacterData::
176  return _components.size();
177 }
178 
179 ////////////////////////////////////////////////////////////////////
180 // Function: EggCharacterData::get_component
181 // Access: Public
182 // Description: Returns the nth joint or slider in the character.
183 // This can be used to walk linearly through all joints
184 // and sliders in the character when you don't care
185 // about making a distinction between the two; it
186 // returns the same objects that can also be discovered
187 // via get_slider() and get_root_joint().
188 ////////////////////////////////////////////////////////////////////
190 get_component(int n) const {
191  nassertr(n >= 0 && n < (int)_components.size(), NULL);
192  return _components[n];
193 }
int get_num_joints() const
Returns the total number of joints in the character joint hierarchy.
EggJointData * find_joint(const string &name) const
Returns the first joint found with the indicated name, or NULL if no joint has that name...
EggJointData * get_root_joint() const
Returns the root joint of the character hierarchy.
EggJointData * find_joint(const string &name)
Returns the first descendent joint found with the indicated name, or NULL if no joint has that name...
Definition: eggJointData.I:54
This corresponds to a single morph slider control.
Definition: eggSliderData.h:31
int get_num_models() const
Returns the total number of models associated with this character.
This is the primary interface into all the egg data, and the root of the egg file structure...
Definition: eggData.h:41
EggData * get_egg_data(int n) const
Returns the EggData representing the egg file that defined this particular model. ...
This is the base class of both EggJointData and EggSliderData.
EggSliderData * get_slider(int n) const
Returns the nth slider in the character slider list.
EggComponentData * get_component(int n) const
Returns the nth joint or slider in the character.
int get_num_components() const
Returns the total number of joints and sliders in the character.
EggNode * get_model_root(int n) const
Returns the model_root of the nth model associated with this character.
This is one node of a hierarchy of EggJointData nodes, each of which represents a single joint of the...
Definition: eggJointData.h:34
EggJointData * get_joint(int n) const
Returns the nth joint in the character joint hierarchy.
A base class for things that may be directly added into the egg hierarchy.
Definition: eggNode.h:38
int get_num_sliders() const
Returns the number of sliders in the character slider list.
EggJointData * make_new_joint(const string &name, EggJointData *parent)
Creates a new joint as a child of the indicated joint and returns it.
int get_model_index(int n) const
Returns the model_index of the nth model associated with this character.