Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Bullet Physics / DBPro Tech Demo

Author
Message
Todd Riggins
21
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 8th Nov 2010 18:32 Edited at: 4th Dec 2010 20:09
Show & Tell Time

edit: image deleted

I have been working on a Bullets Physics Library wrapper and have attached a zipped .exe of it working with DBPro. I'm using the latest Bullet 2.77 Physics SDK to make the wrapper dll from.

My plans are doing more than just doing a physics wrapper. But, I am stuck at the moment with the bullet physics because of two little problems that's pestering me.

First, as you can see in the picture above, the text output is suppose to show the x,y,z locations of each rigidbody box. Somehow when I apply the motionstate's trans matrix to the dbpro object, it positions and rotates the box perfectly, but I then no longer able to get the dbpro commands to report the x,y,z locations.

Second, because of directly applying the physic's matrix to the dbpro's object, somehow the culling of the object's gets all mucked up when moving the camera around. Thus, I have the attached example to show what I mean.

* I'm getting familiar with the DBPro Open Source Code from Google Code. Even though obviously different, I'm trying to look at the implemented ODE Physics on how it deals with updating DBPro objects. It's like I need to update other internal dbpro structures to be able to get this fix'd...

* use W,A,S,D to move around and press the right mouse button to rotate the camera. Esc to end program.

* I do plan on having this physics library itself for free.
Here's the code for this program to look at. The current physic command list at top of it. The dlls I use are not publicly available yet.



ExoDev.Com - A Game Development Community Website! Featuring: XBOX360 CONTROLLER LIBRARY
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 8th Nov 2010 19:10
Nice work! Be great to see this one get finished!!

Matty H
17
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 8th Nov 2010 19:46
Here is some code to update your object and keep euler angles intact, it is slower than updating the matrix directly but as far as I know all the dark basic physics wrappers do it this way.
Bullet should be able to provide you with the quaternion instead of a matrix, also it should also have a 'clamp' function, if not you should be able to write your own or use one from a math library.



Once you have rotated the object, position the object using the regular 'position object' command, this takes care of the culling.
Good luck.

Todd Riggins
21
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 8th Nov 2010 21:40 Edited at: 8th Nov 2010 21:42
Thanks matty. It almost worked, but when running the example, the dbpro objects start to rotate in the wrong directions.

This most likely would be the cause of me not knowing calculus and not knowing how to convert a right handed system into a left handed coordinate system( In which I gave up my attempt at a DarkPhysics plugin back when ). I'll still have a play at it and see if I can figure what things I need to inverse or what... if I can.

The updated example1b.exe is attached to see what happens.

The code below is the coversion of the code you gave me:


This code below is the current BT_PositionObjectToRigidBody function that call the QuatToEuler above:


ExoDev.Com - A Game Development Community Website! Featuring: XBOX360 CONTROLLER LIBRARY
Todd Riggins
21
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 8th Nov 2010 23:25 Edited at: 8th Nov 2010 23:26
Ok, I found a solution. Here's the new QuatToEuler that I took from here:
GameDev.Net

I have no idea what the difference is and why it works.

I can say this time I merged my old way with this Quat2Euler function by decomposing the matrix I had retrieved in the first way I did it. The D3DXMatrixDecompose function allowed me to do that.

So... I will be pounding out physic functions and hopefully get a version out for people to play with in the wip forum here shortly.

Thanks matty for helping me find a solution!

The new code looks like this:




ExoDev.Com - A Game Development Community Website! Featuring: XBOX360 CONTROLLER LIBRARY

Login to post a reply

Server time is: 2026-07-26 05:03:50
Your offset time is: 2026-07-26 05:03:50