Hi,

I try to use the Car without using the carobject-drawablecomponent… The car input and physics work fine, but I am not able to get it drawn.

I use this code:

public void DrawCar()

{

int boneCount = 0;

if (boneTransforms == null || boneCount != model.Bones.Count)

{

boneTransforms = new Matrix[model.Bones.Count];

boneCount = model.Bones.Count;

}

model.CopyAbsoluteBoneTransformsTo(boneTransforms);

foreach (ModelMesh mesh in model.Meshes)

{

foreach (BasicEffect effect in mesh.Effects)

{

// the body has an orientation but also the primitives in the collision skin

// owned by the body can be rotated!

if (car.Chassis.Body.CollisionSkin != null)

effect.World = boneTransforms[mesh.ParentBone.Index] * Matrix.CreateScale(scale) * car.Chassis.Body.CollisionSkin.GetPrimitiveLocal(0).Transform.Orientation * car.Chassis.Body.Orientation * Matrix.CreateTranslation(car.Chassis.Body.Position);

else

effect.World = boneTransforms[mesh.ParentBone.Index] * Matrix.CreateScale(scale) * car.Chassis.Body.Orientation * Matrix.CreateTranslation(car.Chassis.Body.Position);

effect.View = camera.View;

effect.Projection = camera.Projection;

//if (!this.PhysicsBody.IsActive)

// effect.Alpha = 0.4f;

//else

// effect.Alpha = 1.0f;

effect.EnableDefaultLighting();

effect.PreferPerPixelLighting = true;

}

mesh.Draw();

}

// Copy any parent transforms.

Matrix[] transforms = new Matrix[model.Bones.Count];

model.CopyAbsoluteBoneTransformsTo(transforms);

// Draw the model. A model can have multiple meshes, so loop.

foreach (ModelMesh mesh in model.Meshes)

{

// This is where the mesh orientation is set, as well as our camera and projection.

foreach (BasicEffect effect in mesh.Effects)

{

effect.EnableDefaultLighting();

effect.World = boneTransforms[mesh.ParentBone.Index] * Matrix.CreateScale(scale) * car.Chassis.Body.CollisionSkin.GetPrimitiveLocal(0).Transform.Orientation * car.Chassis.Body.Orientation * Matrix.CreateTranslation(car.Chassis.Body.Position);

effect.View = camera.View;

effect.Projection = camera.Projection;

}

// Draw the mesh, using the effects set above.

mesh.Draw();

}

}

public void DrawWheels()

{

Matrix[] boneTransforms = new Matrix[model.Bones.Count];

model.CopyAbsoluteBoneTransformsTo(boneTransforms);

Wheel wh;

wh = car.Wheels[0];

foreach (ModelMesh mesh in wheel.Meshes)

{

Matrix rotMat = Matrix.Identity;

rotMat = Matrix.CreateRotationY(MathHelper.ToRadians(180.0f));

foreach (BasicEffect effect in mesh.Effects)

{

float steer = wh.SteerAngle;

effect.World = boneTransforms[mesh.ParentBone.Index] * rotMat *

Matrix.CreateRotationZ(MathHelper.ToRadians(-wh.AxisAngle)) * // rotate the wheels

Matrix.CreateRotationY(MathHelper.ToRadians(steer)) *

Matrix.CreateTranslation(wh.Pos + wh.Displacement * wh.LocalAxisUp) * car.Chassis.Body.Orientation * // oritentation of wheels

Matrix.CreateTranslation(car.Chassis.Body.Position); // translation

effect.View = camera.View;

effect.Projection = camera.Projection;

effect.EnableDefaultLighting();

effect.PreferPerPixelLighting = true;

}

mesh.Draw();

}

wh = car.Wheels[1];

foreach (ModelMesh mesh in wheel.Meshes)

{

Matrix rotMat = Matrix.Identity;

rotMat = Matrix.CreateRotationY(MathHelper.ToRadians(180.0f));

foreach (BasicEffect effect in mesh.Effects)

{

float steer = wh.SteerAngle;

effect.World = boneTransforms[mesh.ParentBone.Index] * rotMat * // create scale

Matrix.CreateRotationZ(MathHelper.ToRadians(-wh.AxisAngle)) * // rotate the wheels

Matrix.CreateRotationY(MathHelper.ToRadians(steer)) *

Matrix.CreateTranslation(wh.Pos + wh.Displacement * wh.LocalAxisUp) * car.Chassis.Body.Orientation * // oritentation of wheels

Matrix.CreateTranslation(car.Chassis.Body.Position); // translation

effect.View = camera.View;

effect.Projection = camera.Projection;

effect.EnableDefaultLighting();

effect.PreferPerPixelLighting = true;

}

mesh.Draw();

}

wh = car.Wheels[2];

foreach (ModelMesh mesh in wheel.Meshes)

{

Matrix rotMat = Matrix.Identity;

foreach (BasicEffect effect in mesh.Effects)

{

float steer = wh.SteerAngle;

effect.World = boneTransforms[mesh.ParentBone.Index] * rotMat * // create scale

Matrix.CreateRotationZ(MathHelper.ToRadians(-wh.AxisAngle)) * // rotate the wheels

Matrix.CreateRotationY(MathHelper.ToRadians(steer)) *

Matrix.CreateTranslation(wh.Pos + wh.Displacement * wh.LocalAxisUp) * car.Chassis.Body.Orientation * // oritentation of wheels

Matrix.CreateTranslation(car.Chassis.Body.Position); // translation

effect.View = camera.View;

effect.Projection = camera.Projection;

effect.EnableDefaultLighting();

effect.PreferPerPixelLighting = true;

}

mesh.Draw();

}

wh = car.Wheels[3];

foreach (ModelMesh mesh in wheel.Meshes)

{

Matrix rotMat = Matrix.Identity;

foreach (BasicEffect effect in mesh.Effects)

{

float steer = wh.SteerAngle;

effect.World = boneTransforms[mesh.ParentBone.Index] * rotMat * // create scale

Matrix.CreateRotationZ(MathHelper.ToRadians(-wh.AxisAngle)) * // rotate the wheels

Matrix.CreateRotationY(MathHelper.ToRadians(steer)) *

Matrix.CreateTranslation(wh.Pos + wh.Displacement * wh.LocalAxisUp) * car.Chassis.Body.Orientation * // oritentation of wheels

Matrix.CreateTranslation(car.Chassis.Body.Position); // translation

effect.View = camera.View;

effect.Projection = camera.Projection;

effect.EnableDefaultLighting();

effect.PreferPerPixelLighting = true;

}

mesh.Draw();

}

}

But I don't get anything drawn.