29 #include <maya/MString.h> 30 #include <maya/MItDag.h> 31 #include <maya/MSelectionList.h> 32 #include <maya/MGlobal.h> 48 _skeleton_node =
nullptr;
49 _morph_node =
nullptr;
58 MayaNodeDesc *node_desc = r_build_node(dag_path.fullPathName().asChar());
71 MItDag dag_iterator(MItDag::kDepthFirst, MFn::kTransform, &status);
73 status.perror(
"MItDag constructor");
88 while (!dag_iterator.isDone()) {
90 status = dag_iterator.getPath(dag_path);
92 status.perror(
"MItDag::getPath");
101 _root->check_pseudo_joints(
false);
113 _root->tag_joint_recursively();
124 bool found_any =
false;
127 for (ni = _nodes.begin(); ni != _nodes.end(); ++ni) {
129 if (glob.
matches(node->get_name())) {
130 node->tag_joint_recursively();
143 _root->tag_recursively();
154 bool found_any =
false;
157 for (ni = _nodes.begin(); ni != _nodes.end(); ++ni) {
159 if (glob.
matches(node->get_name())) {
160 node->tag_recursively();
176 bool found_any =
false;
179 for (ni = _nodes.begin(); ni != _nodes.end(); ++ni) {
181 if (glob.
matches(node->get_name())) {
182 node->untag_recursively();
199 MItDag dag_iterator(MItDag::kDepthFirst, MFn::kTransform, &status);
201 status.perror(
"MItDag constructor");
205 MSelectionList selection;
206 status = MGlobal::getActiveSelectionList(selection);
208 status.perror(
"MGlobal::getActiveSelectionList");
212 if (selection.isEmpty()) {
214 <<
"Selection list is empty.\n";
220 unsigned int length = selection.length();
221 for (
unsigned int i = 0; i < length; i++) {
223 status = selection.getDagPath(i, root_path);
225 status.perror(
"MSelectionList::getDagPath");
228 dag_iterator.reset(root_path);
229 while (!dag_iterator.isDone()) {
231 status = dag_iterator.getPath(dag_path);
233 status.perror(
"MItDag::getPath");
244 _root->check_pseudo_joints(
false);
256 return _nodes.size();
264 nassertr(n >= 0 && n < (
int)_nodes.size(),
nullptr);
277 _skeleton_node =
nullptr;
278 _morph_node =
nullptr;
279 _nodes_by_path.clear();
291 BlendDescs::iterator bi;
292 for (bi = _blend_descs.
begin(); bi != _blend_descs.
end(); ++bi) {
296 _egg_data = egg_data;
297 _egg_root = egg_root;
298 _skeleton_node = skeleton_node;
299 _morph_node = morph_node;
308 nassertr(_egg_root !=
nullptr,
nullptr);
310 if (node_desc->_egg_group ==
nullptr) {
314 nassertr(node_desc->_parent !=
nullptr,
nullptr);
315 egg_group =
new EggGroup(node_desc->get_name());
319 egg_group->set_group_type(EggGroup::GT_joint);
325 if (node_desc->_parent == _root) {
335 DCAST_INTO_R(parent_user_data, parent_egg_group->
get_user_data(),
nullptr);
345 egg_group->add_object_type(object_type);
348 egg_group->add_object_type(object_type);
351 egg_group->add_object_type(object_type);
356 egg_group->set_scroll_u(value[0]);
357 egg_group->set_scroll_v(value[1]);
358 egg_group->set_scroll_r(value[2]);
364 for (uint ti=0; ti < tag_attribute_names.size(); ti++) {
366 egg_group->
set_tag(tag_attribute_names[ti].substr(3), object_type);
375 if (!visible && egg_group->get_num_object_types() == 0) {
383 egg_group->set_group_type(EggGroup::GT_instance);
384 egg_group->set_billboard_type(EggGroup::BT_axis);
388 egg_group->set_group_type(EggGroup::GT_instance);
389 egg_group->set_billboard_type(EggGroup::BT_point_camera_relative);
393 egg_group->set_group_type(EggGroup::GT_instance);
394 egg_group->set_billboard_type(EggGroup::BT_point_camera_relative);
401 egg_group->set_dcs_type(EggGroup::DC_default);
405 egg_group->set_model_flag(
true);
411 if (parent_user_data ==
nullptr) {
420 user_data->_vertex_color =
true;
424 user_data->_double_sided =
true;
429 if (node_desc->_is_lod) {
432 node_desc->_switch_out,
436 node_desc->_egg_group = egg_group;
439 return node_desc->_egg_group;
448 nassertr(_skeleton_node !=
nullptr,
nullptr);
449 nassertr(node_desc->
is_joint(),
nullptr);
451 if (node_desc->_egg_table ==
nullptr) {
453 nassertr(node_desc->_parent !=
nullptr,
nullptr);
457 node_desc->_anim->set_fps(_fps);
460 if (!node_desc->_parent->
is_joint()) {
470 node_desc->_egg_table = egg_table;
473 return node_desc->_egg_table;
483 return node_desc->_anim;
492 nassertr(_morph_node !=
nullptr,
nullptr);
494 if (blend_desc->_anim ==
nullptr) {
497 egg_anim->set_fps(_fps);
500 blend_desc->_anim = egg_anim;
503 return blend_desc->_anim;
521 if (_ignored_slider_names.insert(name).second) {
523 <<
"Ignoring slider " << name <<
"\n";
539 BlendDescs::iterator bi = _blend_descs.insert(blend_desc).first;
550 return _blend_descs.
size();
558 nassertr(n >= 0 && n < (
int)_blend_descs.
size(),
nullptr);
559 return _blend_descs[n];
567 BlendDescs::iterator bi;
568 for (bi = _blend_descs.
begin(); bi != _blend_descs.
end(); ++bi) {
569 (*bi)->set_slider(0.0);
578 r_build_node(
const string &path) {
581 NodesByPath::const_iterator ni = _nodes_by_path.find(path);
582 if (ni != _nodes_by_path.end()) {
599 size_t bar = path.rfind(
"|");
600 string parent_path, local_name;
601 if (bar != string::npos) {
602 parent_path = path.substr(0, bar);
604 local_name = path.substr(bar + 1);
605 if (local_name == _subroot_parent_name) {
613 if (node_desc != _root) {
614 MayaNodeDesc *parent_node_desc = r_build_node(parent_path);
615 if (parent_node_desc ==
nullptr)
616 mayaegg_cat.info() <<
"empty parent: " << local_name << std::endl;
617 node_desc =
new MayaNodeDesc(
this, parent_node_desc, local_name);
618 _nodes.push_back(node_desc);
622 _nodes_by_path.insert(NodesByPath::value_type(path, node_desc));
EggXfmSAnim * get_egg_anim(MayaNodeDesc *node_desc)
Returns the anim table corresponding to the joint for the indicated node.
A handle to a Maya blend shape description.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void from_dag_path(const MDagPath &dag_path, MayaToEggConverter *converter)
Indicates an association between the MayaNodeDesc and some Maya instance.
void tag_all()
Tags the entire hierarchy for conversion.
int get_num_nodes() const
Returns the total number of nodes in the hierarchy, not counting the root node.
bool ignore_slider(const std::string &name) const
Returns true if the indicated name is on the list of sliders to ignore, 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.
size_type_0 size() const
Returns the number of elements in the ordered vector.
A base class for nodes in the hierarchy that are not leaf nodes.
void clear()
Resets the entire tree in preparation for repopulating with a new scene.
iterator_0 begin()
Returns the iterator that marks the first element in the ordered vector.
Corresponding to an <S$Anim> entry, this stores a single column of numbers, for instance for a morph ...
iterator_0 end()
Returns the iterator that marks the end of the ordered vector.
EggGroup * get_egg_group(MayaNodeDesc *node_desc)
Returns the EggGroupNode corresponding to the group or joint for the indicated node.
This is the primary interface into all the egg data, and the root of the egg file structure.
bool has_dag_path() const
Returns true if a Maya dag path has been associated with this node, false otherwise.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
bool tag_named(const GlobPattern &glob)
Tags nodes matching the indicated glob (and all of their children) for conversion.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool matches(const std::string &candidate) const
Returns true if the candidate string matches the pattern, false otherwise.
bool has_user_data() const
Returns true if a generic user data pointer has recently been set and not yet cleared,...
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...
This is our own Panda specialization on the default STL vector.
MayaBlendDesc * get_blend_desc(int n) const
Returns the nth MayaBlendDesc object discovered in the tree.
void get_tag_attribute_names(MObject &node, pvector< string > &tag_names)
artists should be able to set arbitrary tags.
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void reset_sliders()
Resets all of the sliders associated with all blend shapes down to 0.
bool get_bool_attribute(MObject &node, const string &attribute_name, bool &value)
Extracts the named boolean attribute from the MObject.
MayaBlendDesc * add_blend_desc(MayaBlendDesc *blend_desc)
Adds the indicated MayaBlendDesc object to the list of blends collected so far.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Describes a single instance of a node in the Maya scene graph, relating it to the corresponding egg s...
bool get_vec3d_attribute(MObject &node, const string &attribute_name, LVecBase3d &value)
Extracts the named three-component vector from the MObject.
void report_ignored_slider(const std::string &name)
Outputs a message to the user reporting that a slider was ignored.
bool is_joint() const
Returns true if the node should be treated as a joint by the converter.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
int get_num_blend_descs() const
Returns the number of unique MayaBlendDesc objects (and hence the number of morph sliders) discovered...
AnimationConvert get_animation_convert() const
Returns how source animation will be converted into egg structures.
This corresponds to an <Xfm$Anim_S$> entry, which is a collection of up to nine <S$Anim> entries that...
EggUserData * get_user_data() const
Returns the user data pointer most recently stored on this object, or NULL if nothing was previously ...
MayaNodeDesc * get_node(int n) const
Returns the nth node in the hierarchy, in an arbitrary ordering.
bool tag_joint_named(const GlobPattern &glob)
Tags nodes matching the indicated glob (and all of their children) for conversion.
bool ignore_slider(const std::string &name) const
Returns true if the indicated name is on the list of sliders to ignore, false otherwise.
const MDagPath & get_dag_path() const
Returns the dag path associated with this node.
void set_visibility_mode(VisibilityMode mode)
Specifies whether this geometry is to be considered normally visible, or hidden.
bool build_hierarchy()
Walks through the complete Maya hierarchy but does not tag any nodes for conversion.
This class supervises the construction of an EggData structure from a single Maya file,...
void set_user_data(EggUserData *user_data)
Sets the user data associated with this object.
bool untag_named(const GlobPattern &glob)
Un-tags nodes matching the indicated glob (and all of their children) for conversion.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
EggNode * add_child(EggNode *node)
Adds the indicated child to the group and returns it.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
EggTable * get_egg_table(MayaNodeDesc *node_desc)
Returns the EggTable corresponding to the joint for the indicated node.
EggSAnimData * get_egg_slider(MayaBlendDesc *blend_desc)
Returns the anim table corresponding to the slider for the indicated blend.
void tag_joint_all()
Tags the entire hierarchy for conversion.
bool has_attribute(MObject &node, const string &attribute_name)
Returns true if the node has the indicated attribute, false otherwise.
get_coordinate_system
Returns the coordinate system in which the egg file is defined.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool get_enum_attribute(MObject &node, const string &attribute_name, string &value)
Extracts the enum attribute from the MObject as a string value.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A SwitchCondition that switches the levels-of-detail based on distance from the camera's eyepoint.
This class contains extra user data which is piggybacked onto EggGroup objects for the purpose of the...
bool tag_selected()
Tags the just the selected hierarchy for conversion, or the entire hierarchy if nothing is selected.
This class can be used to test for string matches against standard Unix- shell filename globbing conv...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.