Here is a shape to which I want the model to be attached:
Code: Select all
var wheel = new Cylinder(suspensionLeg.Position + new Vector3(leftSide ? -horizontalWheelOffset : horizontalWheelOffset, -suspensionLeg.HalfHeight, 0), .2f, .3f, 5f);
Code: Select all
var wheel = new Cylinder(suspensionLeg.Position + new Vector3(leftSide ? -horizontalWheelOffset : horizontalWheelOffset, -suspensionLeg.HalfHeight, 0), .2f, .3f, 5f);
Code: Select all
modelWorldTransform = localGraphicalTransform * entity.WorldTransform;
Code: Select all
void AddBackWheel(Vector3 suspensionOffset, BEPUphysics.Entities.Entity body, bool leftSide)
{
var suspensionLeg = new Box(body.Position + suspensionOffset, 0.25f, 0.8f, 0.25f, 10);
const float horizontalWheelOffset = 0.2f;
var wheel = new BEPUphysics.Entities.Prefabs.Cylinder(suspensionLeg.Position + new Vector3(leftSide ? -horizontalWheelOffset : horizontalWheelOffset, -suspensionLeg.HalfHeight, 0), .2f, .3f, 5f);
GameObject3D modelForWheel = new GameObject3D(new FileModel("wheelRim"), new BlinnPhong { DiffuseColor = new Color(30, 30, 30), SpecularIntensity = 0.3f, SpecularPower = 200 });
var wheelEntity = (RigidBody)modelForWheel.AddComponent<RigidBody>();
wheelEntity.Entity = wheel;
wheel.CollisionInformation.LocalPosition = wheel.Position;
wheel.Material.KineticFriction = 2.5f;
wheel.Material.StaticFriction = 2.5f;
wheel.Orientation = Quaternion.CreateFromAxisAngle(Vector3.Forward, MathHelper.PiOver2);
Code: Select all
modelForWheel.Transform.Rotate(new Vector3(0, 0, 90), Space.Local);