示例#1
0
void
dxJointHinge2::setRelativeValues()
{
    dVector3 anchor;
    dJointGetHinge2Anchor(this, anchor);
    setAnchors( this, anchor[0], anchor[1], anchor[2], anchor1, anchor2 );

    dVector3 axis;

    if ( node[0].body )
    {
        dJointGetHinge2Axis1(this, axis);
        setAxes( this, axis[0],axis[1],axis[2], axis1, NULL );
    }

    if ( node[0].body )
    {
        dJointGetHinge2Axis2(this, axis);
        setAxes( this, axis[0],axis[1],axis[2], NULL, axis2 );
    }

    dVector3 ax1, ax2;
    getAxisInfo( ax1, ax2, axis, s0, c0 );

    makeV1andV2();
    makeW1andW2();
}
示例#2
0
void CCar::SWheel::ApplyDamage(u16 level)
{
	inherited::ApplyDamage(level);
	if(!joint) return;
	if(level == 0 )return;
	float sf,df;
	dJointID dj=joint->GetDJoint();
	switch(level) {

	case 1:
		joint->GetJointSDfactors(sf,df);
		sf/=20.f;df*=4.f;
		joint->SetJointSDfactors(sf,df);
		car->m_damage_particles.PlayWheel1(car,bone_id);
		break;
	case 2:
		
		dVector3 v;
	
		dJointGetHinge2Axis2(dj,v);
		v[0]+=0.1f;v[1]+=0.1f;v[2]+=0.1f;
		accurate_normalize(v);
		dJointSetHinge2Axis2(dj,v[0],v[1],v[2]);
		joint->GetJointSDfactors(sf,df);
		sf/=30.f;df*=8.f;
		joint->SetJointSDfactors(sf,df);
		car->m_damage_particles.PlayWheel2(car,bone_id);
		break;
	default: NODEFAULT;
	}
	
}
Vec3f PhysicsHinge2Joint::getAxis2(void)
{
	PhysicsHinge2JointPtr tmpPtr(*this);
	dVector3 a;
	dJointGetHinge2Axis2(tmpPtr->id, a);
	return Vec3f(a[0], a[1], a[2]);
}
示例#4
0
/**
 * This method is called if the joint should be detached. It stores
 * the actual Joint-axis, which can change their orientation at
 * Hinge2Joints, and destroys the helper body and joint.
 **/
void Hinge2Joint::detachJoint() {
	if (active && joint)
	{
		TransformationData entityTrans;
		dVector3 vec;
		dJointGetHinge2Axis1(joint, vec);
		axis1[0] = vec[0];
		axis1[1] = vec[1];
		axis1[2] = vec[2];
		dJointGetHinge2Axis2(joint, vec);
		axis2[0] = vec[0];
		axis2[1] = vec[1];
		axis2[2] = vec[2];
		if (mainEntity != NULL)
		{
			entityTrans = mainEntity->getEnvironmentTransformation();
			gmtl::Quatf entityRot;
			gmtl::Vec3f scaleVec;
			gmtl::AxisAnglef axAng;

	// get the inverse scale values of the mainEntity
/*			scaleVec[0] = 1.0f/mainEntity->getXScale();
			scaleVec[1] = 1.0f/mainEntity->getYScale();
			scaleVec[2] = 1.0f/mainEntity->getZScale();*/
			scaleVec[0] = 1.0f/entityTrans.scale[0];
			scaleVec[1] = 1.0f/entityTrans.scale[1];
			scaleVec[2] = 1.0f/entityTrans.scale[2];
	// get the inverse Rotation of the mainEntity
// 			axAng[0] = -mainEntity->getRotAngle();
// 			axAng[1] = mainEntity->getXRot();
// 			axAng[2] = mainEntity->getYRot();
// 			axAng[3] = mainEntity->getZRot();
// 			gmtl::set(entityRot, axAng);
			entityRot = entityTrans.orientation;
			gmtl::invert(entityRot);

			axis1 *= entityRot;
			axis2 *= entityRot;

			axis1[0] *= scaleVec[0];
			axis1[1] *= scaleVec[1];
			axis1[2] *= scaleVec[2];

			axis2[0] *= scaleVec[0];
			axis2[1] *= scaleVec[1];
			axis2[2] *= scaleVec[2];

			gmtl::normalize(axis1);
			gmtl::normalize(axis2);
		} // if
	} // if

	if (usedHelperJoint)
	{
		dJointDestroy(helperJoint);
		dBodyDestroy(helperBody);
		usedHelperJoint = false;
	} // if
} // detachJoint
示例#5
0
文件: physics.c 项目: ntoand/electro
static void get_phys_joint_axis_2(dJointID j, float *v)
{
    dVector3 V = { 0, 0, 0 };

    switch (dJointGetType(j))
    {
    case dJointTypeHinge2:    dJointGetHinge2Axis2   (j, V); break;
    case dJointTypeUniversal: dJointGetUniversalAxis2(j, V); break;
    default: break;
    }

    v[0] = (float) V[0];
    v[1] = (float) V[1];
    v[2] = (float) V[2];
}
示例#6
0
void TSRODESteeringJoint::GetAxis2( TSRVector3& _vAxis2 )
{
	dJointGetHinge2Axis2( m_ODEJoint.m_JointID, _vAxis2.v );
}