Page 1 of 1

raycast wheels

Posted: Wed Oct 20, 2010 5:22 pm
by slickyrich*
Hi Whats the safest/best way to apply the wheel models without using the BEpuPhysicsDrawer???

Re: raycast wheels

Posted: Wed Oct 20, 2010 5:55 pm
by Norbo
Each wheel has a WorldTransform. Anything that can draw a mesh will work- just use the wheels' WorldTransforms to position it. The engine's job is just to spit out the updated WorldTransforms and it doesn't care how they get used.

Re: raycast wheels

Posted: Wed Oct 20, 2010 7:52 pm
by slickyrich*
thanks very much..another quick question: how do I link the wheel model itself the the engines wheel information?

Re: raycast wheels

Posted: Wed Oct 20, 2010 8:26 pm
by Norbo
I'm not sure what you mean- the WorldTransform is the only real information needed to link it up.

Re: raycast wheels

Posted: Wed Oct 20, 2010 8:34 pm
by slickyrich*
when I ran my project it was just one wheel model at the origin. How can I link Vehicle.Wheels[k](of the physics engine) to Model wheelModel(of xna graphics) because it seems the wheelModel is not using the vehicle.wheel properties I assigned to it.

Re: raycast wheels

Posted: Wed Oct 20, 2010 8:40 pm
by Norbo
Ensure that the WorldTransforms are actually being used each frame as the vehicle moves around. It can't be just set once, since that would just grab the starting position (which may be Vector3.Zero if the update hasn't run yet).

This is a rendering related issue, though. I'd recommend just simplifying the problem a bit and focusing on getting the basic rendering working before trying to pull the physics into it.

Re: raycast wheels

Posted: Wed Oct 20, 2010 8:59 pm
by slickyrich*
thanks Norbo :)

Re: raycast wheels

Posted: Thu Oct 21, 2010 4:29 pm
by slickyrich*
result
result
XDE 2010-10-21 12-18-28-08.jpg (53.16 KiB) Viewed 8042 times
so I got all for wheels rendered with this code

Code: Select all

switch (tireNum)
            {
                case FR:
                    wheelGraphicRotation = Matrix.CreateRotationY(0);
                    wheelTranslation = Matrix.CreateTranslation(62f, 27.5f, 117.9f);
                    wheelWorldMatrix = wheelGraphicRotation * wheelTranslation;
                    
                    break;
                case FL:
                    wheelGraphicRotation = Matrix.CreateRotationY((float)Math.PI);
                    wheelTranslation = Matrix.CreateTranslation(-62f, 27.5f, 117.9f);
                    wheelWorldMatrix = wheelGraphicRotation * wheelTranslation;
                    
                    break;
                case BR:
                    wheelGraphicRotation = Matrix.CreateRotationY(0);
                    wheelTranslation = Matrix.CreateTranslation(62f, 27.5f, -107.1f);
                    wheelWorldMatrix = wheelGraphicRotation * wheelTranslation;
                   
                    break;
                case BL:
                    wheelGraphicRotation = Matrix.CreateRotationY((float)Math.PI);
                    wheelTranslation = Matrix.CreateTranslation(-62f, 27.5f, -107.1f);
                    wheelWorldMatrix = wheelGraphicRotation * wheelTranslation;
                    
                    break;

            }
            
            return wheelWorldMatrix;
but they dont seem to obey the laws of the physics engine what I'm i doing wrong? Can you just show me one example of how I can apply physics to each wheel using the above matrices. I attached a picture of my result.

Re: raycast wheels

Posted: Thu Oct 21, 2010 4:41 pm
by Norbo
Now that you have something actually drawing with different matrices, you just need to use the wheel's WorldTransform.

Examine the BEPUphysicsDemos source's VehicleInput and its usage of the DisplayModel class for an example. Note its initialization and its update process.

general questions on vehicles physics

Posted: Thu Oct 21, 2010 8:36 pm
by slickyrich*
i really think Bepu should post up some documentation on how to use the vehicles physics for the newbies. It is promising but I just dont get it..Is the BebuPhysicsDrawer necessary? becasue the only way to get a models worldtransform is through the ModelDrawer. I tried using the BebuPhysicsDrawer to draw the wheels but it still wouldnt work, I got errors saying "GraphicsDevice component not found". Is there anyway to render without using the BebuPhysicsDrawer? I really need help. There seems to be alot of people who have had success with it so somebody pls help. an example can help(share the knowledge to the less knowledgeable :wink: )

Re: raycast wheels

Posted: Thu Oct 21, 2010 9:44 pm
by Norbo
The WorldTransform that you should be grabbing is that of the WheelShape, which belong to the Wheels of the Vehicle.

BEPUphysics has no dependency on any rendering system. The BEPUphysicsDrawer is completely separate from BEPUphysics itself. It is just a simple debugging/physics visualization system and should not be used as an actual 'graphics engine' for a game.

BEPUphysics doesn't care how you use the information it provides. It just provides the physical information and leaves it up to the user to do something using that physical information.

While having some more Vehicle documentation would be desirable, this problem is related to rendering and not the Vehicle itself. I strongly recommend working out and understanding the rendering issues completely first. Once that is done, it should be easier to see how the vehicle plugs in (by supplying the world transforms to the rendering system).