mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
egg object types in maya2egg
This commit is contained in:
parent
465c6aecff
commit
b63e567d49
@ -29,6 +29,7 @@
|
||||
#include <maya/MPlug.h>
|
||||
#include <maya/MFnAttribute.h>
|
||||
#include <maya/MFnTypedAttribute.h>
|
||||
#include <maya/MFnEnumAttribute.h>
|
||||
#include "post_maya_include.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -47,7 +48,7 @@ get_maya_plug(MObject &node, const string &attribute_name, MPlug &plug) {
|
||||
|
||||
MObject attr = node_fn.attribute(attribute_name.c_str(), &status);
|
||||
if (!status) {
|
||||
maya_cat.error()
|
||||
maya_cat.debug()
|
||||
<< "Object " << node_fn.name() << " does not support attribute "
|
||||
<< attribute_name << "\n";
|
||||
return false;
|
||||
@ -177,6 +178,49 @@ get_vec2d_attribute(MObject &node, const string &attribute_name,
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: get_enum_attribute
|
||||
// Description: Extracts the enum attribute from the MObject as a
|
||||
// string value.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool
|
||||
get_enum_attribute(MObject &node, const string &attribute_name,
|
||||
string &value) {
|
||||
MStatus status;
|
||||
|
||||
MPlug plug;
|
||||
if (!get_maya_plug(node, attribute_name.c_str(), plug)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MFnEnumAttribute enum_attrib(plug.attribute(), &status);
|
||||
if (!status) {
|
||||
maya_cat.error()
|
||||
<< "Not an enum attribute: " << attribute_name << "\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
short index;
|
||||
status = plug.getValue(index);
|
||||
if (!status) {
|
||||
maya_cat.error()
|
||||
<< "Could not get numeric value of " << attribute_name << "\n";
|
||||
status.perror("MPlug::getValue(short)");
|
||||
return false;
|
||||
}
|
||||
|
||||
MString name = enum_attrib.fieldName(index, &status);
|
||||
if (!status) {
|
||||
maya_cat.error()
|
||||
<< "Invalid value for " << attribute_name << ": " << index << "\n";
|
||||
status.perror("MFnEnumAttribute::fieldName()");
|
||||
return false;
|
||||
}
|
||||
|
||||
value = name.asChar();
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: get_string_attribute
|
||||
// Description: Extracts the named string attribute from the
|
||||
@ -376,7 +420,7 @@ list_maya_attributes(MObject &node) {
|
||||
MPlugArray connections;
|
||||
status = node_fn.getConnections(connections);
|
||||
if (!status) {
|
||||
status.perror("MFnDependencyNode::getConnections\n");
|
||||
status.perror("MFnDependencyNode::getConnections");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -64,6 +64,10 @@ bool
|
||||
get_vec2d_attribute(MObject &node, const string &attribute_name,
|
||||
LVecBase2d &value);
|
||||
|
||||
bool
|
||||
get_enum_attribute(MObject &node, const string &attribute_name,
|
||||
string &value);
|
||||
|
||||
bool
|
||||
get_string_attribute(MObject &node, const string &attribute_name,
|
||||
string &value);
|
||||
|
@ -1415,16 +1415,17 @@ get_vertex_weights(const MDagPath &dag_path, const MFnMesh &mesh,
|
||||
////////////////////////////////////////////////////////////////////
|
||||
EggGroup *MayaToEggConverter::
|
||||
get_egg_group(const MDagPath &dag_path, EggGroupNode *egg_root) {
|
||||
return get_egg_group(dag_path.fullPathName().asChar(), egg_root);
|
||||
return r_get_egg_group(dag_path.fullPathName().asChar(), dag_path, egg_root);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MayaToEggConverter::get_egg_group
|
||||
// Function: MayaToEggConverter::r_get_egg_group
|
||||
// Access: Private
|
||||
// Description: The recursive implementation of get_egg_group().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
EggGroup *MayaToEggConverter::
|
||||
get_egg_group(const string &name, EggGroupNode *egg_root) {
|
||||
r_get_egg_group(const string &name, const MDagPath &dag_path,
|
||||
EggGroupNode *egg_root) {
|
||||
// If we have already encountered this pathname, return the
|
||||
// corresponding EggGroup immediately.
|
||||
Groups::const_iterator gi = _groups.find(name);
|
||||
@ -1453,7 +1454,8 @@ get_egg_group(const string &name, EggGroupNode *egg_root) {
|
||||
local_name = name;
|
||||
}
|
||||
|
||||
EggGroup *parent_egg_group = get_egg_group(parent_name, egg_root);
|
||||
EggGroup *parent_egg_group =
|
||||
r_get_egg_group(parent_name, dag_path, egg_root);
|
||||
egg_group = new EggGroup(local_name);
|
||||
|
||||
if (parent_egg_group != (EggGroup *)NULL) {
|
||||
@ -1461,6 +1463,12 @@ get_egg_group(const string &name, EggGroupNode *egg_root) {
|
||||
} else {
|
||||
egg_root->add_child(egg_group);
|
||||
}
|
||||
|
||||
// Check for an object type setting, from Oliver's plug-in.
|
||||
string object_type;
|
||||
if (get_enum_attribute(dag_path.node(), "eggObjectTypes", object_type)) {
|
||||
egg_group->add_object_type(object_type);
|
||||
}
|
||||
}
|
||||
|
||||
_groups.insert(Groups::value_type(name, egg_group));
|
||||
|
@ -113,7 +113,8 @@ private:
|
||||
};
|
||||
|
||||
EggGroup *get_egg_group(const MDagPath &dag_path, EggGroupNode *egg_root);
|
||||
EggGroup *get_egg_group(const string &name, EggGroupNode *egg_root);
|
||||
EggGroup *r_get_egg_group(const string &name, const MDagPath &dag_path,
|
||||
EggGroupNode *egg_root);
|
||||
JointAnim *get_egg_table(const MDagPath &dag_path, EggGroupNode *egg_root);
|
||||
JointAnim *get_egg_table(const string &name, EggGroupNode *egg_root);
|
||||
void set_shader_attributes(EggPrimitive &primitive,
|
||||
|
Loading…
x
Reference in New Issue
Block a user