mirror of
https://github.com/bulletphysics/bullet3
synced 2024-12-13 21:30:09 +00:00
tweaks to rolling friction demo/dof2spring2 demo
This commit is contained in:
parent
184a0013b4
commit
db5f280c3d
@ -120,7 +120,8 @@ void Dof6Spring2Setup::initPhysics()
|
|||||||
|
|
||||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
|
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
|
||||||
m_dynamicsWorld->getDispatchInfo().m_useContinuous = true;
|
m_dynamicsWorld->getDispatchInfo().m_useContinuous = true;
|
||||||
|
m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);
|
||||||
|
|
||||||
m_dynamicsWorld->setGravity(btVector3(0,0,0));
|
m_dynamicsWorld->setGravity(btVector3(0,0,0));
|
||||||
|
|
||||||
// Setup a big ground box
|
// Setup a big ground box
|
||||||
@ -188,6 +189,7 @@ void Dof6Spring2Setup::initPhysics()
|
|||||||
constraint->setDamping(0, 1);
|
constraint->setDamping(0, 1);
|
||||||
#endif
|
#endif
|
||||||
constraint->setEquilibriumPoint(0, 0);
|
constraint->setEquilibriumPoint(0, 0);
|
||||||
|
constraint->setDbgDrawSize(btScalar(2.f));
|
||||||
m_dynamicsWorld->addConstraint(constraint, true);
|
m_dynamicsWorld->addConstraint(constraint, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,6 +222,7 @@ void Dof6Spring2Setup::initPhysics()
|
|||||||
constraint->setDamping(5, 1);
|
constraint->setDamping(5, 1);
|
||||||
#endif
|
#endif
|
||||||
constraint->setEquilibriumPoint(0, 0);
|
constraint->setEquilibriumPoint(0, 0);
|
||||||
|
constraint->setDbgDrawSize(btScalar(2.f));
|
||||||
m_dynamicsWorld->addConstraint(constraint, true);
|
m_dynamicsWorld->addConstraint(constraint, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,6 +256,7 @@ void Dof6Spring2Setup::initPhysics()
|
|||||||
#endif
|
#endif
|
||||||
constraint->setParam(BT_CONSTRAINT_STOP_ERP,0.995,0);
|
constraint->setParam(BT_CONSTRAINT_STOP_ERP,0.995,0);
|
||||||
constraint->setParam(BT_CONSTRAINT_STOP_CFM,0.0,0);
|
constraint->setParam(BT_CONSTRAINT_STOP_CFM,0.0,0);
|
||||||
|
constraint->setDbgDrawSize(btScalar(2.f));
|
||||||
m_dynamicsWorld->addConstraint(constraint, true);
|
m_dynamicsWorld->addConstraint(constraint, true);
|
||||||
constraint = new CONSTRAINT_TYPE(*staticBody, *m_data->m_BouncingTranslateBody, localA, localB EXTRAPARAMS);
|
constraint = new CONSTRAINT_TYPE(*staticBody, *m_data->m_BouncingTranslateBody, localA, localB EXTRAPARAMS);
|
||||||
constraint->setLimit(0, -SIMD_INFINITY, 2);
|
constraint->setLimit(0, -SIMD_INFINITY, 2);
|
||||||
@ -268,6 +272,7 @@ void Dof6Spring2Setup::initPhysics()
|
|||||||
#endif
|
#endif
|
||||||
constraint->setParam(BT_CONSTRAINT_STOP_ERP,0.995,0);
|
constraint->setParam(BT_CONSTRAINT_STOP_ERP,0.995,0);
|
||||||
constraint->setParam(BT_CONSTRAINT_STOP_CFM,0.0,0);
|
constraint->setParam(BT_CONSTRAINT_STOP_CFM,0.0,0);
|
||||||
|
constraint->setDbgDrawSize(btScalar(2.f));
|
||||||
m_dynamicsWorld->addConstraint(constraint, true);
|
m_dynamicsWorld->addConstraint(constraint, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,6 +306,7 @@ void Dof6Spring2Setup::initPhysics()
|
|||||||
constraint->getRotationalLimitMotor(2)->m_targetVelocity = 3.f;
|
constraint->getRotationalLimitMotor(2)->m_targetVelocity = 3.f;
|
||||||
constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 10;
|
constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 10;
|
||||||
#endif
|
#endif
|
||||||
|
constraint->setDbgDrawSize(btScalar(2.f));
|
||||||
m_dynamicsWorld->addConstraint(constraint, true);
|
m_dynamicsWorld->addConstraint(constraint, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,6 +344,7 @@ void Dof6Spring2Setup::initPhysics()
|
|||||||
constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 10;
|
constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 10;
|
||||||
//servo motor is not implemented in 6dofspring constraint
|
//servo motor is not implemented in 6dofspring constraint
|
||||||
#endif
|
#endif
|
||||||
|
constraint->setDbgDrawSize(btScalar(2.f));
|
||||||
m_dynamicsWorld->addConstraint(constraint, true);
|
m_dynamicsWorld->addConstraint(constraint, true);
|
||||||
m_data->m_ServoMotorConstraint = constraint;
|
m_data->m_ServoMotorConstraint = constraint;
|
||||||
}
|
}
|
||||||
@ -378,6 +385,7 @@ void Dof6Spring2Setup::initPhysics()
|
|||||||
constraint->setParam(BT_CONSTRAINT_STOP_ERP,0.9,a);
|
constraint->setParam(BT_CONSTRAINT_STOP_ERP,0.9,a);
|
||||||
constraint->setParam(BT_CONSTRAINT_STOP_CFM,0.0,a);
|
constraint->setParam(BT_CONSTRAINT_STOP_CFM,0.0,a);
|
||||||
}
|
}
|
||||||
|
constraint->setDbgDrawSize(btScalar(1.f));
|
||||||
m_dynamicsWorld->addConstraint(constraint, true);
|
m_dynamicsWorld->addConstraint(constraint, true);
|
||||||
|
|
||||||
if(i < bodycount - 1)
|
if(i < bodycount - 1)
|
||||||
@ -386,7 +394,9 @@ void Dof6Spring2Setup::initPhysics()
|
|||||||
localB.setIdentity();
|
localB.setIdentity();
|
||||||
CONSTRAINT_TYPE* constraintZY = new CONSTRAINT_TYPE(*staticBody, *body, localA, localB EXTRAPARAMS);
|
CONSTRAINT_TYPE* constraintZY = new CONSTRAINT_TYPE(*staticBody, *body, localA, localB EXTRAPARAMS);
|
||||||
constraintZY->setLimit(0, 1, -1);
|
constraintZY->setLimit(0, 1, -1);
|
||||||
|
constraintZY->setDbgDrawSize(btScalar(1.f));
|
||||||
m_dynamicsWorld->addConstraint(constraintZY, true);
|
m_dynamicsWorld->addConstraint(constraintZY, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -404,6 +414,7 @@ void Dof6Spring2Setup::initPhysics()
|
|||||||
m_data->m_ChainLeftConstraint->setParam(BT_CONSTRAINT_STOP_ERP,limitConstraintStrength,a);
|
m_data->m_ChainLeftConstraint->setParam(BT_CONSTRAINT_STOP_ERP,limitConstraintStrength,a);
|
||||||
m_data->m_ChainLeftConstraint->setParam(BT_CONSTRAINT_STOP_CFM,0.0,a);
|
m_data->m_ChainLeftConstraint->setParam(BT_CONSTRAINT_STOP_CFM,0.0,a);
|
||||||
}
|
}
|
||||||
|
m_data->m_ChainLeftConstraint->setDbgDrawSize(btScalar(1.f));
|
||||||
m_dynamicsWorld->addConstraint(m_data->m_ChainLeftConstraint, true);
|
m_dynamicsWorld->addConstraint(m_data->m_ChainLeftConstraint, true);
|
||||||
}
|
}
|
||||||
prevBody = body;
|
prevBody = body;
|
||||||
@ -451,12 +462,14 @@ void Dof6Spring2Setup::animate()
|
|||||||
{
|
{
|
||||||
m_data->m_ChainRightBody->setActivationState(ACTIVE_TAG);
|
m_data->m_ChainRightBody->setActivationState(ACTIVE_TAG);
|
||||||
m_dynamicsWorld->removeConstraint(m_data->m_ChainRightConstraint);
|
m_dynamicsWorld->removeConstraint(m_data->m_ChainRightConstraint);
|
||||||
|
m_data->m_ChainLeftConstraint->setDbgDrawSize(btScalar(2.f));
|
||||||
m_dynamicsWorld->addConstraint(m_data->m_ChainLeftConstraint, true);
|
m_dynamicsWorld->addConstraint(m_data->m_ChainLeftConstraint, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_data->m_ChainLeftBody->setActivationState(ACTIVE_TAG);
|
m_data->m_ChainLeftBody->setActivationState(ACTIVE_TAG);
|
||||||
m_dynamicsWorld->removeConstraint(m_data->m_ChainLeftConstraint);
|
m_dynamicsWorld->removeConstraint(m_data->m_ChainLeftConstraint);
|
||||||
|
m_data->m_ChainRightConstraint->setDbgDrawSize(btScalar(2.f));
|
||||||
m_dynamicsWorld->addConstraint(m_data->m_ChainRightConstraint, true);
|
m_dynamicsWorld->addConstraint(m_data->m_ChainRightConstraint, true);
|
||||||
}
|
}
|
||||||
chainNextFrame = 3.0;
|
chainNextFrame = 3.0;
|
||||||
|
@ -56,6 +56,14 @@ public:
|
|||||||
|
|
||||||
void exitPhysics();
|
void exitPhysics();
|
||||||
|
|
||||||
|
void resetCamera()
|
||||||
|
{
|
||||||
|
float dist = 35;
|
||||||
|
float pitch = 0;
|
||||||
|
float yaw = 14;
|
||||||
|
float targetPos[3]={0,0,0};
|
||||||
|
m_guiHelper->resetCamera(dist,pitch,yaw,targetPos[0],targetPos[1],targetPos[2]);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user