Panda3D
 All Classes Functions Variables Enumerations
eggCharacterData.I
00001 // Filename: eggCharacterData.I
00002 // Created by:  drose (23Feb01)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 
00017 ////////////////////////////////////////////////////////////////////
00018 //     Function: EggCharacterData::get_num_models
00019 //       Access: Public
00020 //  Description: Returns the total number of models associated with
00021 //               this character.
00022 //
00023 //               A "model" here is either a character model (or one
00024 //               LOD of a character model), or a character animation
00025 //               file: in either case, a hierarchy of joints.
00026 ////////////////////////////////////////////////////////////////////
00027 INLINE int EggCharacterData::
00028 get_num_models() const {
00029   return _models.size();
00030 }
00031 
00032 ////////////////////////////////////////////////////////////////////
00033 //     Function: EggCharacterData::get_model_index
00034 //       Access: Public
00035 //  Description: Returns the model_index of the nth model associated
00036 //               with this character.  This model_index may be used to
00037 //               ask questions about the particular model from the
00038 //               EggCharacterCollection object, or from the individual
00039 //               EggJointData and EggSliderData objects.
00040 //
00041 //               A "model" here is either a character model (or one
00042 //               LOD of a character model), or a character animation
00043 //               file: in either case, a hierarchy of joints.
00044 ////////////////////////////////////////////////////////////////////
00045 INLINE int EggCharacterData::
00046 get_model_index(int n) const {
00047   nassertr(n >= 0 && n < (int)_models.size(), 0);
00048   return _models[n]._model_index;
00049 }
00050 
00051 ////////////////////////////////////////////////////////////////////
00052 //     Function: EggCharacterData::get_model_root
00053 //       Access: Public
00054 //  Description: Returns the model_root of the nth model associated
00055 //               with this character.
00056 //
00057 //               This is the node at which the character, animation
00058 //               bundle, or LOD officially began within its particular
00059 //               egg file.
00060 ////////////////////////////////////////////////////////////////////
00061 INLINE EggNode *EggCharacterData::
00062 get_model_root(int n) const {
00063   nassertr(n >= 0 && n < (int)_models.size(), (EggNode *)NULL);
00064   return _models[n]._model_root;
00065 }
00066 
00067 ////////////////////////////////////////////////////////////////////
00068 //     Function: EggCharacterData::get_egg_data
00069 //       Access: Public
00070 //  Description: Returns the EggData representing the egg file that
00071 //               defined this particular model.  Note that one egg
00072 //               file might contain multiple models.
00073 ////////////////////////////////////////////////////////////////////
00074 INLINE EggData *EggCharacterData::
00075 get_egg_data(int n) const {
00076   nassertr(n >= 0 && n < (int)_models.size(), (EggData *)NULL);
00077   return _models[n]._egg_data;
00078 }
00079 
00080 ////////////////////////////////////////////////////////////////////
00081 //     Function: EggCharacterData::get_root_joint
00082 //       Access: Public
00083 //  Description: Returns the root joint of the character hierarchy.
00084 //               This root joint does not represent an actual joint in
00085 //               the hierarchy, but instead is a fictitious joint that
00086 //               is the parent of all the top joints in the hierarchy
00087 //               (since the hierarchy may actually contain zero or
00088 //               more top joints).
00089 ////////////////////////////////////////////////////////////////////
00090 INLINE EggJointData *EggCharacterData::
00091 get_root_joint() const {
00092   return _root_joint;
00093 }
00094 
00095 ////////////////////////////////////////////////////////////////////
00096 //     Function: EggCharacterData::find_joint
00097 //       Access: Public
00098 //  Description: Returns the first joint found with the indicated
00099 //               name, or NULL if no joint has that name.
00100 ////////////////////////////////////////////////////////////////////
00101 INLINE EggJointData *EggCharacterData::
00102 find_joint(const string &name) const {
00103   return _root_joint->find_joint(name);
00104 }
00105 
00106 ////////////////////////////////////////////////////////////////////
00107 //     Function: EggCharacterData::make_new_joint
00108 //       Access: Public
00109 //  Description: Creates a new joint as a child of the indicated joint
00110 //               and returns it.  The new joint will be initialized to
00111 //               the identity transform, so that in inherits the
00112 //               net transform of the indicated parent joint.
00113 ////////////////////////////////////////////////////////////////////
00114 INLINE EggJointData *EggCharacterData::
00115 make_new_joint(const string &name, EggJointData *parent) {
00116   EggJointData *joint = parent->make_new_joint(name);
00117   _joints.push_back(joint);
00118   _components.push_back(joint);
00119   return joint;
00120 }
00121 
00122 ////////////////////////////////////////////////////////////////////
00123 //     Function: EggCharacterData::get_num_joints
00124 //       Access: Public
00125 //  Description: Returns the total number of joints in the character
00126 //               joint hierarchy.
00127 ////////////////////////////////////////////////////////////////////
00128 INLINE int EggCharacterData::
00129 get_num_joints() const {
00130   return _joints.size();
00131 }
00132 
00133 ////////////////////////////////////////////////////////////////////
00134 //     Function: EggCharacterData::get_joint
00135 //       Access: Public
00136 //  Description: Returns the nth joint in the character joint
00137 //               hierarchy.  This returns all of the joints in the
00138 //               hierarchy in an arbitrary ordering.
00139 ////////////////////////////////////////////////////////////////////
00140 INLINE EggJointData *EggCharacterData::
00141 get_joint(int n) const {
00142   nassertr(n >= 0 && n < (int)_joints.size(), NULL);
00143   return _joints[n];
00144 }
00145 
00146 ////////////////////////////////////////////////////////////////////
00147 //     Function: EggCharacterData::get_num_sliders
00148 //       Access: Public
00149 //  Description: Returns the number of sliders in the character
00150 //               slider list.
00151 ////////////////////////////////////////////////////////////////////
00152 INLINE int EggCharacterData::
00153 get_num_sliders() const {
00154   return _sliders.size();
00155 }
00156 
00157 ////////////////////////////////////////////////////////////////////
00158 //     Function: EggCharacterData::get_slider
00159 //       Access: Public
00160 //  Description: Returns the nth slider in the character slider list.
00161 ////////////////////////////////////////////////////////////////////
00162 INLINE EggSliderData *EggCharacterData::
00163 get_slider(int n) const {
00164   nassertr(n >= 0 && n < (int)_sliders.size(), NULL);
00165   return _sliders[n];
00166 }
00167 
00168 ////////////////////////////////////////////////////////////////////
00169 //     Function: EggCharacterData::get_num_components
00170 //       Access: Public
00171 //  Description: Returns the total number of joints and sliders in
00172 //               the character.
00173 ////////////////////////////////////////////////////////////////////
00174 INLINE int EggCharacterData::
00175 get_num_components() const {
00176   return _components.size();
00177 }
00178 
00179 ////////////////////////////////////////////////////////////////////
00180 //     Function: EggCharacterData::get_component
00181 //       Access: Public
00182 //  Description: Returns the nth joint or slider in the character.
00183 //               This can be used to walk linearly through all joints
00184 //               and sliders in the character when you don't care
00185 //               about making a distinction between the two; it
00186 //               returns the same objects that can also be discovered
00187 //               via get_slider() and get_root_joint().
00188 ////////////////////////////////////////////////////////////////////
00189 INLINE EggComponentData *EggCharacterData::
00190 get_component(int n) const {
00191   nassertr(n >= 0 && n < (int)_components.size(), NULL);
00192   return _components[n];
00193 }
 All Classes Functions Variables Enumerations