44 : _loader(loader), _egg_root(root) {
46 _character_node =
new Character(_egg_root->get_name());
47 _bundle = _character_node->get_bundle(0);
49 _morph_root =
nullptr;
50 _skeleton_root =
new PartGroup(_bundle,
"<skeleton>");
51 _structured = structured;
60 return _character_node;
68 return _egg_root->get_name();
84 nassertr(index < (
int)_parts.size(),
nullptr);
99 return get_identity_transform();
102 VertexTransforms::iterator vi = _vertex_transforms.find(index);
103 if (vi != _vertex_transforms.end()) {
109 DCAST_INTO_R(joint, part, get_identity_transform());
112 _vertex_transforms[index] = vt;
123 NodeMap::const_iterator nmi = _node_map.find(egg_node);
124 if (nmi == _node_map.end()) {
127 return (*nmi).second;
141 if (joint->_geom_node !=
nullptr) {
142 node = joint->_geom_node;
155 if (child->
is_geom_node() && child->get_name() == name) {
160 node->add_child(geom_node);
170 if (_morph_root ==
nullptr) {
171 _morph_root =
new PartGroup(_bundle,
"morph");
174 int index = _parts.size();
175 _parts.push_back(slider);
184 VertexSliders::iterator vi = _vertex_sliders.find(name);
185 if (vi != _vertex_sliders.end()) {
192 _vertex_sliders[name] = slider;
202 build_joint_hierarchy(_egg_root, _skeleton_root, -1);
207 make_geometry(_egg_root);
210 parent_joint_nodes(_skeleton_root);
225 if (egg_node->
is_of_type(EggAnimPreload::get_class_type())) {
229 if (egg_anim_preload->has_fps()) {
230 fps = egg_anim_preload->
get_fps();
234 if (egg_anim_preload->has_num_frames()) {
239 if (anim_preload ==
nullptr) {
243 anim_preload->add_anim(egg_node->get_name(), fps, num_frames);
247 if (egg_node->
is_of_type(EggGroup::get_class_type())) {
252 if (egg_group->get_group_type() == EggGroup::GT_joint) {
262 matd = LMatrix4d::ident_mat();
265 LMatrix4 matf = LCAST(PN_stdfloat, matd);
268 new CharacterJoint(_character_node, _character_node->get_bundle(0),
269 part, egg_group->get_name(), matf);
270 index = _parts.size();
271 _parts.push_back(joint);
278 matf = LCAST(PN_stdfloat, matd);
279 joint->_default_value = matf;
280 joint->_value = matf;
288 geom_node->set_preserve_transform(ModelNode::PT_net);
290 joint->_geom_node = geom_node.p();
296 EggGroup::const_iterator ci;
297 for (ci = egg_group->begin(); ci != egg_group->end(); ++ci) {
298 build_joint_hierarchy((*ci), part, index);
302 _node_map[egg_node] = index;
313 PandaNode *joint_node = joint->_geom_node;
314 if (joint_node !=
nullptr) {
315 _character_node->add_child(joint_node);
317 joint_node->
set_transform(TransformState::make_mat(joint->_net_transform));
332make_geometry(
EggNode *egg_node) {
333 if (egg_node->
is_of_type(EggBin::get_class_type())) {
336 if (!egg_bin->empty() &&
337 (egg_bin->get_bin_number() == EggBinner::BN_polyset ||
338 egg_bin->get_bin_number() == EggBinner::BN_patches)) {
342 if (bin_home ==
nullptr) {
345 bin_home = _egg_root;
354 LMatrix4d transform =
358 _loader.
make_polyset(egg_bin, parent, &transform, is_dynamic,
363 if (egg_node->
is_of_type(EggGroupNode::get_class_type())) {
366 EggGroupNode::const_iterator ci;
367 for (ci = egg_group->begin(); ci != egg_group->end(); ++ci) {
390 EggPrimitive::const_iterator vi;
391 for (vi = egg_primitive->begin();
392 vi != egg_primitive->end();
401 if (!vertex->_dxyzs.empty() ||
402 !vertex->_dnormals.empty() ||
403 !vertex->_drgbas.empty()) {
410 if (!(*uvi)->_duvs.empty()) {
422 vertex_home = egg_primitive->get_parent();
424 nassertr(vertex->
gref_size() == 1,
nullptr);
429 if (home !=
nullptr && home != vertex_home) {
440 nassertr(home !=
nullptr,
nullptr);
448 if (home->
is_of_type(EggGroup::get_class_type())) {
451 while (egg_group !=
nullptr &&
452 egg_group->get_group_type() != EggGroup::GT_joint &&
453 egg_group->get_dart_type() == EggGroup::DT_none) {
454 nassertr(egg_group->get_parent() !=
nullptr,
nullptr);
455 home = egg_group->get_parent();
457 if (home->
is_of_type(EggGroup::get_class_type())) {
462 if (egg_group !=
nullptr &&
463 egg_group->get_group_type() == EggGroup::GT_joint &&
483determine_bin_home(
EggBin *egg_bin) {
492 if (!egg_rigid_geometry) {
502 EggGroupNode::const_iterator ci;
503 for (ci = egg_bin->begin(); ci != egg_bin->end(); ++ci) {
506 EggPrimitive::const_iterator vi;
507 for (vi = egg_primitive->begin();
508 vi != egg_primitive->end();
517 if (!vertex->_dxyzs.empty() ||
518 !vertex->_dnormals.empty() ||
519 !vertex->_drgbas.empty()) {
526 if (!(*uvi)->_duvs.empty()) {
538 vertex_home = egg_primitive->get_parent();
540 nassertr(vertex->
gref_size() == 1,
nullptr);
545 if (home !=
nullptr && home != vertex_home) {
558 nassertr(home !=
nullptr,
nullptr);
566 if (home->
is_of_type(EggGroup::get_class_type())) {
569 while (egg_group !=
nullptr &&
570 egg_group->get_group_type() != EggGroup::GT_joint &&
571 egg_group->get_dart_type() == EggGroup::DT_none) {
572 nassertr(egg_group->get_parent() !=
nullptr,
nullptr);
573 home = egg_group->get_parent();
575 if (home->
is_of_type(EggGroup::get_class_type())) {
580 if (egg_group !=
nullptr &&
581 egg_group->get_group_type() == EggGroup::GT_joint &&
587 if (egg_group->get_dcs_type() == EggGroup::DC_none) {
602 egg_group->set_dcs_type(EggGroup::DC_default);
605 geom_node->set_preserve_transform(ModelNode::PT_local);
606 joint->_geom_node = geom_node.p();
617get_identity_transform() {
618 if (_identity_transform ==
nullptr) {
621 return _identity_transform;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
The collection of all the joints and sliders in the character.
This represents one joint of the character's animation, containing an animating transform matrix.
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...
int egg_to_index(EggNode *egg_node) const
Returns the index number associated with the PartGroup node for the given egg node,...
std::string get_name() const
Returns the name of the character.
int create_slider(const std::string &name)
Creates a new morph slider of the given name, and returns its index.
VertexSlider * egg_to_slider(const std::string &name)
Returns the VertexSlider corresponding to the indicated egg slider name.
PartGroup * egg_to_part(EggNode *egg_node) const
Returns the PartGroup node associated with the given egg node.
VertexTransform * egg_to_transform(EggNode *egg_node)
Returns a JointVertexTransform suitable for applying the animation associated with the given egg node...
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.
This is a morph slider within the character.
This is a specialization on VertexSlider that returns the slider value associated with a particular C...
An animated character, with skeleton-morph animation and either soft- skinned or hard-skinned vertice...
This corresponds to an <AnimPreload> entry.
get_fps
This is only valid if has_fps() returns true.
get_num_frames
This is only valid if has_num_frames() returns true.
A type of group node that holds related subnodes.
A base class for nodes in the hierarchy that are not leaf nodes.
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
get_default_pose
Returns a read-only accessor to the initial pose transform.
bool has_dcs_type() const
Returns true if the specified DCS type is not DC_none and not DC_unspecified.
Converts an egg data structure, possibly read from an egg file but not necessarily,...
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.
A base class for things that may be directly added into the egg hierarchy.
const LMatrix4d & get_vertex_frame() const
Returns the coordinate frame of the vertices referenced by primitives at or under this node.
const LMatrix4d & get_node_frame_inv() const
Returns the inverse of the matrix returned by get_node_frame().
A base class for any of a number of kinds of geometry primitives: polygons, point lights,...
Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal.
GroupRef::size_type gref_size() const
Returns the number of elements between gref_begin() and gref_end().
const_uv_iterator uv_end() const
Returns an iterator that allows walking through the complete set of named UV's on the vertex.
const_uv_iterator uv_begin() const
Returns an iterator that allows walking through the complete set of named UV's on the vertex.
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...
A node that holds Geom objects, renderable pieces of geometry.
This node is placed at key points within the scene graph to indicate the roots of "models": subtrees ...
A basic node of the scene graph or data graph.
virtual bool is_geom_node() const
A simple downcast check.
get_child
Returns the nth child node of this node.
set_transform
Sets the transform that will be applied to this node and below.
get_num_children
Returns the number of child nodes this node has.
void set_anim_preload(AnimPreloadTable *table)
Replaces the AnimPreloadTable associated with the PartBundle.
bool force_update()
Updates all the parts in the bundle to reflect the data for the current frame, whether we believe it ...
This is the base class for PartRoot and MovingPart.
get_num_children
Returns the number of child nodes of the group.
void sort_descendants()
Sorts the children nodes at each level of the hierarchy into alphabetical order.
get_child
Returns the nth child of the group.
virtual bool is_character_joint() const
Returns true if this part is a CharacterJoint, false otherwise.
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
This is an abstract base class that retains some slider value, which is a linear value that typically...
This is an iterator adaptor that converts any iterator that returns a pair (e.g.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.