Bullet on XNA
-
- Posts: 8
- Joined: Wed Feb 09, 2011 5:48 pm
Re: Bullet on XNA
Thx for the answer anthrax11.
Btw, soft bodies work? And cloths?
And it's possible to use it with XNA 4.0 (and so with VS2010)??
Btw, soft bodies work? And cloths?
And it's possible to use it with XNA 4.0 (and so with VS2010)??
-
- Posts: 72
- Joined: Wed Feb 24, 2010 9:49 pm
Re: Bullet on XNA
Yes, soft bodies work and XNA 4.0 and VS 2010 are supported. There's a separate release for .NET 4.0.
I have also got cloth working, but there seem to be some driver issues or something and it doesn't seem to work all of the time. Bullet's GPU branch is being worked on though, so I'm keeping an eye on it to see what I might be doing wrong.
I have also got cloth working, but there seem to be some driver issues or something and it doesn't seem to work all of the time. Bullet's GPU branch is being worked on though, so I'm keeping an eye on it to see what I might be doing wrong.
-
- Posts: 8
- Joined: Wed Feb 09, 2011 5:48 pm
Re: Bullet on XNA
Cool, i will try it =Danthrax11 wrote:Yes, soft bodies work and XNA 4.0 and VS 2010 are supported. There's a separate release for .NET 4.0.
I have also got cloth working, but there seem to be some driver issues or something and it doesn't seem to work all of the time. Bullet's GPU branch is being worked on though, so I'm keeping an eye on it to see what I might be doing wrong.
Thx for the help, if any news come out for cloths, let me know please.
-
- Posts: 8
- Joined: Wed Feb 09, 2011 5:48 pm
Re: Bullet on XNA
Btw, anthrax11, i was seeing your demos and one question show up.
Sorry if it's a silly question but i never worked before with bullet so i don't understand if this is bullet's problem or something.
For models in XNA, and using them in bullet, i need to have vertices and indeces? I saw, for example, bunny meshes, and you define them as vertices and indeces. Any model i want to use with bulletsharp is defined this way?
My question is, i want to use some models i have in blender and so i could export them as .fbx and import them in XNA. Can I in anyway use these models in bulletsharp?
Hope you can help,
Viperboy.
Edit: Sorry, i already saw that is possible to import .bullet files (as in bullet is) but i want to know how i can export from bullet those files? I already google it and i found out the "patch -p0 < blabla.patch" for making blender able to export them, but i was not able to do it. Can you explain me how i can export .bullet files?
And what data those files have?
Sorry if it's a silly question but i never worked before with bullet so i don't understand if this is bullet's problem or something.
For models in XNA, and using them in bullet, i need to have vertices and indeces? I saw, for example, bunny meshes, and you define them as vertices and indeces. Any model i want to use with bulletsharp is defined this way?
My question is, i want to use some models i have in blender and so i could export them as .fbx and import them in XNA. Can I in anyway use these models in bulletsharp?
Hope you can help,
Viperboy.
Edit: Sorry, i already saw that is possible to import .bullet files (as in bullet is) but i want to know how i can export from bullet those files? I already google it and i found out the "patch -p0 < blabla.patch" for making blender able to export them, but i was not able to do it. Can you explain me how i can export .bullet files?
And what data those files have?
-
- Posts: 72
- Joined: Wed Feb 24, 2010 9:49 pm
Re: Bullet on XNA
Yeah, if you can load your model to an XNA Model object, then I imagine you could access the IndexBuffers and VertexBuffers, read the floats and remove things like normals and texture coordinates from the vertex stream and feed those ints and floats to the TriangleIndexVertexArray.
For loading .bullet files, check the SerializeDemo for SlimDX.
For loading .bullet files, check the SerializeDemo for SlimDX.
-
- Posts: 8
- Joined: Wed Feb 09, 2011 5:48 pm
Re: Bullet on XNA
My question is, do you know how to export from blender .bullet files? I try and try, but i'm not capable :S
-
- Posts: 225
- Joined: Wed Jan 07, 2009 11:43 am
- Location: London
Re: Bullet on XNA
Speaking of a managed version of Bullet I've finally got round to putting the one I'd been tinkering with up on google code :
http://code.google.com/p/bullet-xna/
It's based on 2.76 with a few fixes from 2.77. It's missing Softbody and Serialisation support at the moment. It does work on the pc and the xbox, using XNA 4.0.
Would be happy to get any feedback / issues etc.
http://code.google.com/p/bullet-xna/
It's based on 2.76 with a few fixes from 2.77. It's missing Softbody and Serialisation support at the moment. It does work on the pc and the xbox, using XNA 4.0.
Would be happy to get any feedback / issues etc.
-
- Posts: 72
- Joined: Wed Feb 24, 2010 9:49 pm
Re: Bullet on XNA
Awesome! I'll try it and see if I can contribute something, maybe even softbodies.
I wonder if there is any reasonable way to make this compatible with other libraries like OpentTK since a fully managed Bullet would be very appealing to Linux/Mono/OpenGL developers.
I wonder if there is any reasonable way to make this compatible with other libraries like OpentTK since a fully managed Bullet would be very appealing to Linux/Mono/OpenGL developers.
-
- Posts: 12
- Joined: Sat Sep 19, 2009 12:44 pm
Re: Bullet on XNA
Just a FYI, it seems to work with monoxna if you hack out the XNA references in the csproj files.
http://code.google.com/p/monoxna/
Mind you, I compiled a 'lite' version monoxna with just the classes needed for bullet-xna.
I've put in a few bug reports on the google code page.
Issue 1:Collision with the HeightfieldTerrainShape and CapsuleShapeZ objects never clears,
Issue 2:Missing GImpactMeshShape and GImpactCollisionAlgorithm,
Issue 3:CollisionObject missing function "Vector3 GetInterpolationLinearVelocity(void)"
I also supplied a patch to issue 3.
(FYI)I wrote an Object Oriented C# binding to the native bullet ages ago based on the bullet API that had most things implemented but it was extremely tough to use in C# because it implemented IDisposable. I'm using the programs that I wrote with that to compare against BulletXNA.
http://code.google.com/p/monoxna/
Mind you, I compiled a 'lite' version monoxna with just the classes needed for bullet-xna.
I've put in a few bug reports on the google code page.
Issue 1:Collision with the HeightfieldTerrainShape and CapsuleShapeZ objects never clears,
Issue 2:Missing GImpactMeshShape and GImpactCollisionAlgorithm,
Issue 3:CollisionObject missing function "Vector3 GetInterpolationLinearVelocity(void)"
I also supplied a patch to issue 3.
(FYI)I wrote an Object Oriented C# binding to the native bullet ages ago based on the bullet API that had most things implemented but it was extremely tough to use in C# because it implemented IDisposable. I'm using the programs that I wrote with that to compare against BulletXNA.
-
- Posts: 1
- Joined: Mon Jul 06, 2009 8:14 pm
Re: Bullet on XNA
Who is currently coordinating the development of the managed version of the C# version of Bullet PE. Do to my need and love of the engine, I would like to invest my time bringing this project back to life. Please contact me if you would like to collaborate.
-
- Posts: 51
- Joined: Tue Dec 11, 2012 9:59 pm
Re: Bullet on XNA
So... is the freeze on soft bodies because they keep btVector3& 's? or in your case IndexedVertex3...
You know you can add an interface IIndexVector3 which supplies all the methods (except the operators) and use that to keep a reference to a struct?
Have to change operators to methods; which I highly recommend anyway because even the latest JIT doesn't do well optimizing operators.
You know you can add an interface IIndexVector3 which supplies all the methods (except the operators) and use that to keep a reference to a struct?
Have to change operators to methods; which I highly recommend anyway because even the latest JIT doesn't do well optimizing operators.
-
- Posts: 225
- Joined: Wed Jan 07, 2009 11:43 am
- Location: London
Re: Bullet on XNA
No particular reason for lack of softbody work - just didn't get round to it at the time.
Would be interesting to look at the conversion of operators to methods, wasn't particularly aware at the time of the performance differences for them. Does move a bit away from trying to make things 'match' the c++ bullet code but would be worth it.
Would be interesting to look at the conversion of operators to methods, wasn't particularly aware at the time of the performance differences for them. Does move a bit away from trying to make things 'match' the c++ bullet code but would be worth it.
-
- Posts: 51
- Joined: Tue Dec 11, 2012 9:59 pm
Re: Bullet on XNA
Array's are always range checked also; moving away from arrays is another performance boost.xexuxjy wrote: Would be interesting to look at the conversion of operators to methods, wasn't particularly aware at the time of the performance differences for them. Does move a bit away from trying to make things 'match' the c++ bullet code but would be worth it.
I started to make some unit-test sort of things; but when I checked the same code for this version vs current git version; found they diverged significantly quickly. the basic solver loop has changed significantly. (even things like gravity are applied in a different place... the same drop from 50 at the same frame it should have it (height 1) XNA still had the cube at 3.5 something... first checked defaults like gravity and they were the same; but tracking back where gravity was applied found the code was significantly different between 2012/13 and now.
My current port matches pretty well... but trying to make it more exact (after 211 frames of 300 it starts to diverge... should enable debug drawing so I can see what they think. It's not in a repository of its own; but the WIP is at -deleted-; when I get it closer to bullet original behavior I'll make a separate repo for it... I wish there was a low-impact way to make a btScalar sort of type to switch between float/double; though can pretty much do a project-wide find/replace for double->float.
I know that support vertexes are used for GJK sort of calculations... but are you familiar with what 'support vertex' really means? Such as... the convex-static plane constraint algorithm finds basically one corner of a cube that hits a surface, which ends up applying all correction force at that point... which results in the origin being able to go 40% into the plane before it settles out... (a 2x2x2 cube with center 1,1,1 goes to 0.62 before resolving entirely... and it stays that deep for 4 or 5 processing frames) It's more work certainly, but finding all points that penetrated and doing a weighted average of those ( weighted by depth) as a resulting point I would think would make more sense; but then that would probably have to be a different calculation than what local support is returning? my test-001 is a cube that falls from fairly high onto a flat plane... so the cube would actually hit the ground face-down and in a mathematically perfect should bounce straight back up; picking a single corner of course results in a more 'real' result because a cube (a die) would never hit face down because of air disturbances etc... but; it's also not a good place to apply the correction impulse.
There's also a large amount of code that I haven't had to touch at all for a basic simulation; or for the core system... where do I find more information on what 'featherstone' and 'gimpact' and 'MLCPSolvers' are for? (oh guess I should do more searching http://box2d.org/files/GDC2014/ErwinCou ... rstone.pdf for instance answers those things)
Sorry I'm just kinda rambling a little
![Smile :)](./images/smilies/icon_smile.gif)
Test 2 is a sphere dropping - it doesn't penetrate as much
test 3 is a box dropping, but a sphere sitting on the ground where it would hit first (0.25,0.25 offset from center with bodies of radius/halfextent 1)
test 4 is the sphere dropping...
I dunno maybe I shouldn't worry about the few decimal points of difference for now and move on to testing things like hinges
Last edited by d3x0r on Thu Dec 03, 2015 8:16 pm, edited 1 time in total.
-
- Posts: 51
- Joined: Tue Dec 11, 2012 9:59 pm
Re: Bullet on XNA
re: Interfaces to track structs; I was wrong. Unfortunately casting a struct to its interface makes a unique boxed instance of the value-type.
really trying very hard to not leverage 'unsafe'.
Oh and C++ (using vs2015) ends up allowing -0 which is reresentable with floats/double format as 0x80000000 ... I fixed most issues by changing invert (unary negative operator) to return 0-vector.X instead of just -vector.X (C++). but the predicted transform and interpolated transforms still end up with -0's. All other decimals are tracking now... working on compound bodies.
Not sure why there's not just a simple utility function in btCompoundShape::setCenterOfMass() which can automatically just go through all attached shapes and apply a translate to them... (keeping an additional m_centerOfMass vector to apply relative deltas) But I've added it to mine for future use.
Edit: I'm also getting a really strange effect; every once in a while a box falling on another static box throws the first very quickly very far away. It's really bizaare since I"m certian there's nothing uninitalized given C# nature of things... I'm testing with an always-constant time step... the setup of the world is competed before doing a tick on a frame... hard to see anything that would cause a 'sometimes' behavior... it's not like 'random' is used. very strange.
Edit2 : There is something random; GetHashCode() used in sorting objects in the HashedBroadphase PairCache... (moved away from integer offsets in favor of the address of the object itself) Every so often the two objects are reversed....
Collision result is different if proxy0 is a static cube and proxy1 is a dynamic cube vs proxy0 being a dynamic cube and proxy1 being a static cube. The launching velocity resulting impulse was because of a porting error... but now when it lands one way it lands square and stays; the other way the cube lands and rotates slightly. Still have to reverse the test in bullet native to see if it's true. It doesn't matter which way the ID's are compared as long as they are always compared the same in find/add and remove.
really trying very hard to not leverage 'unsafe'.
Oh and C++ (using vs2015) ends up allowing -0 which is reresentable with floats/double format as 0x80000000 ... I fixed most issues by changing invert (unary negative operator) to return 0-vector.X instead of just -vector.X (C++). but the predicted transform and interpolated transforms still end up with -0's. All other decimals are tracking now... working on compound bodies.
Not sure why there's not just a simple utility function in btCompoundShape::setCenterOfMass() which can automatically just go through all attached shapes and apply a translate to them... (keeping an additional m_centerOfMass vector to apply relative deltas) But I've added it to mine for future use.
Edit: I'm also getting a really strange effect; every once in a while a box falling on another static box throws the first very quickly very far away. It's really bizaare since I"m certian there's nothing uninitalized given C# nature of things... I'm testing with an always-constant time step... the setup of the world is competed before doing a tick on a frame... hard to see anything that would cause a 'sometimes' behavior... it's not like 'random' is used. very strange.
Edit2 : There is something random; GetHashCode() used in sorting objects in the HashedBroadphase PairCache... (moved away from integer offsets in favor of the address of the object itself) Every so often the two objects are reversed....
Collision result is different if proxy0 is a static cube and proxy1 is a dynamic cube vs proxy0 being a dynamic cube and proxy1 being a static cube. The launching velocity resulting impulse was because of a porting error... but now when it lands one way it lands square and stays; the other way the cube lands and rotates slightly. Still have to reverse the test in bullet native to see if it's true. It doesn't matter which way the ID's are compared as long as they are always compared the same in find/add and remove.
-
- Posts: 225
- Joined: Wed Jan 07, 2009 11:43 am
- Location: London
Re: Bullet on XNA
I avoided unsafe as at the time I wanted it to work on the 360 as well, so unsafe wasn't an option. Was very tempted at times to try with a separate unsafe branch as well though.
Surprised that the hash is showing up with occasional randoms, internalAddPair should swap proxy0 and proxy1 if necessary to enforce consistent ordering.
Surprised that the hash is showing up with occasional randoms, internalAddPair should swap proxy0 and proxy1 if necessary to enforce consistent ordering.