Esempio n. 1
0
    Blade(const NxVec3& pos, const NxReal height, const NxU32 numJoints)
	{
		NxReal partHeight = height / (NxReal)numJoints;
		NxReal radius = 0.1;
		NxVec3 globalAnchor;

		bladeSegs = new NxActor*[numJoints];
		bladeLinks = new NxSphericalJoint*[numJoints];

		NxU32 i;
		for (i = 0; i < numJoints; i++)
		{
			bladeSegs[i] = CreateBlade(pos+NxVec3(0,partHeight/2+radius+(partHeight+radius*2)*i,0),NxVec3(radius/2,(partHeight+2*radius)/2,radius/2),numJoints-i+1);
			bladeSegs[i]->setLinearDamping(10);
			SetActorCollisionGroup(bladeSegs[i],1);
		}

		// Anchor blade to ground
		globalAnchor = bladeSegs[0]->getCMassGlobalPosition() - NxVec3(0,partHeight/2,0);
		bladeLinks[0] = CreateBladeLink(bladeSegs[0],NULL,globalAnchor, NxVec3(0,1,0));

		for (i = 1; i < numJoints; i++)
		{
			globalAnchor = bladeSegs[i]->getCMassGlobalPosition() - NxVec3(0,partHeight/2,0);
			bladeLinks[i] = CreateBladeLink(bladeSegs[i], bladeSegs[i-1], globalAnchor, NxVec3(0,1,0));
		}
	}
Esempio n. 2
0
Cutter::Cutter(NxVec3 pos, string fname)
{
	m_cutterHeight = 0.0f;
	m_cutterRotateAngle = 0.0f;
	m_cutterON = false;
	m_cutterParams = new CutterParams;
	m_attachedTriPod = NULL;

	CfgLoader cfg(fname, m_cutterParams->getVariableList());

	//D3DXMatrixRotationYawPitchRoll(&dimm->matChassisRotation, rotateChassis.y, rotateChassis.x, rotateChassis.z);

	ObjectParams temp;
	temp.loadFromFile("Objects\\" + m_cutterParams->chassisModel);
	m_objChassis = new Surface(temp.meshName, temp.generateMaterial(), Vec3(0, 0, 0));
	temp.loadFromFile("Objects\\" + m_cutterParams->cutterModel);
	m_objCutter = new Surface(temp.meshName, temp.generateMaterial(), Vec3(0, 0, 0));

	Vec3 min = m_objChassis->boundingBox.Min;
	//min.y -= 1.0f;
	Vec3 max = m_objChassis->boundingBox.Max;
	//max.y += 0.5f;
	m_actionBox = new ActionBox(min, max);

	core.game->getWorld()->addToWorld(m_objChassis, NO_COLLISION, 0, GROUP_NON_COLLIDABLE, NULL, 1);
	core.game->getWorld()->addToWorld(m_objCutter, NO_COLLISION, 0, GROUP_NON_COLLIDABLE, NULL, 1);

	m_cutterParams->dimm = Vec3(m_objChassis->boundingBox.getWidth()/2, m_objChassis->boundingBox.getHeight()/6, m_objChassis->boundingBox.getDepth()/2);

	m_actor = core.dynamics->createBox(pos, NxVec3(m_cutterParams->dimm), m_cutterParams->density);
	SetActorCollisionGroup(m_actor, GROUP_COLLIDABLE_NON_PUSHABLE);
	NxMaterial *anisoMaterial = NULL;
	//if(!anisoMaterial)
	{
		//Create an anisotropic material
		NxMaterialDesc material; 
		//Anisotropic friction material
		material.restitution = 0.01f;
		material.staticFriction = 0.01f;
		material.dynamicFriction = 0.01f;
		material.dynamicFrictionV = 0.1f;
		material.staticFrictionV = 0.1f;
		material.dirOfAnisotropy.set(1,0,0);
		material.flags = NX_MF_ANISOTROPIC;
		anisoMaterial = core.dynamics->getScene()->createMaterial(material);
	}
	m_actor->getShapes()[0]->setMaterial(anisoMaterial->getMaterialIndex());
}
Esempio n. 3
0
VehicleController::VehicleController(Vec3 pos, VehicleEngine* vehEngine, VehicleParams *vehParams, VehicleParamsEx *vehParamsEx, bool steerableWheelsFront)
{
	m_forward = Vec3(0, 0, 0);

	m_scene = core.dynamics->getScene();
	m_vehiclePose = new VehiclePose;
	m_vehicleParams = vehParams;
	m_vehicleParamsEx = vehParamsEx;
	m_vehicleEngine = vehEngine;
	m_actor = NULL;

	m_wheelFrontLeft = NULL;
	m_wheelFrontRight = NULL;
	m_wheelRearLeft = NULL;
	m_wheelRearRight = NULL;

	m_poseGiven = false;

	m_setCurrentSteerAngle = false;
	m_setCurrentMotorTorque = false;
	m_setCurrentBrakeTorque = false;

	m_currentSteerAngle = 0.0f;
	m_currentMotorTorque = 0.0f;
	m_currentBrakeTorque = 0.0f;

	m_steerableWheelsFront = steerableWheelsFront;

	switch(m_vehicleParams->wheelDriveType)
	{
		case 0:
			m_wheelDriveType = WDT_2WD;
			break;
		case 1:
			m_wheelDriveType = WDT_4WD;
			break;
		case 2:
			m_wheelDriveType = WDT_FWD;
			break;
		default:
			m_wheelDriveType = WDT_2WD;
	}

	D3DXMatrixIdentity(&m_vehiclePose->matChassis);
	D3DXMatrixIdentity(&m_vehiclePose->matFrontLeftWheel);
	D3DXMatrixIdentity(&m_vehiclePose->matFrontRightWheel);
	D3DXMatrixIdentity(&m_vehiclePose->matRearLeftWheel);
	D3DXMatrixIdentity(&m_vehiclePose->matRearRightWheel);

	m_actor = core.dynamics->createBox(NxVec3(pos), NxVec3(m_vehicleParams->chassisDimm), m_vehicleParams->chassisDensity);
	SetActorCollisionGroup(m_actor, GROUP_COLLIDABLE_NON_PUSHABLE);

	//Wheel material globals
	NxMaterial* wsm = NULL;

	NxTireFunctionDesc lngTFD;
	lngTFD.extremumSlip = 1.0f;
	lngTFD.extremumValue = 0.02f;
	lngTFD.asymptoteSlip = 2.0f;
	lngTFD.asymptoteValue = 0.01f;	
	lngTFD.stiffnessFactor = 100.0f;

	NxTireFunctionDesc latTFD;
	latTFD.extremumSlip = 1.0f;
	latTFD.extremumValue = 0.02f;
	latTFD.asymptoteSlip = 2.0f;
	latTFD.asymptoteValue = 0.01f;	
	latTFD.stiffnessFactor = 100.0f;

	NxTireFunctionDesc slipTFD;
	slipTFD.extremumSlip = 1.0f;
	slipTFD.extremumValue = 0.02f;
	slipTFD.asymptoteSlip = 2.0f;
	slipTFD.asymptoteValue = 0.01f;	
	slipTFD.stiffnessFactor = 100.0f;  

	NxTireFunctionDesc medTFD;
	medTFD.extremumSlip = 1.0f;
	medTFD.extremumValue = 0.02f;
	medTFD.asymptoteSlip = 2.0f;
	medTFD.asymptoteValue = 0.01f;	
	medTFD.stiffnessFactor = 100.0f;

	// Front left wheel
	NxWheelDesc wheelDesc;
	wheelDesc.frictionToFront = 3.0f;
	wheelDesc.frictionToSide = 3.0f;


	/*wheelDesc4.wheelSuspension = wheelDesc3.wheelSuspension = wheelDesc2.wheelSuspension = wheelDesc.wheelSuspension = 0.0001;
	wheelDesc4.springRestitution = wheelDesc3.springRestitution = wheelDesc2.springRestitution = wheelDesc.springRestitution = 0.0001;
	wheelDesc4.springDamping = wheelDesc3.springDamping = wheelDesc2.springDamping = wheelDesc.springDamping = 0.001;
	wheelDesc4.springBias = wheelDesc3.springBias = wheelDesc2.springBias = wheelDesc.springBias = 0.001;
	wheelDesc4.maxBrakeForce = wheelDesc3.maxBrakeForce = wheelDesc2.maxBrakeForce = wheelDesc.maxBrakeForce = 0.01;*/

	if(!m_vehicleParamsEx)
	{
		wheelDesc.wheelSuspension = 0.05f;
		wheelDesc.springRestitution = 1000.0f;
		wheelDesc.springDamping = 0.5f / 10000000000000;
		wheelDesc.springBias = 1.0f / 10000000000000;
		wheelDesc.maxBrakeForce = 0.01f; // 100;
		/*
		wheelDesc4.wheelSuspension = wheelDesc3.wheelSuspension = wheelDesc2.wheelSuspension = wheelDesc.wheelSuspension = 0.5f;
		wheelDesc4.springRestitution = wheelDesc3.springRestitution = wheelDesc2.springRestitution = wheelDesc.springRestitution = 1000.0f;
		wheelDesc4.springDamping = wheelDesc3.springDamping = wheelDesc2.springDamping = wheelDesc.springDamping = 0.5f / 1;
		wheelDesc4.springBias = wheelDesc3.springBias = wheelDesc2.springBias = wheelDesc.springBias = 1.0f / 100000;
		wheelDesc4.maxBrakeForce = wheelDesc3.maxBrakeForce = wheelDesc2.maxBrakeForce = wheelDesc.maxBrakeForce = 0.01f; // 100;*/
	}
	else
	{
		wheelDesc.frictionToFront = m_vehicleParamsEx->frictionToFront;
		wheelDesc.frictionToSide = m_vehicleParamsEx->frictionToSide;

		wheelDesc.wheelSuspension = m_vehicleParamsEx->wheelSuspension;
		wheelDesc.springRestitution = m_vehicleParamsEx->springRestitution;
		wheelDesc.springDamping = m_vehicleParamsEx->springDamping;
		wheelDesc.springBias = m_vehicleParamsEx->springBias;
		wheelDesc.maxBrakeForce = m_vehicleParamsEx->maxBrakeForce; // 100;
	}


	wheelDesc.wheelApproximation = 0;
	wheelDesc.wheelRadius = m_vehicleParams->frontWheelsRadius;
	wheelDesc.wheelWidth = m_vehicleParams->frontWheelsWidth;  // 0.1
	wheelDesc.position = NxVec3(m_vehicleParams->posFrontLeftWheel);
	wheelDesc.wheelFlags = NX_WF_BUILD_LOWER_HALF | NX_WF_ACCELERATED | 
						   NX_WF_STEERABLE_INPUT | NX_WF_CLAMPED_FRICTION;

	// Front right wheel
	NxWheelDesc wheelDesc2 = wheelDesc;
	wheelDesc2.wheelRadius = m_vehicleParams->frontWheelsRadius;
	wheelDesc2.wheelWidth = m_vehicleParams->frontWheelsWidth;  // 0.1
	wheelDesc2.position = NxVec3(m_vehicleParams->posFrontRightWheel);
	
	// Rear left wheel
	NxWheelDesc wheelDesc3 = wheelDesc;
	wheelDesc3.wheelRadius = m_vehicleParams->rearWheelsRadius;
	wheelDesc3.wheelWidth = m_vehicleParams->rearWheelsWidth;  // 0.1
	wheelDesc3.position = NxVec3(m_vehicleParams->posRearLeftWheel);
	
	// Rear right wheel
	NxWheelDesc wheelDesc4 = wheelDesc;
	wheelDesc4.wheelRadius = m_vehicleParams->rearWheelsRadius;
	wheelDesc4.wheelWidth = m_vehicleParams->rearWheelsWidth;  // 0.1
	wheelDesc4.position = NxVec3(m_vehicleParams->posRearRightWheel);


	m_wheelFrontLeft = AddWheelToActor(m_actor, &wheelDesc);
	m_wheelFrontRight = AddWheelToActor(m_actor, &wheelDesc2);
	m_wheelRearLeft = AddWheelToActor(m_actor, &wheelDesc3);
	m_wheelRearRight = AddWheelToActor(m_actor, &wheelDesc4);

	m_wheelFrontLeft->userData = (void*)new ShapeUserData;
	m_wheelFrontRight->userData = (void*)new ShapeUserData;
	m_wheelRearLeft->userData = (void*)new ShapeUserData;
	m_wheelRearRight->userData = (void*)new ShapeUserData;

	((ShapeUserData*)m_wheelFrontLeft->userData)->vehicleActor = m_actor;
	((ShapeUserData*)m_wheelFrontRight->userData)->vehicleActor = m_actor;
	((ShapeUserData*)m_wheelRearLeft->userData)->vehicleActor = m_actor;
	((ShapeUserData*)m_wheelRearRight->userData)->vehicleActor = m_actor;

	m_wheelFrontLeft->setWheelFlags(m_wheelFrontLeft->getWheelFlags() | NX_WF_INPUT_LAT_SLIPVELOCITY  );
	m_wheelFrontRight->setWheelFlags(m_wheelFrontRight->getWheelFlags() | NX_WF_INPUT_LAT_SLIPVELOCITY  );
	m_wheelRearLeft->setWheelFlags(m_wheelRearLeft->getWheelFlags() | NX_WF_INPUT_LAT_SLIPVELOCITY  );
	m_wheelRearRight->setWheelFlags(m_wheelRearRight->getWheelFlags() | NX_WF_INPUT_LAT_SLIPVELOCITY  );

	// LOWER THE CENTER OF MASS
	NxVec3 massPos = m_actor->getCMassLocalPosition();
	massPos.y = m_vehicleParams->posFrontLeftWheel.y - m_vehicleParams->frontWheelsRadius;
	m_actor->setCMassOffsetLocalPosition(massPos);
	m_actor->wakeUp(1e30);
	//stopMotorAndBreak();
}
Esempio n. 4
0
void PhysCreateStaticRigidBodyMesh ( int iObject )
{
	sObject* pObject = dbGetObject ( iObject );

	if ( !pObject )
		return;

	int iCount = 0;
	
	for ( int iMesh = 0; iMesh < pObject->iMeshCount; iMesh++ )
	{
		NxVec3* pVertices		= new NxVec3 [ pObject->ppMeshList [ iMesh ]->dwVertexCount ];
		int		iVertexCount	= pObject->ppMeshList [ iMesh ]->dwVertexCount;
		int*	iTriangles		= new int [ pObject->ppMeshList [ iMesh ]->dwIndexCount ];
		int		iTriangleCount	= pObject->ppMeshList [ iMesh ]->dwIndexCount;

		sOffsetMap offsetMap;
		GetFVFOffsetMap ( pObject->ppMeshList [ iMesh ], &offsetMap );

		for ( int i = 0; i < iVertexCount; i++ )
		{
			pVertices [ i ].x = *( ( float* ) pObject->ppMeshList [ iMesh ]->pVertexData + offsetMap.dwX + ( offsetMap.dwSize * i ) );
			pVertices [ i ].y = *( ( float* ) pObject->ppMeshList [ iMesh ]->pVertexData + offsetMap.dwY + ( offsetMap.dwSize * i ) );
			pVertices [ i ].z = *( ( float* ) pObject->ppMeshList [ iMesh ]->pVertexData + offsetMap.dwZ + ( offsetMap.dwSize * i ) );
		}

		for ( i = 0; i < iTriangleCount; i++ )
			iTriangles [ i ] = pObject->ppMeshList [ iMesh ]->pIndices [ i ];
		
		NxTriangleMeshDesc levelDesc;
		levelDesc.numVertices			= iVertexCount;
		levelDesc.numTriangles			= iTriangleCount / 3;
		levelDesc.pointStrideBytes		= sizeof ( NxVec3 );
		levelDesc.triangleStrideBytes   = 3 * sizeof ( int );
		levelDesc.points				= pVertices;
		levelDesc.triangles				= iTriangles;
		levelDesc.flags					= NX_CF_COMPUTE_CONVEX;

		NxTriangleMeshShapeDesc levelShapeDesc;
		NxInitCooking ( );
		
		MemoryWriteBuffer buf;
		bool status = NxCookTriangleMesh ( levelDesc, buf );
		
		if ( status )
		{
			levelShapeDesc.meshData = gPhysicsSDK->createTriangleMesh ( MemoryReadBuffer ( buf.data ) );
		
			NxActor* actor = NULL;

			NxActorDesc actorDesc;
			actorDesc.shapes.pushBack ( &levelShapeDesc );

			actor = gScene->createActor ( actorDesc );
			
			sPhysObject* pPhys = new sPhysObject;
			pPhys->iID      = iObject;
			actor->userData = ( void* )pPhys;

			SetActorCollisionGroup ( actor, GROUP_COLLIDABLE_NON_PUSHABLE );
		}
	}
}
Esempio n. 5
0
TriPod::TriPod(IVehicle *vehicle, string fname, bool FrontTriPod)
{
	m_tractor = true;
	m_vehicle = vehicle;
	m_triPodDimms = new TriPodDimms;
	m_isLifted = false;
	m_attachedDevice = NULL;
	m_attachedTrailer = NULL;
	m_jointTopPodDevice = NULL;
	m_jointBottomLeftPodDevice = NULL;
	m_jointBottomRightPodDevice = NULL;
	m_jointTrailer = NULL;

	string topPodModel;
	string bottomPodModel;

	m_triPodDimms->getVariableList()->push_back(new CfgVariable(V_STRING, &topPodModel, getVarName(topPodModel)));
	m_triPodDimms->getVariableList()->push_back(new CfgVariable(V_STRING, &bottomPodModel, getVarName(bottomPodModel)));

	CfgLoader(fname, m_triPodDimms->getVariableList());

	m_objTop = new Surface(topPodModel, new Material(MT_DEFAULT, "wood.jpg"), Vec3(0, 0, 0));
	m_objBottom = new Surface(bottomPodModel, new Material(MT_DEFAULT, "wood.jpg"), Vec3(0, 0, 0));

	NxVec3 actorTopPos = NxVec3(m_vehicle->getVehicleController()->getVehicleParams()->posTriPodBack) + NxVec3(m_triPodDimms->posTopPodTractorConnector);
	NxVec3 actorBottomPos = NxVec3(m_vehicle->getVehicleController()->getVehicleParams()->posTriPodBack) + NxVec3(m_triPodDimms->posBottomPodTractorConnector);

	NxVec3 actorTopDimm = NxVec3(m_objTop->boundingBox.getWidth()/2, m_objTop->boundingBox.getHeight()/2, m_objTop->boundingBox.getDepth()/2);
	NxVec3 actorBottomDimm = NxVec3(m_objBottom->boundingBox.getWidth()/2, m_objBottom->boundingBox.getHeight()/2, m_objBottom->boundingBox.getDepth()/2);


	/*m_actorTop = core.dynamics->createBox(actorTopPos, actorTopDimm, 1);
	m_actorBottom = core.dynamics->createBox(actorBottomPos, actorBottomDimm, 1);*/
	m_actorTop = core.dynamics->createBox(actorTopPos, NxVec3(D3DXVec3Length(&Vec3(m_triPodDimms->posTopPodTractorConnector - m_triPodDimms->posTopPodDeviceConnector))/2, 0.1f, 0.1f), 500);
	m_actorBottom = core.dynamics->createBox(actorBottomPos, NxVec3(D3DXVec3Length(&Vec3(m_triPodDimms->posBottomPodTractorConnector - m_triPodDimms->posBottomPodDeviceConnector))/2, 0.1f, m_triPodDimms->width / 2), 500);
	/*m_triPodDimms->posTopPodDeviceConnector.x -= 0.2f;
	m_triPodDimms->posBottomPodDeviceConnector.x -= 0.2f;*/

	/*SetActorCollisionGroup(m_actorTop, GROUP_COLLIDABLE_NON_PUSHABLE);
	SetActorCollisionGroup(m_actorBottom, GROUP_COLLIDABLE_NON_PUSHABLE);*/
	SetActorCollisionGroup(m_actorTop, GROUP_COLLIDABLE_NON_PUSHABLE);
	SetActorCollisionGroup(m_actorBottom, GROUP_COLLIDABLE_NON_PUSHABLE);

	core.game->getWorld()->addToWorld(m_objTop, NO_COLLISION, 0, GROUP_NON_COLLIDABLE, NULL, 1);
	core.game->getWorld()->addToWorld(m_objBottom, NO_COLLISION, 0, GROUP_NON_COLLIDABLE, NULL, 1);

	m_frontPod = FrontTriPod;

	if(!m_frontPod)
	{
		float highLimit = D3DX_PI * 0.12f;
		float lowLimit = D3DX_PI * -0.1f;
		m_jointMotorTop = new NxMotorDesc(0, NX_MAX_REAL, 0);
		m_jointMotorBottom = new NxMotorDesc(0, NX_MAX_REAL, 0);

		Vec3 newPosTop = m_vehicle->getVehicleController()->getBackJointPoint() + (m_triPodDimms->posTopPod) - m_triPodDimms->posTopPodTractorConnector;
		Vec3 newPosBottom = m_vehicle->getVehicleController()->getBackJointPoint() + (m_triPodDimms->posBottomPod) - m_triPodDimms->posBottomPodTractorConnector;

		Vec3 moveTop = m_vehicle->getVehicleController()->getBackJointPoint() + (m_triPodDimms->posTopPod);// - m_triPodDimms->posTopPodTractorConnector;
		Vec3 moveBottom = m_vehicle->getVehicleController()->getBackJointPoint() + (m_triPodDimms->posBottomPod);// - m_triPodDimms->posBottomPodTractorConnector;
		/*Vec3 moveTop = Vec3(actorTopPos.x, actorTopPos.y, actorTopPos.z) - m_vehicle->getVehicleController()->getBackJointPoint();
		Vec3 moveBottom = Vec3(actorBottomPos.x, actorBottomPos.y, actorBottomPos.z) - m_vehicle->getVehicleController()->getBackJointPoint();*/
		/*m_actorTop->setGlobalPosition(m_actorTop->getGlobalPosition() + NxVec3(moveTop));
		m_actorBottom->setGlobalPosition(m_actorBottom->getGlobalPosition() + NxVec3(moveBottom));*/
		m_actorTop->setGlobalPosition(NxVec3(newPosTop));
		m_actorBottom->setGlobalPosition(NxVec3(newPosBottom));


		NxRevoluteJointDesc revDescTop;
		revDescTop.actor[0] = m_vehicle->getVehicleController()->getActor();
		revDescTop.actor[1] = m_actorTop;
		revDescTop.localNormal[0] = NxVec3(0, 1, 0);
		revDescTop.localNormal[1] = NxVec3(0, 1, 0);
		revDescTop.limit.high.value = highLimit;
		revDescTop.limit.low.value = lowLimit;
		revDescTop.setGlobalAxis(NxVec3(0, 0, 1)); //The direction of the axis the bodies revolve around.
		revDescTop.setGlobalAnchor(NxVec3(moveTop)); //Reference point that the axis passes through.
		revDescTop.projectionMode = NX_JPM_POINT_MINDIST;
		revDescTop.projectionDistance = 0.1f;

		revDescTop.motor = *m_jointMotorTop;
		revDescTop.flags |= NX_RJF_MOTOR_ENABLED | NX_RJF_LIMIT_ENABLED;

		m_jointTop = (NxRevoluteJoint*)core.dynamics->getScene()->createJoint(revDescTop);

		/*NxRevoluteJointDesc revDescBottom;
		revDescBottom.actor[0] = m_vehicle->getVehicleController()->getActor();
		revDescBottom.actor[1] = m_actorBottom;
		revDescBottom.localNormal[0] = NxVec3(0, 1, 0);
		revDescBottom.localNormal[1] = NxVec3(0, 1, 0);
		revDescBottom.limit.high.value = highLimit;
		revDescBottom.limit.low.value = lowLimit;
		revDescBottom.setGlobalAxis(NxVec3(0, 0, 1)); //The direction of the axis the bodies revolve around.
		revDescBottom.setGlobalAnchor(NxVec3(moveBottom)); //Reference point that the axis passes through.

		revDescBottom.motor = *m_jointMotorBottom;
		revDescBottom.flags |= NX_RJF_MOTOR_ENABLED | NX_RJF_LIMIT_ENABLED;

		//m_jointBottom = (NxRevoluteJoint*)core.dynamics->getScene()->createJoint(revDescBottom);*/

		Vec3 leftPos = Vec3(0, 0, m_triPodDimms->width/2);
		Mat temp;
		m_actorTop->getGlobalPose().getColumnMajor44((NxF32*)&temp);
		temp._41 = 0;
		temp._42 = 0;
		temp._43 = 0;
		D3DXVec3TransformCoord(&leftPos, &leftPos, &temp);





		NxRevoluteJointDesc revDescBottom;
		revDescBottom.actor[0] = m_vehicle->getVehicleController()->getActor();
		revDescBottom.actor[1] = m_actorBottom;
		revDescBottom.localNormal[0] = NxVec3(0, 1, 0);
		revDescBottom.localNormal[1] = NxVec3(0, 1, 0);
		revDescBottom.limit.high.value = highLimit;
		revDescBottom.limit.low.value = lowLimit;
		revDescBottom.setGlobalAxis(NxVec3(0, 0, 1)); //The direction of the axis the bodies revolve around.
		revDescBottom.setGlobalAnchor(NxVec3(moveBottom + leftPos)); //Reference point that the axis passes through.
		revDescBottom.projectionMode = NX_JPM_POINT_MINDIST;
		revDescBottom.projectionDistance = 0.1f;

		revDescBottom.motor = *m_jointMotorBottom;
		revDescBottom.flags |= NX_RJF_MOTOR_ENABLED | NX_RJF_LIMIT_ENABLED;

		m_jointBottomLeft = (NxRevoluteJoint*)core.dynamics->getScene()->createJoint(revDescBottom);







		NxRevoluteJointDesc revDescBottom1;
		revDescBottom1.actor[0] = m_vehicle->getVehicleController()->getActor();
		revDescBottom1.actor[1] = m_actorBottom;
		revDescBottom1.localNormal[0] = NxVec3(0, 1, 0);
		revDescBottom1.localNormal[1] = NxVec3(0, 1, 0);
		revDescBottom1.setGlobalAxis(NxVec3(0, 0, 1)); //The direction of the axis the bodies revolve around.
		revDescBottom1.setGlobalAnchor(NxVec3(moveBottom - leftPos));
		revDescBottom1.limit.high.value = highLimit;
		revDescBottom1.limit.low.value = lowLimit;
		revDescBottom1.projectionMode = NX_JPM_POINT_MINDIST;
		revDescBottom1.projectionDistance = 0.1f;

		revDescBottom1.motor = *m_jointMotorBottom;
		revDescBottom1.flags |= NX_RJF_MOTOR_ENABLED | NX_RJF_LIMIT_ENABLED;


		m_jointBottomRight = (NxRevoluteJoint*)core.dynamics->getScene()->createJoint(revDescBottom1);
	}
	else
	{
		Vec3 switchVec;
		switchVec = m_triPodDimms->posBottomPodDeviceConnector;
		m_triPodDimms->posBottomPodDeviceConnector = m_triPodDimms->posBottomPodTractorConnector;
		m_triPodDimms->posBottomPodTractorConnector = switchVec;

		switchVec = m_triPodDimms->posTopPodDeviceConnector;
		m_triPodDimms->posTopPodDeviceConnector = m_triPodDimms->posTopPodTractorConnector;
		m_triPodDimms->posTopPodTractorConnector = switchVec;

		float highLimit = D3DX_PI * 0.12f;
		float lowLimit = D3DX_PI * -0.1f;
		m_jointMotorTop = new NxMotorDesc(0, NX_MAX_REAL, 0);
		m_jointMotorBottom = new NxMotorDesc(0, NX_MAX_REAL, 0);

		Vec3 newPosTop = m_vehicle->getVehicleController()->getFrontJointPoint() + (m_triPodDimms->posTopPod) - m_triPodDimms->posTopPodTractorConnector;
		Vec3 newPosBottom = m_vehicle->getVehicleController()->getFrontJointPoint() + (m_triPodDimms->posBottomPod) - m_triPodDimms->posBottomPodTractorConnector;

		Vec3 moveTop = m_vehicle->getVehicleController()->getFrontJointPoint() + (m_triPodDimms->posTopPod);// - m_triPodDimms->posTopPodTractorConnector;
		Vec3 moveBottom = m_vehicle->getVehicleController()->getFrontJointPoint() + (m_triPodDimms->posBottomPod);// - m_triPodDimms->posBottomPodTractorConnector;
		/*Vec3 moveTop = Vec3(actorTopPos.x, actorTopPos.y, actorTopPos.z) - m_vehicle->getVehicleController()->getBackJointPoint();
		Vec3 moveBottom = Vec3(actorBottomPos.x, actorBottomPos.y, actorBottomPos.z) - m_vehicle->getVehicleController()->getBackJointPoint();*/
		/*m_actorTop->setGlobalPosition(m_actorTop->getGlobalPosition() + NxVec3(moveTop));
		m_actorBottom->setGlobalPosition(m_actorBottom->getGlobalPosition() + NxVec3(moveBottom));*/
		m_actorTop->setGlobalPosition(NxVec3(newPosTop));
		m_actorBottom->setGlobalPosition(NxVec3(newPosBottom));


		NxRevoluteJointDesc revDescTop;
		revDescTop.actor[0] = m_vehicle->getVehicleController()->getActor();
		revDescTop.actor[1] = m_actorTop;
		revDescTop.localNormal[0] = NxVec3(0, 1, 0);
		revDescTop.localNormal[1] = NxVec3(0, 1, 0);
		revDescTop.limit.high.value = highLimit;
		revDescTop.limit.low.value = lowLimit;
		revDescTop.setGlobalAxis(NxVec3(0, 0, -1)); //The direction of the axis the bodies revolve around.
		revDescTop.setGlobalAnchor(NxVec3(moveTop)); //Reference point that the axis passes through.
		revDescTop.projectionMode = NX_JPM_POINT_MINDIST;
		revDescTop.projectionDistance = 0.1f;

		revDescTop.motor = *m_jointMotorTop;
		revDescTop.flags |= NX_RJF_MOTOR_ENABLED | NX_RJF_LIMIT_ENABLED;

		m_jointTop = (NxRevoluteJoint*)core.dynamics->getScene()->createJoint(revDescTop);



		Vec3 leftPos = Vec3(0, 0, m_triPodDimms->width/2);
		Mat temp;
		m_actorTop->getGlobalPose().getColumnMajor44((NxF32*)&temp);
		temp._41 = 0;
		temp._42 = 0;
		temp._43 = 0;
		D3DXVec3TransformCoord(&leftPos, &leftPos, &temp);





		NxRevoluteJointDesc revDescBottom;
		revDescBottom.actor[0] = m_vehicle->getVehicleController()->getActor();
		revDescBottom.actor[1] = m_actorBottom;
		revDescBottom.localNormal[0] = NxVec3(0, 1, 0);
		revDescBottom.localNormal[1] = NxVec3(0, 1, 0);
		revDescBottom.limit.high.value = highLimit;
		revDescBottom.limit.low.value = lowLimit;
		revDescBottom.setGlobalAxis(NxVec3(0, 0, -1)); //The direction of the axis the bodies revolve around.
		revDescBottom.setGlobalAnchor(NxVec3(moveBottom + leftPos)); //Reference point that the axis passes through.
		revDescBottom.projectionMode = NX_JPM_POINT_MINDIST;
		revDescBottom.projectionDistance = 0.1f;

		revDescBottom.motor = *m_jointMotorBottom;
		revDescBottom.flags |= NX_RJF_MOTOR_ENABLED | NX_RJF_LIMIT_ENABLED;

		m_jointBottomLeft = (NxRevoluteJoint*)core.dynamics->getScene()->createJoint(revDescBottom);







		NxRevoluteJointDesc revDescBottom1;
		revDescBottom1.actor[0] = m_vehicle->getVehicleController()->getActor();
		revDescBottom1.actor[1] = m_actorBottom;
		revDescBottom1.localNormal[0] = NxVec3(0, 1, 0);
		revDescBottom1.localNormal[1] = NxVec3(0, 1, 0);
		revDescBottom1.setGlobalAxis(NxVec3(0, 0, -1)); //The direction of the axis the bodies revolve around.
		revDescBottom1.setGlobalAnchor(NxVec3(moveBottom - leftPos));
		revDescBottom1.limit.high.value = highLimit;
		revDescBottom1.limit.low.value = lowLimit;
		revDescBottom1.projectionMode = NX_JPM_POINT_MINDIST;
		revDescBottom1.projectionDistance = 0.1f;

		revDescBottom1.motor = *m_jointMotorBottom;
		revDescBottom1.flags |= NX_RJF_MOTOR_ENABLED | NX_RJF_LIMIT_ENABLED;


		m_jointBottomRight = (NxRevoluteJoint*)core.dynamics->getScene()->createJoint(revDescBottom1);
	}
	lift();
	update();
}
Esempio n. 6
0
void InitNx()
{
	// Create a memory allocator
    gAllocator = new UserAllocator;

    // Create the physics SDK
    gPhysicsSDK = NxCreatePhysicsSDK(NX_PHYSICS_SDK_VERSION, gAllocator);
    if (!gPhysicsSDK)  return;

	// Set the physics parameters
	gPhysicsSDK->setParameter(NX_SKIN_WIDTH, 0.01);

	// Set the debug visualization parameters
	gPhysicsSDK->setParameter(NX_VISUALIZATION_SCALE, 1);
	gPhysicsSDK->setParameter(NX_VISUALIZE_COLLISION_SHAPES, 1);
	gPhysicsSDK->setParameter(NX_VISUALIZE_ACTOR_AXES, 1);
	gPhysicsSDK->setParameter(NX_VISUALIZE_JOINT_LIMITS, 1);

    // Create the scene
    NxSceneDesc sceneDesc;
    sceneDesc.gravity               = gDefaultGravity;
    sceneDesc.simType				= NX_SIMULATION_HW;
    gScene = gPhysicsSDK->createScene(sceneDesc);	
	if(!gScene)
	{ 
		sceneDesc.simType = NX_SIMULATION_SW; 
		gScene = gPhysicsSDK->createScene(sceneDesc);  
		if(!gScene) return;
	}

//	gScene->setTiming(0.01);  // timeStep, maxIter, TIMESTEP_FIXED

	// Create the default material
	NxMaterial* defaultMaterial = gScene->getMaterialFromIndex(0); 
	defaultMaterial->setRestitution(0.5);
	defaultMaterial->setStaticFriction(0.5);
	defaultMaterial->setDynamicFriction(0.5);

	// Create the objects in the scene
	CreateGroundPlane();

	NxU32 r;
	NxI32 x, z;
	NxReal fRX, fRZ;

	// create grass block
	for (x = -patchsize; x < patchsize; x++)
	{
		for (z = -patchsize; z < patchsize; z++)
		{
			fRX = NxMath::rand(-45,45)*0.01;
			fRZ = NxMath::rand(-45,45)*0.01;

			r = NxMath::rand(0,4);

			if (r == 0) 
			{
				grassBlade[x+patchsize][z+patchsize] = new Blade(NxVec3(scale*(x+fRX),0,scale*(z+fRZ)),3,4);
			} 
			else if (r == 1) 
			{ 
				grassBlade[x+patchsize][z+patchsize] = new Blade(NxVec3(scale*(x+fRX),0,scale*(z+fRZ)),1.8,2);
			} 
			else if (r == 1) 
			{ 
				grassBlade[x+patchsize][z+patchsize] = new Blade(NxVec3(scale*(x+fRX),0,scale*(z+fRZ)),2,3);
			} 
			else if (r == 1) 
			{ 
				grassBlade[x+patchsize][z+patchsize] = new Blade(NxVec3(scale*(x+fRX),0,scale*(z+fRZ)),1.5,2);
			} 
			else 
			{ 
				grassBlade[x+patchsize][z+patchsize] = new Blade(NxVec3(scale*(x+fRX),0,scale*(z+fRZ)),2.1,3);
			}
		}
	}

	gScene->setGroupCollisionFlag(1,1,false);

	ball = CreateBall(NxVec3(0,10,0),1.5,350);

	SetActorCollisionGroup(ball, 3);
	
	gSelectedActor = ball;
	gCameraSpeed = 20;
	gForceStrength = 850000;

	// Initialize HUD
	InitializeHUD();

	// Get the current time
	getElapsedTime();

	// Start the first frame of the simulation
	if (gScene)  StartPhysics();
}
Esempio n. 7
0
Tractor::Tractor(Dynamics *dyn, NxVec3 pos, string fname)
{
	m_vehicleDimms = new VehicleDimms;
	//VehicleDimms *vd = new VehicleDimms;
	VehicleParamsEx *vp = new VehicleParamsEx;
	vector<CfgVariable*> vars;
	vars = *m_vehicleDimms->getVariableList();
	for(int i = 0; i < vp->getVariableList()->size(); i++)
	{
		vars.push_back((*vp->getVariableList())[i]);
	}
	Vec3 rotateFrontLeftWheel;
	Vec3 rotateFrontRightWheel;
	Vec3 rotateRearLeftWheel;
	Vec3 rotateRearRightWheel;

	Vec3 rotateChassis;
	string paramsType;
	string wheelFrontLeftModel;
	string wheelFrontRightModel;
	string wheelRearLeftModel;
	string wheelRearRightModel;
	string chassisModel;

	vars.push_back(new CfgVariable(V_VEC3, &rotateFrontLeftWheel, getVarName(rotateFrontLeftWheel)));
	vars.push_back(new CfgVariable(V_VEC3, &rotateFrontRightWheel, getVarName(rotateFrontRightWheel)));
	vars.push_back(new CfgVariable(V_VEC3, &rotateRearLeftWheel, getVarName(rotateRearLeftWheel)));
	vars.push_back(new CfgVariable(V_VEC3, &rotateRearRightWheel, getVarName(rotateRearRightWheel)));
	vars.push_back(new CfgVariable(V_VEC3, &rotateChassis, getVarName(rotateChassis)));

	vars.push_back(new CfgVariable(V_STRING, &paramsType, getVarName(paramsType)));

	vars.push_back(new CfgVariable(V_STRING, &wheelFrontLeftModel, getVarName(wheelFrontLeftModel)));
	vars.push_back(new CfgVariable(V_STRING, &wheelFrontRightModel, getVarName(wheelFrontRightModel)));
	vars.push_back(new CfgVariable(V_STRING, &wheelRearLeftModel, getVarName(wheelRearLeftModel)));
	vars.push_back(new CfgVariable(V_STRING, &wheelRearRightModel, getVarName(wheelRearRightModel)));
	vars.push_back(new CfgVariable(V_STRING, &chassisModel, getVarName(chassisModel)));

	CfgLoader cfg(fname, &vars);

	D3DXMatrixRotationYawPitchRoll(&m_vehicleDimms->matFrontLeftWheelRotation, rotateFrontLeftWheel.y, rotateFrontLeftWheel.x, rotateFrontLeftWheel.z);
	D3DXMatrixRotationYawPitchRoll(&m_vehicleDimms->matFrontRightWheelRotation, rotateFrontRightWheel.y, rotateFrontRightWheel.x, rotateFrontRightWheel.z);
	D3DXMatrixRotationYawPitchRoll(&m_vehicleDimms->matRearLeftWheelRotation, rotateRearLeftWheel.y, rotateRearLeftWheel.x, rotateRearLeftWheel.z);
	D3DXMatrixRotationYawPitchRoll(&m_vehicleDimms->matRearRightWheelRotation, rotateRearRightWheel.y, rotateRearRightWheel.x, rotateRearRightWheel.z);


	D3DXMatrixRotationYawPitchRoll(&m_vehicleDimms->matChassisRotation, rotateChassis.y, rotateChassis.x, rotateChassis.z);

	m_objChassis = new RendObj(chassisModel, new Material("wood.jpg", "", ""), Vec3(0, 0, 0));
	m_objFrontLeftWheel = new RendObj(wheelFrontLeftModel, new Material("wood.jpg", "", ""), Vec3(0, 0, 0));
	m_objFrontRightWheel = new RendObj(wheelFrontRightModel, new Material("wood.jpg", "", ""), Vec3(0, 0, 0));
	m_objRearLeftWheel = new RendObj(wheelRearLeftModel, new Material("wood.jpg", "", ""), Vec3(0, 0, 0));
	m_objRearRightWheel = new RendObj(wheelRearRightModel, new Material("wood.jpg", "", ""), Vec3(0, 0, 0));

	core.game->getWorld()->addToWorld(m_objChassis, NO_COLLISION, 0, GROUP_NON_COLLIDABLE);
	core.game->getWorld()->addToWorld(m_objFrontLeftWheel, NO_COLLISION, 0, GROUP_NON_COLLIDABLE);
	core.game->getWorld()->addToWorld(m_objFrontRightWheel, NO_COLLISION, 0, GROUP_NON_COLLIDABLE);
	core.game->getWorld()->addToWorld(m_objRearLeftWheel, NO_COLLISION, 0, GROUP_NON_COLLIDABLE);
	core.game->getWorld()->addToWorld(m_objRearRightWheel, NO_COLLISION, 0, GROUP_NON_COLLIDABLE);

	m_vehicleDimms->chassisDimm = Vec3(m_objChassis->getPose()->boundingBox.getWidth()/2, m_objChassis->getPose()->boundingBox.getHeight()/6, m_objChassis->getPose()->boundingBox.getDepth()/2);

	stopMotorAndBreak();

	m_jointPoint = m_vehicleDimms->jointPoint;
	m_joinedTrailer = NULL;
	m_joint = NULL;

	m_oldPos = Vec3(0, 0, 0);
	m_forward = Vec3(1, 0, 0);
	m_poseGiven = false;
	m_scene = dyn->getScene();
	m_setCurrentSteerAngle = false;
	m_setCurrentMotorTorque = false;
	m_setCurrentBrakeTorque = false;
	m_currentSteerAngle = 0;
	m_currentMotorTorque = 0;
	m_currentBrakeTorque = 0;
	m_vehiclePose = new VehiclePose;

	m_joint = NULL;
	m_joinedTrailer = NULL;

	D3DXMatrixIdentity(&m_vehiclePose->matChassis);
	D3DXMatrixIdentity(&m_vehiclePose->matFrontLeftWheel);
	D3DXMatrixIdentity(&m_vehiclePose->matFrontRightWheel);
	D3DXMatrixIdentity(&m_vehiclePose->matRearLeftWheel);
	D3DXMatrixIdentity(&m_vehiclePose->matRearRightWheel);

	//m_actor = dyn->createBox(pos + NxVec3(0,0.5,0), NxVec3(2,0.25,1), 10);
	m_actor = dyn->createBox(pos + NxVec3(0,0.5,0), NxVec3(m_vehicleDimms->chassisDimm), m_vehicleDimms->chassisDensity);
	SetActorCollisionGroup(m_actor, GROUP_COLLIDABLE_NON_PUSHABLE);
	//m_actor = dyn->createBox(pos + NxVec3(0,0.5,0), NxVec3(2,0.25,1), dimm->chassisDensity);

// Wheel material globals
	NxMaterial* wsm = NULL;

	NxTireFunctionDesc lngTFD;
	lngTFD.extremumSlip = 1.0f;
	lngTFD.extremumValue = 0.02f;
	lngTFD.asymptoteSlip = 2.0f;
	lngTFD.asymptoteValue = 0.01f;	
	lngTFD.stiffnessFactor = 1000000.0f;

	NxTireFunctionDesc latTFD;
	latTFD.extremumSlip = 1.0f;
	latTFD.extremumValue = 0.02f;
	latTFD.asymptoteSlip = 2.0f;
	latTFD.asymptoteValue = 0.01f;	
	latTFD.stiffnessFactor = 1000000.0f;

	NxTireFunctionDesc slipTFD;
	slipTFD.extremumSlip = 1.0f;
	slipTFD.extremumValue = 0.02f;
	slipTFD.asymptoteSlip = 2.0f;
	slipTFD.asymptoteValue = 0.01f;	
	slipTFD.stiffnessFactor = 100.0f;  

	NxTireFunctionDesc medTFD;
	medTFD.extremumSlip = 1.0f;
	medTFD.extremumValue = 0.02f;
	medTFD.asymptoteSlip = 2.0f;
	medTFD.asymptoteValue = 0.01f;	
	medTFD.stiffnessFactor = 10000.0f;

	// Front left wheel
	NxWheelDesc wheelDesc;
	wheelDesc.frictionToFront = 100.0f;
	wheelDesc.frictionToSide = 1.0f;


	wheelDesc.wheelApproximation = 0;
	wheelDesc.wheelRadius = m_vehicleDimms->frontWheelsRadius;
	wheelDesc.wheelWidth = m_vehicleDimms->frontWheelsWidth;  // 0.1
	wheelDesc.wheelSuspension = 10;  
	wheelDesc.springRestitution = 0.1;
	wheelDesc.springDamping = 10;
	wheelDesc.springBias = 10;  
	wheelDesc.maxBrakeForce = 0.01;
	wheelDesc.position = NxVec3(m_vehicleDimms->posFrontLeftWheel);
	wheelDesc.wheelFlags = NX_WF_USE_WHEELSHAPE | NX_WF_BUILD_LOWER_HALF | NX_WF_ACCELERATED | 
						   NX_WF_AFFECTED_BY_HANDBRAKE | NX_WF_STEERABLE_INPUT;

	// Front right wheel
	NxWheelDesc wheelDesc2;
	wheelDesc2.frictionToFront = 100.0f;
	wheelDesc2.frictionToSide = 1.0f;



	wheelDesc2.wheelApproximation = 0;
	wheelDesc2.wheelRadius = m_vehicleDimms->frontWheelsRadius;
	wheelDesc2.wheelWidth = m_vehicleDimms->frontWheelsWidth;  // 0.1
	wheelDesc2.wheelSuspension = 10;  
	wheelDesc2.springRestitution = 0.1;
	wheelDesc2.springDamping = 10;
	wheelDesc2.springBias = 10;  
	wheelDesc.maxBrakeForce = 0.01;
	wheelDesc2.position = NxVec3(m_vehicleDimms->posFrontRightWheel);
	wheelDesc2.wheelFlags = NX_WF_USE_WHEELSHAPE | NX_WF_BUILD_LOWER_HALF | NX_WF_ACCELERATED | 
							NX_WF_AFFECTED_BY_HANDBRAKE | NX_WF_STEERABLE_INPUT;

	// Rear left wheel
	NxWheelDesc wheelDesc3;
	wheelDesc3.frictionToFront = 100.0f;
	wheelDesc3.frictionToSide = 1.0f;



	wheelDesc3.wheelApproximation = 0;
	wheelDesc3.wheelRadius = m_vehicleDimms->rearWheelsRadius;
	wheelDesc3.wheelWidth = m_vehicleDimms->rearWheelsWidth;  // 0.1
	wheelDesc3.wheelSuspension = 10;  
	wheelDesc3.springRestitution = 0.1;
	wheelDesc3.springDamping = 10;
	wheelDesc3.springBias = 10;  
	wheelDesc3.maxBrakeForce = 0.01;
	wheelDesc3.position = NxVec3(m_vehicleDimms->posRearLeftWheel);
	wheelDesc3.wheelFlags = NX_WF_USE_WHEELSHAPE | NX_WF_BUILD_LOWER_HALF | NX_WF_ACCELERATED | 
							NX_WF_AFFECTED_BY_HANDBRAKE | NX_WF_STEERABLE_INPUT;

	// Rear right wheel
	NxWheelDesc wheelDesc4;
	wheelDesc4.frictionToFront = 100.0f;
	wheelDesc4.frictionToSide = 1.0f;


	wheelDesc4.wheelApproximation = 0;
	wheelDesc4.wheelRadius = m_vehicleDimms->rearWheelsRadius;
	wheelDesc4.wheelWidth = m_vehicleDimms->rearWheelsWidth;  // 0.1
	wheelDesc4.wheelSuspension = 10;  
	wheelDesc4.springRestitution = 0.1;
	wheelDesc4.springDamping = 10;
	wheelDesc4.springBias = 10;  
	wheelDesc4.maxBrakeForce = 0.01;
	wheelDesc4.position = NxVec3(m_vehicleDimms->posRearRightWheel);
	wheelDesc4.wheelFlags = NX_WF_USE_WHEELSHAPE | NX_WF_BUILD_LOWER_HALF | NX_WF_ACCELERATED | 
							NX_WF_AFFECTED_BY_HANDBRAKE | NX_WF_STEERABLE_INPUT;


	wheelDesc4.frictionToFront = wheelDesc3.frictionToFront = wheelDesc2.frictionToFront = wheelDesc.frictionToFront = 100.0f;
	wheelDesc4.frictionToSide = wheelDesc3.frictionToSide = wheelDesc2.frictionToSide = wheelDesc.frictionToSide = 1.0f;


	/*wheelDesc4.wheelSuspension = wheelDesc3.wheelSuspension = wheelDesc2.wheelSuspension = wheelDesc.wheelSuspension = 0.0001;
	wheelDesc4.springRestitution = wheelDesc3.springRestitution = wheelDesc2.springRestitution = wheelDesc.springRestitution = 0.0001;
	wheelDesc4.springDamping = wheelDesc3.springDamping = wheelDesc2.springDamping = wheelDesc.springDamping = 0.001;
	wheelDesc4.springBias = wheelDesc3.springBias = wheelDesc2.springBias = wheelDesc.springBias = 0.001;
	wheelDesc4.maxBrakeForce = wheelDesc3.maxBrakeForce = wheelDesc2.maxBrakeForce = wheelDesc.maxBrakeForce = 0.01;*/

	if(paramsType != "Extended")
	{
		wheelDesc4.wheelSuspension = wheelDesc3.wheelSuspension = wheelDesc2.wheelSuspension = wheelDesc.wheelSuspension = 0.5f / 10;
		wheelDesc4.springRestitution = wheelDesc3.springRestitution = wheelDesc2.springRestitution = wheelDesc.springRestitution = 1000.0f / 100000000000;
		wheelDesc4.springDamping = wheelDesc3.springDamping = wheelDesc2.springDamping = wheelDesc.springDamping = 0.5f / 10000000000000;
		wheelDesc4.springBias = wheelDesc3.springBias = wheelDesc2.springBias = wheelDesc.springBias = 1.0f / 10000000000000;
		wheelDesc4.maxBrakeForce = wheelDesc3.maxBrakeForce = wheelDesc2.maxBrakeForce = wheelDesc.maxBrakeForce = 0.01f; // 100;
	}
	else
	{
		wheelDesc4.frictionToFront = wheelDesc3.frictionToFront = wheelDesc2.frictionToFront = wheelDesc.frictionToFront = vp->frictionToFront;
		wheelDesc4.frictionToSide = wheelDesc3.frictionToSide = wheelDesc2.frictionToSide = wheelDesc.frictionToSide = vp->frictionToSide;

		wheelDesc4.wheelSuspension = wheelDesc3.wheelSuspension = wheelDesc2.wheelSuspension = wheelDesc.wheelSuspension = vp->wheelSuspension;
		wheelDesc4.springRestitution = wheelDesc3.springRestitution = wheelDesc2.springRestitution = wheelDesc.springRestitution = vp->springRestitution;
		wheelDesc4.springDamping = wheelDesc3.springDamping = wheelDesc2.springDamping = wheelDesc.springDamping = vp->springDamping;
		wheelDesc4.springBias = wheelDesc3.springBias = wheelDesc2.springBias = wheelDesc.springBias = vp->springBias;
		wheelDesc4.maxBrakeForce = wheelDesc3.maxBrakeForce = wheelDesc2.maxBrakeForce = wheelDesc.maxBrakeForce = vp->maxBrakeForce; // 100;
	}

	m_wheelFrontLeft = AddWheelToActor(m_actor, &wheelDesc);
	m_wheelFrontRight = AddWheelToActor(m_actor, &wheelDesc2);
	m_wheelRearLeft = AddWheelToActor(m_actor, &wheelDesc3);
	m_wheelRearRight = AddWheelToActor(m_actor, &wheelDesc4);

	m_wheelFrontLeft->userData = (void*)new ShapeUserData;
	m_wheelFrontRight->userData = (void*)new ShapeUserData;
	m_wheelRearLeft->userData = (void*)new ShapeUserData;
	m_wheelRearRight->userData = (void*)new ShapeUserData;

	// LOWER THE CENTER OF MASS
	NxVec3 massPos = m_actor->getCMassLocalPosition();
	massPos.y -= 1;
	m_actor->setCMassOffsetLocalPosition(massPos);
	m_actor->wakeUp(1e30);
}