本文整理汇总了C++中btRigidBody::setLinearVelocity方法的典型用法代码示例。如果您正苦于以下问题:C++ btRigidBody::setLinearVelocity方法的具体用法?C++ btRigidBody::setLinearVelocity怎么用?C++ btRigidBody::setLinearVelocity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类btRigidBody
的用法示例。
在下文中一共展示了btRigidBody::setLinearVelocity方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void Hinge2Vehicle::resetForklift()
{
gVehicleSteering = 0.f;
gBreakingForce = defaultBreakingForce;
gEngineForce = 0.f;
m_carChassis->setCenterOfMassTransform(btTransform::getIdentity());
m_carChassis->setLinearVelocity(btVector3(0,0,0));
m_carChassis->setAngularVelocity(btVector3(0,0,0));
m_dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(m_carChassis->getBroadphaseHandle(),getDynamicsWorld()->getDispatcher());
#if 0
if (m_vehicle)
{
m_vehicle->resetSuspension();
for (int i=0;i<m_vehicle->getNumWheels();i++)
{
//synchronize the wheels with the (interpolated) chassis worldtransform
m_vehicle->updateWheelTransform(i,true);
}
}
#endif
btTransform liftTrans;
liftTrans.setIdentity();
liftTrans.setOrigin(m_liftStartPos);
m_liftBody->activate();
m_liftBody->setCenterOfMassTransform(liftTrans);
m_liftBody->setLinearVelocity(btVector3(0,0,0));
m_liftBody->setAngularVelocity(btVector3(0,0,0));
btTransform forkTrans;
forkTrans.setIdentity();
forkTrans.setOrigin(m_forkStartPos);
m_forkBody->activate();
m_forkBody->setCenterOfMassTransform(forkTrans);
m_forkBody->setLinearVelocity(btVector3(0,0,0));
m_forkBody->setAngularVelocity(btVector3(0,0,0));
// m_liftHinge->setLimit(-LIFT_EPS, LIFT_EPS);
m_liftHinge->setLimit(0.0f, 0.0f);
m_liftHinge->enableAngularMotor(false, 0, 0);
m_forkSlider->setLowerLinLimit(0.1f);
m_forkSlider->setUpperLinLimit(0.1f);
m_forkSlider->setPoweredLinMotor(false);
btTransform loadTrans;
loadTrans.setIdentity();
loadTrans.setOrigin(m_loadStartPos);
m_loadBody->activate();
m_loadBody->setCenterOfMassTransform(loadTrans);
m_loadBody->setLinearVelocity(btVector3(0,0,0));
m_loadBody->setAngularVelocity(btVector3(0,0,0));
}
示例2: utilSyncHeadRepresentation
void BulletWrapper::utilSyncHeadRepresentation(const EigenTypes::Vector3f& headPosition, float deltaTime)
{
// apply velocities or apply positions
btVector3 target = ToBullet(headPosition);
btVector3 current = m_HeadRepresentation->getWorldTransform().getOrigin();
btVector3 targetVelocity = (target - current) / deltaTime;
m_HeadRepresentation->setLinearVelocity(targetVelocity);
m_HeadRepresentation->setAngularVelocity(btVector3(0, 0, 0));
}
示例3: PhysicsObject
PhysicsObject(btDiscreteDynamicsWorld & world, const T & shape,
btScalar mass, btVector3 velocity,
const btTransform & transform,
GameBall * ptrBall):
_shape(shape),
_motionState(transform),
_rigidBody(mass, &_motionState, &_shape),
_ptrBall(ptrBall)
{
// TODO angular velocity ?
_rigidBody.setLinearVelocity(velocity);
_rigidBody.setDamping(0.1, 0.1);
_rigidBody.setRestitution(0.7);
_rigidBody.setFriction(0.1);
// TODO _rigidBody.setRollingFriction(0.01);
world.addRigidBody(&_rigidBody);
}
示例4: make_dynamic
void make_dynamic(CommonRigidBodyBase* bullet_scene, float ftime_ms)
{
if(!is_kinematic)
return;
float base_time = 1/90.f;
float frame_time = ftime_ms / 1000.f;
rigid_body->saveKinematicState(base_time);
rigid_body->setLinearVelocity(bullet_scene->getBodyAvgVelocity(rigid_body));
rigid_body->setAngularVelocity(bullet_scene->getBodyAvgAngularVelocity(rigid_body));
toggleSaveMotion();
bullet_scene->makeDynamic(rigid_body);
is_kinematic = false;
}
示例5: setVelocity
virtual void setVelocity(const btVector3& v) {m_body->setLinearVelocity(v); }