fixed some compile issue for Mac Dynamica plugin, see

http://code.google.com/p/bullet/issues/detail?id=221

added some missing file for autotools/Makefile.am

fix: btBulletWorldImporter::loadFileFromMemory always returned false, if it was succesful
This commit is contained in:
erwin.coumans
2010-01-31 16:46:06 +00:00
parent c71b968110
commit 4140a20552
8 changed files with 217 additions and 208 deletions

View File

@@ -1,6 +1,6 @@
#MayaPlugin Makefile
MAYA_LOCATION?=/Applications/Autodesk/maya2008/devkit
MAYA_LOCATION?=/Applications/Autodesk/maya2009/devkit
## MAYA_LOCATION is the Maya installation directory. It should be already defined in your
# environment variables. If not, please change it to the appropriate directory
@@ -30,16 +30,22 @@ CPPFLAGS = -DMAC_PLUGIN -DOSMac_MachO_ -DBits32_ -m32 -DUNIX -D_BOOL -DOSMac_ -D
LDFLAGS = -ldl -shared
BULLET_INCLUDE=-I$(BULLET)/src -I.
BULLET_LIB=-L$(BULLET)/out/macosxx86/optimize/libs -L$(BULLET)/src \
-lBulletColladaConverter -lcolladadom -llibxml -lGIMPACTUtils -lbulletdynamics \
-lGIMPACTUtils -lbulletdynamics \
-lbulletcollision -lbulletmath
#BULLET_LIB=-L$(BULLET)/src/.libs \
# -lbulletdynamics \
# -lbulletcollision -lbulletmath
GL_LIB=-framework OpenGL
MAYA_INCLUDE=-I$(MAYA)/include
MAYA_LIB=-L/Applications/Autodesk/maya2008/Maya.app/Contents/MacOS -lOpenMaya -lFoundation -Wl,-executable_path,/Applications/Autodesk/maya2008/Maya.app/Contents/MacOS -lOpenMayaUI -lOpenMayaFX -lOpenMaya -lFoundation
MAYA_LIB=-L/Applications/Autodesk/maya2009/Maya.app/Contents/MacOS -lOpenMaya -lFoundation -Wl,-executable_path,/Applications/Autodesk/maya2009/Maya.app/Contents/MacOS -lOpenMayaUI -lOpenMayaFX -lOpenMaya -lFoundation
SOURCES = pluginMain.cpp colladaExport.cpp rigidBodyNode.cpp rigidBodyArrayNode.cpp collisionShapeNode.cpp \
SOURCES = pluginMain.cpp bulletExport.cpp rigidBodyNode.cpp rigidBodyArrayNode.cpp collisionShapeNode.cpp \
solver.cpp bt_solver.cpp dSolverNode.cpp dSolverCmd.cpp dRigidBodyCmd.cpp dRigidBodyArrayCmd.cpp \
pdbIO.cpp drawUtils.cpp constraint/dHingeConstraintCmd.cpp constraint/dSliderConstraintCmd.cpp \
constraint/hingeConstraintNode.cpp constraint/sixdofConstraintNode.cpp constraint/dNailConstraintCmd.cpp \

View File

@@ -18,9 +18,9 @@ not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Written by: Herbert Law <Herbert.Law@gmail.com>
Modified by Roman Ponomarev <rponom@gmail.com>
01/22/2010 : Constraints reworked
Modified by Roman Ponomarev <rponom@gmail.com>
01/22/2010 : Constraints reworked
*/
//hingeConstraintNode.cpp
@@ -42,8 +42,8 @@ Modified by Roman Ponomarev <rponom@gmail.com>
#include "mayaUtils.h"
#include "solver.h"
#include "dSolverNode.h"
#include "constraint/bt_hinge_constraint.h"
#include "dSolverNode.h"
#include "constraint/bt_hinge_constraint.h"
MTypeId hingeConstraintNode::typeId(0x10033B);
MString hingeConstraintNode::typeName("dHingeConstraint");
@@ -341,7 +341,8 @@ void hingeConstraintNode::draw( M3dView & view, const MDagPath &path,
rigid_bodyB->get_transform(pos, rot);
m_constraint->worldToA(pos, posB);
}
m_constraint->worldFromB(vec3f(0.f, 0.f, 0.f), pos);
vec3f zeroVec(0.f,0.f,0.f);
m_constraint->worldFromB(zeroVec, pos);
m_constraint->worldToA(pos, pivB);
}
@@ -369,22 +370,30 @@ void hingeConstraintNode::draw( M3dView & view, const MDagPath &path,
glVertex3f(0.0, 0.0, 1.0);
vec3f posT, posP, posM;
vec3f minusXVec(-1.f,0.f,0.f);
vec3f posXVec(1.f,0.f,0.f);
vec3f minusYVec (0.f,-1.f,0.f);
vec3f posYVec (0.f,1.f,0.f);
vec3f minusZVec (0.f,0.f,-1.f);
vec3f posZVec (0.f,0.f,1.f);
m_constraint->worldFromB(vec3f(-1.f, 0.f, 0.f), posT);
m_constraint->worldFromB(minusXVec, posT);
m_constraint->worldToA(posT, posM);
m_constraint->worldFromB(vec3f( 1.f, 0.f, 0.f), posT);
m_constraint->worldFromB(posXVec, posT);
m_constraint->worldToA(posT, posP);
glVertex3f(posM[0], posM[1], posM[2]);
glVertex3f(posP[0], posP[1], posP[2]);
m_constraint->worldFromB(vec3f( 0.f, -1.f, 0.f), posT);
m_constraint->worldFromB(minusYVec, posT);
m_constraint->worldToA(posT, posM);
m_constraint->worldFromB(vec3f( 0.f, 1.f, 0.f), posT);
m_constraint->worldFromB(posYVec, posT);
m_constraint->worldToA(posT, posP);
glVertex3f(posM[0], posM[1], posM[2]);
glVertex3f(posP[0], posP[1], posP[2]);
m_constraint->worldFromB(vec3f( 0.f, 0.f, -1.f), posT);
m_constraint->worldFromB(minusZVec, posT);
m_constraint->worldToA(posT, posM);
m_constraint->worldFromB(vec3f( 0.f, 0.f, 1.f), posT);
m_constraint->worldFromB(posZVec, posT);
m_constraint->worldToA(posT, posP);
glVertex3f(posM[0], posM[1], posM[2]);
glVertex3f(posP[0], posP[1], posP[2]);
@@ -469,13 +478,13 @@ void hingeConstraintNode::computeConstraint(const MPlug& plug, MDataBlock& data)
pivInB[i] = (float)mPivInB[i];
}
float3& mRotInA = data.inputValue(ia_rotationInA).asFloat3();
MEulerRotation meulerA(deg2rad(mRotInA[0]), deg2rad(mRotInA[1]), deg2rad(mRotInA[2]));
MQuaternion mquatA = meulerA.asQuaternion();
quatf rotA((float)mquatA.w, (float)mquatA.x, (float)mquatA.y, (float)mquatA.z);
MEulerRotation meulerA(deg2rad(mRotInA[0]), deg2rad(mRotInA[1]), deg2rad(mRotInA[2]));
MQuaternion mquatA = meulerA.asQuaternion();
quatf rotA((float)mquatA.w, (float)mquatA.x, (float)mquatA.y, (float)mquatA.z);
float3& mRotInB = data.inputValue(ia_rotationInB).asFloat3();
MEulerRotation meulerB(deg2rad(mRotInB[0]), deg2rad(mRotInB[1]), deg2rad(mRotInB[2]));
MQuaternion mquatB = meulerB.asQuaternion();
quatf rotB((float)mquatB.w, (float)mquatB.x, (float)mquatB.y, (float)mquatB.z);
MEulerRotation meulerB(deg2rad(mRotInB[0]), deg2rad(mRotInB[1]), deg2rad(mRotInB[2]));
MQuaternion mquatB = meulerB.asQuaternion();
quatf rotB((float)mquatB.w, (float)mquatB.x, (float)mquatB.y, (float)mquatB.z);
m_constraint = solver_t::create_hinge_constraint(rigid_bodyA, pivInA, rotA, rigid_bodyB, pivInB, rotB);
constraint = static_cast<constraint_t::pointer>(m_constraint);
solver_t::add_constraint(constraint);
@@ -491,9 +500,9 @@ void hingeConstraintNode::computeConstraint(const MPlug& plug, MDataBlock& data)
pivInA[i] = (float)mPivInA[i];
}
float3& mRotInA = data.inputValue(ia_rotationInA).asFloat3();
MEulerRotation meuler(deg2rad(mRotInA[0]), deg2rad(mRotInA[1]), deg2rad(mRotInA[2]));
MQuaternion mquat = meuler.asQuaternion();
quatf rotA((float)mquat.w, (float)mquat.x, (float)mquat.y, (float)mquat.z);
MEulerRotation meuler(deg2rad(mRotInA[0]), deg2rad(mRotInA[1]), deg2rad(mRotInA[2]));
MQuaternion mquat = meuler.asQuaternion();
quatf rotA((float)mquat.w, (float)mquat.x, (float)mquat.y, (float)mquat.z);
m_constraint = solver_t::create_hinge_constraint(rigid_bodyA, pivInA, rotA);
constraint = static_cast<constraint_t::pointer>(m_constraint);
solver_t::add_constraint(constraint);
@@ -518,8 +527,8 @@ void hingeConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& data
fnParentTransform.setScale(fixScale);
MVector mtranslation = fnParentTransform.getTranslation(MSpace::kTransform, &status);
if(dSolverNode::isStartTime)
{ // allow to edit pivots
if(dSolverNode::isStartTime)
{ // allow to edit pivots
MPlug plgRigidBodyA(thisObject, ia_rigidBodyA);
MPlug plgRigidBodyB(thisObject, ia_rigidBodyB);
MObject update;
@@ -558,8 +567,8 @@ void hingeConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& data
}
if(m_constraint)
{
MQuaternion mrotation;
fnParentTransform.getRotation(mrotation, MSpace::kTransform);
MQuaternion mrotation;
fnParentTransform.getRotation(mrotation, MSpace::kTransform);
bool doUpdatePivot = m_constraint->getPivotChanged();
if(!doUpdatePivot)
{
@@ -569,46 +578,46 @@ void hingeConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& data
float deltaPX = worldP[0] - float(mtranslation.x);
float deltaPY = worldP[1] - float(mtranslation.y);
float deltaPZ = worldP[2] - float(mtranslation.z);
float deltaRX = (float)mrotation.x - worldR[1];
float deltaRY = (float)mrotation.y - worldR[2];
float deltaRZ = (float)mrotation.z - worldR[3];
float deltaRW = (float)mrotation.w - worldR[0];
float deltaSq = deltaPX * deltaPX + deltaPY * deltaPY + deltaPZ * deltaPZ
+ deltaRX * deltaRX + deltaRY * deltaRY + deltaRZ * deltaRZ + deltaRW * deltaRW;
float deltaRX = (float)mrotation.x - worldR[1];
float deltaRY = (float)mrotation.y - worldR[2];
float deltaRZ = (float)mrotation.z - worldR[3];
float deltaRW = (float)mrotation.w - worldR[0];
float deltaSq = deltaPX * deltaPX + deltaPY * deltaPY + deltaPZ * deltaPZ
+ deltaRX * deltaRX + deltaRY * deltaRY + deltaRZ * deltaRZ + deltaRW * deltaRW;
doUpdatePivot = (deltaSq > FLT_EPSILON);
}
if(doUpdatePivot)
{
m_constraint->set_world(vec3f((float) mtranslation[0], (float) mtranslation[1], (float) mtranslation[2]),
quatf((float)mrotation.w, (float)mrotation.x, (float)mrotation.y, (float)mrotation.z));
quatf((float)mrotation.w, (float)mrotation.x, (float)mrotation.y, (float)mrotation.z));
vec3f pivInA, pivInB;
quatf rotInA, rotInB;
m_constraint->get_frameA(pivInA, rotInA);
m_constraint->get_frameB(pivInB, rotInB);
MDataHandle hPivInA = data.outputValue(ia_pivotInA);
float3 &ihPivInA = hPivInA.asFloat3();
MDataHandle hPivInB = data.outputValue(ia_pivotInB);
float3 &ihPivInB = hPivInB.asFloat3();
for(int i = 0; i < 3; i++)
{
ihPivInA[i] = pivInA[i];
ihPivInB[i] = pivInB[i];
}
MDataHandle hRotInA = data.outputValue(ia_rotationInA);
float3 &hrotInA = hRotInA.asFloat3();
MQuaternion mrotA(rotInA[1], rotInA[2], rotInA[3], rotInA[0]);
MEulerRotation newrotA(mrotA.asEulerRotation());
hrotInA[0] = rad2deg((float)newrotA.x);
hrotInA[1] = rad2deg((float)newrotA.y);
hrotInA[2] = rad2deg((float)newrotA.z);
MDataHandle hRotInB = data.outputValue(ia_rotationInB);
float3 &hrotInB = hRotInB.asFloat3();
MQuaternion mrotB(rotInB[1], rotInB[2], rotInB[3], rotInB[0]);
MEulerRotation newrotB(mrotB.asEulerRotation());
hrotInB[0] = rad2deg((float)newrotB.x);
hrotInB[1] = rad2deg((float)newrotB.y);
hrotInB[2] = rad2deg((float)newrotB.z);
m_constraint->setPivotChanged(false);
MDataHandle hPivInA = data.outputValue(ia_pivotInA);
float3 &ihPivInA = hPivInA.asFloat3();
MDataHandle hPivInB = data.outputValue(ia_pivotInB);
float3 &ihPivInB = hPivInB.asFloat3();
for(int i = 0; i < 3; i++)
{
ihPivInA[i] = pivInA[i];
ihPivInB[i] = pivInB[i];
}
MDataHandle hRotInA = data.outputValue(ia_rotationInA);
float3 &hrotInA = hRotInA.asFloat3();
MQuaternion mrotA(rotInA[1], rotInA[2], rotInA[3], rotInA[0]);
MEulerRotation newrotA(mrotA.asEulerRotation());
hrotInA[0] = rad2deg((float)newrotA.x);
hrotInA[1] = rad2deg((float)newrotA.y);
hrotInA[2] = rad2deg((float)newrotA.z);
MDataHandle hRotInB = data.outputValue(ia_rotationInB);
float3 &hrotInB = hRotInB.asFloat3();
MQuaternion mrotB(rotInB[1], rotInB[2], rotInB[3], rotInB[0]);
MEulerRotation newrotB(mrotB.asEulerRotation());
hrotInB[0] = rad2deg((float)newrotB.x);
hrotInB[1] = rad2deg((float)newrotB.y);
hrotInB[2] = rad2deg((float)newrotB.z);
m_constraint->setPivotChanged(false);
}
}
}
@@ -619,8 +628,8 @@ void hingeConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& data
vec3f worldP;
quatf worldR;
m_constraint->get_world(worldP, worldR);
fnParentTransform.setTranslation(MVector(worldP[0], worldP[1], worldP[2]), MSpace::kTransform);
fnParentTransform.setRotation(MQuaternion(worldR[1], worldR[2], worldR[3], worldR[0]));
fnParentTransform.setTranslation(MVector(worldP[0], worldP[1], worldP[2]), MSpace::kTransform);
fnParentTransform.setRotation(MQuaternion(worldR[1], worldR[2], worldR[3], worldR[0]));
}
}
data.setClean(plug);

View File

@@ -18,9 +18,9 @@ not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Written by: Herbert Law <Herbert.Law@gmail.com>
Modified by Roman Ponomarev <rponom@gmail.com>
01/22/2010 : Constraints reworked
Modified by Roman Ponomarev <rponom@gmail.com>
01/22/2010 : Constraints reworked
*/
//sixdofConstraintNode.cpp
@@ -42,8 +42,8 @@ Modified by Roman Ponomarev <rponom@gmail.com>
#include "mayaUtils.h"
#include "solver.h"
#include "dSolverNode.h"
#include "constraint/bt_sixdof_constraint.h"
#include "dSolverNode.h"
#include "constraint/bt_sixdof_constraint.h"
MTypeId sixdofConstraintNode::typeId(0x100384);
MString sixdofConstraintNode::typeName("dSixdofConstraint");
@@ -274,7 +274,14 @@ void sixdofConstraintNode::draw( M3dView & view, const MDagPath &path,
M3dView::DisplayStatus status )
{
update();
vec3f zeroVec(0.f,0.f,0.f);
vec3f minusXVec(-1.f,0.f,0.f);
vec3f posXVec(1.f,0.f,0.f);
vec3f minusYVec (0.f,-1.f,0.f);
vec3f posYVec (0.f,1.f,0.f);
vec3f minusZVec (0.f,0.f,-1.f);
vec3f posZVec (0.f,0.f,1.f);
view.beginGL();
glPushAttrib( GL_ALL_ATTRIB_BITS );
@@ -301,7 +308,7 @@ void sixdofConstraintNode::draw( M3dView & view, const MDagPath &path,
rigid_bodyB->get_transform(pos, rot);
m_constraint->worldToA(pos, posB);
}
m_constraint->worldFromB(vec3f(0.f, 0.f, 0.f), pos);
m_constraint->worldFromB(zeroVec, pos);
m_constraint->worldToA(pos, pivB);
}
@@ -330,21 +337,21 @@ void sixdofConstraintNode::draw( M3dView & view, const MDagPath &path,
vec3f posT, posP, posM;
m_constraint->worldFromB(vec3f(-1.f, 0.f, 0.f), posT);
m_constraint->worldFromB(minusXVec, posT);
m_constraint->worldToA(posT, posM);
m_constraint->worldFromB(vec3f( 1.f, 0.f, 0.f), posT);
m_constraint->worldFromB(posXVec, posT);
m_constraint->worldToA(posT, posP);
glVertex3f(posM[0], posM[1], posM[2]);
glVertex3f(posP[0], posP[1], posP[2]);
m_constraint->worldFromB(vec3f( 0.f, -1.f, 0.f), posT);
m_constraint->worldFromB(minusYVec, posT);
m_constraint->worldToA(posT, posM);
m_constraint->worldFromB(vec3f( 0.f, 1.f, 0.f), posT);
m_constraint->worldFromB(posYVec, posT);
m_constraint->worldToA(posT, posP);
glVertex3f(posM[0], posM[1], posM[2]);
glVertex3f(posP[0], posP[1], posP[2]);
m_constraint->worldFromB(vec3f( 0.f, 0.f, -1.f), posT);
m_constraint->worldFromB(minusZVec, posT);
m_constraint->worldToA(posT, posM);
m_constraint->worldFromB(vec3f( 0.f, 0.f, 1.f), posT);
m_constraint->worldFromB(posZVec, posT);
m_constraint->worldToA(posT, posP);
glVertex3f(posM[0], posM[1], posM[2]);
glVertex3f(posP[0], posP[1], posP[2]);
@@ -430,13 +437,13 @@ void sixdofConstraintNode::computeConstraint(const MPlug& plug, MDataBlock& data
pivInB[i] = (float)mPivInB[i];
}
float3& mRotInA = data.inputValue(ia_rotationInA).asFloat3();
MEulerRotation meulerA(deg2rad(mRotInA[0]), deg2rad(mRotInA[1]), deg2rad(mRotInA[2]));
MQuaternion mquatA = meulerA.asQuaternion();
quatf rotA((float)mquatA.w, (float)mquatA.x, (float)mquatA.y, (float)mquatA.z);
MEulerRotation meulerA(deg2rad(mRotInA[0]), deg2rad(mRotInA[1]), deg2rad(mRotInA[2]));
MQuaternion mquatA = meulerA.asQuaternion();
quatf rotA((float)mquatA.w, (float)mquatA.x, (float)mquatA.y, (float)mquatA.z);
float3& mRotInB = data.inputValue(ia_rotationInB).asFloat3();
MEulerRotation meulerB(deg2rad(mRotInB[0]), deg2rad(mRotInB[1]), deg2rad(mRotInB[2]));
MQuaternion mquatB = meulerB.asQuaternion();
quatf rotB((float)mquatB.w, (float)mquatB.x, (float)mquatB.y, (float)mquatB.z);
MEulerRotation meulerB(deg2rad(mRotInB[0]), deg2rad(mRotInB[1]), deg2rad(mRotInB[2]));
MQuaternion mquatB = meulerB.asQuaternion();
quatf rotB((float)mquatB.w, (float)mquatB.x, (float)mquatB.y, (float)mquatB.z);
m_constraint = solver_t::create_sixdof_constraint(rigid_bodyA, pivInA, rotA, rigid_bodyB, pivInB, rotB);
constraint = static_cast<constraint_t::pointer>(m_constraint);
solver_t::add_constraint(constraint);
@@ -452,9 +459,9 @@ void sixdofConstraintNode::computeConstraint(const MPlug& plug, MDataBlock& data
pivInA[i] = (float)mPivInA[i];
}
float3& mRotInA = data.inputValue(ia_rotationInA).asFloat3();
MEulerRotation meuler(deg2rad(mRotInA[0]), deg2rad(mRotInA[1]), deg2rad(mRotInA[2]));
MQuaternion mquat = meuler.asQuaternion();
quatf rotA((float)mquat.w, (float)mquat.x, (float)mquat.y, (float)mquat.z);
MEulerRotation meuler(deg2rad(mRotInA[0]), deg2rad(mRotInA[1]), deg2rad(mRotInA[2]));
MQuaternion mquat = meuler.asQuaternion();
quatf rotA((float)mquat.w, (float)mquat.x, (float)mquat.y, (float)mquat.z);
m_constraint = solver_t::create_sixdof_constraint(rigid_bodyA, pivInA, rotA);
constraint = static_cast<constraint_t::pointer>(m_constraint);
solver_t::add_constraint(constraint);
@@ -480,8 +487,8 @@ void sixdofConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& dat
fnParentTransform.setScale(fixScale);
MVector mtranslation = fnParentTransform.getTranslation(MSpace::kTransform, &status);
if(dSolverNode::isStartTime)
{ // allow to edit pivots
if(dSolverNode::isStartTime)
{ // allow to edit pivots
MPlug plgRigidBodyA(thisObject, ia_rigidBodyA);
MPlug plgRigidBodyB(thisObject, ia_rigidBodyB);
MObject update;
@@ -520,8 +527,8 @@ void sixdofConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& dat
}
if(m_constraint)
{
MQuaternion mrotation;
fnParentTransform.getRotation(mrotation, MSpace::kTransform);
MQuaternion mrotation;
fnParentTransform.getRotation(mrotation, MSpace::kTransform);
bool doUpdatePivot = m_constraint->getPivotChanged();
if(!doUpdatePivot)
{
@@ -531,46 +538,46 @@ void sixdofConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& dat
float deltaPX = worldP[0] - float(mtranslation.x);
float deltaPY = worldP[1] - float(mtranslation.y);
float deltaPZ = worldP[2] - float(mtranslation.z);
float deltaRX = (float)mrotation.x - worldR[1];
float deltaRY = (float)mrotation.y - worldR[2];
float deltaRZ = (float)mrotation.z - worldR[3];
float deltaRW = (float)mrotation.w - worldR[0];
float deltaSq = deltaPX * deltaPX + deltaPY * deltaPY + deltaPZ * deltaPZ
+ deltaRX * deltaRX + deltaRY * deltaRY + deltaRZ * deltaRZ + deltaRW * deltaRW;
float deltaRX = (float)mrotation.x - worldR[1];
float deltaRY = (float)mrotation.y - worldR[2];
float deltaRZ = (float)mrotation.z - worldR[3];
float deltaRW = (float)mrotation.w - worldR[0];
float deltaSq = deltaPX * deltaPX + deltaPY * deltaPY + deltaPZ * deltaPZ
+ deltaRX * deltaRX + deltaRY * deltaRY + deltaRZ * deltaRZ + deltaRW * deltaRW;
doUpdatePivot = (deltaSq > FLT_EPSILON);
}
if(doUpdatePivot)
{
m_constraint->set_world(vec3f((float) mtranslation[0], (float) mtranslation[1], (float) mtranslation[2]),
quatf((float)mrotation.w, (float)mrotation.x, (float)mrotation.y, (float)mrotation.z));
quatf((float)mrotation.w, (float)mrotation.x, (float)mrotation.y, (float)mrotation.z));
vec3f pivInA, pivInB;
quatf rotInA, rotInB;
m_constraint->get_frameA(pivInA, rotInA);
m_constraint->get_frameB(pivInB, rotInB);
MDataHandle hPivInA = data.outputValue(ia_pivotInA);
float3 &ihPivInA = hPivInA.asFloat3();
MDataHandle hPivInB = data.outputValue(ia_pivotInB);
float3 &ihPivInB = hPivInB.asFloat3();
for(int i = 0; i < 3; i++)
{
ihPivInA[i] = pivInA[i];
ihPivInB[i] = pivInB[i];
}
MDataHandle hRotInA = data.outputValue(ia_rotationInA);
float3 &hrotInA = hRotInA.asFloat3();
MQuaternion mrotA(rotInA[1], rotInA[2], rotInA[3], rotInA[0]);
MEulerRotation newrotA(mrotA.asEulerRotation());
hrotInA[0] = rad2deg((float)newrotA.x);
hrotInA[1] = rad2deg((float)newrotA.y);
hrotInA[2] = rad2deg((float)newrotA.z);
MDataHandle hRotInB = data.outputValue(ia_rotationInB);
float3 &hrotInB = hRotInB.asFloat3();
MQuaternion mrotB(rotInB[1], rotInB[2], rotInB[3], rotInB[0]);
MEulerRotation newrotB(mrotB.asEulerRotation());
hrotInB[0] = rad2deg((float)newrotB.x);
hrotInB[1] = rad2deg((float)newrotB.y);
hrotInB[2] = rad2deg((float)newrotB.z);
m_constraint->setPivotChanged(false);
MDataHandle hPivInA = data.outputValue(ia_pivotInA);
float3 &ihPivInA = hPivInA.asFloat3();
MDataHandle hPivInB = data.outputValue(ia_pivotInB);
float3 &ihPivInB = hPivInB.asFloat3();
for(int i = 0; i < 3; i++)
{
ihPivInA[i] = pivInA[i];
ihPivInB[i] = pivInB[i];
}
MDataHandle hRotInA = data.outputValue(ia_rotationInA);
float3 &hrotInA = hRotInA.asFloat3();
MQuaternion mrotA(rotInA[1], rotInA[2], rotInA[3], rotInA[0]);
MEulerRotation newrotA(mrotA.asEulerRotation());
hrotInA[0] = rad2deg((float)newrotA.x);
hrotInA[1] = rad2deg((float)newrotA.y);
hrotInA[2] = rad2deg((float)newrotA.z);
MDataHandle hRotInB = data.outputValue(ia_rotationInB);
float3 &hrotInB = hRotInB.asFloat3();
MQuaternion mrotB(rotInB[1], rotInB[2], rotInB[3], rotInB[0]);
MEulerRotation newrotB(mrotB.asEulerRotation());
hrotInB[0] = rad2deg((float)newrotB.x);
hrotInB[1] = rad2deg((float)newrotB.y);
hrotInB[2] = rad2deg((float)newrotB.z);
m_constraint->setPivotChanged(false);
}
}
}
@@ -581,8 +588,8 @@ void sixdofConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& dat
vec3f worldP;
quatf worldR;
m_constraint->get_world(worldP, worldR);
fnParentTransform.setTranslation(MVector(worldP[0], worldP[1], worldP[2]), MSpace::kTransform);
fnParentTransform.setRotation(MQuaternion(worldR[1], worldR[2], worldR[3], worldR[0]));
fnParentTransform.setTranslation(MVector(worldP[0], worldP[1], worldP[2]), MSpace::kTransform);
fnParentTransform.setRotation(MQuaternion(worldR[1], worldR[2], worldR[3], worldR[0]));
}
}
data.setClean(plug);

View File

@@ -18,9 +18,9 @@ not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Written by: Herbert Law <Herbert.Law@gmail.com>
Modified by Roman Ponomarev <rponom@gmail.com>
01/22/2010 : Constraints reworked
Modified by Roman Ponomarev <rponom@gmail.com>
01/22/2010 : Constraints reworked
*/
//sliderConstraintNode.cpp
@@ -42,8 +42,8 @@ Modified by Roman Ponomarev <rponom@gmail.com>
#include "mayaUtils.h"
#include "solver.h"
#include "dSolverNode.h"
#include "constraint/bt_slider_constraint.h"
#include "dSolverNode.h"
#include "constraint/bt_slider_constraint.h"
MTypeId sliderConstraintNode::typeId(0x100385);
MString sliderConstraintNode::typeName("dSliderConstraint");
@@ -270,6 +270,13 @@ void sliderConstraintNode::draw( M3dView & view, const MDagPath &path,
M3dView::DisplayStatus status )
{
update();
vec3f zeroVec(0.f,0.f,0.f);
vec3f minusXVec(-1.f,0.f,0.f);
vec3f posXVec(1.f,0.f,0.f);
vec3f minusYVec (0.f,-1.f,0.f);
vec3f posYVec (0.f,1.f,0.f);
vec3f minusZVec (0.f,0.f,-1.f);
vec3f posZVec (0.f,0.f,1.f);
view.beginGL();
glPushAttrib( GL_ALL_ATTRIB_BITS );
@@ -297,7 +304,7 @@ void sliderConstraintNode::draw( M3dView & view, const MDagPath &path,
rigid_bodyB->get_transform(pos, rot);
m_constraint->worldToA(pos, posB);
}
m_constraint->worldFromB(vec3f(0.f, 0.f, 0.f), pos);
m_constraint->worldFromB(zeroVec, pos);
m_constraint->worldToA(pos, pivB);
}
@@ -326,21 +333,21 @@ void sliderConstraintNode::draw( M3dView & view, const MDagPath &path,
vec3f posT, posP, posM;
m_constraint->worldFromB(vec3f(-1.f, 0.f, 0.f), posT);
m_constraint->worldFromB(minusXVec, posT);
m_constraint->worldToA(posT, posM);
m_constraint->worldFromB(vec3f( 1.f, 0.f, 0.f), posT);
m_constraint->worldFromB(posXVec, posT);
m_constraint->worldToA(posT, posP);
glVertex3f(posM[0], posM[1], posM[2]);
glVertex3f(posP[0], posP[1], posP[2]);
m_constraint->worldFromB(vec3f( 0.f, -1.f, 0.f), posT);
m_constraint->worldFromB(minusYVec, posT);
m_constraint->worldToA(posT, posM);
m_constraint->worldFromB(vec3f( 0.f, 1.f, 0.f), posT);
m_constraint->worldFromB(posYVec, posT);
m_constraint->worldToA(posT, posP);
glVertex3f(posM[0], posM[1], posM[2]);
glVertex3f(posP[0], posP[1], posP[2]);
m_constraint->worldFromB(vec3f( 0.f, 0.f, -1.f), posT);
m_constraint->worldFromB(minusZVec, posT);
m_constraint->worldToA(posT, posM);
m_constraint->worldFromB(vec3f( 0.f, 0.f, 1.f), posT);
m_constraint->worldFromB(posZVec, posT);
m_constraint->worldToA(posT, posP);
glVertex3f(posM[0], posM[1], posM[2]);
glVertex3f(posP[0], posP[1], posP[2]);
@@ -426,13 +433,13 @@ void sliderConstraintNode::computeConstraint(const MPlug& plug, MDataBlock& data
pivInB[i] = (float)mPivInB[i];
}
float3& mRotInA = data.inputValue(ia_rotationInA).asFloat3();
MEulerRotation meulerA(deg2rad(mRotInA[0]), deg2rad(mRotInA[1]), deg2rad(mRotInA[2]));
MQuaternion mquatA = meulerA.asQuaternion();
quatf rotA((float)mquatA.w, (float)mquatA.x, (float)mquatA.y, (float)mquatA.z);
MEulerRotation meulerA(deg2rad(mRotInA[0]), deg2rad(mRotInA[1]), deg2rad(mRotInA[2]));
MQuaternion mquatA = meulerA.asQuaternion();
quatf rotA((float)mquatA.w, (float)mquatA.x, (float)mquatA.y, (float)mquatA.z);
float3& mRotInB = data.inputValue(ia_rotationInB).asFloat3();
MEulerRotation meulerB(deg2rad(mRotInB[0]), deg2rad(mRotInB[1]), deg2rad(mRotInB[2]));
MQuaternion mquatB = meulerB.asQuaternion();
quatf rotB((float)mquatB.w, (float)mquatB.x, (float)mquatB.y, (float)mquatB.z);
MEulerRotation meulerB(deg2rad(mRotInB[0]), deg2rad(mRotInB[1]), deg2rad(mRotInB[2]));
MQuaternion mquatB = meulerB.asQuaternion();
quatf rotB((float)mquatB.w, (float)mquatB.x, (float)mquatB.y, (float)mquatB.z);
m_constraint = solver_t::create_slider_constraint(rigid_bodyA, pivInA, rotA, rigid_bodyB, pivInB, rotB);
constraint = static_cast<constraint_t::pointer>(m_constraint);
solver_t::add_constraint(constraint);
@@ -448,9 +455,9 @@ void sliderConstraintNode::computeConstraint(const MPlug& plug, MDataBlock& data
pivInA[i] = (float)mPivInA[i];
}
float3& mRotInA = data.inputValue(ia_rotationInA).asFloat3();
MEulerRotation meuler(deg2rad(mRotInA[0]), deg2rad(mRotInA[1]), deg2rad(mRotInA[2]));
MQuaternion mquat = meuler.asQuaternion();
quatf rotA((float)mquat.w, (float)mquat.x, (float)mquat.y, (float)mquat.z);
MEulerRotation meuler(deg2rad(mRotInA[0]), deg2rad(mRotInA[1]), deg2rad(mRotInA[2]));
MQuaternion mquat = meuler.asQuaternion();
quatf rotA((float)mquat.w, (float)mquat.x, (float)mquat.y, (float)mquat.z);
m_constraint = solver_t::create_slider_constraint(rigid_bodyA, pivInA, rotA);
constraint = static_cast<constraint_t::pointer>(m_constraint);
solver_t::add_constraint(constraint);
@@ -475,8 +482,8 @@ void sliderConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& dat
fnParentTransform.setScale(fixScale);
MVector mtranslation = fnParentTransform.getTranslation(MSpace::kTransform, &status);
if(dSolverNode::isStartTime)
{ // allow to edit pivots
if(dSolverNode::isStartTime)
{ // allow to edit pivots
MPlug plgRigidBodyA(thisObject, ia_rigidBodyA);
MPlug plgRigidBodyB(thisObject, ia_rigidBodyB);
MObject update;
@@ -515,8 +522,8 @@ void sliderConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& dat
}
if(m_constraint)
{
MQuaternion mrotation;
fnParentTransform.getRotation(mrotation, MSpace::kTransform);
MQuaternion mrotation;
fnParentTransform.getRotation(mrotation, MSpace::kTransform);
bool doUpdatePivot = m_constraint->getPivotChanged();
if(!doUpdatePivot)
{
@@ -526,46 +533,46 @@ void sliderConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& dat
float deltaPX = worldP[0] - float(mtranslation.x);
float deltaPY = worldP[1] - float(mtranslation.y);
float deltaPZ = worldP[2] - float(mtranslation.z);
float deltaRX = (float)mrotation.x - worldR[1];
float deltaRY = (float)mrotation.y - worldR[2];
float deltaRZ = (float)mrotation.z - worldR[3];
float deltaRW = (float)mrotation.w - worldR[0];
float deltaSq = deltaPX * deltaPX + deltaPY * deltaPY + deltaPZ * deltaPZ
+ deltaRX * deltaRX + deltaRY * deltaRY + deltaRZ * deltaRZ + deltaRW * deltaRW;
float deltaRX = (float)mrotation.x - worldR[1];
float deltaRY = (float)mrotation.y - worldR[2];
float deltaRZ = (float)mrotation.z - worldR[3];
float deltaRW = (float)mrotation.w - worldR[0];
float deltaSq = deltaPX * deltaPX + deltaPY * deltaPY + deltaPZ * deltaPZ
+ deltaRX * deltaRX + deltaRY * deltaRY + deltaRZ * deltaRZ + deltaRW * deltaRW;
doUpdatePivot = (deltaSq > FLT_EPSILON);
}
if(doUpdatePivot)
{
m_constraint->set_world(vec3f((float) mtranslation[0], (float) mtranslation[1], (float) mtranslation[2]),
quatf((float)mrotation.w, (float)mrotation.x, (float)mrotation.y, (float)mrotation.z));
quatf((float)mrotation.w, (float)mrotation.x, (float)mrotation.y, (float)mrotation.z));
vec3f pivInA, pivInB;
quatf rotInA, rotInB;
m_constraint->get_frameA(pivInA, rotInA);
m_constraint->get_frameB(pivInB, rotInB);
MDataHandle hPivInA = data.outputValue(ia_pivotInA);
float3 &ihPivInA = hPivInA.asFloat3();
MDataHandle hPivInB = data.outputValue(ia_pivotInB);
float3 &ihPivInB = hPivInB.asFloat3();
for(int i = 0; i < 3; i++)
{
ihPivInA[i] = pivInA[i];
ihPivInB[i] = pivInB[i];
}
MDataHandle hRotInA = data.outputValue(ia_rotationInA);
float3 &hrotInA = hRotInA.asFloat3();
MQuaternion mrotA(rotInA[1], rotInA[2], rotInA[3], rotInA[0]);
MEulerRotation newrotA(mrotA.asEulerRotation());
hrotInA[0] = rad2deg((float)newrotA.x);
hrotInA[1] = rad2deg((float)newrotA.y);
hrotInA[2] = rad2deg((float)newrotA.z);
MDataHandle hRotInB = data.outputValue(ia_rotationInB);
float3 &hrotInB = hRotInB.asFloat3();
MQuaternion mrotB(rotInB[1], rotInB[2], rotInB[3], rotInB[0]);
MEulerRotation newrotB(mrotB.asEulerRotation());
hrotInB[0] = rad2deg((float)newrotB.x);
hrotInB[1] = rad2deg((float)newrotB.y);
hrotInB[2] = rad2deg((float)newrotB.z);
m_constraint->setPivotChanged(false);
MDataHandle hPivInA = data.outputValue(ia_pivotInA);
float3 &ihPivInA = hPivInA.asFloat3();
MDataHandle hPivInB = data.outputValue(ia_pivotInB);
float3 &ihPivInB = hPivInB.asFloat3();
for(int i = 0; i < 3; i++)
{
ihPivInA[i] = pivInA[i];
ihPivInB[i] = pivInB[i];
}
MDataHandle hRotInA = data.outputValue(ia_rotationInA);
float3 &hrotInA = hRotInA.asFloat3();
MQuaternion mrotA(rotInA[1], rotInA[2], rotInA[3], rotInA[0]);
MEulerRotation newrotA(mrotA.asEulerRotation());
hrotInA[0] = rad2deg((float)newrotA.x);
hrotInA[1] = rad2deg((float)newrotA.y);
hrotInA[2] = rad2deg((float)newrotA.z);
MDataHandle hRotInB = data.outputValue(ia_rotationInB);
float3 &hrotInB = hRotInB.asFloat3();
MQuaternion mrotB(rotInB[1], rotInB[2], rotInB[3], rotInB[0]);
MEulerRotation newrotB(mrotB.asEulerRotation());
hrotInB[0] = rad2deg((float)newrotB.x);
hrotInB[1] = rad2deg((float)newrotB.y);
hrotInB[2] = rad2deg((float)newrotB.z);
m_constraint->setPivotChanged(false);
}
}
}
@@ -576,8 +583,8 @@ void sliderConstraintNode::computeWorldMatrix(const MPlug& plug, MDataBlock& dat
vec3f worldP;
quatf worldR;
m_constraint->get_world(worldP, worldR);
fnParentTransform.setTranslation(MVector(worldP[0], worldP[1], worldP[2]), MSpace::kTransform);
fnParentTransform.setRotation(MQuaternion(worldR[1], worldR[2], worldR[3], worldR[0]));
fnParentTransform.setTranslation(MVector(worldP[0], worldP[1], worldP[2]), MSpace::kTransform);
fnParentTransform.setRotation(MQuaternion(worldR[1], worldR[2], worldR[3], worldR[0]));
}
}
data.setClean(plug);

View File

@@ -614,7 +614,7 @@ bool btBulletWorldImporter::loadFileFromMemory( bParse::btBulletFile* bulletFil
}
return false;
return true;
}
btTypedConstraint* btBulletWorldImporter::createUniversalD6Constraint(class btRigidBody* body0,class btRigidBody* otherBody,