irrBullet 0.1.8 - Bullet physics wrapper

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Whirled Peas
Posts: 47
Joined: Mon Jan 10, 2011 8:01 pm
Location: SoCal

Post by Whirled Peas »

tried that, it gives me an error: 'class IRigidBody' has no member named 'setPosition'

I'm guessing that there has to be a function within the Bullet library that would do it. Either that, or perhaps you can turn off the rigidbody, position the node, then turn it back on again or something along those lines.

Update:


did some looking and found the function setActiveState() which seems like the kind of function to do the job, but I get the same error as with setPosition(), anybody know the function I need?

Other Update:

So I was doing some more looking around and found this lovely thread on the bullet physics forums which features posts from cobra himself:

http://bulletphysics.org/Bullet/phpBB3/ ... php?t=5501

here is the code that cobra posted on that site:

Code: Select all

// Copyright (C) 2009-2010 Josiah Hartzell (Skyreign Software)
// This file is part of the "irrBullet" Bullet physics extension library and wrapper.
// For conditions of distribution and use, see copyright notice in irrbullet.h

#include "Bullet/btBulletDynamicsCommon.h"
#include "Bullet/btBulletCollisionCommon.h"
#include "motionstate.h"
#include "bulletworld.h"

using namespace irr;
using namespace core;
using namespace scene;

IMotionState::IMotionState(const btTransform &initialPos)
{
    worldTransform = initialPos;
    ManualRotation = false;
    VelocityAsRotation = false;
}

void IMotionState::getWorldTransform(btTransform &worldTrans) const
{
    worldTrans = worldTransform;
}

void IMotionState::setWorldTransform(const btTransform &worldTrans)
{
    if(object)
    {
        ISceneNode *node = object->getCollisionShape()->getSceneNode();

        irr::core::matrix4 matr;
        btTransformToIrrlichtMatrix(worldTrans, matr);

        node->setPosition(matr.getTranslation());
        if(!ManualRotation)
        {
                node->setRotation(matr.getRotationDegrees());
        }

        worldTransform = worldTrans;
    }

    else if(failed == false)
            printf("irrBullet: [ERR] Object (%i) could not be updated\n", object->getUniqueID());
}


IMotionState::~IMotionState()
{
}
Now, I'm guessing this is the method I should use in order to put an object at a specific desired set of coordinates. I'm also guessing that this is supposed to be implemented as a class rather than a function, and that when using it I should create an instance of it like this:

Code: Select all

IMotionState* TransformThingy;


Although I'm not quite sure how I'm supposed to implement it as the code listed in the thread doesn't seem to show a constructor or function which takes a scene node or rigid body as an argument. Or does it work like one adds a rigidbody to a bulletworld simulation:

Code: Select all

TransformClass *ClassInstance = alreadyCreatedRigidBody->addClassInstance(ClassInstance);
I might be able to figure this stuff out on my own by playing around with, although that post is a few months old and thus may be out of date, also I'm not at home right now, so it'll have to wait until at least I get home.
Last edited by Whirled Peas on Wed Mar 09, 2011 4:26 am, edited 1 time in total.
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Post by cobra »

Whirled Peas wrote:tried that, it gives me an error: 'class IRigidBody' has no member named 'setPosition'

I'm guessing that there has to be a function within the Bullet library that would do it. Either that, or perhaps you can turn off the rigidbody, position the node, then turn it back on again or something along those lines.

Update:


did some looking and found the function setActiveState() which seems like the kind of function to do the job, but I get the same error as with setPosition(), anybody know the function I need?
Hi Whirled Peas.

The function you are looking for is ICollisionObject::setWorldTransform().

You give this an irr::core::matrix4 describing the desired transformation.


Here is an example:

Code: Select all

irr::core::matrix4 myMat;
mat.setTranslation(desiredPosition);
mat.setRotationDegrees(desiredRotation);

myRigidBody->setWorldTransform(myMat);
Your rigid body will then have that transformation.

irrBullet makes manually transforming collision objects very easy. :)
Last edited by cobra on Wed Mar 09, 2011 4:27 am, edited 1 time in total.
Josiah Hartzell
Image
Whirled Peas
Posts: 47
Joined: Mon Jan 10, 2011 8:01 pm
Location: SoCal

Post by Whirled Peas »

Ah, ninja'd on the answer to my own question :D

thanks cobra, I'll give it a look if I have the time when I get home after work tonight.
\
Also, the method you listed will only set the position and rotation each time it is called and then letting the simulation take over from there right? So it won't suddenly turn said object into a kinematic object or become entirely reliant on having its transformation being 'manually controlled' correct?

So for instance, I have a sphere which is falling, it passes through some given region which sets off the requirements for a function to get called which implements the previously mentioned method and 'teleports' said sphere to a new set of coordinates and without calling said function again the sphere starts falling again from its new position.

Finally, do I have to give both a rotation and position parameter? Or will it automatically just use the node's current position or rotation? Or do I have to tell it to do that?

Thanks again.
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

Whirled Peas wrote:Ah, ninja'd on the answer to my own question :D
Finally, do I have to give both a rotation and position parameter? Or will it automatically just use the node's current position or rotation? Or do I have to tell it to do that?

Thanks again.
If you create the matrix yourself than you will have to set its position and rotation AFAIK.
Instead you could use the function that gets its transform, edit its position and set it back to the body.

And I said that it was a pseudo code, didn't really knew if such thing exists here, tough I think its available in irrBP or maybe the bullet itself can't really remember.
Working on game: Marrbles (Currently stopped).
Dark Dragon DX
Posts: 24
Joined: Fri Nov 05, 2010 11:46 pm

Post by Dark Dragon DX »

Hey, I'm writing an FPS player controller (nobody seems to like the Kinematic player controller that comes with Bullet) and I'm having issues with collision detection. I originally started out with a re sized cube at (5,7,5) and it works fine except that it sometimes tunnels through objects (mission geometry). Also, it has weird issues with standing still (it starts sinking into the geometry like it wants to tunnel, then it catches itself and slides back upward).

Then I have seen that you said that is an issue with Bullet and not your wrapper (it's because cubes don't have enough vertices), so I tried using a GImpact mesh to simulate the player mesh exactly (dwarf as a test). It worked fine (sinking issue appeared to be gone) except collision was with other objects was incredibly laggy (if it was pushed into something long enough). And sometimes I would STILL get the player through some objects.

After that I tried a sphere collision mesh, which yielded the same results as the box collision ... :cry:

I would prefer if exact collision worked (so shooting would be more realistic), but I was wondering if anyone here had any ideas.
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

Well normally games go a differet route.
While the player is on ground and in full the playercharacter is basicly a static object which you move around. the static object normally either uses a zylinder or sphere for collision detection(not reaction with the world). this applies as long as the player is not interacting with other entities execpt the world mesh. which is in itself static. physics objects like barrels normally either don't exist in multiplayer/are static or react but have no effect on the player.

Now the second thing. When the character is interacting with some entity like an explosion the static controlling is turned of and a ragdoll representation takes over animation and movement of the model.

now u said you accurate hitting. well that is achieved with hitboxes around the bones of a mesh. that way its pretty fast. and incase you really need it you could still make a slow triangle raycast if a hitbox was hit but then only on the triangles that belong to that hitbox.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Dark Dragon DX
Posts: 24
Joined: Fri Nov 05, 2010 11:46 pm

Post by Dark Dragon DX »

Sudi wrote:Well normally games go a differet route.
While the player is on ground and in full the playercharacter is basicly a static object which you move around. the static object normally either uses a zylinder or sphere for collision detection(not reaction with the world). this applies as long as the player is not interacting with other entities execpt the world mesh. which is in itself static. physics objects like barrels normally either don't exist in multiplayer/are static or react but have no effect on the player.
Box and sphere collision don't work properly (tunneling issues) so I should try a cylinder.
Sudi wrote: Now the second thing. When the character is interacting with some entity like an explosion the static controlling is turned of and a ragdoll representation takes over animation and movement of the model.
I'm relatively new to both irrBullet and Irrlicht (starrted C++ programming around late 2010, but I had lots of non-OOP programming in a C++ like language before-hand), I'm not too sure how to set up a ragdoll properly (past experiments either ended with a crash message or an epic spaztastic rubber man.
Sudi wrote: now u said you accurate hitting. well that is achieved with hitboxes around the bones of a mesh. that way its pretty fast. and incase you really need it you could still make a slow triangle raycast if a hitbox was hit but then only on the triangles that belong to that hitbox.
How exactly would this be done? As said above, I'm new to Irrlicht, Bullet, and C++ ...
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

Dark Dragon DX wrote:
Sudi wrote:Well normally games go a differet route.
While the player is on ground and in full the playercharacter is basicly a static object which you move around. the static object normally either uses a zylinder or sphere for collision detection(not reaction with the world). this applies as long as the player is not interacting with other entities execpt the world mesh. which is in itself static. physics objects like barrels normally either don't exist in multiplayer/are static or react but have no effect on the player.
Box and sphere collision don't work properly (tunneling issues) so I should try a cylinder.
Well i am pretty sure the collision system work just the dynamics are a little odd when you are sitting on a giant triangle with a tiny sphere. Therefor i said only use collision data. Collide the sphere/box/zylinder manually with the gameworld and then place it. The character in all games is not controlled by physics as long as the player is in charge.
Dark Dragon DX wrote:
Sudi wrote: Now the second thing. When the character is interacting with some entity like an explosion the static controlling is turned of and a ragdoll representation takes over animation and movement of the model.
I'm relatively new to both irrBullet and Irrlicht (starrted C++ programming around late 2010, but I had lots of non-OOP programming in a C++ like language before-hand), I'm not too sure how to set up a ragdoll properly (past experiments either ended with a crash message or an epic spaztastic rubber man.
Well that has actually not much todo with irrlicht/bullet and c++ its more a logical question.
Dark Dragon DX wrote:
Sudi wrote: now u said you accurate hitting. well that is achieved with hitboxes around the bones of a mesh. that way its pretty fast. and incase you really need it you could still make a slow triangle raycast if a hitbox was hit but then only on the triangles that belong to that hitbox.
How exactly would this be done? As said above, I'm new to Irrlicht, Bullet, and C++ ...
Same as above. There is no perfect way to do it just do it somehow.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Dark Dragon DX
Posts: 24
Joined: Fri Nov 05, 2010 11:46 pm

Post by Dark Dragon DX »

Sudi wrote:
Dark Dragon DX wrote:
Sudi wrote:Well normally games go a differet route.
While the player is on ground and in full the playercharacter is basicly a static object which you move around. the static object normally either uses a zylinder or sphere for collision detection(not reaction with the world). this applies as long as the player is not interacting with other entities execpt the world mesh. which is in itself static. physics objects like barrels normally either don't exist in multiplayer/are static or react but have no effect on the player.
Box and sphere collision don't work properly (tunneling issues) so I should try a cylinder.
Well i am pretty sure the collision system work just the dynamics are a little odd when you are sitting on a giant triangle with a tiny sphere. Therefor i said only use collision data. Collide the sphere/box/zylinder manually with the gameworld and then place it. The character in all games is not controlled by physics as long as the player is in charge.
There is a way to manually force a collision? I didn't know that ... is there a special function or something to do so? Or perhaps you just mean not move the box via physics unless it's going up or down and move it along the X and z manually?
Sudi wrote:
Dark Dragon DX wrote:
Sudi wrote: Now the second thing. When the character is interacting with some entity like an explosion the static controlling is turned of and a ragdoll representation takes over animation and movement of the model.
I'm relatively new to both irrBullet and Irrlicht (starrted C++ programming around late 2010, but I had lots of non-OOP programming in a C++ like language before-hand), I'm not too sure how to set up a ragdoll properly (past experiments either ended with a crash message or an epic spaztastic rubber man.
Well that has actually not much todo with irrlicht/bullet and c++ its more a logical question.
Dark Dragon DX wrote:
Sudi wrote: now u said you accurate hitting. well that is achieved with hitboxes around the bones of a mesh. that way its pretty fast. and incase you really need it you could still make a slow triangle raycast if a hitbox was hit but then only on the triangles that belong to that hitbox.
How exactly would this be done? As said above, I'm new to Irrlicht, Bullet, and C++ ...
Same as above. There is no perfect way to do it just do it somehow.
Alright, I have some idea on how to do exact collision. If a projectile hits the main collision box a raycast takes over to figure out where exactly on the player it has hit and deal damage determined from that data.
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

Dark Dragon DX wrote:
Sudi wrote:
Dark Dragon DX wrote: Box and sphere collision don't work properly (tunneling issues) so I should try a cylinder.
Well i am pretty sure the collision system work just the dynamics are a little odd when you are sitting on a giant triangle with a tiny sphere. Therefor i said only use collision data. Collide the sphere/box/zylinder manually with the gameworld and then place it. The character in all games is not controlled by physics as long as the player is in charge.
There is a way to manually force a collision? I didn't know that ... is there a special function or something to do so? Or perhaps you just mean not move the box via physics unless it's going up or down and move it along the X and z manually?
Well bullet allows you to collide any collision object at any time with the physics world and produce collision points.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
jibblesmgee
Posts: 42
Joined: Thu Jan 06, 2011 9:12 am

I know, it's been asked a million times:

Post by jibblesmgee »

I'm using VS 2008 and irrbullet 1.7.

I have added the correct library directories and irrBullet.lib to my linker, but I still keep getting the stupid unresolved external symbol linker error.

What am I doing wrong?

I hate VS 2008... but please give me some advice for it, because I'm forced to use it.

[edit] well... I figured out one part, but now I have even more trouble.

Several error LNK2005 issues... (already defined) and 50 unresolved external symbols... welllllll...[/edit]
jibblesmgee
Posts: 42
Joined: Thu Jan 06, 2011 9:12 am

Post by jibblesmgee »

Ok, I've finally got my problem narrowed down. MSVC 2008 is getting confused because some of the symbols defined are defined in default libraries already. If I block out those default libraries however, there's a gap created and the symbols get lost in the void. I'm trying to figure out how to work around it, but I'm not having any luck yet. if I could find a way to link the default libs AFTER the irrbullet libs linked, it might work... but i think another option would be a less time consuming solution.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Don't use 'using' maybe?
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

hybrid wrote:Don't use 'using' maybe?
It causes linker errors?

Hm and also, offtopic: How is it possible that even when I use core::vector3df it compiles fine, tough I never ever used using namespace keyword in my project?
Working on game: Marrbles (Currently stopped).
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

As I understood he got compile errors due to name clashes with std:: namespace (or some other lib and namespace) and left out some libs when linking. This can cause linker errors then.
If you don't use 'using namespace irr' somewhere, you cannot use core::vector3df but have to use irr::core::vector3df
But maybe some lib has a malformed header? At least Irtrlicht shouldn't have any using in the headers, besides those required for legacy compliance (might already be removed, though).
Post Reply