mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
support hard-skinning
This commit is contained in:
parent
6d6241be32
commit
26869342b8
@ -208,7 +208,7 @@ expose(EggGroup::DCSType dcs_type) {
|
|||||||
bool EggJointNodePointer::
|
bool EggJointNodePointer::
|
||||||
has_vertices() const {
|
has_vertices() const {
|
||||||
if (_joint != (EggGroup *)NULL) {
|
if (_joint != (EggGroup *)NULL) {
|
||||||
return (_joint->vref_size() != 0);
|
return (_joint->vref_size() != 0) || _joint->has_primitives();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -65,6 +65,21 @@ get_maya_plug(MObject &node, const string &attribute_name, MPlug &plug) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: is_connected
|
||||||
|
// Description: Returns true if the named connection exists on the
|
||||||
|
// node and is connected to anything, false otherwise.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool
|
||||||
|
is_connected(MObject &node, const string &attribute_name) {
|
||||||
|
MPlug plug;
|
||||||
|
if (!get_maya_plug(node, attribute_name, plug)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return plug.isConnected();
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: has_attribute
|
// Function: has_attribute
|
||||||
// Description: Returns true if the node has the indicated attribute,
|
// Description: Returns true if the node has the indicated attribute,
|
||||||
@ -559,10 +574,17 @@ list_maya_attributes(MObject &node) {
|
|||||||
<< name << " has " << connections.length() << " connections.\n";
|
<< name << " has " << connections.length() << " connections.\n";
|
||||||
for (i = 0; i < connections.length(); i++) {
|
for (i = 0; i < connections.length(); i++) {
|
||||||
MPlug plug = connections[i];
|
MPlug plug = connections[i];
|
||||||
|
|
||||||
maya_cat.info(false)
|
maya_cat.info(false)
|
||||||
<< " " << i << ". " << plug.name().asChar() << ", "
|
<< " " << i << ". " << plug.name().asChar() << ", "
|
||||||
<< plug.attribute().apiTypeStr() << ", "
|
<< plug.attribute().apiTypeStr() << ", "
|
||||||
<< plug.node().apiTypeStr() << "\n";
|
<< plug.node().apiTypeStr();
|
||||||
|
if (plug.isConnected()) {
|
||||||
|
maya_cat.info(false)
|
||||||
|
<< " (*)";
|
||||||
|
}
|
||||||
|
maya_cat.info(false)
|
||||||
|
<< "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,9 @@ class MObject;
|
|||||||
bool
|
bool
|
||||||
get_maya_plug(MObject &node, const string &attribute_name, MPlug &plug);
|
get_maya_plug(MObject &node, const string &attribute_name, MPlug &plug);
|
||||||
|
|
||||||
|
bool
|
||||||
|
is_connected(MObject &node, const string &attribute_name);
|
||||||
|
|
||||||
template<class ValueType>
|
template<class ValueType>
|
||||||
bool
|
bool
|
||||||
get_maya_attribute(MObject &node, const string &attribute_name,
|
get_maya_attribute(MObject &node, const string &attribute_name,
|
||||||
|
@ -17,9 +17,24 @@
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "mayaNodeDesc.h"
|
#include "mayaNodeDesc.h"
|
||||||
|
#include "maya_funcs.h"
|
||||||
|
|
||||||
TypeHandle MayaNodeDesc::_type_handle;
|
TypeHandle MayaNodeDesc::_type_handle;
|
||||||
|
|
||||||
|
// This is a list of the names of Maya connections that count as a
|
||||||
|
// transform.
|
||||||
|
static const char *transform_connections[] = {
|
||||||
|
"translate",
|
||||||
|
"translateX",
|
||||||
|
"translateY",
|
||||||
|
"translateZ",
|
||||||
|
"rotate",
|
||||||
|
"rotateX",
|
||||||
|
"rotateY",
|
||||||
|
"rotateZ",
|
||||||
|
};
|
||||||
|
static const int num_transform_connections = sizeof(transform_connections) / sizeof(const char *);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: MayaNodeDesc::Constructor
|
// Function: MayaNodeDesc::Constructor
|
||||||
// Access: Public
|
// Access: Public
|
||||||
@ -72,6 +87,31 @@ from_dag_path(const MDagPath &dag_path) {
|
|||||||
if (_parent != (MayaNodeDesc *)NULL) {
|
if (_parent != (MayaNodeDesc *)NULL) {
|
||||||
_parent->mark_joint_parent();
|
_parent->mark_joint_parent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// The node is not a joint, but maybe its transform is
|
||||||
|
// controlled by connected inputs. If so, we should treat it
|
||||||
|
// like a joint.
|
||||||
|
bool transform_connected = false;
|
||||||
|
|
||||||
|
MStatus status;
|
||||||
|
MObject node = dag_path.node(&status);
|
||||||
|
if (status) {
|
||||||
|
for (int i = 0;
|
||||||
|
i < num_transform_connections && !transform_connected;
|
||||||
|
i++) {
|
||||||
|
if (is_connected(node, transform_connections[i])) {
|
||||||
|
transform_connected = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transform_connected) {
|
||||||
|
_joint_type = JT_joint;
|
||||||
|
if (_parent != (MayaNodeDesc *)NULL) {
|
||||||
|
_parent->mark_joint_parent();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -662,15 +662,7 @@ process_model_node(MayaNodeDesc *node_desc) {
|
|||||||
mayaegg_cat.debug(false) << "\n";
|
mayaegg_cat.debug(false) << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node_desc->is_joint()) {
|
if (dag_node.inUnderWorld()) {
|
||||||
// Don't bother with joints unless we're getting an animatable
|
|
||||||
// model.
|
|
||||||
if (_animation_convert == AC_model) {
|
|
||||||
EggGroup *egg_group = _tree.get_egg_group(node_desc);
|
|
||||||
get_joint_transform(dag_path, egg_group);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (dag_node.inUnderWorld()) {
|
|
||||||
if (mayaegg_cat.is_debug()) {
|
if (mayaegg_cat.is_debug()) {
|
||||||
mayaegg_cat.debug()
|
mayaegg_cat.debug()
|
||||||
<< "Ignoring underworld node " << path
|
<< "Ignoring underworld node " << path
|
||||||
@ -700,7 +692,7 @@ process_model_node(MayaNodeDesc *node_desc) {
|
|||||||
|
|
||||||
} else if (dag_path.hasFn(MFn::kNurbsSurface)) {
|
} else if (dag_path.hasFn(MFn::kNurbsSurface)) {
|
||||||
EggGroup *egg_group = _tree.get_egg_group(node_desc);
|
EggGroup *egg_group = _tree.get_egg_group(node_desc);
|
||||||
get_transform(dag_path, egg_group);
|
get_transform(node_desc, dag_path, egg_group);
|
||||||
|
|
||||||
MFnNurbsSurface surface(dag_path, &status);
|
MFnNurbsSurface surface(dag_path, &status);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
@ -718,7 +710,7 @@ process_model_node(MayaNodeDesc *node_desc) {
|
|||||||
// things in them.
|
// things in them.
|
||||||
if (_animation_convert != AC_model) {
|
if (_animation_convert != AC_model) {
|
||||||
EggGroup *egg_group = _tree.get_egg_group(node_desc);
|
EggGroup *egg_group = _tree.get_egg_group(node_desc);
|
||||||
get_transform(dag_path, egg_group);
|
get_transform(node_desc, dag_path, egg_group);
|
||||||
|
|
||||||
MFnNurbsCurve curve(dag_path, &status);
|
MFnNurbsCurve curve(dag_path, &status);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
@ -732,7 +724,7 @@ process_model_node(MayaNodeDesc *node_desc) {
|
|||||||
|
|
||||||
} else if (dag_path.hasFn(MFn::kMesh)) {
|
} else if (dag_path.hasFn(MFn::kMesh)) {
|
||||||
EggGroup *egg_group = _tree.get_egg_group(node_desc);
|
EggGroup *egg_group = _tree.get_egg_group(node_desc);
|
||||||
get_transform(dag_path, egg_group);
|
get_transform(node_desc, dag_path, egg_group);
|
||||||
|
|
||||||
MFnMesh mesh(dag_path, &status);
|
MFnMesh mesh(dag_path, &status);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
@ -761,13 +753,13 @@ process_model_node(MayaNodeDesc *node_desc) {
|
|||||||
// locators within character models may not be meaningful.
|
// locators within character models may not be meaningful.
|
||||||
egg_group->set_dcs_type(EggGroup::DC_net);
|
egg_group->set_dcs_type(EggGroup::DC_net);
|
||||||
}
|
}
|
||||||
get_transform(dag_path, egg_group);
|
get_transform(node_desc, dag_path, egg_group);
|
||||||
make_locator(dag_path, dag_node, egg_group);
|
make_locator(dag_path, dag_node, egg_group);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Just a generic node.
|
// Just a generic node.
|
||||||
EggGroup *egg_group = _tree.get_egg_group(node_desc);
|
EggGroup *egg_group = _tree.get_egg_group(node_desc);
|
||||||
get_transform(dag_path, egg_group);
|
get_transform(node_desc, dag_path, egg_group);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -780,10 +772,15 @@ process_model_node(MayaNodeDesc *node_desc) {
|
|||||||
// and applies it to the corresponding Egg node.
|
// and applies it to the corresponding Egg node.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void MayaToEggConverter::
|
void MayaToEggConverter::
|
||||||
get_transform(const MDagPath &dag_path, EggGroup *egg_group) {
|
get_transform(MayaNodeDesc *node_desc, const MDagPath &dag_path,
|
||||||
|
EggGroup *egg_group) {
|
||||||
if (_animation_convert == AC_model) {
|
if (_animation_convert == AC_model) {
|
||||||
// When we're getting an animated model, we only get transforms
|
// When we're getting an animated model, we only get transforms
|
||||||
// for joints.
|
// for joints, and they get converted in a special way.
|
||||||
|
|
||||||
|
if (node_desc->is_joint()) {
|
||||||
|
get_joint_transform(dag_path, egg_group);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1769,8 +1766,7 @@ get_vertex_weights(const MDagPath &dag_path, const MFnMesh &mesh,
|
|||||||
it.next();
|
it.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
mayaegg_cat.error()
|
// The mesh was not soft-skinned.
|
||||||
<< "Unable to find a cluster handle for the DG node.\n";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,8 @@ private:
|
|||||||
bool convert_hierarchy(EggGroupNode *egg_root);
|
bool convert_hierarchy(EggGroupNode *egg_root);
|
||||||
bool process_model_node(MayaNodeDesc *node_desc);
|
bool process_model_node(MayaNodeDesc *node_desc);
|
||||||
|
|
||||||
void get_transform(const MDagPath &dag_path, EggGroup *egg_group);
|
void get_transform(MayaNodeDesc *node_desc, const MDagPath &dag_path,
|
||||||
|
EggGroup *egg_group);
|
||||||
void get_joint_transform(const MDagPath &dag_path, EggGroup *egg_group);
|
void get_joint_transform(const MDagPath &dag_path, EggGroup *egg_group);
|
||||||
|
|
||||||
// I ran into core dumps trying to pass around a MFnMesh object by
|
// I ran into core dumps trying to pass around a MFnMesh object by
|
||||||
|
Loading…
x
Reference in New Issue
Block a user