48 : _loader(loader), _egg_root(root) {
50 _character_node =
new Character(_egg_root->get_name());
51 _bundle = _character_node->get_bundle(0);
53 _morph_root =
nullptr;
54 _skeleton_root =
new PartGroup(_bundle,
"<skeleton>");
55 _structured = structured;
64 return _character_node;
72 return _egg_root->get_name();
88 nassertr(index < (
int)_parts.size(),
nullptr);
103 return get_identity_transform();
106 VertexTransforms::iterator vi = _vertex_transforms.find(index);
107 if (vi != _vertex_transforms.end()) {
113 DCAST_INTO_R(joint, part, get_identity_transform());
116 _vertex_transforms[index] = vt;
127 NodeMap::const_iterator nmi = _node_map.find(egg_node);
128 if (nmi == _node_map.end()) {
131 return (*nmi).second;
145 if (joint->_geom_node !=
nullptr) {
146 node = joint->_geom_node;
159 if (child->
is_geom_node() && child->get_name() == name) {
164 node->add_child(geom_node);
174 if (_morph_root ==
nullptr) {
175 _morph_root =
new PartGroup(_bundle,
"morph");
178 int index = _parts.size();
179 _parts.push_back(slider);
188 VertexSliders::iterator vi = _vertex_sliders.find(name);
189 if (vi != _vertex_sliders.end()) {
196 _vertex_sliders[name] = slider;
206 build_joint_hierarchy(_egg_root, _skeleton_root, -1);
211 make_geometry(_egg_root);
213 _bundle->sort_descendants();
214 parent_joint_nodes(_skeleton_root);
227 void CharacterMaker::
229 if (egg_node->
is_of_type(EggAnimPreload::get_class_type())) {
233 if (egg_anim_preload->has_fps()) {
234 fps = egg_anim_preload->
get_fps();
238 if (egg_anim_preload->has_num_frames()) {
243 if (anim_preload ==
nullptr) {
245 _bundle->set_anim_preload(anim_preload);
247 anim_preload->add_anim(egg_node->get_name(), fps, num_frames);
251 if (egg_node->
is_of_type(EggGroup::get_class_type())) {
256 if (egg_group->get_group_type() == EggGroup::GT_joint) {
266 matd = LMatrix4d::ident_mat();
269 LMatrix4 matf = LCAST(PN_stdfloat, matd);
272 new CharacterJoint(_character_node, _character_node->get_bundle(0),
273 part, egg_group->get_name(), matf);
274 index = _parts.size();
275 _parts.push_back(joint);
282 matf = LCAST(PN_stdfloat, matd);
283 joint->_default_value = matf;
284 joint->_value = matf;
294 joint->_geom_node = geom_node.p();
300 EggGroup::const_iterator ci;
301 for (ci = egg_group->begin(); ci != egg_group->end(); ++ci) {
302 build_joint_hierarchy((*ci), part, index);
306 _node_map[egg_node] = index;
313 void CharacterMaker::
317 PandaNode *joint_node = joint->_geom_node;
318 if (joint_node !=
nullptr) {
319 _character_node->add_child(joint_node);
321 joint_node->
set_transform(TransformState::make_mat(joint->_net_transform));
335 void CharacterMaker::
336 make_geometry(
EggNode *egg_node) {
337 if (egg_node->
is_of_type(EggBin::get_class_type())) {
340 if (!egg_bin->empty() &&
341 (egg_bin->get_bin_number() == EggBinner::BN_polyset ||
342 egg_bin->get_bin_number() == EggBinner::BN_patches)) {
346 if (bin_home ==
nullptr) {
349 bin_home = _egg_root;
358 LMatrix4d transform =
362 _loader.
make_polyset(egg_bin, parent, &transform, is_dynamic,
367 if (egg_node->
is_of_type(EggGroupNode::get_class_type())) {
370 EggGroupNode::const_iterator ci;
371 for (ci = egg_group->begin(); ci != egg_group->end(); ++ci) {
394 EggPrimitive::const_iterator vi;
395 for (vi = egg_primitive->begin();
396 vi != egg_primitive->end();
405 if (!vertex->_dxyzs.empty() ||
406 !vertex->_dnormals.empty() ||
407 !vertex->_drgbas.empty()) {
414 if (!(*uvi)->_duvs.empty()) {
426 vertex_home = egg_primitive->get_parent();
428 nassertr(vertex->
gref_size() == 1,
nullptr);
433 if (home !=
nullptr && home != vertex_home) {
444 nassertr(home !=
nullptr,
nullptr);
452 if (home->
is_of_type(EggGroup::get_class_type())) {
455 while (egg_group !=
nullptr &&
456 egg_group->get_group_type() != EggGroup::GT_joint &&
457 egg_group->get_dart_type() == EggGroup::DT_none) {
458 nassertr(egg_group->get_parent() !=
nullptr,
nullptr);
459 home = egg_group->get_parent();
461 if (home->is_of_type(EggGroup::get_class_type())) {
466 if (egg_group !=
nullptr &&
467 egg_group->get_group_type() == EggGroup::GT_joint &&
487 determine_bin_home(
EggBin *egg_bin) {
496 if (!egg_rigid_geometry) {
506 EggGroupNode::const_iterator ci;
507 for (ci = egg_bin->begin(); ci != egg_bin->end(); ++ci) {
510 EggPrimitive::const_iterator vi;
511 for (vi = egg_primitive->begin();
512 vi != egg_primitive->end();
521 if (!vertex->_dxyzs.empty() ||
522 !vertex->_dnormals.empty() ||
523 !vertex->_drgbas.empty()) {
530 if (!(*uvi)->_duvs.empty()) {
542 vertex_home = egg_primitive->get_parent();
544 nassertr(vertex->
gref_size() == 1,
nullptr);
549 if (home !=
nullptr && home != vertex_home) {
562 nassertr(home !=
nullptr,
nullptr);
570 if (home->
is_of_type(EggGroup::get_class_type())) {
573 while (egg_group !=
nullptr &&
574 egg_group->get_group_type() != EggGroup::GT_joint &&
575 egg_group->get_dart_type() == EggGroup::DT_none) {
576 nassertr(egg_group->get_parent() !=
nullptr,
nullptr);
577 home = egg_group->get_parent();
579 if (home->is_of_type(EggGroup::get_class_type())) {
584 if (egg_group !=
nullptr &&
585 egg_group->get_group_type() == EggGroup::GT_joint &&
591 if (egg_group->get_dcs_type() == EggGroup::DC_none) {
607 egg_group->set_dcs_type(EggGroup::DC_default);
611 joint->_geom_node = geom_node.p();
622 get_identity_transform() {
623 if (_identity_transform ==
nullptr) {
626 return _identity_transform;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A base class for any of a number of kinds of geometry primitives: polygons, point lights,...
GroupRef::size_type gref_size() const
Returns the number of elements between gref_begin() and gref_end().
A basic node of the scene graph or data graph.
This is an iterator adaptor that converts any iterator that returns a pair (e.g.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This table records data about a list of animations for a particular model, such as number of frames a...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
VertexSlider * egg_to_slider(const std::string &name)
Returns the VertexSlider corresponding to the indicated egg slider name.
The collection of all the joints and sliders in the character.
const LMatrix4d & get_node_frame_inv() const
Returns the inverse of the matrix returned by get_node_frame().
An animated character, with skeleton-morph animation and either soft- skinned or hard-skinned vertice...
const LMatrix4d & get_vertex_frame() const
Returns the coordinate frame of the vertices referenced by primitives at or under this node.
A base class for nodes in the hierarchy that are not leaf nodes.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
double get_fps() const
This is only valid if has_fps() returns true.
This is a specialization on VertexSlider that returns the slider value associated with a particular C...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
GroupRef::const_iterator gref_begin() const
Returns an iterator that can, in conjunction with gref_end(), be used to traverse the entire set of g...
This is an abstract base class that retains some slider value, which is a linear value that typically...
bool add_net_transform(PandaNode *node)
Adds the indicated node to the list of nodes that will be updated each frame with the joint's net tra...
This is a morph slider within the character.
PartGroup * egg_to_part(EggNode *egg_node) const
Returns the PartGroup node associated with the given egg node.
get_num_children
Returns the number of child nodes of the group.
std::string get_name() const
Returns the name of the character.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
set_transform
Sets the transform that will be applied to this node and below.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
get_num_children
Returns the number of child nodes this node has.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This node is placed at key points within the scene graph to indicate the roots of "models": subtrees ...
int get_num_frames() const
This is only valid if has_num_frames() returns true.
PandaNode * part_to_node(PartGroup *part, const std::string &name) const
Returns the scene graph node associated with the given PartGroup node, if there is one.
get_default_pose
Returns a read-only accessor to the initial pose transform.
This corresponds to an <AnimPreload> entry.
Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int create_slider(const std::string &name)
Creates a new morph slider of the given name, and returns its index.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int egg_to_index(EggNode *egg_node) const
Returns the index number associated with the PartGroup node for the given egg node,...
virtual bool is_character_joint() const
Returns true if this part is a CharacterJoint, false otherwise.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
const_uv_iterator uv_begin() const
Returns an iterator that allows walking through the complete set of named UV's on the vertex.
A base class for things that may be directly added into the egg hierarchy.
This represents one joint of the character's animation, containing an animating transform matrix.
bool has_dcs_type() const
Returns true if the specified DCS type is not DC_none and not DC_unspecified.
void force_update()
Recalculates the character even if we think it doesn't need it.
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_child
Returns the nth child of the group.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_child
Returns the nth child node of this node.
VertexTransform * egg_to_transform(EggNode *egg_node)
Returns a JointVertexTransform suitable for applying the animation associated with the given egg node...
void set_preserve_transform(PreserveTransform preserve_transform)
Sets the preserve_transform flag.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual bool is_geom_node() const
A simple downcast check.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A node that holds Geom objects, renderable pieces of geometry.
void make_polyset(EggBin *egg_bin, PandaNode *parent, const LMatrix4d *transform, bool is_dynamic, CharacterMaker *character_maker)
Creates a polyset–that is, a Geom–from the primitives that have already been grouped into a bin.
const_uv_iterator uv_end() const
Returns an iterator that allows walking through the complete set of named UV's on the vertex.
Converts an egg data structure, possibly read from an egg file but not necessarily,...
A type of group node that holds related subnodes.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the base class for PartRoot and MovingPart.