mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -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::
|
||||
has_vertices() const {
|
||||
if (_joint != (EggGroup *)NULL) {
|
||||
return (_joint->vref_size() != 0);
|
||||
return (_joint->vref_size() != 0) || _joint->has_primitives();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -65,6 +65,21 @@ get_maya_plug(MObject &node, const string &attribute_name, MPlug &plug) {
|
||||
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
|
||||
// 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";
|
||||
for (i = 0; i < connections.length(); i++) {
|
||||
MPlug plug = connections[i];
|
||||
|
||||
maya_cat.info(false)
|
||||
<< " " << i << ". " << plug.name().asChar() << ", "
|
||||
<< 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
|
||||
get_maya_plug(MObject &node, const string &attribute_name, MPlug &plug);
|
||||
|
||||
bool
|
||||
is_connected(MObject &node, const string &attribute_name);
|
||||
|
||||
template<class ValueType>
|
||||
bool
|
||||
get_maya_attribute(MObject &node, const string &attribute_name,
|
||||
|
@ -17,9 +17,24 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "mayaNodeDesc.h"
|
||||
#include "maya_funcs.h"
|
||||
|
||||
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
|
||||
// Access: Public
|
||||
@ -72,6 +87,31 @@ from_dag_path(const MDagPath &dag_path) {
|
||||
if (_parent != (MayaNodeDesc *)NULL) {
|
||||
_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";
|
||||
}
|
||||
|
||||
if (node_desc->is_joint()) {
|
||||
// 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 (dag_node.inUnderWorld()) {
|
||||
if (mayaegg_cat.is_debug()) {
|
||||
mayaegg_cat.debug()
|
||||
<< "Ignoring underworld node " << path
|
||||
@ -700,7 +692,7 @@ process_model_node(MayaNodeDesc *node_desc) {
|
||||
|
||||
} else if (dag_path.hasFn(MFn::kNurbsSurface)) {
|
||||
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);
|
||||
if (!status) {
|
||||
@ -718,7 +710,7 @@ process_model_node(MayaNodeDesc *node_desc) {
|
||||
// things in them.
|
||||
if (_animation_convert != AC_model) {
|
||||
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);
|
||||
if (!status) {
|
||||
@ -732,7 +724,7 @@ process_model_node(MayaNodeDesc *node_desc) {
|
||||
|
||||
} else if (dag_path.hasFn(MFn::kMesh)) {
|
||||
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);
|
||||
if (!status) {
|
||||
@ -761,13 +753,13 @@ process_model_node(MayaNodeDesc *node_desc) {
|
||||
// locators within character models may not be meaningful.
|
||||
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);
|
||||
|
||||
} else {
|
||||
// Just a generic node.
|
||||
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;
|
||||
@ -780,10 +772,15 @@ process_model_node(MayaNodeDesc *node_desc) {
|
||||
// and applies it to the corresponding Egg node.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
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) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -1768,9 +1765,8 @@ get_vertex_weights(const MDagPath &dag_path, const MFnMesh &mesh,
|
||||
|
||||
it.next();
|
||||
}
|
||||
|
||||
mayaegg_cat.error()
|
||||
<< "Unable to find a cluster handle for the DG node.\n";
|
||||
|
||||
// The mesh was not soft-skinned.
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,8 @@ private:
|
||||
bool convert_hierarchy(EggGroupNode *egg_root);
|
||||
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);
|
||||
|
||||
// I ran into core dumps trying to pass around a MFnMesh object by
|
||||
|
Loading…
x
Reference in New Issue
Block a user