raycast wheels

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
slickyrich*
Posts: 17
Joined: Thu Aug 12, 2010 5:58 am

raycast wheels

Post by slickyrich* »

Hi Whats the safest/best way to apply the wheel models without using the BEpuPhysicsDrawer???
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: raycast wheels

Post 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.
slickyrich*
Posts: 17
Joined: Thu Aug 12, 2010 5:58 am

Re: raycast wheels

Post by slickyrich* »

thanks very much..another quick question: how do I link the wheel model itself the the engines wheel information?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: raycast wheels

Post by Norbo »

I'm not sure what you mean- the WorldTransform is the only real information needed to link it up.
slickyrich*
Posts: 17
Joined: Thu Aug 12, 2010 5:58 am

Re: raycast wheels

Post 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.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: raycast wheels

Post 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.
slickyrich*
Posts: 17
Joined: Thu Aug 12, 2010 5:58 am

Re: raycast wheels

Post by slickyrich* »

thanks Norbo :)
slickyrich*
Posts: 17
Joined: Thu Aug 12, 2010 5:58 am

Re: raycast wheels

Post by slickyrich* »

result
result
XDE 2010-10-21 12-18-28-08.jpg (53.16 KiB) Viewed 8041 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.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: raycast wheels

Post 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.
slickyrich*
Posts: 17
Joined: Thu Aug 12, 2010 5:58 am

general questions on vehicles physics

Post 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: )
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: raycast wheels

Post 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).
Post Reply