当前位置: 首页>>代码示例>>C++>>正文


C++ btRigidBody类代码示例

本文整理汇总了C++中btRigidBody的典型用法代码示例。如果您正苦于以下问题:C++ btRigidBody类的具体用法?C++ btRigidBody怎么用?C++ btRigidBody使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了btRigidBody类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: s_fixed

btRigidBody& btKart::getFixedBody()
{
    static btRigidBody s_fixed(0, 0,0);
    s_fixed.setMassProps(btScalar(0.),btVector3(btScalar(0.),
                         btScalar(0.),btScalar(0.)));
    return s_fixed;
}
开发者ID:Flakebi,项目名称:stk-code,代码行数:7,代码来源:btKart.cpp

示例2: btScalar

void	btWheelInfo::updateWheel(const btRigidBody& chassis,RaycastInfo& raycastInfo)
{
	(void)raycastInfo;

	
	if (m_raycastInfo.m_isInContact)

	{
		btScalar	project= m_raycastInfo.m_contactNormalWS.dot( m_raycastInfo.m_wheelDirectionWS );
		btVector3	 chassis_velocity_at_contactPoint;
		btVector3 relpos = m_raycastInfo.m_contactPointWS - chassis.getCenterOfMassPosition();
		chassis_velocity_at_contactPoint = chassis.getVelocityInLocalPoint( relpos );
		btScalar projVel = m_raycastInfo.m_contactNormalWS.dot( chassis_velocity_at_contactPoint );
		if ( project >= btScalar(-0.1))
		{
			m_suspensionRelativeVelocity = btScalar(0.0);
			m_clippedInvContactDotSuspension = btScalar(1.0) / btScalar(0.1);
		}
		else
		{
			btScalar inv = btScalar(-1.) / project;
			m_suspensionRelativeVelocity = projVel * inv;
			m_clippedInvContactDotSuspension = inv;
		}
		
	}

	else	// Not in contact : position wheel in a nice (rest length) position
	{
		m_raycastInfo.m_suspensionLength = this->getSuspensionRestLength();
		m_suspensionRelativeVelocity = btScalar(0.0);
		m_raycastInfo.m_contactNormalWS = -m_raycastInfo.m_wheelDirectionWS;
		m_clippedInvContactDotSuspension = btScalar(1.0);
	}
}
开发者ID:dreamsxin,项目名称:Scene3D,代码行数:35,代码来源:btWheelInfo.cpp

示例3: s_fixed

btRigidBody* gkDynamicsWorld::getFixedBody()
{
	static btRigidBody s_fixed(0, 0,0);
    s_fixed.setMassProps(btScalar(0.),btVector3(btScalar(0.),btScalar(0.),btScalar(0.)));

    return &s_fixed;
}
开发者ID:Draion,项目名称:Gamekit,代码行数:7,代码来源:gkDynamicsWorld.cpp

示例4:

// constructor
// anchor, axis1 and axis2 are in world coordinate system
// axis1 must be orthogonal to axis2
btUniversalConstraint::btUniversalConstraint(btRigidBody& rbA, btRigidBody& rbB, const btVector3& anchor, const btVector3& axis1, const btVector3& axis2)
: btGeneric6DofConstraint(rbA, rbB, btTransform::getIdentity(), btTransform::getIdentity(), true),
 m_anchor(anchor),
 m_axis1(axis1),
 m_axis2(axis2)
{
	// build frame basis
	// 6DOF constraint uses Euler angles and to define limits
	// it is assumed that rotational order is :
	// Z - first, allowed limits are (-PI,PI);
	// new position of Y - second (allowed limits are (-PI/2 + epsilon, PI/2 - epsilon), where epsilon is a small positive number
	// used to prevent constraint from instability on poles;
	// new position of X, allowed limits are (-PI,PI);
	// So to simulate ODE Universal joint we should use parent axis as Z, child axis as Y and limit all other DOFs
	// Build the frame in world coordinate system first
	btVector3 zAxis = m_axis1.normalize();
	btVector3 yAxis = m_axis2.normalize();
	btVector3 xAxis = yAxis.cross(zAxis); // we want right coordinate system
	btTransform frameInW;
	frameInW.setIdentity();
	frameInW.getBasis().setValue(	xAxis[0], yAxis[0], zAxis[0],
									xAxis[1], yAxis[1], zAxis[1],
									xAxis[2], yAxis[2], zAxis[2]);
	frameInW.setOrigin(anchor);
	// now get constraint frame in local coordinate systems
	m_frameInA = rbA.getCenterOfMassTransform().inverse() * frameInW;
	m_frameInB = rbB.getCenterOfMassTransform().inverse() * frameInW;
	// sei limits
	setLinearLowerLimit(btVector3(0., 0., 0.));
	setLinearUpperLimit(btVector3(0., 0., 0.));
	setAngularLowerLimit(btVector3(0.f, -SIMD_HALF_PI + UNIV_EPS, -SIMD_PI + UNIV_EPS));
	setAngularUpperLimit(btVector3(0.f,  SIMD_HALF_PI - UNIV_EPS,  SIMD_PI - UNIV_EPS));
}
开发者ID:g-pechorin,项目名称:bullet2stripped,代码行数:36,代码来源:btUniversalConstraint.cpp

示例5: shortestArcQuat

btHingeConstraint::btHingeConstraint(btRigidBody& rbA,const btVector3& pivotInA,btVector3& axisInA)
:btTypedConstraint(HINGE_CONSTRAINT_TYPE, rbA), m_angularOnly(false), m_enableAngularMotor(false)
{

	// since no frame is given, assume this to be zero angle and just pick rb transform axis
	// fixed axis in worldspace
	btVector3 rbAxisA1, rbAxisA2;
	btPlaneSpace1(axisInA, rbAxisA1, rbAxisA2);

	m_rbAFrame.getOrigin() = pivotInA;
	m_rbAFrame.getBasis().setValue( rbAxisA1.getX(),rbAxisA2.getX(),axisInA.getX(),
									rbAxisA1.getY(),rbAxisA2.getY(),axisInA.getY(),
									rbAxisA1.getZ(),rbAxisA2.getZ(),axisInA.getZ() );

	btVector3 axisInB = rbA.getCenterOfMassTransform().getBasis() * -axisInA;

	btQuaternion rotationArc = shortestArcQuat(axisInA,axisInB);
	btVector3 rbAxisB1 =  quatRotate(rotationArc,rbAxisA1);
	btVector3 rbAxisB2 = axisInB.cross(rbAxisB1);


	m_rbBFrame.getOrigin() = rbA.getCenterOfMassTransform()(pivotInA);
	m_rbBFrame.getBasis().setValue( rbAxisB1.getX(),rbAxisB2.getX(),axisInB.getX(),
									rbAxisB1.getY(),rbAxisB2.getY(),axisInB.getY(),
									rbAxisB1.getZ(),rbAxisB2.getZ(),axisInB.getZ() );
	
	//start with free
	m_lowerLimit = btScalar(1e30);
	m_upperLimit = btScalar(-1e30);
	m_biasFactor = 0.3f;
	m_relaxationFactor = 1.0f;
	m_limitSoftness = 0.9f;
	m_solveLimit = false;
}
开发者ID:andemi02,项目名称:orkid,代码行数:34,代码来源:btHingeConstraint.cpp

示例6: shortestArcQuat

btHingeConstraint::btHingeConstraint(btRigidBody& rbA,const btVector3& pivotInA,const btVector3& axisInA, bool useReferenceFrameA)
:btTypedConstraint(HINGE_CONSTRAINT_TYPE, rbA), m_angularOnly(false), m_enableAngularMotor(false), 
m_useSolveConstraintObsolete(HINGE_USE_OBSOLETE_SOLVER),
m_useOffsetForConstraintFrame(HINGE_USE_FRAME_OFFSET),
m_useReferenceFrameA(useReferenceFrameA),
m_flags(0),m_limit()
{

	// since no frame is given, assume this to be zero angle and just pick rb transform axis
	// fixed axis in worldspace
	btVector3 rbAxisA1, rbAxisA2;
	btPlaneSpace1(axisInA, rbAxisA1, rbAxisA2);

	m_rbAFrame.getOrigin() = pivotInA;
	m_rbAFrame.getBasis().setValue( rbAxisA1.getX(),rbAxisA2.getX(),axisInA.getX(),
									rbAxisA1.getY(),rbAxisA2.getY(),axisInA.getY(),
									rbAxisA1.getZ(),rbAxisA2.getZ(),axisInA.getZ() );

	btVector3 axisInB = rbA.getCenterOfMassTransform().getBasis() * axisInA;

	btQuaternion rotationArc = shortestArcQuat(axisInA,axisInB);
	btVector3 rbAxisB1 =  quatRotate(rotationArc,rbAxisA1);
	btVector3 rbAxisB2 = axisInB.cross(rbAxisB1);


	m_rbBFrame.getOrigin() = rbA.getCenterOfMassTransform()(pivotInA);
	m_rbBFrame.getBasis().setValue( rbAxisB1.getX(),rbAxisB2.getX(),axisInB.getX(),
									rbAxisB1.getY(),rbAxisB2.getY(),axisInB.getY(),
									rbAxisB1.getZ(),rbAxisB2.getZ(),axisInB.getZ() );
	
	m_referenceSign = m_useReferenceFrameA ? btScalar(-1.f) : btScalar(1.f);
}
开发者ID:ArmorBearerSlave,项目名称:awayphysics-core-fp11,代码行数:32,代码来源:btHingeConstraint.cpp

示例7: if

btHingeConstraint::btHingeConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB,
									 const btVector3& axisInA,const btVector3& axisInB, bool useReferenceFrameA)
									 :btTypedConstraint(HINGE_CONSTRAINT_TYPE, rbA,rbB),
#ifdef _BT_USE_CENTER_LIMIT_
									 m_limit(),
#endif
									 m_angularOnly(false),
									 m_enableAngularMotor(false),
									 m_useSolveConstraintObsolete(HINGE_USE_OBSOLETE_SOLVER),
									 m_useOffsetForConstraintFrame(HINGE_USE_FRAME_OFFSET),
									 m_useReferenceFrameA(useReferenceFrameA),
									 m_flags(0),
									 m_normalCFM(0),
									 m_normalERP(0),
									 m_stopCFM(0),
									 m_stopERP(0)
{
	m_rbAFrame.getOrigin() = pivotInA;
	
	// since no frame is given, assume this to be zero angle and just pick rb transform axis
	btVector3 rbAxisA1 = rbA.getCenterOfMassTransform().getBasis().getColumn(0);

	btVector3 rbAxisA2;
	btScalar projection = axisInA.dot(rbAxisA1);
	if (projection >= 1.0f - SIMD_EPSILON) {
		rbAxisA1 = -rbA.getCenterOfMassTransform().getBasis().getColumn(2);
		rbAxisA2 = rbA.getCenterOfMassTransform().getBasis().getColumn(1);
	} else if (projection <= -1.0f + SIMD_EPSILON) {
		rbAxisA1 = rbA.getCenterOfMassTransform().getBasis().getColumn(2);
		rbAxisA2 = rbA.getCenterOfMassTransform().getBasis().getColumn(1);      
	} else {
		rbAxisA2 = axisInA.cross(rbAxisA1);
		rbAxisA1 = rbAxisA2.cross(axisInA);
	}

	m_rbAFrame.getBasis().setValue( rbAxisA1.getX(),rbAxisA2.getX(),axisInA.getX(),
									rbAxisA1.getY(),rbAxisA2.getY(),axisInA.getY(),
									rbAxisA1.getZ(),rbAxisA2.getZ(),axisInA.getZ() );

	btQuaternion rotationArc = shortestArcQuat(axisInA,axisInB);
	btVector3 rbAxisB1 =  quatRotate(rotationArc,rbAxisA1);
	btVector3 rbAxisB2 =  axisInB.cross(rbAxisB1);	
	
	m_rbBFrame.getOrigin() = pivotInB;
	m_rbBFrame.getBasis().setValue( rbAxisB1.getX(),rbAxisB2.getX(),axisInB.getX(),
									rbAxisB1.getY(),rbAxisB2.getY(),axisInB.getY(),
									rbAxisB1.getZ(),rbAxisB2.getZ(),axisInB.getZ() );
	
#ifndef	_BT_USE_CENTER_LIMIT_
	//start with free
	m_lowerLimit = btScalar(1.0f);
	m_upperLimit = btScalar(-1.0f);
	m_biasFactor = 0.3f;
	m_relaxationFactor = 1.0f;
	m_limitSoftness = 0.9f;
	m_solveLimit = false;
#endif
	m_referenceSign = m_useReferenceFrameA ? btScalar(-1.f) : btScalar(1.f);
}
开发者ID:Aatch,项目名称:bullet3,代码行数:59,代码来源:btHingeConstraint.cpp

示例8: createBulletObject

  void createBulletObject(Shape shape)
  {
    switch (shape) {
      case ConvexHull : {
        btConvexHullShape* bcs = new btConvexHullShape();
        for (size_t i=0; i<data.size(); i++) {
          glm::vec3& v = data[i].vertex;
          bcs->addPoint( glmvec3_to_btVector3(v) );
        }
        btScalar mass(ball_mass);
        btVector3 localInertia(0,0,0);
        //using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
        // position and motion
        btTransform ballTransform;
        ballTransform.setIdentity();
        ballTransform.setOrigin(btVector3(0,ball_initial_height,0));
        btDefaultMotionState* bulletMotionState = new btDefaultMotionState(btTransform(ballTransform));
        // ball rigidbody info
        btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,bulletMotionState,bcs,localInertia);
        // tweak rigidbody info
        rbInfo.m_restitution = grestitution;
        rbInfo.m_friction = gfriction;
        // add ball to the world
        rigidbody = new btRigidBody(rbInfo);
        if(!rigidbody) std::cout << "bulletBallBody pointer null" << std::endl; 
        dynamicsWorld->addRigidBody(rigidbody);
        break;
      }
      case TriangleMesh : { 
        // Shape
        btBvhTriangleMeshShape* boardShape = new btBvhTriangleMeshShape( &bt_triangles, true );

        btScalar mass(board_mass);
        btVector3 localInertia(0,0,0);

        // transform : default position
        btTransform boardTransform;
        boardTransform.setIdentity();
        boardTransform.setOrigin(btVector3(0,0,0));
        btDefaultMotionState* bulletMotionState = new btDefaultMotionState(btTransform(boardTransform));
        btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,bulletMotionState,boardShape,localInertia);

        // tweak rigidbody properties
        rbInfo.m_restitution = grestitution;
        rbInfo.m_friction = gfriction;
        // add to the world
        rigidbody = new btRigidBody(rbInfo);
        if(!rigidbody) std::cout << "bulletBoardBody pointer null" << std::endl; 
        rigidbody->setActivationState(DISABLE_DEACTIVATION);
        dynamicsWorld->addRigidBody(rigidbody);
        break; 
      }
      case None : {
        break;
      }
    } // end switch
    
    

  }
开发者ID:YutaMatsumoto,项目名称:airhocky,代码行数:60,代码来源:j7.cpp

示例9: init

    void init(objects_container* _ctr, btRigidBody* _rigid_body, bool _can_slide = false)
    {
        ctr = _ctr;
        rigid_body = _rigid_body;

        //if(ctr)
        //    b = get_bbox(ctr);
        //else
        {
            btVector3 bmin;
            btVector3 bmax;

            btTransform none;
            none.setOrigin(btVector3(0,0,0));
            none.setRotation(btQuaternion().getIdentity());

            rigid_body->getCollisionShape()->getAabb(none, bmin, bmax);

            b.min = {bmin.x(), bmin.y(), bmin.z()};
            b.max = {bmax.x(), bmax.y(), bmax.z()};
        }

        can_slide = _can_slide;

        base_diff = base_diff.identity();
    }
开发者ID:20k,项目名称:leap-motion-bullet-physics-test,代码行数:26,代码来源:grabbables.hpp

示例10:

btPoint2PointConstraint::btPoint2PointConstraint(btRigidBody& rbA,const btVector3& pivotInA)
:btTypedConstraint(POINT2POINT_CONSTRAINT_TYPE,rbA),m_pivotInA(pivotInA),m_pivotInB(rbA.getCenterOfMassTransform()(pivotInA)),
m_flags(0),
m_useSolveConstraintObsolete(false)
{
	
}
开发者ID:JinMyong,项目名称:Game_MatchEmUp,代码行数:7,代码来源:btPoint2PointConstraint.cpp

示例11: if

btHingeConstraint::btHingeConstraint(btRigidBody& rbA,btRigidBody& rbB, const btVector3& pivotInA,const btVector3& pivotInB,
									 btVector3& axisInA,btVector3& axisInB)
									 :btTypedConstraint(HINGE_CONSTRAINT_TYPE, rbA,rbB),
									 m_angularOnly(false),
									 m_enableAngularMotor(false)
{
	m_rbAFrame.getOrigin() = pivotInA;
	
	// since no frame is given, assume this to be zero angle and just pick rb transform axis
	btVector3 rbAxisA1 = rbA.getCenterOfMassTransform().getBasis().getColumn(0);

	btVector3 rbAxisA2;
	btScalar projection = axisInA.dot(rbAxisA1);
	if (projection >= 1.0f - SIMD_EPSILON) {
		rbAxisA1 = -rbA.getCenterOfMassTransform().getBasis().getColumn(2);
		rbAxisA2 = rbA.getCenterOfMassTransform().getBasis().getColumn(1);
	} else if (projection <= -1.0f + SIMD_EPSILON) {
		rbAxisA1 = rbA.getCenterOfMassTransform().getBasis().getColumn(2);
		rbAxisA2 = rbA.getCenterOfMassTransform().getBasis().getColumn(1);      
	} else {
		rbAxisA2 = axisInA.cross(rbAxisA1);
		rbAxisA1 = rbAxisA2.cross(axisInA);
	}

	m_rbAFrame.getBasis().setValue( rbAxisA1.getX(),rbAxisA2.getX(),axisInA.getX(),
									rbAxisA1.getY(),rbAxisA2.getY(),axisInA.getY(),
									rbAxisA1.getZ(),rbAxisA2.getZ(),axisInA.getZ() );

	btQuaternion rotationArc = shortestArcQuat(axisInA,axisInB);
	btVector3 rbAxisB1 =  quatRotate(rotationArc,rbAxisA1);
	btVector3 rbAxisB2 =  axisInB.cross(rbAxisB1);	
	
	m_rbBFrame.getOrigin() = pivotInB;
	m_rbBFrame.getBasis().setValue( rbAxisB1.getX(),rbAxisB2.getX(),-axisInB.getX(),
									rbAxisB1.getY(),rbAxisB2.getY(),-axisInB.getY(),
									rbAxisB1.getZ(),rbAxisB2.getZ(),-axisInB.getZ() );
	
	//start with free
	m_lowerLimit = btScalar(1e30);
	m_upperLimit = btScalar(-1e30);
	m_biasFactor = 0.3f;
	m_relaxationFactor = 1.0f;
	m_limitSoftness = 0.9f;
	m_solveLimit = false;

}
开发者ID:andemi02,项目名称:orkid,代码行数:46,代码来源:btHingeConstraint.cpp

示例12:

	virtual ~RigidObject() 
	{
		if(body->getMotionState())
			delete body->getMotionState();
		world->removeRigidBody(body);
		delete body;
	}
开发者ID:jdduke,项目名称:Cinder,代码行数:7,代码来源:triMeshApp.cpp

示例13: 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));
}
开发者ID:FutingFan,项目名称:hackstate,代码行数:9,代码来源:PhysicsLayer.cpp

示例14: removePickingConstraint

 void removePickingConstraint() {
   if (pickConstraint && dynamicsWorld)
   {
     dynamicsWorld->removeConstraint(pickConstraint);
     delete pickConstraint;
     pickedBody->forceActivationState(ACTIVE_TAG);
     pickedBody->setDeactivationTime( 0.f );
   }
   pickConstraint = NULL;
   pickedBody = NULL;
 }
开发者ID:fedemarino31,项目名称:leaptower,代码行数:11,代码来源:NaClAMBullet.cpp

示例15:

	virtual ~RigidObject() 
	{
		if(body)
		{
			if(body->getMotionState() != NULL)
				delete body->getMotionState();
	//		if(body->getCollisionShape() != NULL)
	//			delete body->getCollisionShape();
			world->removeRigidBody(body);
			delete body;
		}
	}
开发者ID:jdduke,项目名称:Cinder,代码行数:12,代码来源:winBodiesApp.cpp


注:本文中的btRigidBody类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。