possibilities of BEPU physics

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
J2T
Posts: 48
Joined: Sat Sep 20, 2008 6:20 pm
Contact:

possibilities of BEPU physics

Post by J2T »

Hi Community,

i'm actually writting a litte jump'n'run game and have some questions related to the possibilities of BEPU!

I started my physics or better to say collisionsystem with JigLibX but i'm searching for a new pysiscs engine and found this one!Reason i like to change is the bad documentation, non active community...

With JigLibX is loaded my static map as an TriangleMesh to do collisiondection...so trianglebased!Is there a similar system in this engine?It think so because its state-of-the-art to do static maps so.
Okay with this every thing goes good. I can trow cubes, capusles etc like in your demos...works fine!

But now my problem begin. I need a charactermovement-physik. So my character can collide with fences, walls etc. With a normal capusle/box i had the problem that they are tilting etc. when they collide.
I've read that i can solve such issus(also stairs) with an 'stand-right-up-capsule'. Means a capusle that can never lean or tilting. I've readed that is is possible with raycasting....
Is in BEPU such a capsule?
I quickly saw the character controller maybe this could help me...

And my last question is how easy or not easy is it to write a charactermovement controller. With JigLibX i had big problems to write one with all the forces, impulses etc :lol:

I hope i found the time tommorw to look closer at the demos!The character movement on the terrain looks intersting so far :D

and btw. is in BEPU an diverence between an pysicssystem and collisionsystem?

Thanks for advice!
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: possibilities of BEPU physics

Post by Norbo »

The StaticTriangleGroup can be given a mesh/model/triangle list/vertex buffer + index buffer to create a static map. The initializeData methods which take a Model or Mesh work well in many cases (generally good results with .fbx's), but there are still some cases where using a custom content processor to extract triangle data will be more robust (an example of how to do this can be found in the Picking with Per Triangle Accuracy sample on the xna site).

To keep a capsule from rotating, you could set the localInertiaTensorInverse to Toolbox.zeroMatrix. There are other constraint based methods, but this is the quickest and most direct method. The CharacterController is open source in the demos, so you can take a look at how its set up.

Personally, I found writing the character controller to be a bit of a chore since it's halfway separated from the physics systems, but now that the base is there it should be significantly easier to just extend it to match the desired behaviors.

There is not a well defined line between the collision detection system and the response system, though it would not be impossible. If you have a specific goal in mind, I could outline how you could go about doing it. There are many different collision queries in the Toolbox that can be used independently as well.

Thanks for checking it out!
J2T
Posts: 48
Joined: Sat Sep 20, 2008 6:20 pm
Contact:

Re: possibilities of BEPU physics

Post by J2T »

Hi Norbo,
thanks for your fast reply!

Very nice Playgrounddemo...thats what i need :D
Yes i saw it in the source that your also using the StaticTriangleGroup and a model for the demo!I've not tested today but i think it should work very well we're also using *.fbx!

Yes i also had have problems with an charactercontroller implementation with JigLibX but as i can see you've did a great job so far!I hope i found the time the next few days to go on a deeper view!

I asked because in JigLibX you can use a collisionsystem without physics!So in my old implementation i only used the collisionsystem and not physics. For example i didn't use the gravity and implemented a jump function for my own!But as i can see in your Charactercontroller there is a jump function so maybe i will use this...
So far no specific goal in mind :wink:

btw is there only a grid for space or are there other system like sweep and prune?

And sry perhabs a stupid question related to your xml-doc. How can i view this in a better way then using IE or FireFox?Maybe with VS or another tool?!Sry i'm only using Doxygen for this purposes!

Thanks anyway :D
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: possibilities of BEPU physics

Post by Norbo »

Right now there's just the grid-based methods. If I have time, I hope to get another method implemented in v0.7.0, either based on SAP or something a little more experimental. It's also possible to create a subclass of BroadPhase to create your own if you get the urge :wink:

Currently the .xml documentation is designed as in-code reference through intellisense. Eventually I'm going to revise the website's documentation into the API (from the xml) and a more paradigm based second portion. Until then, you can set up an xml documentation viewer like http://dotnet.jku.at/DocView/.
J2T
Posts: 48
Joined: Sat Sep 20, 2008 6:20 pm
Contact:

Re: possibilities of BEPU physics

Post by J2T »

Thanks for the link!btw. for documentation i can fully recommend doxygen!It's free, nice html view, takes the intellisense comments also, good navigation through classes and there structure and when u want it can export simple uml diagrams :D just a suggestion :mrgreen:

I have a question related to the box and the capsule:
First how could i scale a box with an vector3?Theres is just one float scale in constructCube(). But i like to strech the box and can't use a fixed scale for all directions...
So ie it only works with an Vector3(50,50,50) cuz scale is 50.0f. But not with ie Vector3(25,50,100)

And i have some problems with the capsule...a bit of code could help:

Code: Select all

public Capsule(Vector3 newPosition, float radius, float length, Matrix rotation)
        {
            Position = newPosition;
            Scale = new Vector3(radius, radius, length/2);
            Rotation = Quaternion.CreateFromRotationMatrix(rotation);

            toAddCapsule = new BEPUphysics.Capsule(newPosition, length, radius, 50.0f);
           
            //toAddCapsule.bounciness = 0;
            //toAddCapsule.friction = .3f;
            toAddCapsule.makePhysical(50);
            PhysicsManager.addEntity(toAddCapsule);
            //toAddCapsule.tag = "noDisplayObject"; //Prevent a normal DisplayObject from being created for this entity later.

            zPhereModel boxmodel = new zPhereModel("Content/Models/Capsule");

            ModelManager.AddModel(boxmodel, "capsulemodel");

            this.ModelName = "capsulemodel";
            this.OcclusionModelName = "capsulemodel";
        }
When i use this, the capsule goes always a bit though the ground or ie. collides earlier then it have to. So far not a correct movement!Sure i mean the model/view...physics work correct!
Position,Scale and Rotation are for drawing. I also tested to not devide the lenght in scale through two...no success!

With LigLibX it worked normal but i don't did something else. Also just the radius and lenght!

Code: Select all

_collisionSkin.AddPrimitive(new JigLibX.Geometry.Capsule(Vector3.Transform(Vector3.Zero, rotation), rotation, radius, length),
                                        (int)MaterialTable.MaterialID.UserDefined,
                                        new MaterialProperties(0.8f, 0.7f, 0.6f));
Maybe there is just one thing...the update():

Code: Select all

 Position = toAddCapsule.centerPosition;
            Rotation = toAddCapsule.orientationQuaternion;
In my opinion this is also correct. It works fine for the box too...maybe the centerposition isn't correct for a capsule?!

Thanks for your advice!
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: possibilities of BEPU physics

Post by Norbo »

A box can be created using either the PrimitiveToolbox or the Box's own constructors. The constructCube() method is designed to cut down the parameters for a cube, while the constructors of a box are more general and allow you to specify the length, width, and height.

I suspect you may be encountering the buffered nature of the centerPosition/orientationQuaternion fields. They are updated at the end of a physics engine update. If you want to access the current value, you can directly access it using the internalCenterPosition or internalOrientationQuaternion fields. The reason for the split is timestep interpolation and threading safety.

By the way, when you construct an object using a constructor with mass, you don't need to use makePhysical later.
J2T
Posts: 48
Joined: Sat Sep 20, 2008 6:20 pm
Contact:

Re: possibilities of BEPU physics

Post by J2T »

Thanks for these explanations :D
Post Reply