Beispiel #1
0
void RaycastVehicle::AddWheel(Node* wheelNode,
                                Vector3 wheelDirection, Vector3 wheelAxle,
                                float restLength, float wheelRadius,
                                bool frontWheel)
{
    btRaycastVehicle* vehicle = vehicleData_->Get();
    int id = GetNumWheels();
    Vector3 connectionPoint = wheelNode->GetWorldPosition() - node_->GetWorldPosition();
    btVector3 connectionPointCS0(connectionPoint.x_, connectionPoint.y_, connectionPoint.z_);
    btVector3 wheelDirectionCS0(wheelDirection.x_, wheelDirection.y_, wheelDirection.z_);
    btVector3 wheelAxleCS(wheelAxle.x_, wheelAxle.y_, wheelAxle.z_);
    btWheelInfo& wheel = vehicle->addWheel(connectionPointCS0,
                            wheelDirectionCS0,
                            wheelAxleCS,
                            restLength,
                            wheelRadius,
                            vehicleData_->tuning_,
                            frontWheel);

    wheelNodes_.Push(wheelNode);
    origRotation_.Push(wheelNode->GetWorldRotation());
    skidInfoCumulative_.Push(1.0f);
    wheelSideSlipSpeed_.Push(0.0f);
    wheel.m_raycastInfo.m_isInContact = false;
}
void CarHandlingDemo::addWheels(
	btVector3* halfExtents,
	btRaycastVehicle* vehicle,
	btRaycastVehicle::btVehicleTuning tuning)
{
	//The direction of the raycast, the btRaycastVehicle uses raycasts instead of simiulating the wheels with rigid bodies
	btVector3 wheelDirectionCS0(0, -1, 0);

	//The axis which the wheel rotates arround
	btVector3 wheelAxleCS(-1, 0, 0);

	btScalar suspensionRestLength(0.7);

	btScalar wheelWidth(0.4);

	btScalar wheelRadius(0.5);

	//The height where the wheels are connected to the chassis
	btScalar connectionHeight(1.2);

	//All the wheel configuration assumes the vehicle is centered at the origin and a right handed coordinate system is used
	btVector3 wheelConnectionPoint(halfExtents->x() - wheelRadius, connectionHeight, halfExtents->z() - wheelWidth);

	//Adds the front wheels
	vehicle->addWheel(wheelConnectionPoint, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, tuning, true);

	vehicle->addWheel(wheelConnectionPoint * btVector3(-1, 1, 1), wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, tuning, true);

	//Adds the rear wheels
	vehicle->addWheel(wheelConnectionPoint* btVector3(1, 1, -1), wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, tuning, false);

	vehicle->addWheel(wheelConnectionPoint * btVector3(-1, 1, -1), wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, tuning, false);

	//Configures each wheel of our vehicle, setting its friction, damping compression, etc.
	//For more details on what each parameter does, refer to the docs
	for (int i = 0; i < vehicle->getNumWheels(); i++)
	{
		btWheelInfo& wheel = vehicle->getWheelInfo(i);
		wheel.m_suspensionStiffness = 50;
		wheel.m_wheelsDampingCompression = btScalar(0.3) * 2 * btSqrt(wheel.m_suspensionStiffness);//btScalar(0.8);
		wheel.m_wheelsDampingRelaxation = btScalar(0.5) * 2 * btSqrt(wheel.m_suspensionStiffness);//1;
		//Larger friction slips will result in better handling
		wheel.m_frictionSlip = btScalar(1.2);
		wheel.m_rollInfluence = 1;
	}
}
Beispiel #3
0
void RaycastVehicle::ApplyAttributes()
{
    int index = 0;
    hullBody_ = node_->GetOrCreateComponent<RigidBody>();
    Scene* scene = GetScene();
    vehicleData_->Init(scene, hullBody_);
    VariantVector& value = loadedWheelData_;
    int numObjects = value[index++].GetInt();
    int wheelIndex = 0;
    origRotation_.Clear();
    skidInfoCumulative_.Clear();
    wheelSideSlipSpeed_.Clear();

    for (int i = 0; i < numObjects; i++)
    {
        int node_id = value[index++].GetInt();
        Vector3 direction = value[index++].GetVector3();
        Vector3 axle = value[index++].GetVector3();
        float restLength = value[index++].GetFloat();
        float radius = value[index++].GetFloat();
        bool isFrontWheel = value[index++].GetBool();
        float steering = value[index++].GetFloat();
        Vector3 connectionPoint = value[index++].GetVector3();
        Quaternion origRotation = value[index++].GetQuaternion();
        float skidInfoC = value[index++].GetFloat();
        float sideSlipSpeed = value[index++].GetFloat();

        bool isContact = value[index++].GetBool();
        Vector3 contactPosition = value[index++].GetVector3();
        Vector3 contactNormal = value[index++].GetVector3();
        float suspensionStiffness = value[index++].GetFloat();
        float dampingRelaxation = value[index++].GetFloat();
        float dampingCompression = value[index++].GetFloat();
        float frictionSlip = value[index++].GetFloat();
        float rollInfluence = value[index++].GetFloat();
        float engineForce = value[index++].GetFloat();
        float brake = value[index++].GetFloat();
        float skidInfo = value[index++].GetFloat();
        Node* wheelNode = GetScene()->GetNode(node_id);
        if (!wheelNode)
        {
            URHO3D_LOGERROR("RaycastVehicle: Incorrect node id = " + String(node_id) + " index: " + String(index));
            continue;
        }
        btRaycastVehicle* vehicle = vehicleData_->Get();
        int id = GetNumWheels();
        btVector3 connectionPointCS0(connectionPoint.x_, connectionPoint.y_, connectionPoint.z_);
        btVector3 wheelDirectionCS0(direction.x_, direction.y_, direction.z_);
        btVector3 wheelAxleCS(axle.x_, axle.y_, axle.z_);
        btWheelInfo& wheel = vehicle->addWheel(connectionPointCS0,
                                wheelDirectionCS0,
                                wheelAxleCS,
                                restLength,
                                radius,
                                vehicleData_->tuning_,
                                isFrontWheel);
        wheelNodes_.Push(wheelNode);
        origRotation_.Push(origRotation);
        skidInfoCumulative_.Push(skidInfoC);
        wheelSideSlipSpeed_.Push(sideSlipSpeed);
        SetSteeringValue(wheelIndex, steering);
        wheel.m_raycastInfo.m_isInContact = isContact;
        wheel.m_raycastInfo.m_contactNormalWS = btVector3(contactNormal.x_, contactNormal.y_, contactNormal.z_);
        wheel.m_raycastInfo.m_contactPointWS = btVector3(contactPosition.x_, contactPosition.y_, contactPosition.z_);
        wheel.m_suspensionStiffness = suspensionStiffness;
        wheel.m_wheelsDampingRelaxation = dampingRelaxation;
        wheel.m_wheelsDampingCompression = dampingCompression;
        wheel.m_frictionSlip = frictionSlip;
        wheel.m_rollInfluence = rollInfluence;
        wheel.m_engineForce = engineForce;
        wheel.m_brake = brake;
        wheel.m_skidInfo = skidInfo;
        wheelIndex++;
    }
    URHO3D_LOGDEBUG("maxSideSlipSpeed_ value: " + String(maxSideSlipSpeed_));
    URHO3D_LOGDEBUG("loaded items: " + String(index));
    URHO3D_LOGDEBUG("loaded wheels: " + String(GetNumWheels()));
}
bool Vehicle::LoadContent(DxGraphics* dx, ResourceManager& resources)
{
	m_dynamicsWorld = resources.GetPhysicsManager()->GetWorld();

	//Loads the content of all the modules
	if (!m_body->LoadContent(dx, m_body->GetPosition(), resources, m_body->GetYaw(), m_body->GetPitch(),
		m_body->GetRoll(), m_scale + m_body->GetScale()))
	{
		return false;
	}
	for (unsigned int i = 0; i < 4; i++)
	{
		if (i == 0 || i == 1)
		{
			if (!m_retros[i]->LoadContent(dx, m_retros[i]->GetPosition(), resources, m_retros[i]->GetYaw(),
				m_retros[i]->GetPitch(), m_retros[i]->GetRoll(), m_scale + m_retros[i]->GetScale()))
			{
				return false;
			}
		}

		if (!m_wheels[i]->LoadContent(dx, m_wheels[i]->GetPosition(), resources, m_wheels[i]->GetYaw(),
			m_wheels[i]->GetPitch(), m_wheels[i]->GetRoll(), m_scale + m_wheels[i]->GetScale()))
		{
			return false;
		}
	}

	if (!m_spoiler->LoadContent(dx, m_spoiler->GetPosition(), resources, m_spoiler->GetYaw(),
		m_spoiler->GetPitch(), m_spoiler->GetRoll(), m_scale + m_spoiler->GetScale()))
	{
		return false;
	}


	//ASSIGN CAR INFORMATION
	m_vehicleInfo.m_engineForce = m_retros[0]->engineForce;
	m_vehicleInfo.m_defaultEngineForce = m_retros[0]->engineForce;
	m_vehicleInfo.m_frictionSlip = BT_LARGE_FLOAT;
	m_vehicleInfo.m_rollInfluence = 0.0001f;
	m_vehicleInfo.m_suspensionRestLength1 = 0.2f;
	m_vehicleInfo.m_suspensionStiffness = 40.0f;
	m_vehicleInfo.m_wheelsDampingCompression = 4.4f; //4.4
	m_vehicleInfo.m_wheelsDampingRelaxation = 10.2f; //20
	m_vehicleInfo.m_steeringForce = 0.05f;
	m_vehicleInfo.m_breakingForce = 100;
	m_vehicleInfo.m_maxSteeringAngle = 0.10f;

	//Calcualte mass of the car, based on components.
	m_mass = m_body->GetWeight() + m_spoiler->GetWeight() + (m_wheels[0]->GetWeight() * 4) + (m_retros[0]->GetWeight() * 2);

	//initialize the compound, start adding all the aprts together
	m_vehicleCompound = new btCompoundShape();

	//CREATE VEHICLE PARTS

	//BODY
	m_vehicleCompound->addChildShape(m_body->GetLocalTranslation(), m_body->CreateCollisionShape());

	//RETROS
	for (int x = 0; x < 2; x++)
	{
		m_vehicleCompound->addChildShape(m_retros[x]->GetLocalTranslation(), m_retros[x]->CreateCollisionShape());
	}
	//SPOILER
	m_vehicleCompound->addChildShape(m_spoiler->GetLocalTranslation(), m_spoiler->CreateCollisionShape());


	//set the car Transform 
	btTransform tr;
	tr.setIdentity();
	tr.setOrigin(btVector3(m_position.x, m_position.y, m_position.z));
	//Combine all the parts into a rigid body object.
	m_rigidBody = localCreateRigidBody(m_mass, tr, m_vehicleCompound);


	/// Create raycasting for the vechicle and attach it to the car
	{
		m_vehicleRayCaster = new btDefaultVehicleRaycaster(m_dynamicsWorld);
		m_vehicle = new btRaycastVehicle(m_tuning, m_rigidBody, m_vehicleRayCaster);
		///never deactivate the vehicle
		m_rigidBody->setActivationState(DISABLE_DEACTIVATION);
		//add the vehicle to the simualtion.
		m_dynamicsWorld->addVehicle(m_vehicle);

		//Set up coordiante system , Y-up, Z-forward
		int rightIndex = 0;
		int upIndex = 1;
		int forwardIndex = 2;
		m_vehicle->setCoordinateSystem(rightIndex, upIndex, forwardIndex);

		bool isFrontWheel = true;
		btVector3 wheelDirectionCS0(0.0f, -1.0f, 0.0f);
		btVector3 wheelAxleCS(-1.0f, 0.0f, 0.0f);
		btScalar suspensionRestLength(0.2f);

		//initialize wheels
		for (int x = 0; x < 4; x++)
		{
			XMFLOAT3 colExt = m_wheels[x]->GetCollisionExtents();
			float	wheelRadius = colExt.y;
			float	wheelWidth = colExt.z;
			//determine which wheels are at the back
			if (x > 2) isFrontWheel = false;

			XMFLOAT3 offset = m_wheels[x]->GetOffset();
			btVector3 connectionPointCS0 = btVector3(offset.x, offset.y, offset.z);
			m_vehicle->addWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, m_tuning, isFrontWheel);
		}
		//Rotate the wheel for the other side.
		m_wheels[1]->SetYaw(m_wheels[2]->GetYaw() + XM_PI);
		m_wheels[3]->SetYaw(m_wheels[3]->GetYaw() + XM_PI);

		//Wheel parameters.
		for (int i = 0; i < m_vehicle->getNumWheels(); i++)
		{
			btWheelInfo& wheel = m_vehicle->getWheelInfo(i);
			wheel.m_suspensionStiffness = m_vehicleInfo.m_suspensionStiffness;
			wheel.m_wheelsDampingRelaxation = m_vehicleInfo.m_wheelsDampingRelaxation;
			wheel.m_wheelsDampingCompression = m_vehicleInfo.m_wheelsDampingCompression;
			wheel.m_frictionSlip = m_vehicleInfo.m_frictionSlip;
			wheel.m_rollInfluence = m_vehicleInfo.m_rollInfluence;
			wheel.m_suspensionRestLength1 = m_vehicleInfo.m_suspensionRestLength1;
		}
	}

	m_loaded = true;
	return true;
}
Beispiel #5
0
//=============================================================================
//=============================================================================
void Vehicle::Init()
{
    // This function is called only from the main program when initially creating the vehicle, not on scene load
    ResourceCache* cache = GetSubsystem<ResourceCache>();
    
    StaticModel* hullObject = node_->CreateComponent<StaticModel>();
    hullBody_ = node_->CreateComponent<RigidBody>();
    CollisionShape* hullColShape = node_->CreateComponent<CollisionShape>();
    
    hullBody_->SetMass(1200.0f);
    hullBody_->SetLinearDamping(0.2f); // Some air resistance
    hullBody_->SetAngularDamping(0.5f);
    hullBody_->SetCollisionLayer(1);

    
    int rightIndex = 0;
    int upIndex = 1;
    int forwardIndex = 2;
    PhysicsWorld *pPhysWorld = GetScene()->GetComponent<PhysicsWorld>();
    btDynamicsWorld *pbtDynWorld = (btDynamicsWorld*)pPhysWorld->GetWorld();
    
    m_vehicleRayCaster = new btDefaultVehicleRaycaster( pbtDynWorld );
    m_vehicle = new btRaycastVehicle( m_tuning, hullBody_->GetBody(), m_vehicleRayCaster );
    pbtDynWorld->addVehicle( m_vehicle );
    
    

    
    m_vehicle->setCoordinateSystem( rightIndex, upIndex, forwardIndex );
    
    
    //Vector3 v3BoxExtents = Vector3::ONE;//Vector3(1.5f, 1.0f, 3.0f);
    hullObject->SetModel(cache->GetResource<Model>("MyProjects/MiniCooper/test/Chassis_001.mdl"));
    node_->SetScale( Vector3(1.0f, 1.0f, 1.0f) );
  
    
    hullColShape->SetConvexHull(cache->GetResource<Model>("MyProjects/MiniCooper/test/collision.mdl"));
    //hullColShape->SetConvexHull(cache->GetResource<Model>("Models/Box.mdl"));
    //hullColShape->SetBox((hullObject->GetBoundingBox()).Size());
    //hullColShape->SetTriangleMesh(cache->GetResource<Model>("Models/Box.mdl"));
    //hullColShape->SetSize(Vector3(1.0f, 1.0f, 3.0f));
    
    
    //hullColShape->SetPosition((hullObject->GetBoundingBox()).Center() - Vector3(0.0f, 0.0f, 0.0f) );
    //hullColShape->SetPosition( Vector3(0.0f, +0.2f, 0.0f) );
    
    
    
    
   
    
    hullObject->SetCastShadows(true);

    
    Node* patricleTest = node_->CreateChild("patricleTest");
    patricleTest->LoadXML(cache->GetResource<XMLFile>("MyProjects/MiniCooper/particleTest.xml")->GetRoot());
    patricleTest->SetPosition(Vector3(0.0f, 0.2f, -2.0f));

    Node* lightTest = node_->CreateChild("lightTest");
    lightTest->LoadXML(cache->GetResource<XMLFile>("MyProjects/MiniCooper/lightTest.xml")->GetRoot());
    lightTest->SetPosition(Vector3(0.0f, 0.2f, 2.0f));
    

    
    
    

    

    //float connectionHeight = -0.4f;//1.2f;
    //float connectionHeight = 0.0f;
    bool isFrontWheel=true;
    btVector3 wheelDirectionCS0(0,-1,0);
    btVector3 wheelAxleCS(1,0,0);
    
    double wheelOffset = 0.5;
    
    
    // front right
    //////////////
    Node* node_wheel_temp0 = GetScene()->CreateChild("node_wheel_temp0");
    StaticModel* model_wheel_temp0 = node_wheel_temp0->CreateComponent<StaticModel>();
    model_wheel_temp0->SetModel(cache->GetResource<Model>("MyProjects/MiniCooper/test/wheel_000.mdl"));
    model_wheel_temp0->ApplyMaterialList("MyProjects/MiniCooper/test/wheel_000.txt");
    model_wheel_temp0->SetCastShadows(true);

    //btVector3 connectionPointCS0(((model_wheel_temp0->GetBoundingBox()).Center()).x_, ((model_wheel_temp0->GetBoundingBox()).Center()).y_, ((model_wheel_temp0->GetBoundingBox()).Center()).z_);
    //wheelRadius = model_wheel_temp0->GetBoundingBox().HalfSize().y_;
    //m_vehicle->addWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, m_tuning, isFrontWheel);
    btVector3 connectionPointCS0((model_wheel_temp0->GetBoundingBox()).Center().x_,((model_wheel_temp0->GetBoundingBox()).Center()).y_ + wheelOffset,((model_wheel_temp0->GetBoundingBox()).Center()).z_);
    m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,btVector3(-1,0,0),suspensionRestLength,wheelRadius,m_tuning,isFrontWheel);


    Node* node_wheel_0 = GetScene()->CreateChild("node_wheel_0");
    node_wheel_0->SetPosition((model_wheel_temp0->GetBoundingBox()).Center());
    node_wheel_0->SetRotation(Quaternion(0.0f, 0.0f, 90.0f));
    node_wheel_temp0->SetParent(node_wheel_0);
    m_vpNodeWheel.Push( node_wheel_0 );

    //SDL_Log( "node_wheel_temp0: %f, %f, %f \n", ((model_wheel_temp0->GetBoundingBox()).Center()).x_, ((model_wheel_temp0->GetBoundingBox()).Center()).y_, ((model_wheel_temp0->GetBoundingBox()).Center()).z_);
    //SDL_Log( "node_wheel_temp0.HalfSize: %s \n", model_wheel_temp0->GetBoundingBox().HalfSize().ToString().CString() );

    //SDL_Log("##################### \n");
    //SDL_Log("node_wheel_temp0WorldP: %f, %f, %f \n", node_wheel_temp0->GetWorldPosition().x_, node_wheel_temp0->GetWorldPosition().y_, node_wheel_temp0->GetWorldPosition().z_);
    //SDL_Log("node_wheel_temp0P: %f, %f, %f \n", node_wheel_temp0->GetPosition().x_, node_wheel_temp0->GetPosition().y_, node_wheel_temp0->GetPosition().z_);

    //SDL_Log( "model_wheel_temp0BoundP: %f, %f, %f \n", ((model_wheel_temp0->GetBoundingBox()).Center()).x_, ((model_wheel_temp0->GetBoundingBox()).Center()).y_, ((model_wheel_temp0->GetBoundingBox()).Center()).z_);

    //node_wheel_temp0->SetPosition(node_wheel_temp0->GetPosition() - (model_wheel_temp0->GetBoundingBox()).Center());

    //SDL_Log("transform: %f, %f, %f \n", v3Origin.x_, v3Origin.y_, v3Origin.z_);
    //v3Origin = v3Origin - Vector3(0.704, 0.379, 1.19);
    //SDL_Log("transform: %f, %f, %f \n", v3Origin.x_, v3Origin.y_, v3Origin.z_);





    // front left
    /////////////
    Node* node_wheel_temp1 = GetScene()->CreateChild("node_wheel_temp1");
    StaticModel* model_wheel_temp1 = node_wheel_temp1->CreateComponent<StaticModel>();
    model_wheel_temp1->SetModel(cache->GetResource<Model>("MyProjects/MiniCooper/test/wheel_001.mdl"));
    model_wheel_temp1->SetCastShadows(true);

    //btVector3 connectionPointCS0(((model_wheel_temp0->GetBoundingBox()).Center()).x_, ((model_wheel_temp0->GetBoundingBox()).Center()).y_, ((model_wheel_temp0->GetBoundingBox()).Center()).z_);
    //wheelRadius = model_wheel_temp0->GetBoundingBox().HalfSize().y_;
    //m_vehicle->addWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, m_tuning, isFrontWheel);
    connectionPointCS0 = btVector3((model_wheel_temp1->GetBoundingBox()).Center().x_,((model_wheel_temp1->GetBoundingBox()).Center()).y_ + wheelOffset,((model_wheel_temp1->GetBoundingBox()).Center()).z_);
    m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,btVector3(-1,0,0),suspensionRestLength,wheelRadius,m_tuning,isFrontWheel);


    Node* node_wheel_1 = GetScene()->CreateChild("node_wheel_1");
    node_wheel_1->SetPosition((model_wheel_temp1->GetBoundingBox()).Center());
    node_wheel_1->SetRotation(Quaternion(0.0f, 0.0f, -90.0f));
    node_wheel_temp1->SetParent(node_wheel_1);
    m_vpNodeWheel.Push( node_wheel_1 );



    

    
    
    isFrontWheel = false;


    // back right
    /////////////
    Node* node_wheel_temp2 = GetScene()->CreateChild("node_wheel_temp2");
    StaticModel* model_wheel_temp2 = node_wheel_temp2->CreateComponent<StaticModel>();
    model_wheel_temp2->SetModel(cache->GetResource<Model>("MyProjects/MiniCooper/test/wheel_002.mdl"));
    model_wheel_temp2->SetCastShadows(true);

    //btVector3 connectionPointCS0(((model_wheel_temp0->GetBoundingBox()).Center()).x_, ((model_wheel_temp0->GetBoundingBox()).Center()).y_, ((model_wheel_temp0->GetBoundingBox()).Center()).z_);
    //wheelRadius = model_wheel_temp0->GetBoundingBox().HalfSize().y_;
    //m_vehicle->addWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, m_tuning, isFrontWheel);
    connectionPointCS0 = btVector3((model_wheel_temp2->GetBoundingBox()).Center().x_,((model_wheel_temp2->GetBoundingBox()).Center()).y_ + wheelOffset,((model_wheel_temp2->GetBoundingBox()).Center()).z_);
    m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,btVector3(-1,0,0),suspensionRestLength,wheelRadius,m_tuning,isFrontWheel);


    Node* node_wheel_2 = GetScene()->CreateChild("node_wheel_2");
    node_wheel_2->SetPosition((model_wheel_temp2->GetBoundingBox()).Center());
    node_wheel_2->SetRotation(Quaternion(0.0f, 0.0f, 90.0f));
    node_wheel_temp2->SetParent(node_wheel_2);
    m_vpNodeWheel.Push( node_wheel_2 );




    // back left
    /////////////
    /// \brief objectNode3


    Node* node_wheel_temp3 = GetScene()->CreateChild("node_wheel_temp3");
    StaticModel* model_wheel_temp3 = node_wheel_temp3->CreateComponent<StaticModel>();
    model_wheel_temp3->SetModel(cache->GetResource<Model>("MyProjects/MiniCooper/test/wheel_003.mdl"));
    model_wheel_temp3->SetCastShadows(true);

    //btVector3 connectionPointCS0(((model_wheel_temp0->GetBoundingBox()).Center()).x_, ((model_wheel_temp0->GetBoundingBox()).Center()).y_, ((model_wheel_temp0->GetBoundingBox()).Center()).z_);
    //wheelRadius = model_wheel_temp0->GetBoundingBox().HalfSize().y_;
    //m_vehicle->addWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, m_tuning, isFrontWheel);
    connectionPointCS0 = btVector3((model_wheel_temp3->GetBoundingBox()).Center().x_,((model_wheel_temp3->GetBoundingBox()).Center()).y_ + wheelOffset,((model_wheel_temp3->GetBoundingBox()).Center()).z_);
    m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,btVector3(-1,0,0),suspensionRestLength,wheelRadius,m_tuning,isFrontWheel);


    Node* node_wheel_3 = GetScene()->CreateChild("node_wheel_2");
    node_wheel_3->SetPosition((model_wheel_temp3->GetBoundingBox()).Center());
    node_wheel_3->SetRotation(Quaternion(0.0f, 0.0f, -90.0f));
    node_wheel_temp3->SetParent(node_wheel_3);
    m_vpNodeWheel.Push( node_wheel_3 );





    
  /*
    for ( int i = 0; i < m_vehicle->getNumWheels(); i++ )
    {
        btWheelInfo& wheel = m_vehicle->getWheelInfo( i );
        wheel.m_suspensionStiffness = suspensionStiffness;
        wheel.m_wheelsDampingRelaxation = suspensionDamping;
        wheel.m_wheelsDampingCompression = suspensionCompression;
        wheel.m_frictionSlip = wheelFriction;
        wheel.m_rollInfluence = rollInfluence;

        
        
    }
    */
    
    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);

            btTransform transform = m_vehicle->getWheelTransformWS( i );

            /*

            //Vector3 v3Origin = ToVector3( transform.getOrigin() );
            //Quaternion qRot = ToQuaternion( transform.getRotation() );

            // create wheel node
            Node *wheelNode = GetScene()->CreateChild();


            //wheelNode->SetPosition( v3Origin );

            //btWheelInfo whInfo = m_vehicle->getWheelInfo( i );
            //Vector3 v3PosLS = ToVector3( whInfo.m_chassisConnectionPointCS );



            //wheelNode->SetRotation( v3PosLS.x_ >= 0.0 ? Quaternion(0.0f, 0.0f, -90.0f) : Quaternion(0.0f, 0.0f, 90.0f) );
            //wheelNode->SetScale(Vector3(1.0f, 0.65f, 1.0f));

            StaticModel *pWheel = wheelNode->CreateComponent<StaticModel>();
            if(i == 0)
                pWheel->SetModel(cache->GetResource<Model>("MyProjects/SimpeCar/wheel.mdl"));
            else
                pWheel->SetModel(cache->GetResource<Model>("MyProjects/SimpeCar/wheel.mdl"));

            if(i == 0) {
                //wheelNode->SetPosition( Vector3(50,50,50) );
                //wheelNode->SetRotation(Quaternion(0.0f, 0.0f, 0.0f));
            }else {
                //wheelNode->SetPosition( v3Origin );
                //wheelNode->SetRotation(Quaternion(0.0f, 0.0f, 0.0f));
            }

            m_vpNodeWheel.Push( wheelNode );

            //pWheel->SetModel(cache->GetResource<Model>("MyProjects/MiniCooper/test/wheel_004.mdl"));
            pWheel->SetMaterial(cache->GetResource<Material>("MyProjects/SimpeCar/TireTextureMaterial.xml"));
            pWheel->SetCastShadows(true);
            */
        }
    }
}