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


C++ btTransform::setOrigin方法代码示例

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


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

示例1: btScalar

	btSoftSingleRayCallback(const btVector3& rayFromWorld,const btVector3& rayToWorld,const btSoftRigidDynamicsWorld* world,btCollisionWorld::RayResultCallback& resultCallback)
	:m_rayFromWorld(rayFromWorld),
	m_rayToWorld(rayToWorld),
	m_world(world),
	m_resultCallback(resultCallback)
	{
		m_rayFromTrans.setIdentity();
		m_rayFromTrans.setOrigin(m_rayFromWorld);
		m_rayToTrans.setIdentity();
		m_rayToTrans.setOrigin(m_rayToWorld);

		btVector3 rayDir = (rayToWorld-rayFromWorld);

		rayDir.normalize ();
		///what about division by zero? --> just set rayDirection[i] to INF/1e30
		m_rayDirectionInverse[0] = rayDir[0] == btScalar(0.0) ? btScalar(1e30) : btScalar(1.0) / rayDir[0];
		m_rayDirectionInverse[1] = rayDir[1] == btScalar(0.0) ? btScalar(1e30) : btScalar(1.0) / rayDir[1];
		m_rayDirectionInverse[2] = rayDir[2] == btScalar(0.0) ? btScalar(1e30) : btScalar(1.0) / rayDir[2];
		m_signs[0] = m_rayDirectionInverse[0] < 0.0;
		m_signs[1] = m_rayDirectionInverse[1] < 0.0;
		m_signs[2] = m_rayDirectionInverse[2] < 0.0;

		m_lambda_max = rayDir.dot(m_rayToWorld-m_rayFromWorld);

	}
开发者ID:greenbaum,项目名称:duetto-bullet,代码行数:25,代码来源:btSoftRigidDynamicsWorld.cpp

示例2: ConvertMatrixToBull

void ConvertMatrixToBull(const matrix3x4_t& hl, btTransform& transform)
{
	Vector forward, left, up, pos;

	forward.x = hl[0][0];
	forward.y = hl[1][0];
	forward.z = hl[2][0];

	left.x = hl[0][1];
	left.y = hl[1][1];
	left.z = hl[2][1];

	up.x = hl[0][2];
	up.y = hl[1][2];
	up.z = hl[2][2];

	pos.x = hl[0][3];
	pos.y = hl[1][3];
	pos.z = hl[2][3];

	btVector3 bullForward, bullLeft, bullUp, origin;
	ConvertDirectionToBull(forward, bullForward);
	ConvertDirectionToBull(-left, bullLeft);
	ConvertDirectionToBull(up, bullUp);
	ConvertPosToBull(pos, origin);

	transform.setBasis(btMatrix3x3(bullForward.x(), bullUp.x(), bullLeft.x(), bullForward.y(), bullUp.y(), bullLeft.y(), bullForward.z(), bullUp.z(), bullLeft.z()));
	transform.setOrigin(origin);
}
开发者ID:Jcw87,项目名称:Gmod-vphysics,代码行数:29,代码来源:convert.cpp

示例3:

//**************************************************************************************************************************pose2DtoTf()
void PSMpositionNode::pose2DToTf(const geometry_msgs::Pose2D& pose, btTransform& t)
{
    t.setOrigin(btVector3(pose.x, pose.y, 0.0));
    btQuaternion q;
    q.setRPY(0, 0, pose.theta);
    t.setRotation(q);
}
开发者ID:sunzhusz,项目名称:pixhawk-kinect-pkg,代码行数:8,代码来源:mainNode.cpp

示例4: getWorldTransform

// This callback is invoked by the physics simulation in two cases:
// (1) when the RigidBody is first added to the world
//     (irregardless of PhysicsMotionType: STATIC, DYNAMIC, or KINEMATIC)
// (2) at the beginning of each simulation step for KINEMATIC RigidBody's --
//     it is an opportunity for outside code to update the object's simulation position
void EntityMotionState::getWorldTransform(btTransform& worldTrans) const {
    BT_PROFILE("getWorldTransform");
    if (!_entity) {
        return;
    }
    assert(entityTreeIsLocked());
    if (_motionType == MOTION_TYPE_KINEMATIC) {
        BT_PROFILE("kinematicIntegration");
        uint32_t thisStep = ObjectMotionState::getWorldSimulationStep();
        if (hasInternalKinematicChanges()) {
            // ACTION_CAN_CONTROL_KINEMATIC_OBJECT_HACK: This kinematic body was moved by an Action
            // and doesn't require transform update because the body is authoritative and its transform
            // has already been copied out --> do no kinematic integration.
            clearInternalKinematicChanges();
            _lastKinematicStep = thisStep;
            return;
        }
        // This is physical kinematic motion which steps strictly by the subframe count
        // of the physics simulation and uses full gravity for acceleration.
        _entity->setAcceleration(_entity->getGravity());

        float dt = (thisStep - _lastKinematicStep) * PHYSICS_ENGINE_FIXED_SUBSTEP;
        _lastKinematicStep = thisStep;
        _entity->stepKinematicMotion(dt);

        // and set the acceleration-matches-gravity count high so that if we send an update
        // it will use the correct acceleration for remote simulations
        _accelerationNearlyGravityCount = (uint8_t)(-1);
    }
    worldTrans.setOrigin(glmToBullet(getObjectPosition()));
    worldTrans.setRotation(glmToBullet(_entity->getWorldOrientation()));
}
开发者ID:Menithal,项目名称:hifi,代码行数:37,代码来源:EntityMotionState.cpp

示例5: updateTriggerPosition

//-------------------------------------------------------------------------------------------------------
void Road::updateTriggerPosition(btTransform& trans)
{
    trans.setIdentity();
    trans.setOrigin(GameState::ogreVecToBullet(mPosition));
    Ogre::Quaternion rotation = Ogre::Vector3::UNIT_Z.getRotationTo(mDirection);
    trans.setRotation(btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w));
}
开发者ID:fsxfreak,项目名称:Catreon,代码行数:8,代码来源:Road.cpp

示例6: getWorldTransform

void MotionState::getWorldTransform(btTransform &transform) const
{
    lua_rawgeti(L, LUA_REGISTRYINDEX, component_ref);
    lua_getfield(L, -1, "transform");
    lua_remove(L, -2);
    // the stack now contains just the transform component
    
    // get the origin
    {
        lua_getfield(L, -1, "pos");
        double x, y, z;
        l_tovect(L, -1, &x, &y, &z);
        lua_pop(L, 1);

        transform.setOrigin(btVector3(x, y, z));
    }

    // get the rotation
    {
        lua_getfield(L, -1, "orientation");
        double w, x, y, z;
        l_toquaternion(L, -1, &w, &x, &y, &z);
        lua_pop(L, 1);

        transform.setRotation(btQuaternion(x, y, z, w));
    }

    lua_pop(L, 1);
}
开发者ID:henkboom,项目名称:dokidoki-physics,代码行数:29,代码来源:physics.cpp

示例7:

void	fbMotionState::getWorldTransform(btTransform& worldTrans) const
{
	assert(mVisualObj);
	worldTrans.setIdentity();
	worldTrans.setRotation(FBToBullet(mVisualObj->GetRot()));
	worldTrans.setOrigin(FBToBullet(mVisualObj->GetPos()));	
}
开发者ID:fastbird,项目名称:fastbirdEngine,代码行数:7,代码来源:fbMotionState.cpp

示例8: getWorldTransform

// This callback is invoked by the physics simulation in two cases:
// (1) when the RigidBody is first added to the world
//     (irregardless of PhysicsMotionType: STATIC, DYNAMIC, or KINEMATIC)
// (2) at the beginning of each simulation step for KINEMATIC RigidBody's --
//     it is an opportunity for outside code to update the object's simulation position
void EntityMotionState::getWorldTransform(btTransform& worldTrans) const {
    BT_PROFILE("getWorldTransform");
    if (!_entity) {
        return;
    }
    assert(entityTreeIsLocked());
    if (_motionType == MOTION_TYPE_KINEMATIC) {
        BT_PROFILE("kinematicIntegration");
        // This is physical kinematic motion which steps strictly by the subframe count
        // of the physics simulation and uses full gravity for acceleration.
        _entity->setAcceleration(_entity->getGravity());
        uint32_t thisStep = ObjectMotionState::getWorldSimulationStep();
        float dt = (thisStep - _lastKinematicStep) * PHYSICS_ENGINE_FIXED_SUBSTEP;
        _entity->stepKinematicMotion(dt);

        // bypass const-ness so we can remember the step
        const_cast<EntityMotionState*>(this)->_lastKinematicStep = thisStep;

        // and set the acceleration-matches-gravity count high so that if we send an update
        // it will use the correct acceleration for remote simulations
        _accelerationNearlyGravityCount = (uint8_t)(-1);
    }
    worldTrans.setOrigin(glmToBullet(getObjectPosition()));
    worldTrans.setRotation(glmToBullet(_entity->getRotation()));
}
开发者ID:imgntn,项目名称:hifi,代码行数:30,代码来源:EntityMotionState.cpp

示例9:

	virtual	void	addCamera(_bObj* tmpObject)
	{
		m_cameraTrans.setOrigin(btVector3(tmpObject->location[IRR_X],tmpObject->location[IRR_Y],tmpObject->location[IRR_Z]));
		btMatrix3x3 mat;
		mat.setEulerZYX(tmpObject->rotphr[0],tmpObject->rotphr[1],tmpObject->rotphr[2]);
		m_cameraTrans.setBasis(mat);
	}
开发者ID:ani19tha,项目名称:dynamica,代码行数:7,代码来源:BasicDemo.cpp

示例10: calculatePrincipalAxisTransform

void btCompoundShape::calculatePrincipalAxisTransform(btScalar* masses, btTransform& principal, btVector3& inertia) const
{
	int n = m_children.size();

	btScalar totalMass = 0;
	btVector3 center(0, 0, 0);
	int k;

	for (k = 0; k < n; k++)
	{
		btAssert(masses[k]>0);
		center += m_children[k].m_transform.getOrigin() * masses[k];
		totalMass += masses[k];
	}

	btAssert(totalMass>0);

	center /= totalMass;
	principal.setOrigin(center);

	btMatrix3x3 tensor(0, 0, 0, 0, 0, 0, 0, 0, 0);
	for ( k = 0; k < n; k++)
	{
		btVector3 i;
		m_children[k].m_childShape->calculateLocalInertia(masses[k], i);

		const btTransform& t = m_children[k].m_transform;
		btVector3 o = t.getOrigin() - center;

		//compute inertia tensor in coordinate system of compound shape
		btMatrix3x3 j = t.getBasis().transpose();
		j[0] *= i[0];
		j[1] *= i[1];
		j[2] *= i[2];
		j = t.getBasis() * j;

		//add inertia tensor
		tensor[0] += j[0];
		tensor[1] += j[1];
		tensor[2] += j[2];

		//compute inertia tensor of pointmass at o
		btScalar o2 = o.length2();
		j[0].setValue(o2, 0, 0);
		j[1].setValue(0, o2, 0);
		j[2].setValue(0, 0, o2);
		j[0] += o * -o.x(); 
		j[1] += o * -o.y(); 
		j[2] += o * -o.z();

		//add inertia tensor of pointmass
		tensor[0] += masses[k] * j[0];
		tensor[1] += masses[k] * j[1];
		tensor[2] += masses[k] * j[2];
	}

	tensor.diagonalize(principal.getBasis(), btScalar(0.00001), 20);
	inertia.setValue(tensor[0][0], tensor[1][1], tensor[2][2]);
}
开发者ID:OnlyTheGhosts,项目名称:OWEngine,代码行数:59,代码来源:btCompoundShape.cpp

示例11: draw

static void draw(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    float xpos = box1->getCenterOfMassPosition().getX();
    float ypos = box1->getCenterOfMassPosition().getY();
    float zpos = box1->getCenterOfMassPosition().getZ();

    printf("%f %f %f\n",xpos,ypos,zpos);
    
	btTransform trans = box1->getWorldTransform();
	trans.setOrigin(btVector3(BoxVel[0], BoxVel[1], BoxVel[2]));
	box1->setWorldTransform(trans);
	box1->getMotionState()->getWorldTransform(trans);
	trans.setOrigin(btVector3(BoxVel[0], BoxVel[1], BoxVel[2]));
	box1->getMotionState()->setWorldTransform(trans);

//*** draw box1 
glColor3f(0.0, 0.0, 1.0);
glPushMatrix();
box1->getMotionState()->getWorldTransform(trans);
trans.getOpenGLMatrix(matrix);
glMultMatrixf(matrix);
glutSolidCube(40);
glPopMatrix();

//*** draw box2
glColor3f(1.0, 1.0, 0.0);
glPushMatrix();
box2->getMotionState()->getWorldTransform(trans);
trans.getOpenGLMatrix(matrix);
glMultMatrixf(matrix);
glutSolidCube(10);
glPopMatrix();

// draw box 3
glColor3f(0.0,0.0,1.0);
glPushMatrix();
box3->getMotionState()->getWorldTransform(trans);
trans.getOpenGLMatrix(matrix);
glMultMatrixf(matrix);
glutSolidCube(30);
glPopMatrix();

glutSwapBuffers();
}
开发者ID:devashishtyagi,项目名称:cubequest,代码行数:46,代码来源:rendercollision.cpp

示例12: getWorldTransform

	void getWorldTransform(btTransform& worldTrans) const
    {
        worldTrans.setBasis( btMatrix3x3(transform[0][0], transform[0][1], transform[0][2],
                                         transform[1][0], transform[1][1], transform[1][2],
                                         transform[2][0], transform[2][1], transform[2][2]) );

        worldTrans.setOrigin( btVector3(transform[0][3], transform[1][3], transform[2][3]));
    }
开发者ID:BackupTheBerlios,项目名称:slon,代码行数:8,代码来源:BulletRigidBody.cpp

示例13: getWorldTransform

	virtual void getWorldTransform(btTransform& tform) const
	{
		const auto& p = m_part->dummy->getDefaultTranslation();
		const auto& o = glm::toQuat(m_part->dummy->getDefaultRotation());
		tform.setOrigin(btVector3(p.x, p.y, p.z));
		tform.setRotation(btQuaternion(o.x, o.y, o.z, o.w));
		tform = m_object->collision->getBulletBody()->getWorldTransform() * tform;
	}
开发者ID:JayFoxRox,项目名称:openrw,代码行数:8,代码来源:VehicleObject.cpp

示例14: gaen_to_bullet_transform

void gaen_to_bullet_transform(btTransform & bT, const mat43 & gT)
{
    bT.setBasis(btMatrix3x3(gT[0][0], gT[1][0], gT[2][0],
                            gT[0][1], gT[1][1], gT[2][1],
                            gT[0][2], gT[1][2], gT[2][2]));

    bT.setOrigin(btVector3(gT[3][0], gT[3][1], gT[3][2]));
}
开发者ID:lachlanorr,项目名称:gaen,代码行数:8,代码来源:ModelPhysics.cpp

示例15: getWorldTransform

// virtual
void AvatarMotionState::getWorldTransform(btTransform& worldTrans) const {
    worldTrans.setOrigin(glmToBullet(getObjectPosition()));
    worldTrans.setRotation(glmToBullet(getObjectRotation()));
    if (_body) {
        _body->setLinearVelocity(glmToBullet(getObjectLinearVelocity()));
        _body->setAngularVelocity(glmToBullet(getObjectAngularVelocity()));
    }
}
开发者ID:Nex-Pro,项目名称:hifi,代码行数:9,代码来源:AvatarMotionState.cpp


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