copying the initial* to position and rotation for rigid body arrays in the

first frame
This commit is contained in:
nicola.candussi
2008-09-22 10:41:56 +00:00
parent 255de503e0
commit 106b18813e
2 changed files with 15 additions and 1 deletions

View File

@@ -271,6 +271,9 @@ void initRigidBodyArray(MObject &node)
MPlug plgInitialVelocity(node, rigidBodyArrayNode::ia_initialVelocity); MPlug plgInitialVelocity(node, rigidBodyArrayNode::ia_initialVelocity);
MPlug plgInitialSpin(node, rigidBodyArrayNode::ia_initialSpin); MPlug plgInitialSpin(node, rigidBodyArrayNode::ia_initialSpin);
MPlug plgPosition(node, rigidBodyArrayNode::io_position);
MPlug plgRotation(node, rigidBodyArrayNode::io_rotation);
MPlug plgElement; MPlug plgElement;
for(size_t j = 0; j < rbs.size(); ++j) { for(size_t j = 0; j < rbs.size(); ++j) {
vec3f pos; vec3f pos;
@@ -299,10 +302,21 @@ void initRigidBodyArray(MObject &node)
MEulerRotation meuler(deg2rad(rot[0]), deg2rad(rot[1]), deg2rad(rot[2])); MEulerRotation meuler(deg2rad(rot[0]), deg2rad(rot[1]), deg2rad(rot[2]));
MQuaternion mquat = meuler.asQuaternion(); MQuaternion mquat = meuler.asQuaternion();
rbs[j]->set_transform(pos, quatf(mquat.w, mquat.x, mquat.y, mquat.z)); rbs[j]->set_transform(pos, quatf(mquat.w, mquat.x, mquat.y, mquat.z));
rbs[j]->set_linear_velocity(vel); rbs[j]->set_linear_velocity(vel);
rbs[j]->set_angular_velocity(spin); rbs[j]->set_angular_velocity(spin);
rbs[j]->set_kinematic(false); rbs[j]->set_kinematic(false);
plgElement = plgPosition.elementByLogicalIndex(j);
plgElement.child(0).setValue(pos[0]);
plgElement.child(1).setValue(pos[1]);
plgElement.child(2).setValue(pos[2]);
plgElement = plgRotation.elementByLogicalIndex(j);
plgElement.child(0).setValue(rot[0]);
plgElement.child(1).setValue(rot[1]);
plgElement.child(2).setValue(rot[2]);
} }
} else { } else {

View File

@@ -293,7 +293,7 @@ void rigidBodyNode::draw( M3dView & view, const MDagPath &path,
glPushAttrib( GL_ALL_ATTRIB_BITS ); glPushAttrib( GL_ALL_ATTRIB_BITS );
if(m_rigid_body) { if(m_rigid_body) {
//remove the scale, since it's already include in the node transform //remove the scale, since it's already included in the node transform
vec3f scale; vec3f scale;
m_rigid_body->collision_shape()->get_scale(scale); m_rigid_body->collision_shape()->get_scale(scale);