BtOgre - Simple, Thin Bullet-Ogre Connection (now on git!)

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13
Contact:

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git!)

Post by nikki »

nikki wrote:You should try asking on the Bullet forums (I don't have much time these days to help :( ).
Garibalde
Halfling
Posts: 69
Joined: Thu Apr 16, 2009 2:38 am
Location: Montreal, Quebec
x 2
Contact:

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git!)

Post by Garibalde »

kurty wrote:As you can see , i tried mNinjaBody->applyCentralForce(mTrans * evt.timeSinceLastFrame); but the result was that node and shape wasn't synchronised after few keyboard entries.
Here is what i got working with the apply force/torque.

Code: Select all

Ogre::Vector3 UserForce = mDirection * 2;
Ogre::Vector3 UserTorque = mRotateval * 15;
mToolBody->setActivationState(DISABLE_DEACTIVATION);
mToolBody->applyForce(btVector3(UserForce.x,UserForce.y,UserForce.z),btVector3(0,0,0));
mToolBody->applyTorque(btVector3(UserTorque.x,UserTorque.y,UserTorque.z));
mToolState->setWorldTransform(mToolBody->getWorldTransform());
instead of applyforce you can use applycentralforce (which is applied at the center of the body), with applyforce i have set the force offset to zero hence equivalently it applies at the center also.

This will apply forces/torques to move the rigid body.
it seems you have to set setactivationState to DISABLE_DEACTIVATION each iteration or i find that the body stops moving.
you also have to sync the state of the body also.

hope this helps you.
Garibalde
Garibalde
VIRMED Simulation Technologies Inc.
http://www.virmed.com
Garibalde
Halfling
Posts: 69
Joined: Thu Apr 16, 2009 2:38 am
Location: Montreal, Quebec
x 2
Contact:

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git!)

Post by Garibalde »

I am still having issues with switching a body to kinematics and then colliding with other rigid bodies in the simulation.
The kinematic object seems to pass through the rigid bodies. However when i use force to move the object like in the
previous post everything works. From what i understand from reading all the threads in bullet forum and here is that
this should be possible. Anyone know what can possibly be wrong here.

Thanks.
Garibalde
Garibalde
VIRMED Simulation Technologies Inc.
http://www.virmed.com
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13
Contact:

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git!)

Post by nikki »

Garibalde wrote:I am still having issues with switching a body to kinematics and then colliding with other rigid bodies in the simulation.
The kinematic object seems to pass through the rigid bodies. However when i use force to move the object like in the
previous post everything works.
Just remove the dynamic body and re-add as kinematic. Make sure to set mass to 0, etc., to keep it kinematic. To make it dynamic again, do the opposite.
Garibalde
Halfling
Posts: 69
Joined: Thu Apr 16, 2009 2:38 am
Location: Montreal, Quebec
x 2
Contact:

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git!)

Post by Garibalde »

Hi nikki,

Code: Select all

Ogre::Vector3 cPos = mToolNode->getPosition() + (mDirection * 0.1);
Ogre::Vector3 tmp = mRotateval * 0.05;
Ogre::Quaternion dOri(tmp.x,tmp.y,tmp.z);
Ogre::Quaternion cOri = mToolNode->getOrientation() + dOri;
Globals::phyWorld->removeRigidBody(mToolBody);
mToolBody->setCollisionFlags(mToolBody->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
mToolBody->setActivationState(DISABLE_DEACTIVATION);
btTransform btt;
mToolBody->getMotionState()->getWorldTransform(btt);
btt.setOrigin(BtOgre::Convert::toBullet(cPos));
btt.setRotation(BtOgre::Convert::toBullet(cOri));
mToolBody->getMotionState()->setWorldTransform(btt);
mToolBody->setCenterOfMassTransform(btt);
Globals::phyWorld->addRigidBody(mToolBody);
mToolBody->activate(true);
http://www.bulletphysics.org/Bullet/php ... f=9&t=4517

I posted this in the bullet forums but no replies yet. This is what i have done and i still cant get collision between the kinematic body and rigid bodies. Can you see what i could be doing wrong here? If you have a sample code to do what i need. That would be great to just give me a kick in the right direction. I tried this all xmas and didnt get anywhere.. at least i got a kinematic body without collisions :) however i would very much like collisions and physics effects on the rigid bodies.

Thanks
Garibalde
Garibalde
VIRMED Simulation Technologies Inc.
http://www.virmed.com
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git!)

Post by jacmoe »

nikki wrote:
nikki wrote:You should try asking on the Bullet forums (I don't have much time these days to help :( ).
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
dwarki27
Gnoblar
Posts: 2
Joined: Fri Mar 19, 2010 11:16 am

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git

Post by dwarki27 »

Nikki, am very new to Ogre3D.. I need a little help.. How do i write a bullet debugdraw where in it coverts a ogre 3Dline(on creatin) to bullet...?
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13
Contact:

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git

Post by nikki »

dwarki27 wrote:Nikki, am very new to Ogre3D.. I need a little help.. How do i write a bullet debugdraw where in it coverts a ogre 3Dline(on creatin) to bullet...?
You mean you want to do a raycast? I'm not sure I got what 'convert ogre 3Dline to bullet' means...
dwarki27
Gnoblar
Posts: 2
Joined: Fri Mar 19, 2010 11:16 am

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git

Post by dwarki27 »

well.. lemme explain.. there is a 3d sudoku game being developed.. and the cubes for it, i think use Ogre.. Inorder to interact with the individual cubes, i need a bullet transformation.. say, as soon as a line is drawn using ogre, there is a bullet layer to it.. I may not be good with the technical lingo used here..
User avatar
rogerdv
Gnome
Posts: 351
Joined: Fri May 09, 2003 10:43 pm
Location: Cuba
x 1
Contact:

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git

Post by rogerdv »

Can somebody share with me some code to illustrate how to correctly move/rotate an animated shape? Im trying to implement some basic 3rd person view with free lok, but when I try to move the robot using applyCentralForce it advances but slowly sinks in the ground mesh.
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13
Contact:

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git

Post by nikki »

dwarki27 wrote:well.. lemme explain.. there is a 3d sudoku game being developed.. and the cubes for it, i think use Ogre.. Inorder to interact with the individual cubes, i need a bullet transformation.. say, as soon as a line is drawn using ogre, there is a bullet layer to it.. I may not be good with the technical lingo used here..
Create a Line class that manages all the work of a Line. Let it handle creation of the Ogre stuff, and make it also create a cylinder of required length and radius to represent the line in bullet.
rogerdv wrote:Can somebody share with me some code to illustrate how to correctly move/rotate an animated shape? Im trying to implement some basic 3rd person view with free lok, but when I try to move the robot using applyCentralForce it advances but slowly sinks in the ground mesh.
The Bullet documentation and forums have some information on handling characters. I don't think you want complete dynamics with your robot, so the Kinematic Character Controller might be useful.
User avatar
toglia
Gnome
Posts: 336
Joined: Sat Dec 08, 2007 4:28 am
Location: Canada
x 7

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git

Post by toglia »

I need to create a hinge pivot to this mesh here, its a 320 triangle geo-sphere with inverted normals (so collisions are detected
inside).

But for some reason I can't thanks to the local inertia:

Code: Select all

Ogre::Entity* entity = mSceneManager->createEntity("bomboFisica.mesh");
BtOgre::StaticMeshToShapeConverter converter(entity);
btBvhTriangleMeshShape * shape;
shape = converter.createTrimesh();

btRigidBody::btRigidBodyConstructionInfo info(1.0, NULL, shape, btVector3(0,0,0));
btTransform frame;
frame.setIdentity();
frame.setOrigin(btVector3(0, 0, 0));
info.m_startWorldTransform = frame;

btRigidBody* body = new btRigidBody(info);
btVector3 localInertia(0.0, 0.0, 0.0);
shape->calculateLocalInertia(1.0 / body->getInvMass(), localInertia);
body->setMassProps(1.0 / body->getInvMass(), localInertia);
body->updateInertiaTensor();
There seems to be something wrong with:

Code: Select all

shape->calculateLocalInertia(1.0 / body->getInvMass(), localInertia);
It is leaving the localInertia variable on {0,0,0} which is later giving problems to the hinge.

What is that local inertia anyway? I just want it to have a perfectly centered center of mass...

P.D.: Nikki, thanks for this cool wrapper. Its just what I was looking for.
User avatar
toglia
Gnome
Posts: 336
Joined: Sat Dec 08, 2007 4:28 am
Location: Canada
x 7

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git

Post by toglia »

From the btTriangleMeshShape.cpp "moving concave objects not supported". It is weird, cause I had already hinged a compound containing concave triangles...
spa_10
Gnoblar
Posts: 3
Joined: Fri Oct 30, 2009 4:02 pm

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git

Post by spa_10 »

Hello,

We're working with btogre and We have some problem and we don't know what it means can anyone tell us what this is about???

OGRE EXCEPTION(4:ItemIdentityException): Resource group with name 'BtOgre' already exists! in ResourceGroupManager::createResourceGroup at ../src/OgreReResourceGroupManager.cpp(line 93)
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13
Contact:

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git

Post by nikki »

Hmm, maybe it should check if the ResourceGroup already exists. Try the latest git commit. Also, are you sure you're not creating two instances of BtOgre::DebugDrawer?
spa_10
Gnoblar
Posts: 3
Joined: Fri Oct 30, 2009 4:02 pm

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git

Post by spa_10 »

Yes we're creating two instances of BtOgre::DebugDrawer because we need to work with 2 Scene Nodes because we're working with a static and a kinematic body and we don't know how to do this...
could you give us some advice?
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13
Contact:

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git

Post by nikki »

You only need one DebugDrawer. Just create one, somewhere near where you create the Bullet physics world.
Caifie
Gnoblar
Posts: 17
Joined: Tue Mar 16, 2010 11:37 am

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git

Post by Caifie »

hi, there!

btogre is good to use bullet in ogre, except with the new ogre1.7 terrain?

does anybody knows how to combine the new ogre1.7 terrain with the bullet?
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13
Contact:

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git

Post by nikki »

If you can get the mesh data as an Ogre::VertexData object, you can do the following:-

Code: Select all

BtOgre::StaticMeshToShapeConverter conv;
conv.addStaticVertexData(vd); //Ogre::VertexData *vd; your vertex data.
shape = conv.createTrimesh();
Caifie
Gnoblar
Posts: 17
Joined: Tue Mar 16, 2010 11:37 am

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git

Post by Caifie »

tks, the terrain is solved.

another question, how to connect the btKinematicCharacterController to ogre.

if it is rigidbody, we can use RigidBodyState to connect a ogre scenenode.

but how can we do with the btKinematicCharacterController ? there seems nowhere to use RigidBodyState in btKinematicCharacterController.
afshin
Kobold
Posts: 34
Joined: Wed Nov 10, 2010 11:12 pm
Location: Canada

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git

Post by afshin »

Hi Guys,

I have meshes exported from Maya and Blender to Ogre. However when I want to enable physics on these meshes, btogre conversion from mesh to bullet is not done properly. I was wondering if anyone can tell me what I am missing? Here is a simple Cube exported as mesh from maya and rendered in OGRE. I have a more complex mesh which is a tube and I have a same problem posted below.

I have posted this issue under a separate thread here: http://www.ogre3d.org/forums/viewtopic.php?f=5&t=62050

Any help is greatly appreciated :)



Image


Here is my more complex mesh:

Image
apanloco
Gnoblar
Posts: 4
Joined: Thu Dec 30, 2010 9:41 am

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git

Post by apanloco »

@afshin: can you tell me what your percieved problem is? To me it looks good. The lines you see are the normals from the object. If you think they are too big you need to scale the object up (and move the camera out). The normals are always drawn with size 1. So if the cube has size 1 the normals will look like that. But if you resize the cube to let's say 100, the normals will look like small spines sticking out.

The doughnut, well, I can't say if it's correct since it's so messy but my guess is that it is correct too. Try scaling it up (and moving the camera out) and see what it looks like.
afshin
Kobold
Posts: 34
Joined: Wed Nov 10, 2010 11:12 pm
Location: Canada

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git

Post by afshin »

apanloco wrote:@afshin: can you tell me what your percieved problem is? To me it looks good. The lines you see are the normals from the object. If you think they are too big you need to scale the object up (and move the camera out). The normals are always drawn with size 1. So if the cube has size 1 the normals will look like that. But if you resize the cube to let's say 100, the normals will look like small spines sticking out.

The doughnut, well, I can't say if it's correct since it's so messy but my guess is that it is correct too. Try scaling it up (and moving the camera out) and see what it looks like.

I figured it out ... Well initially the problem was that the mesh which I was passing to Bullet was too complex (too many vertices). This is why when something collided with something else, the frame rate per second would drop down to low numbers. What I did was I passed a separate mesh to btOgre than the one I drew on the screen. I lowered the resolution using Maya and used that for physics. The issue is now resolved. So in summery, I visualize a high-res mesh but for physics I used a low-res one and this works great.

Thanks for your response :)
rs_kryptik61636
Gnoblar
Posts: 2
Joined: Sat Jan 15, 2011 11:49 am

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git

Post by rs_kryptik61636 »

Hi

I'm using BtOgre and the soft body support that Igvier provided to connect Bullet and OGRE in order to implement a surgical simulator. I'm trying to implement mesh cutting right now and as a start am trying to make small holes in the mesh. After looking at some of the Bullet demo code and the glue/fracture sample code (http://code.google.com/p/bullet/issues/detail?id=90), I came up with the following internal tick callback function:

Code: Select all

void cuttingCallback( btDynamicsWorld *world, btScalar timeStep )
{
	int numManifolds = world->getDispatcher()->getNumManifolds();
	for( int i = 0; i < numManifolds; i++ )
	{
		btPersistentManifold *currentManifold = world->getDispatcher()->getManifoldByIndexInternal(i);
		if(!currentManifold)
			continue;

		for( int p = 0; p < currentManifold->getNumContacts(); p++ )
		{
			btVector3 hitPoint = currentManifold->getContactPoint(p).getPositionWorldOnA();
			ImplicitSphere iSphere(hitPoint,10);
			Globals::psb->refine(&iSphere,0.0001,true);
		}
	}
}
where Globals::psb is the soft body. Does anyone have any idea where I'm going wrong?
WhirledPeas
Kobold
Posts: 27
Joined: Thu Mar 10, 2011 7:51 pm
x 1

Re: BtOgre - Simple, Thin Bullet-Ogre Connection (now on git

Post by WhirledPeas »

Hi, I just found this little package and am interested in using it. I have a question. Do I have to build it before I use it or can I just use the headers and libraries straight out of the box?

If I do have to build, how am I supposed to edit the premake.lua file? the comments say to add the include directories for Ogre and Bullet, but I'm not sure how exactly to enter that in:

package.includepaths = {
-- Add Ogre, OIS and bullet include directories if you don't use pkg-config
"./exampleapp",
"../include",
}
am I supposed to make it:

"Ogre",
"c:/ogre/include"

Also, I don't have an include directory as far as I can tell with bullet.

thanks for the help.
Post Reply