29#include <maya/MString.h>
30#include <maya/MItDag.h>
31#include <maya/MSelectionList.h>
32#include <maya/MGlobal.h>
50 _skeleton_node =
nullptr;
51 _morph_node =
nullptr;
60 MayaNodeDesc *node_desc = r_build_node(dag_path.fullPathName().asChar());
73 MItDag dag_iterator(MItDag::kDepthFirst, MFn::kTransform, &status);
75 status.perror(
"MItDag constructor");
90 while (!dag_iterator.isDone()) {
92 status = dag_iterator.getPath(dag_path);
94 status.perror(
"MItDag::getPath");
103 _root->check_pseudo_joints(
false);
115 _root->tag_joint_recursively();
126 bool found_any =
false;
129 for (ni = _nodes.begin(); ni != _nodes.end(); ++ni) {
131 if (glob.
matches(node->get_name())) {
132 node->tag_joint_recursively();
145 _root->tag_recursively();
156 bool found_any =
false;
159 for (ni = _nodes.begin(); ni != _nodes.end(); ++ni) {
161 if (glob.
matches(node->get_name())) {
162 node->tag_recursively();
178 bool found_any =
false;
181 for (ni = _nodes.begin(); ni != _nodes.end(); ++ni) {
183 if (glob.
matches(node->get_name())) {
184 node->untag_recursively();
201 MItDag dag_iterator(MItDag::kDepthFirst, MFn::kTransform, &status);
203 status.perror(
"MItDag constructor");
207 MSelectionList selection;
208 status = MGlobal::getActiveSelectionList(selection);
210 status.perror(
"MGlobal::getActiveSelectionList");
214 if (selection.isEmpty()) {
216 <<
"Selection list is empty.\n";
222 unsigned int length = selection.length();
223 for (
unsigned int i = 0; i < length; i++) {
225 status = selection.getDagPath(i, root_path);
227 status.perror(
"MSelectionList::getDagPath");
230 dag_iterator.reset(root_path);
231 while (!dag_iterator.isDone()) {
233 status = dag_iterator.getPath(dag_path);
235 status.perror(
"MItDag::getPath");
246 _root->check_pseudo_joints(
false);
258 return _nodes.size();
266 nassertr(n >= 0 && n < (
int)_nodes.size(),
nullptr);
279 _skeleton_node =
nullptr;
280 _morph_node =
nullptr;
281 _nodes_by_path.clear();
293 BlendDescs::iterator bi;
294 for (bi = _blend_descs.
begin(); bi != _blend_descs.
end(); ++bi) {
298 _egg_data = egg_data;
299 _egg_root = egg_root;
300 _skeleton_node = skeleton_node;
301 _morph_node = morph_node;
310 nassertr(_egg_root !=
nullptr,
nullptr);
312 if (node_desc->_egg_group ==
nullptr) {
316 nassertr(node_desc->_parent !=
nullptr,
nullptr);
317 egg_group =
new EggGroup(node_desc->get_name());
321 egg_group->set_group_type(EggGroup::GT_joint);
327 if (node_desc->_parent == _root) {
337 DCAST_INTO_R(parent_user_data, parent_egg_group->
get_user_data(),
nullptr);
347 for (
unsigned int i = 1; ; i++) {
348 std::ostringstream attr;
349 attr <<
"eggObjectTypes" << i;
361 egg_group->add_object_type(object_type);
366 egg_group->set_scroll_u(value[0]);
367 egg_group->set_scroll_v(value[1]);
368 egg_group->set_scroll_r(value[2]);
374 for (uint ti=0; ti < tag_attribute_names.size(); ti++) {
376 egg_group->
set_tag(tag_attribute_names[ti].substr(3), object_type);
385 if (!visible && egg_group->get_num_object_types() == 0) {
393 egg_group->set_group_type(EggGroup::GT_instance);
394 egg_group->set_billboard_type(EggGroup::BT_axis);
398 egg_group->set_group_type(EggGroup::GT_instance);
399 egg_group->set_billboard_type(EggGroup::BT_point_camera_relative);
403 egg_group->set_group_type(EggGroup::GT_instance);
404 egg_group->set_billboard_type(EggGroup::BT_point_camera_relative);
411 egg_group->set_dcs_type(EggGroup::DC_default);
415 egg_group->set_model_flag(
true);
421 if (parent_user_data ==
nullptr) {
430 user_data->_vertex_color =
true;
434 user_data->_double_sided =
true;
439 if (node_desc->_is_lod) {
442 node_desc->_switch_out,
446 node_desc->_egg_group = egg_group;
449 return node_desc->_egg_group;
458 nassertr(_skeleton_node !=
nullptr,
nullptr);
459 nassertr(node_desc->
is_joint(),
nullptr);
461 if (node_desc->_egg_table ==
nullptr) {
463 nassertr(node_desc->_parent !=
nullptr,
nullptr);
467 node_desc->_anim->set_fps(_fps);
470 if (!node_desc->_parent->
is_joint()) {
480 node_desc->_egg_table = egg_table;
483 return node_desc->_egg_table;
493 return node_desc->_anim;
502 nassertr(_morph_node !=
nullptr,
nullptr);
504 if (blend_desc->_anim ==
nullptr) {
507 egg_anim->set_fps(_fps);
510 blend_desc->_anim = egg_anim;
513 return blend_desc->_anim;
531 if (_ignored_slider_names.insert(name).second) {
533 <<
"Ignoring slider " << name <<
"\n";
549 BlendDescs::iterator bi = _blend_descs.insert(blend_desc).first;
560 return _blend_descs.
size();
568 nassertr(n >= 0 && n < (
int)_blend_descs.
size(),
nullptr);
569 return _blend_descs[n];
577 BlendDescs::iterator bi;
578 for (bi = _blend_descs.
begin(); bi != _blend_descs.
end(); ++bi) {
579 (*bi)->set_slider(0.0);
588r_build_node(
const string &path) {
591 NodesByPath::const_iterator ni = _nodes_by_path.find(path);
592 if (ni != _nodes_by_path.end()) {
609 size_t bar = path.rfind(
"|");
610 string parent_path, local_name;
611 if (bar != string::npos) {
612 parent_path = path.substr(0, bar);
614 local_name = path.substr(bar + 1);
615 if (local_name == _subroot_parent_name) {
623 if (node_desc != _root) {
624 MayaNodeDesc *parent_node_desc = r_build_node(parent_path);
625 if (parent_node_desc ==
nullptr)
626 mayaegg_cat.info() <<
"empty parent: " << local_name << std::endl;
627 node_desc =
new MayaNodeDesc(
this, parent_node_desc, local_name);
628 _nodes.push_back(node_desc);
632 _nodes_by_path.insert(NodesByPath::value_type(path, node_desc));
This is the primary interface into all the egg data, and the root of the egg file structure.
get_coordinate_system
Returns the coordinate system in which the egg file is defined.
A base class for nodes in the hierarchy that are not leaf nodes.
EggNode * add_child(EggNode *node)
Adds the indicated child to the group and returns it.
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
void set_tag(const std::string &key, const std::string &value)
Associates a user-defined value with a user-defined key which is stored on the node.
bool has_object_type(const std::string &object_type) const
Returns true if the indicated object type has been added to the group, or false otherwise.
bool remove_object_type(const std::string &object_type)
Removes the first instance of the indicated object type from the group if it is present.
EggUserData * get_user_data() const
Returns the user data pointer most recently stored on this object, or NULL if nothing was previously ...
bool has_user_data() const
Returns true if a generic user data pointer has recently been set and not yet cleared,...
void set_user_data(EggUserData *user_data)
Sets the user data associated with this object.
void set_visibility_mode(VisibilityMode mode)
Specifies whether this geometry is to be considered normally visible, or hidden.
Corresponding to an entry, this stores a single column of numbers, for instance for a morph target,...
A SwitchCondition that switches the levels-of-detail based on distance from the camera's eyepoint.
This corresponds to an <Xfm$Anim_S$> entry, which is a collection of up to nine entries that specify...
This class can be used to test for string matches against standard Unix- shell filename globbing conv...
bool matches(const std::string &candidate) const
Returns true if the candidate string matches the pattern, false otherwise.
A handle to a Maya blend shape description.
This class contains extra user data which is piggybacked onto EggGroup objects for the purpose of the...
Describes a single instance of a node in the Maya scene graph, relating it to the corresponding egg s...
const MDagPath & get_dag_path() const
Returns the dag path associated with this node.
void from_dag_path(const MDagPath &dag_path, MayaToEggConverter *converter)
Indicates an association between the MayaNodeDesc and some Maya instance.
bool is_joint() const
Returns true if the node should be treated as a joint by the converter.
bool has_dag_path() const
Returns true if a Maya dag path has been associated with this node, false otherwise.
void reset_sliders()
Resets all of the sliders associated with all blend shapes down to 0.
EggGroup * get_egg_group(MayaNodeDesc *node_desc)
Returns the EggGroupNode corresponding to the group or joint for the indicated node.
void clear()
Resets the entire tree in preparation for repopulating with a new scene.
MayaNodeDesc * get_node(int n) const
Returns the nth node in the hierarchy, in an arbitrary ordering.
bool ignore_slider(const std::string &name) const
Returns true if the indicated name is on the list of sliders to ignore, false otherwise.
void tag_joint_all()
Tags the entire hierarchy for conversion.
bool tag_named(const GlobPattern &glob)
Tags nodes matching the indicated glob (and all of their children) for conversion.
MayaNodeDesc * build_node(const MDagPath &dag_path)
Returns a pointer to the node corresponding to the indicated dag_path object, creating it first if ne...
EggXfmSAnim * get_egg_anim(MayaNodeDesc *node_desc)
Returns the anim table corresponding to the joint for the indicated node.
void report_ignored_slider(const std::string &name)
Outputs a message to the user reporting that a slider was ignored.
EggTable * get_egg_table(MayaNodeDesc *node_desc)
Returns the EggTable corresponding to the joint for the indicated node.
bool tag_selected()
Tags the just the selected hierarchy for conversion, or the entire hierarchy if nothing is selected.
int get_num_nodes() const
Returns the total number of nodes in the hierarchy, not counting the root node.
void clear_egg(EggData *egg_data, EggGroupNode *egg_root, EggGroupNode *skeleton_node, EggGroupNode *morph_node)
Removes all of the references to generated egg structures from the tree, and prepares the tree for ge...
MayaBlendDesc * get_blend_desc(int n) const
Returns the nth MayaBlendDesc object discovered in the tree.
bool tag_joint_named(const GlobPattern &glob)
Tags nodes matching the indicated glob (and all of their children) for conversion.
MayaBlendDesc * add_blend_desc(MayaBlendDesc *blend_desc)
Adds the indicated MayaBlendDesc object to the list of blends collected so far.
EggSAnimData * get_egg_slider(MayaBlendDesc *blend_desc)
Returns the anim table corresponding to the slider for the indicated blend.
bool build_hierarchy()
Walks through the complete Maya hierarchy but does not tag any nodes for conversion.
bool untag_named(const GlobPattern &glob)
Un-tags nodes matching the indicated glob (and all of their children) for conversion.
int get_num_blend_descs() const
Returns the number of unique MayaBlendDesc objects (and hence the number of morph sliders) discovered...
void tag_all()
Tags the entire hierarchy for conversion.
This class supervises the construction of an EggData structure from a single Maya file,...
bool ignore_slider(const std::string &name) const
Returns true if the indicated name is on the list of sliders to ignore, false otherwise.
AnimationConvert get_animation_convert() const
Returns how source animation will be converted into egg structures.
iterator_0 begin()
Returns the iterator that marks the first element in the ordered vector.
size_type_0 size() const
Returns the number of elements in the ordered vector.
iterator_0 end()
Returns the iterator that marks the end of the ordered vector.
This is our own Panda specialization on the default STL vector.
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.
bool get_vec3d_attribute(MObject &node, const string &attribute_name, LVecBase3d &value)
Extracts the named three-component vector from the MObject.
void get_tag_attribute_names(MObject &node, pvector< string > &tag_names)
artists should be able to set arbitrary tags.
bool get_enum_attribute(MObject &node, const string &attribute_name, string &value)
Extracts the enum attribute from the MObject as a string value.
bool has_attribute(MObject &node, const string &attribute_name)
Returns true if the node has the indicated attribute, false otherwise.
bool get_bool_attribute(MObject &node, const string &attribute_name, bool &value)
Extracts the named boolean attribute from the MObject.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.