Ok, now i will not sleep for 10 days !... unless... you share it, with us!serengeor wrote:Well, I have my own version of this wrapper (...) I have soft body ropes implemented
(C++) Simple Bullet Physics Class/Manager
-
- Competition winner
- Posts: 117
- Joined: Wed Jun 30, 2010 8:44 am
- Location: Portugal
- Contact:
Re: (C++) Simple Bullet Physics Class/Manager
Re: (C++) Simple Bullet Physics Class/Manager
Hm, my implementation is not ideal, I had to hack it a bit to get it to work (because of a way my wrapper works).jorgerosa wrote:Ok, now i will not sleep for 10 days !... unless... you share it, with us!serengeor wrote:Well, I have my own version of this wrapper (...) I have soft body ropes implemented
If you need it I can try to make it work with irrlicht without my framework, though it might take a day or two to get me working on it
Working on game: Marrbles (Currently stopped).
Re: (C++) Simple Bullet Physics Class/Manager
I have made it to work it with irrlicht only but I still need to test it a bit, add some helper functions and make the code a bit cleaner
Maybe you need some more features I should add to it?
Maybe you need some more features I should add to it?
Working on game: Marrbles (Currently stopped).
-
- Competition winner
- Posts: 117
- Joined: Wed Jun 30, 2010 8:44 am
- Location: Portugal
- Contact:
Re: (C++) Simple Bullet Physics Class/Manager
Thanks for your efforts serengeor, you are awesome, man!... As always!...
In fact I´ve been working hard too on that stuff, this code is what i achived until now (from others code all over the forums and the internet). And guess what?... Its works 100%! No issues with that.
What this code snippet does: Gets all nodes from an array, and "converts" all that nodes to bullet world physics... Simple! Perfect for me!
And it works with lattest irrlicht 1.7.2 and bullet 2.7.8 versions!
Now... I wanted more... It works great with all static nodes and animated nodes too.......
...BUT!... Only the physics dont follow the animated irrlicht nodes... They keep static in place where they where created, and if node is moved... they dont follow. (Since my english is bad, almost as your guys code... ...i will post all my code there, with my comments, so any improvements on it would be great, so we could have an handy complete "code snippet" to use now, and in future, when using simple bullet stuff in irrlicht).
Again, if i have no help on this... no worries... I´ll find a solution and post it here asap.
MUSTS:
• BASED MAINLY (BETWEEN MANY OTHERS CODE SNIPPETS AROUND THERE) ON THIS CODE:
http://www.bulletphysics.org/Bullet/php ... f=9&t=2756
• BULLET DEBUGGER FOR IRRLICHT: (To see the physics in the irrlicht render)
http://irrlicht.sourceforge.net/forum/v ... hp?t=38289
EDIT1: im trying to add my code, to this post, but when i do it, sourceforge.net, gives a 500 SERVER INTERNAL ERROR !!!..
EDIT2: Added. The above issue only happens, when i add the <CODE> tags in this post.... odd... ok, lets move forward anyway...
In fact I´ve been working hard too on that stuff, this code is what i achived until now (from others code all over the forums and the internet). And guess what?... Its works 100%! No issues with that.
What this code snippet does: Gets all nodes from an array, and "converts" all that nodes to bullet world physics... Simple! Perfect for me!
And it works with lattest irrlicht 1.7.2 and bullet 2.7.8 versions!
Now... I wanted more... It works great with all static nodes and animated nodes too.......
...BUT!... Only the physics dont follow the animated irrlicht nodes... They keep static in place where they where created, and if node is moved... they dont follow. (Since my english is bad, almost as your guys code... ...i will post all my code there, with my comments, so any improvements on it would be great, so we could have an handy complete "code snippet" to use now, and in future, when using simple bullet stuff in irrlicht).
Again, if i have no help on this... no worries... I´ll find a solution and post it here asap.
MUSTS:
• BASED MAINLY (BETWEEN MANY OTHERS CODE SNIPPETS AROUND THERE) ON THIS CODE:
http://www.bulletphysics.org/Bullet/php ... f=9&t=2756
• BULLET DEBUGGER FOR IRRLICHT: (To see the physics in the irrlicht render)
http://irrlicht.sourceforge.net/forum/v ... hp?t=38289
EDIT1: im trying to add my code, to this post, but when i do it, sourceforge.net, gives a 500 SERVER INTERNAL ERROR !!!..
EDIT2: Added. The above issue only happens, when i add the <CODE> tags in this post.... odd... ok, lets move forward anyway...
Code: Select all
// Irrlicht stuff: #include "irrlicht.h" // Declare Used Namespaces: using namespace irr; using namespace core; using namespace video; using namespace scene; using namespace io; using namespace gui; // Bullet stuff: #include "btBulletCollisionCommon.h" #include "btBulletDynamicsCommon.h" btDiscreteDynamicsWorld *bWorld; ....... ....... ....... int main(int argc, char** argv){ ....... ....... ....... /// Adding Static nodes: scene::IMeshSceneNode* nodeA = smgr->addMeshSceneNode(smgr->getMesh("floor.obj")); scene::IMeshSceneNode* nodeB = smgr->addMeshSceneNode(smgr->getMesh("buildings1.obj")); scene::IMeshSceneNode* nodeC = smgr->addMeshSceneNode(smgr->getMesh("buildings2.obj")); scene::IMeshSceneNode* nodeD = smgr->addMeshSceneNode(smgr->getMesh("rocks.obj")); scene::IMeshSceneNode* nodeE = smgr->addMeshSceneNode(smgr->getMesh("trees.obj")); /// Adding Dynamic nodes: // IAnimatedMeshSceneNode: scene::IAnimatedMeshSceneNode* nodeF = smgr->addAnimatedMeshSceneNode(smgr->getMesh("bus_01.md3")); /// MD3 !!! // IMeshSceneNode: scene::IMeshSceneNode* nodeG = smgr->addMeshSceneNode(smgr->getMesh("bus_02.obj")); // Animator: scene::ISceneNodeAnimator* run = 0; run = smgr->createFlyCircleAnimator(core::vector3df(0,0,0),30.0f,0.00041f); nodeG->addAnimator(run); run->drop(); ....... ....... ....... /// ############################################################################################ /// /// BULLET PHYSICS WORLD: /// /// ############################################################################################ /// Bullet: Creating Main Physics World: btDbvtBroadphase* broadphase = new btDbvtBroadphase(); btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration(); btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration); btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver(); bWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration); /// Dynamic world creation bWorld->setGravity(btVector3(0,-9.80665,0)); // Set world gravity /// "CONVERTING" IRRLICHT NODES TO BULLET: "ALL IN ONE CODE" (Sort of...) btTriangleIndexVertexArray* staticVertexArray = new btTriangleIndexVertexArray(); core::array<scene::ISceneNode*> myNodes; /// I want to "add" these nodes to bullet physics world, ok computer? So... just do it! You little #$%$#$%&# ! :evil: myNodes.push_back(nodeA); /// Added Node: Floor myNodes.push_back(nodeB); /// Added Node: Buildings 1 myNodes.push_back(nodeC); /// Added Node: Buildings 2 myNodes.push_back(nodeD); /// Added Node: Rocks myNodes.push_back(nodeE); /// Added Node: Trees myNodes.push_back(nodeF); /// Added Node: Bus 1 (ANIMATED NODE) myNodes.push_back(nodeG); /// Added Node: Bus 2 (ANIMATED NODE) /// ############################################################################################ /// /// "ISSUE": /// All nodes are added, including the animated nodeF and nodeG, to the Bullet physics world, /// but their physics dont follow their nodes animations (positions/movements/...) /// /// ############################################################################################ /// LOOP: for(u32 N=0; N<myNodes.size(); ++N){ IMesh *mesh = NULL; // Get irrlicht node type: switch(myNodes[N]->getType()){ case scene::ESNT_ANIMATED_MESH: mesh = ((scene::IAnimatedMeshSceneNode*)myNodes[N])->getMesh(); break; default: mesh = ((scene::IMeshSceneNode*)myNodes[N])->getMesh(); break; } // Extract index and vertex data from the irrLicht mesh: const u32 cnt = mesh->getMeshBufferCount(); for(u32 i=0; i<cnt; ++i){ IMeshBuffer* buf = NULL; buf = mesh->getMeshBuffer(i); s32 idxCnt = buf->getIndexCount(); s32 vertexCnt = buf->getVertexCount(); f32* vtx3 = new f32[vertexCnt*3]; matrix4 mat; mat *= myNodes[N]->getAbsoluteTransformation(); switch(buf->getVertexType()){ case video::EVT_STANDARD: { video::S3DVertex* vtx = (video::S3DVertex*)buf->getVertices(); for(s32 j=0; j<vertexCnt; ++j){ vector3df pos = vtx[j].Pos; mat.transformVect(pos); vtx3[j*3+0] = pos.X; vtx3[j*3+1] = pos.Y; vtx3[j*3+2] = pos.Z; }} break; case video::EVT_2TCOORDS: { video::S3DVertex2TCoords* vtx = (video::S3DVertex2TCoords*)buf->getVertices(); for(s32 j=0; j<vertexCnt; ++j){ vector3df pos = vtx[j].Pos; mat.transformVect(pos); vtx3[j*3+0] = pos.X; vtx3[j*3+1] = pos.Y; vtx3[j*3+2] = pos.Z; }} break; case video::EVT_TANGENTS: { video::S3DVertexTangents* vtx = (video::S3DVertexTangents*)buf->getVertices(); for(s32 j=0; j<vertexCnt; ++j){ vector3df pos = vtx[j].Pos; mat.transformVect(pos); vtx3[j*3+0] = pos.X; vtx3[j*3+1] = pos.Y; vtx3[j*3+2] = pos.Z; }} break; } // Convert irrLicht's 'unsigned short' array of indices to an array of 'unsigned int's that bullet can use: u16* bufIndices = buf->getIndices(); u32* u32bufIndices = new u32[idxCnt]; for(s32 i=0; i<idxCnt; ++i){ u32bufIndices[i] = bufIndices[i]; } btIndexedMesh bMesh; bMesh.m_numTriangles = idxCnt / 3; bMesh.m_triangleIndexBase = (const unsigned char *) u32bufIndices; bMesh.m_triangleIndexStride = 3*sizeof(u32); bMesh.m_numVertices = vertexCnt; bMesh.m_vertexBase = (const unsigned char *)vtx3; bMesh.m_vertexStride = 3*sizeof(f32); staticVertexArray->addIndexedMesh(bMesh); } } /// Bullet: Add to the physics world: btCollisionShape* shapev = new btBvhTriangleMeshShape(staticVertexArray, false); btRigidBody* rigidBodyv = new btRigidBody(0, new btDefaultMotionState(), shapev, btVector3(0,0,0)); bWorld->addRigidBody(rigidBodyv); while(device->run()){ ....... ....... ....... /// Update physics: bWorld->stepSimulation(frameDeltaTime, 1); ....... ....... ....... } }
Last edited by jorgerosa on Mon Mar 19, 2012 8:48 am, edited 1 time in total.
Re: (C++) Simple Bullet Physics Class/Manager
Here's the wrapper I talked about earlier if it misses any features that you think should be in the wrapper please tell me. I'd be happy to update it because I use it myself IrrBtWrapper.tar.gz - 6.8 Mb ( seams to be deleted, should have put it in my dropbox account )
PS. it contains linux debug executable with sample on how to use it, though not all features are used.
Edit: updated link, renamed wrapper as cobra asked.
PS. it contains linux debug executable with sample on how to use it, though not all features are used.
Edit: updated link, renamed wrapper as cobra asked.
Last edited by serengeor on Mon Oct 08, 2012 7:43 am, edited 2 times in total.
Working on game: Marrbles (Currently stopped).
-
- Competition winner
- Posts: 117
- Joined: Wed Jun 30, 2010 8:44 am
- Location: Portugal
- Contact:
Re: (C++) Simple Bullet Physics Class/Manager
Thanks for share it, serengeor. I´ll try it as soon as i get home.serengeor wrote:Here's the wrapper I talked about earlier if it misses any features that you think should be in the wrapper please tell me. I'd be happy to update it because I use it myself PS. it contains linux debug executable with sample on how to use it, though not all features are used.
Re: (C++) Simple Bullet Physics Class/Manager
serengeor wrote:Here's the wrapper I talked about earlier if it misses any features that you think should be in the wrapper please tell me. I'd be happy to update it because I use it myself IrrBulletWrapper.tar.gz - 6.8 Mb
PS. it contains linux debug executable with sample on how to use it, though not all features are used.
Hi Serengeor,
Please note for others that this is not the original irrBullet that I developed. The name can be misleading to people who don't know.
Thanks.
Re: (C++) Simple Bullet Physics Class/Manager
I thought so, but I didn't have really that time to think of a good name for it. It doesn't really have any name in my framework.cobra wrote:serengeor wrote:Here's the wrapper I talked about earlier if it misses any features that you think should be in the wrapper please tell me. I'd be happy to update it because I use it myself IrrBulletWrapper.tar.gz - 6.8 Mb
PS. it contains linux debug executable with sample on how to use it, though not all features are used.
Hi Serengeor,
Please note for others that this is not the original irrBullet that I developed. The name can be misleading to people who don't know.
Thanks.
Ill try to rename it.
Edit: there you go cobra. I hope there isn't any wrapper named like that, is there?
Working on game: Marrbles (Currently stopped).
Re: (C++) Simple Bullet Physics Class/Manager
bump,
For anyone using my wrapper I must warn you that filtered callback class is not working correctly, sometimes it gets bodies with incorrect filter. I can't find the problem, but I have some workaround so if anyone needs it just ask. Also if you know how to fix it, I would be happy to know that too.
For anyone using my wrapper I must warn you that filtered callback class is not working correctly, sometimes it gets bodies with incorrect filter. I can't find the problem, but I have some workaround so if anyone needs it just ask. Also if you know how to fix it, I would be happy to know that too.
Working on game: Marrbles (Currently stopped).