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)); }
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)); }
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); }
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; }
virtual void setVelocity(const btVector3& v) {m_body->setLinearVelocity(v); }