Custom car fbx model

Discuss any questions about BEPUphysics or problems encountered.
Danthekilla
Posts: 136
Joined: Sun Jan 17, 2010 11:35 am

Re: Custom car fbx model

Post by Danthekilla »

As norbo has said the rendering system in bepu is pretty much for debugging physics only.
You need to go to the xna website and download the chase camera which will should you how to make a proper working camera and render models using xna.

Once you have that you can then add bepu physics to that project with ease. But just remember that 3d physics are not an easy task (expessially cars etc...) to add to a game.
slickyrich*
Posts: 17
Joined: Thu Aug 12, 2010 5:58 am

Re: Custom car fbx model

Post by slickyrich* »

thanks man...Debugging is exacting what i want to do. I already have a debug camera the only problem i'm having now is to resolve the entity.worldmatrix. I get this message System.NullReferenceException was unhandled Message=NullReferenceException at the "worldmatrix" line

Code: Select all

 public Car(Game game, Vector3 position)
        {
            worldMatrix = entity.WorldTransform * offsetTransform;
when I debug.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Custom car fbx model

Post by Norbo »

If it is happening on that line, it means the entity reference you're using is null. Make sure it actually receives a value before it gets used.

Usually, I or others will refer people to the BEPUphysics forums for help with the actual physics engine since it's a specialized topic. However, other places are much better for learning C# or game development in general. Also, learning game development at the same time as a 3d physics engine might be a little tricky :)
slickyrich*
Posts: 17
Joined: Thu Aug 12, 2010 5:58 am

Re: Custom car fbx model

Post by slickyrich* »

so what kind of values does entity receive?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Custom car fbx model

Post by Norbo »

The field 'entity' refers to some Entity object, or null. If it is never assigned to an actual object of type Entity, it will refer to null. If the field is used while referring to null, you get a null reference exception.

This is a pretty simple programming problem. If you narrow your scope a bit so that you take one step at a time, the learning process would be a lot easier.
henners
Posts: 1
Joined: Thu Mar 31, 2011 4:55 pm

Re: Custom car fbx model

Post by henners »

Hey, I have a related question:

I got the wheels to render in their correct locations and with the help of the physicsDemos got the back 2 to start spinning, but they do it in the wrong direction, perpendicular to the car.

Code I used to create the wheels,:

Code: Select all

  Matrix wheelGraphicRotation = Matrix.CreateFromAxisAngle(Vector3.Forward, MathHelper.PiOver2);
            car.AddWheel(new Wheel(
                new RaycastWheelShape(.375f, wheelGraphicRotation),
                new WheelSuspension(2000, 100f, Vector3.Down, .8f, new Vector3(-1.8f, 0.5f, 1f)),
                new WheelDrivingMotor(2.5f, 30000, 10000),
                new WheelBrake(1.5f, 2, .02f),
                new WheelSlidingFriction(4, 5)));
            car.AddWheel(new Wheel(
                new RaycastWheelShape(.375f, Matrix.CreateRotationY(MathHelper.Pi)),
                new WheelSuspension(2000, 100f, Vector3.Down, .8f, new Vector3(-1.8f, 0.5f, -1f)),
                new WheelDrivingMotor(2.5f, 30000, 10000),
                new WheelBrake(1.5f, 2, .02f),
                new WheelSlidingFriction(4, 5)));
            car.AddWheel(new Wheel(
                new RaycastWheelShape(.375f, wheelGraphicRotation),
                new WheelSuspension(2000, 100f, Vector3.Down, .8f, new Vector3(1.8f, 0.5f, 1f)),
                new WheelDrivingMotor(2.5f, 30000, 10000),
                new WheelBrake(1.5f, 2, .02f),
                new WheelSlidingFriction(4, 5)));
            car.AddWheel(new Wheel(
                new RaycastWheelShape(.375f, Matrix.CreateRotationY(MathHelper.Pi)),
                new WheelSuspension(2000, 100f, Vector3.Down, .8f, new Vector3(1.8f, 0.5f, -1f)),
                new WheelDrivingMotor(2.5f, 30000, 10000),
                new WheelBrake(1.5f, 2, .02f),
                new WheelSlidingFriction(4, 5)));
Also I know this isn't what this forum is for, but if you could help me it would be nice; my models are too small for the terrain I've created. I've tried using Matrix.CreateScale() to scale the worldMatrix on each mesh, but nothing happens.

Thanks in advance, and thanks for the engine.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Custom car fbx model

Post by Norbo »

but they do it in the wrong direction, perpendicular to the car.
It sounds like the local graphic transform is just incorrect. The purpose of the local transform is to get some arbitrary model (which could be set up in any way) to match the local space transform of the 'real' wheel. If it doesn't actually match the local space shape, it will spin in incorrect ways.

If you want a make a wheel that drives in a different direction, change the wheel's LocalForwardDirection.
my models are too small for the terrain I've created. I've tried using Matrix.CreateScale() to scale the worldMatrix on each mesh, but nothing happens.
If nothing happens, then the transform was applied either to the wrong thing or at the wrong time. Make sure it's not being overwritten later. Follow the execution from your initial transformation through until it draws wrong and analyze each step to see if it matches your expectations. If it doesn't, then there's a good starting point for further debugging.
Post Reply