Page 1 of 1

Bepu Physics with XNA 3.1

Posted: Sun Oct 16, 2011 9:17 am
by Nadeeja
OK so I know that the latest bepu physics version is much better and faster but because of a little issue I had to downgrade to XNA 3.1 and Bepu 0.14. The issue is the need for a render engine that can work with bepu. So I decided to choose Sunburn framework which seems cool and easy. And I downloaded bepu 0.14 and the sunburn framework works good. But I ran into some problems with bepu.

1. there's no Space.ForceUpdater.Gravity in this version. I managed to find this, Space.SimulationSettings.MotionUpdate.Gravity
But it doesn't seem to have any effect. Any help?

2. There's no StaticMesh. any alternatives to that?

Thanks.

Re: Bepu Physics with XNA 3.1

Posted: Sun Oct 16, 2011 7:40 pm
by Norbo
I managed to find this, Space.SimulationSettings.MotionUpdate.Gravity
But it doesn't seem to have any effect. Any help?
If the entities are in the space, have IsAffectedByGravity set to true (it is by default), and are dynamic, it should work.
2. There's no StaticMesh. any alternatives to that?
The StaticTriangleGroup serves the same purpose, though it is less robust and slower than the more recent StaticMesh.

I won't be able to help a whole lot with those old versions, though. Fixes to any bugs you might find won't be made into a hotfix for v0.14.x, but rather incorporated into the latest development version. The source code for those versions isn't available, either. Instead of using really old versions of BEPUphysics, you may want to consider grabbing the source of v1.0.0 and downgrading it to XNA 3.1. If I remember correctly, the only significant change was the TriangleMesh.GetVerticesAndIndicesFromModel convenience method. However, that method isn't vital and is easily replaced by another vertex extraction method (there are some XNA 3.1 approaches floating around the web, or you could a custom build-time content processor to do it like in the triangle picking sample on the XNA site.

Re: Bepu Physics with XNA 3.1

Posted: Thu Oct 27, 2011 2:06 pm
by Nadeeja
Hey Norbo thanks for replying and sorry for the late reply. I didn't have any time to get my hands on the game.
consider grabbing the source of v1.0.0 and downgrading it to XNA 3.1
Thanks for the suggestion.But I don't know what you mean... I'm kind of new to these stuff so can you point me in the right direction?
How can I downgrade the source to XNA 3.1?

Thanks.

Re: Bepu Physics with XNA 3.1

Posted: Thu Oct 27, 2011 6:44 pm
by Norbo
The primary source download (available here: http://bepuphysics.codeplex.com/SourceC ... changesets) is just a regular old solution full of XNA projects. Since some project structure data may have changed between XNA 3.1 and XNA 4.0 and you aren't interested in downgrading the demos, the easiest method is probably to take the BEPUphysics library source code, drag it into an XNA 3.1 project (you can pull a whole file and folder structure from windows explorer into the Visual Studio project), and try to compile. Don't try to downgrade the BEPUphysicsDemos project- there will be numerous problems since it includes rendering.

There will be some errors. For all the TriangleMesh.GetVerticesAndIndicesFromModel methods and their helpers, you'll have to just comment them out, delete them, or downgrade them manually to XNA 3.1 since they work on XNA 4.0 Models and VertexBuffer. These methods are not fundamentally needed by the engine. They are just convenience helpers that can be replaced by a content processor, like the one in the Picking with Triangle Accuracy sample on the main XNA site.

Re: Bepu Physics with XNA 3.1

Posted: Fri Oct 28, 2011 6:26 am
by Nadeeja
Thanks for the reply.

So if I understood correctly, I should create a new XNA 3.1 game and drag and drop the content of BepuPhysics(from the source) to the solution explorer?

I did that and encountered some errors.I managed to resolve some of them.

But there's these errors -

The type or namespace name 'CollisionPair' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Nadeeja\Desktop\Bepu Source\BepuPhysics\BepuPhysics\Constraints\Collision\Testing\SlidingFrictionTwoAxisObsolete.cs

The type or namespace name 'Contact' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Nadeeja\Desktop\Bepu Source\BepuPhysics\BepuPhysics\Constraints\Collision\Testing\ContactPenetrationConstraintDETester.cs


I failed to find the appropriate using directive to resolve this error...

When I tried right click - resolve - using BEPUphysics.CollisionTests it gave me like an additional 20 errors.

I greatly appreciate your help.

Re: Bepu Physics with XNA 3.1

Posted: Fri Oct 28, 2011 6:34 am
by Norbo
So if I understood correctly, I should create a new XNA 3.1 game and drag and drop the content of BepuPhysics(from the source) to the solution explorer?
An XNA game library, but yes.
But there's these errors -
I forgot about those. There's some files in the project which have compilation turned off. You can safely delete files in any folder named Testing or Tests in the library, or you can select them and right click and change their build action to None instead of Compile.

Re: Bepu Physics with XNA 3.1

Posted: Fri Oct 28, 2011 6:45 am
by Nadeeja
wow thanks for the quick reply!

Did exactly as you told and everything's fine except for one error -

'System.Threading.Thread' does not contain a definition for 'Yield' C:\Users\Nadeeja\Desktop\Bepu Source\Library\BepuSource\BepuSource\Threading\SpinLock.cs

Any idea?

Thank you so much for your help! :D

Re: Bepu Physics with XNA 3.1

Posted: Fri Oct 28, 2011 6:53 am
by Norbo
Thread.Yield seems to be only available in .NET 4.0. It should be possible to force the project to target .NET 4.0 instead by going into the project's properties and fiddling around- unless there is some sort of odd restriction built in.

Re: Bepu Physics with XNA 3.1

Posted: Fri Oct 28, 2011 7:28 am
by Nadeeja
I saw this in the code

Code: Select all

#if WINDOWS
                Thread.Yield();
#else
                Thread.Sleep(0);
#endif
So I just replaced Thread.Yield with Thread.Sleep(0) and it compiled(at last!). Don't know if It'll cause problems later though...

Anyway Thanks for all the help Norbo! :D

I love this engine :)

Re: Bepu Physics with XNA 3.1

Posted: Sun Oct 30, 2011 9:10 am
by Nadeeja
Hey Norbo,

I tried compiling the ModelDrawer Source with XNA 3.1 and it also had many errors. Is it possible to do this? If not is there a way to display the collision meshes ?

Thanks.

Re: Bepu Physics with XNA 3.1

Posted: Sun Oct 30, 2011 6:25 pm
by Norbo
Unfortunately, there does not exist a 3.1 version of the renderer which works with v1.0.0. The old version would have compatibility problems with the engine, and as you've seen, XNA 4.0 changed a lot of rendering code so rendering isn't easily downgraded.

Fortunately, you can just use regular old Models or your own system to display the data. If you want to use the same shape vertex/index creation methods as the ModelDrawer, you can go into the source and find the various entity graphics builder methods (under Models/Display Types/Entity Types).

Also, it might be easy enough to downgrade the BruteModelDrawer since it's a lot simpler than the InstancedModelDrawer (though the ModelDrawer would still need to be downgraded).