irrBullet 0.1.8 - Bullet physics wrapper

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Post by polylux »

Wanna send me the release to check the linux targets?
beer->setMotivationCallback(this);
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Post by cobra »

Hi Polylux.

This time I wanted to get this release out as soon as possible, so there is no time to do such thorough Linux testing. Next time would be great, though.

Thank you for the offer.



Also,

irrBullet 0.1.71 has been released!

Get it here:
http://sourceforge.net/projects/irrbull ... z/download


or from the irrBullet trunk:
https://irrbullet.svn.sourceforge.net/s ... llet/trunk


Please report any bugs you may come across during your use of irrBullet, and be sure to request useful features via PM.

Thank you, and enjoy irrBullet!

- Josiah

Changelog:
irrBullet 0.1.71 Release:
Fixed: attributes memory leak in IRaycastVehicle
Improved: ICollisionShape getName() function
Fixed: crash in RaycastTank example
Changed: srand() parameter in Collision example now uses device time instead of time(NULL)
Fixed: ICollisionObject destructor is now virtual
Fixed: typo in ICollisionShape where a reference to a temporary was returned
Fixed: ISoftBody destructor is now virtual
Added: "Special Thanks" section in readme.txt for credits and attributions
Removed: extra qualifier (typo) for CExampleFramework::createParticleSystem()
Changed: irrBullet Code::Blocks projects now use global variable for Irrlicht include rather than the full path
API CHANGE: irrBulletWorld::getCollisionObject() changed to getCollisionObjectByIndex()
API CHANGE: irrBulletWorld::getLiquidBody() changed to getLiquidBodyByIndex()
Removed: ICollisionObject::getName()
Added: ICollisionObject::getIdentification()
API CHANGE: removed second parameter from IRaycastVehicle constructors; they don't need the unused irrBulletWorld pointer
Changed: ITriangleMeshShape::createShape() made pure virtual
Improved: fixed many minor compiler warnings
Added: Linux Debug and Release build targets to Code::Blocks project (Thanks Polylux!)
Changed: Windows GCC build targets renamed
Added: Linux Debug and Release build targets to irrBullet example projects
Added: Win32 GCC Release and Debug build targets to irrBullet example projects
Added: Linux makefiles (Thanks Johannes Lorenz/Lo!)
Added: pre-built MSVC 2008 Bullet libs (lib/win32_visualstudio/2008)
Added: pre-built MSVC 2010 Bullet libs (lib/win32_visualstudio/2010)
Fixed: accidental string literal comparison in bulletworld.cpp, line 412 (Thanks Johannes Lorenz/Lo!)
Last edited by cobra on Sat Feb 12, 2011 3:53 am, edited 1 time in total.
Josiah Hartzell
Image
g0bl1n
Posts: 63
Joined: Thu Feb 21, 2008 8:45 am

Post by g0bl1n »

I was wondering if there is a way to create "localized gravity"? Such as gravity that is only applied on plane of some sort, or when an object is within an invisible square of sorts? I'm not quite sure if that is a common thing for physics engines, just figured I'd ask, because I've been playing around with this for about 3 hours now and I must say I'm quite impressed, although I'm not a huge fan of the framework setup...but that's just me!

Reason I ask is that I have always wanted to make a sandbox multiplayer game where everyone is on a ship stranded in space, and there can be combat inside the ship and people can pilot ships and have battles in space... I know, ambitious...but I've been waiting for Battlefront 3 to come out for forever... :?
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Post by cobra »

Hi b0bl1n.

I'm glad irrBullet is useful for you!

One way you can do this with irrBullet right now is to add an ILiquidBody to the world and change some parameters (by modifying the water current and the density); however, this is not the way I recommend.

The other way is to make your own class that inherits from ICollisionObjectAffector and overrides affectObject().

With this, you can then check each object's position against an AABB and apply the required forces.

You could also iterate through all of the objects in your game's main loop and do the same.
Josiah Hartzell
Image
g0bl1n
Posts: 63
Joined: Thu Feb 21, 2008 8:45 am

Post by g0bl1n »

Is there a keep upright function? I'm trying to create a player, I'm not quite sure if making the player model the collision body and making it stay upright is the route to go, but it seemed like the thing to do... I'm open to any other suggestions though!!!

EDIT:
Oh yea, I apparently have a memory leak with a class:

Code: Select all

class Fighter
{
    public:
        std::string _meshName;
        IAnimatedMesh* _mesh;
        IAnimatedMeshSceneNode *_node;
        IGImpactMeshShape *_shape;
        IRigidBody* _body;
        f32 _mass;
        f32 _scale;

        Fighter(ICameraSceneNode *camera):_meshName("models/F-15.3ds"),_mass(1000000.0),_scale(0.25)
        {
            _mesh=smgr->getMesh(_meshName.c_str());
            _node=smgr->addAnimatedMeshSceneNode(_mesh);
            _node->setScale(vector3df(_scale,_scale,_scale));
            _node->setPosition(camera->getPosition());
            _node->setMaterialFlag(EMF_LIGHTING,false);
            _node->setMaterialFlag(EMF_NORMALIZE_NORMALS,true);

            _shape=new IGImpactMeshShape(_node,_mesh,_mass);

            _body=world->addRigidBody(_shape);
        }

        ~Fighter()
        {
            smgr->addToDeletionQueue(_node);
            world->removeCollisionObject(_body,true);
        }
};
When I create a Fighter then delete one, the memory doesn't free up... Although with my cube class it does, but I cannot figure out why. My only thoughts are cleanup the _shape but I cannot find any functions to do that, and just deleting it causes an error. Any ideas?
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Post by cobra »

Hi g0bl1n.

The way to keep your rigid body upright is using IRigidBody::setAngularFactor(vector3df(0.0f,1.0f,0.0f)).

This will multiply the X and Z axes of the angular velocities given to the rigid body by zero, and so the only allowed rotation will be on the Y axis.

There's setAngularFactory() and setLinearFactor(). The parameters you pass to them are the values by which their respective velocities will be multiplied.

I used this method for an FPS framework I made. I sold it, so I can not give you the source, but I'll get to an example some time when I can.

It's called dynamic character controller, as opposed to kinematic character controller.


As for your memory leak, the collision shape will be deleted in the rigid body's destructor, so you don't have to free it yourself.

You could try removing the mesh from Irrlicht's mesh cache.

I hope you figure it out.

- Josiah
Josiah Hartzell
Image
g0bl1n
Posts: 63
Joined: Thu Feb 21, 2008 8:45 am

Post by g0bl1n »

I can't believe I forgot about the mesh, I must have mistaken it for a texture and thought Irrlicht would manage that for me. Is it better to load all the meshes once and just reference them? Now that I think about it that's probably the route to go. After my classes I'll go try out the stay upright stuff, thanks a lot!
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Post by cobra »

g0bl1n wrote:I can't believe I forgot about the mesh, I must have mistaken it for a texture and thought Irrlicht would manage that for me. Is it better to load all the meshes once and just reference them? Now that I think about it that's probably the route to go. After my classes I'll go try out the stay upright stuff, thanks a lot!

Irrlicht does manage the mesh for you.

However, it also keeps a cache of meshes until the scene manager's destructor is called, and that is called when the Irrlicht device is deleted.

If you just create a new Fighter instance and then delete it and check the memory while your program is still running, the mesh's memory will not be deallocated and so you will think you have a leak.

Use ISceneManager::removeMesh() to remove the mesh from the cache when you're done using it. This will already be done in ~ISceneManager(), though, when you delete the Irrlicht device.

Irrlicht won't load a mesh if it has already been loaded.

- Josiah
Josiah Hartzell
Image
Whirled Peas
Posts: 47
Joined: Mon Jan 10, 2011 8:01 pm
Location: SoCal

Post by Whirled Peas »

Hi guys,

Been working in irrbullet for a bit, and I've been having some trouble with IBvhTriangleMeshShape. Here's a snipped of the code from my project:

Code: Select all

smgr->addCameraSceneNode(0, vector3df(0,5,-10), vector3df(0,0,0));


    //create the bullet physics world
    irrBulletWorld* world = createIrrBulletWorld(device, true, debugDraw);

    //set the gravity in the world
    world->setGravity(vector3df(0, -10, 0));

    //create the collision shape of the mesh


    ICollisionShape *doohicky = new IBvhTriangleMeshShape(node, mesh, 5.0);
    //ICollisionShape *grndshape = new IBoxShape(grndNode, 0, false);
    ICollisionShape *grndshape = new IBvhTriangleMeshShape(grndNode, device->getSceneManager()->getMesh("c:/gamemedia/terrmesh1.b3d"), 0);

    doohicky->setMargin(0.07);
    grndshape->setMargin(0.07);

    IRigidBody *body = world->addRigidBody(doohicky);
    IRigidBody *gbody = world->addRigidBody(grndshape);


    gbody->setCollisionFlags(ECF_STATIC_OBJECT);
Now the 'ground' mesh is just a basic box, and the 'mesh' mesh is a slightly more complicated mesh than a sphere or cube, so that I can test to see how well triangle mesh collisions work in bullet.

So the problem is that when I use the boxshape shape, the 'mesh' object merely falls and hits the 'ground' mesh and sits there like it was using a cube shape in stead of a trimesh shape, in other words, it doesn't settle on its side or anything. Now, if I use the IBvhTriangleMeshShape in stead, the collision doesn't happen at all and the falling object merely falls right through it.

Now, I've done searches and taken a look at the other example programs, although some of them are a bit lacking in the comments area, so I probably missed something, probably another line or something like that.

Any help would be greatly appreciated.

thanks in advance.
lokiare
Posts: 40
Joined: Wed Feb 04, 2009 5:40 pm

Post by lokiare »

Is there a tutorial or quick-start guide somewhere. I'm new to physics engines and I'm looking at this one, but I have no idea how to integrate it. The tutorial I found on the internet was for a previous version and it was incomplete. Thanks in advance.
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Post by cobra »

Whirled Peas wrote:Hi guys,

Been working in irrbullet for a bit, and I've been having some trouble with IBvhTriangleMeshShape. Here's a snipped of the code from my project:

Code: Select all

smgr->addCameraSceneNode(0, vector3df(0,5,-10), vector3df(0,0,0));


    //create the bullet physics world
    irrBulletWorld* world = createIrrBulletWorld(device, true, debugDraw);

    //set the gravity in the world
    world->setGravity(vector3df(0, -10, 0));

    //create the collision shape of the mesh


    ICollisionShape *doohicky = new IBvhTriangleMeshShape(node, mesh, 5.0);
    //ICollisionShape *grndshape = new IBoxShape(grndNode, 0, false);
    ICollisionShape *grndshape = new IBvhTriangleMeshShape(grndNode, device->getSceneManager()->getMesh("c:/gamemedia/terrmesh1.b3d"), 0);

    doohicky->setMargin(0.07);
    grndshape->setMargin(0.07);

    IRigidBody *body = world->addRigidBody(doohicky);
    IRigidBody *gbody = world->addRigidBody(grndshape);


    gbody->setCollisionFlags(ECF_STATIC_OBJECT);
Now the 'ground' mesh is just a basic box, and the 'mesh' mesh is a slightly more complicated mesh than a sphere or cube, so that I can test to see how well triangle mesh collisions work in bullet.

So the problem is that when I use the boxshape shape, the 'mesh' object merely falls and hits the 'ground' mesh and sits there like it was using a cube shape in stead of a trimesh shape, in other words, it doesn't settle on its side or anything. Now, if I use the IBvhTriangleMeshShape in stead, the collision doesn't happen at all and the falling object merely falls right through it.

Now, I've done searches and taken a look at the other example programs, although some of them are a bit lacking in the comments area, so I probably missed something, probably another line or something like that.

Any help would be greatly appreciated.

thanks in advance.

Hi Whirled Peas.

The mistake you're making is that you're using a BvH Triangle Mesh Shape for a dynamic rigid body. This shape is only to be used for static rigid bodies.

For dynamic triangle mesh shapes you need to use IGImpactMeshShape.


Your post is quite vague. I can't understand exactly what problem you have with the box shape.

If you could upload a video and show me what is going wrong and what you expect it to do instead, I can help you more.

-----------------------------

@lokiare:

There are examples with source code and Windows binaries included in the SDK, as well as Doxygen documentation and a FAQ in the "doc" folder.
Josiah Hartzell
Image
lokiare
Posts: 40
Joined: Wed Feb 04, 2009 5:40 pm

Post by lokiare »

I got it to compile and everything is running ok, but I can't seem to find what I need to integrate it. The examples are a little cryptic. I am kind of looking for a tutorial style documentation that steps you through writing a simple program and explains what each component is and does as they are added. I've got some experience with Irrlicht, but none with physics programs...
Whirled Peas
Posts: 47
Joined: Mon Jan 10, 2011 8:01 pm
Location: SoCal

Post by Whirled Peas »

okay, thank you so much cobra, that did it!


However, now it runs really slow and eventually turns into a slide show. I seem to recall reading somewhere about using some kind of optimization or something, but don't remember where.


Again, any help would be greatly appreciated, thanks much.
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Post by cobra »

Whirled Peas wrote:okay, thank you so much cobra, that did it!


However, now it runs really slow and eventually turns into a slide show. I seem to recall reading somewhere about using some kind of optimization or something, but don't remember where.


Again, any help would be greatly appreciated, thanks much.

You could make a more coarse mesh and pass that to the triangle shape constructor. It won't affect the visual representation. Just make sure it approximates the shape enough to fool the player.
Josiah Hartzell
Image
Whirled Peas
Posts: 47
Joined: Mon Jan 10, 2011 8:01 pm
Location: SoCal

Post by Whirled Peas »

ok, so is performance more affected by the per mesh poly count on collision meshes? Or is it more the overall poly count for the entire scene?

Cuz I wind up playing with more cubes in some of those examples provided with irrBullet than there are poly's in the simple scene I've got here and I have yet to run into the kind of lag I get in the program I created.
Post Reply