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
aj1nkya
Kobold
Posts: 25
Joined: Sat Nov 03, 2012 9:16 am
Location: India

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

Post by aj1nkya »

jokoon wrote:but my collision shape is still shifted from the static geometry position...
did u able to solve it? I am also having same problem.
I created my own 3D rectangle mesh by using ManualObject. i have applyed createBox() on that mesh. But i also get shape shifted from model position.
Working on Disaster Simulator to simulate Flooding and earthquake using Ogre and Bullet
jokoon
Goblin
Posts: 203
Joined: Sun Aug 23, 2009 8:30 am
x 3

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

Post by jokoon »

aj1nkya wrote:
jokoon wrote:but my collision shape is still shifted from the static geometry position...
did u able to solve it? I am also having same problem.
I created my own 3D rectangle mesh by using ManualObject. i have applyed createBox() on that mesh. But i also get shape shifted from model position.
Yes I was, my code was wrong. Is your scene node at 0,0,0 ?
aj1nkya
Kobold
Posts: 25
Joined: Sat Nov 03, 2012 9:16 am
Location: India

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

Post by aj1nkya »

jokoon wrote:Yes I was, my code was wrong. Is your scene node at 0,0,0 ?
i have building_node which is at 0,0,0. Then i have pillar_node which is child node of building_node and it is at 0,0,0. Now if i apply box shape on pillar node i get it as shifted from pillar_node.
Working on Disaster Simulator to simulate Flooding and earthquake using Ogre and Bullet
jokoon
Goblin
Posts: 203
Joined: Sun Aug 23, 2009 8:30 am
x 3

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

Post by jokoon »

Maybe you should try to create a collision shape from your manual object instead of using createBox, it can be done with btogre with btvhtriangle thing, I don't remember.

Code: Select all

 
	Entity * dadad = scmgr -> createEntity("dummy","bonome.mesh");
        BtOgre::StaticMeshToShapeConverter df;
        df.addEntity(dadad);
        btCollisionShape * bla = df.createTrimesh();

This last function returns some kind of collision shape that you add to your collision object(s). Just tried it, works for me.
aj1nkya
Kobold
Posts: 25
Joined: Sat Nov 03, 2012 9:16 am
Location: India

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

Post by aj1nkya »

jokoon wrote:This last function returns some kind of collision shape that you add to your collision object(s). Just tried it, works for me.
Hey can you look at my post http://www.ogre3d.org/addonforums/viewt ... 12&t=29862
Does my code is correct?
Working on Disaster Simulator to simulate Flooding and earthquake using Ogre and Bullet
haimat
Halfling
Posts: 52
Joined: Tue Mar 05, 2013 1:44 am

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

Post by haimat »

In my application at one point I need to attach a scene node to another parent. When bullet is disabled this works fine. However, when using BtOgre, and bullet enabled, then as soon as I change the parent the object in the scene "jumps" to another position. It seems that somehow the motion state gets confused, so that after the parent of the node has been changed it's position is set to a new (wrong) position by the motion state.

I tried to re-create and re-set the motion state to the rigid after the parent of the node has been changed, but unfortunately that didn't help.

Any ideas how I could solve this?
Emphasis
Gnoblar
Posts: 7
Joined: Thu Oct 10, 2013 12:18 am

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

Post by Emphasis »

When using AnimatedMeshToShapeConverter, is there ANY way I do not have to call createTrimesh() every update? If I don't, the collisionshapes do not update, however this is fiendishly slow on characters with > 200 vertices.. I have looked everywhere as far as I know but the best I can can come up with is just that, the slow approach.

I've put this here so it might get noticed better than in the regular help-forums, please see my original topic: http://www.ogre3d.org/forums/viewtopic.php?f=2&t=79282

BTW thanks for BtOgre, love it :)
Last edited by Emphasis on Thu Oct 31, 2013 10:11 am, edited 1 time in total.
User avatar
c6burns
Beholder
Posts: 1512
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines
x 138

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

Post by c6burns »

N_K
Greenskin
Posts: 115
Joined: Wed Dec 07, 2011 9:05 pm
x 4

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

Post by N_K »

Sorry for bumping this, but I have no idea what to do next.

I've implemented a btKinematicCharacterController in my application. It works fine, however, I'd like to use it to "drive" the camera, which is an Ogre scene node. But as far as I know, BtOgre can only join rigid bodies to Ogre scene nodes, but the kinematic character controller uses a btPairCachingGhostObject. Is there a way to link the controller to the camera node somehow?

Thanks in advance.
scrawl
OGRE Expert User
OGRE Expert User
Posts: 1119
Joined: Sat Jan 01, 2011 7:57 pm
x 216

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

Post by scrawl »

N_K wrote:Sorry for bumping this, but I have no idea what to do next.

I've implemented a btKinematicCharacterController in my application. It works fine, however, I'd like to use it to "drive" the camera, which is an Ogre scene node. But as far as I know, BtOgre can only join rigid bodies to Ogre scene nodes, but the kinematic character controller uses a btPairCachingGhostObject. Is there a way to link the controller to the camera node somehow?

Thanks in advance.
BtOgre's motion state class is called RigidBodyState, but looking at it's code I don't see anything specific to rigid bodies in there, so you should be able to use it for any kind of object.
N_K
Greenskin
Posts: 115
Joined: Wed Dec 07, 2011 9:05 pm
x 4

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

Post by N_K »

Indeed, but the btPairCachingGhostObject won't accept a BtOgre::RigidBodyState (or any kind of user defined motion state for that matter). It uses it's own internal system for handling motion states.
User avatar
c6burns
Beholder
Posts: 1512
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines
x 138

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

Post by c6burns »

motion states in bullet are a btRigidBody concept, they are not inherited from btCollisionObject and that is why they are not available to btGhostObject. All the motion state is doing is providing a convenient hook to get/set the world transform, which is nothing you couldn't do yourself every frame. One solution would be to maintain a desired camera position (based on an offset of something, such as your character) and just move the camera there, or use interpolation to move between current and desired position.
N_K
Greenskin
Posts: 115
Joined: Wed Dec 07, 2011 9:05 pm
x 4

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

Post by N_K »

So the most convenient solution would be to get the world transform of the ghost object, then convert it to Ogre::Vector3, then move the camera with this vector. I've been thinking about this earlier. Thanks for your help, I'll try to implement it later and see how it goes.
molmasepic
Halfling
Posts: 95
Joined: Tue Jun 21, 2011 5:35 pm

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

Post by molmasepic »

Hello. Just recently I have created a Manual Object and converted it to a node, but when taking the node's entity to make the collision shape, I get an assert for "pRep, file OgreSharedPtr.h."

I tried other strategies on this thread but the same exact line keeps messing up. Here is the code:

Code: Select all

ManualObject* textureArrayObject = myGameScene->createManualObject(mapFile+"_TexAtlas");
        textureArrayObject->begin(texArrayMat->getName(), RenderOperation::OT_TRIANGLE_LIST);
        for(int r=0;r<pHeight;++r){
            for(int c=0;c<pWidth;++c){
                float idx=0.5;
                for (int b = 0; b < bytes; b++)
                    p[b] = buf[bytes * (pWidth * r + c) + b];
                for(int a=0;a<tileVals.size();++a){
                    if (hex == tileVals[a]){
                        idx = float(a)/float(tileVals.size()); //scale to 0->1
                        ///std::cout<<"picked value: " <<i<<std::endl;
                        break;
                    }
                }
                ///Triangle 0
                textureArrayObject->position(c*quadSize, 0, r*quadSize);
                textureArrayObject->textureCoord(0, 0, idx);
                textureArrayObject->position((c+1)*quadSize, 0, r*quadSize);
                textureArrayObject->textureCoord(1, 0, idx);
                textureArrayObject->position((c+1)*quadSize, 0, (r+1)*quadSize);
                textureArrayObject->textureCoord(1, 1, idx);
                ///Triangle 1
                textureArrayObject->position(c*quadSize, 0, r*quadSize);
                textureArrayObject->textureCoord(0, 0, idx);
                textureArrayObject->position((c+1)*quadSize, 0, (r+1)*quadSize);
                textureArrayObject->textureCoord(1, 1, idx);
                textureArrayObject->position(c*quadSize, 0, (r+1)*quadSize);
                textureArrayObject->textureCoord(0, 1, idx);
            }
        }
        textureArrayObject->end();
        myMesh=textureArrayObject->convertToMesh(mapFile+"_mesh");
        myCollMesh=textureArrayObject->convertToMesh(mapFile+"_Collmesh");
        ///mapM
		mapM.entity=myGameScene->createEntity(myMesh);
		mapM.entity->setMaterialName(texArrayMat->getName());
		mapM.node=myGameScene->getRootSceneNode()->createChildSceneNode();
		mapM.node->attachObject(mapM.entity);
		mapM.node->setPosition((quadSize*pWidth/-2)-oWidth,0,(quadSize*pHeight/-2)-oHeight);
		///CollM
		collM.entity=myGameScene->createEntity(myCollMesh);
		collM.entity->setMaterialName("ClearColl");
		collM.node=myGameScene->getRootSceneNode()->createChildSceneNode();
		collM.node->attachObject(collM.entity);
		collM.node->setPosition((quadSize*pWidth/-2)-oWidth,0,(quadSize*pHeight/-2)-oHeight);
		///Collision
		BtOgre::StaticMeshToShapeConverter converter(collM.entity);
        btBvhTriangleMeshShape *mShape = converter.createTrimesh();
		//Inertia
		btScalar mass = 5;
        btVector3 inertia;
        mShape->calculateLocalInertia(mass, inertia);
        BtOgre::RigidBodyState *state = new BtOgre::RigidBodyState(collM.node);
        coll.body=new btRigidBody(mass, state, mShape, inertia);
        coll.body->setActivationState(ISLAND_SLEEPING);
        myGameDW->addRigidBody(coll.body);
As seen by the code, I am creating a texture array manual object. More info here: http://www.ogre3d.org/forums/viewtopic.php?f=2&t=78085

Any help would be appreciated.
User avatar
jorgerosa
Gnoblar
Posts: 19
Joined: Mon Dec 07, 2009 7:50 pm
x 3
Contact:

BtOgre - StaticMeshToShapeConverter issue...

Post by jorgerosa »

Hello all, I have this situation:
(Just in case: I´m always using all the very lattest software and libraries. Code::Blocks 13.12, BtOgre, Bullet 2.82, Ogre 1.90, etc, etc, etc)

This runs OK...

Code: Select all

BtOgre::StaticMeshToShapeConverter conv; // OK...
App crashes here, at this line:

Code: Select all

btBvhTriangleMeshShape* myshape = conv.createTrimesh(); // CRASH!
Console says:

Code: Select all

File: <path>\btogre-master\btOgre.cpp, line 321
Expression: mvertexCount && (mIndexCount >=6) && ("Mesh must have some vertices and at least 6 indices (2 triangles)")
<...> Runtime to terminate it in an unusual way <...>
What am I missing?.. (I remember that I´ve done this before, 2 or 3 years ago, and was ok...)
THANKS for any help! :)
Last edited by jorgerosa on Thu Jun 19, 2014 10:17 am, edited 5 times in total.
User avatar
c6burns
Beholder
Posts: 1512
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines
x 138

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

Post by c6burns »

Not sure why exactly this happened, but the best course of action might be to set a break in BtOgre.cpp at the start of StaticMeshToShapeConverter::addEntity. Step through that method and you will probably find that somehow VertexIndexToShape::addStaticVertexData is not getting called. This will be the cause of the assert during the later call to createTrimesh()
User avatar
jorgerosa
Gnoblar
Posts: 19
Joined: Mon Dec 07, 2009 7:50 pm
x 3
Contact:

[SOLVED] BtOgre - StaticMeshToShapeConverter issue...

Post by jorgerosa »

c6burns, thanks for the tips! :)
StaticMeshToShapeConverter had no defined entity to be processed. So, I´ve "fixed" it this way:

Code: Select all

BtOgre::StaticMeshToShapeConverter conv([color=#FF0000]myentity[/color]); // OK
btBvhTriangleMeshShape* myshape = conv.createTrimesh(); // OK
User avatar
c6burns
Beholder
Posts: 1512
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines
x 138

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

Post by c6burns »

Oh I didn't even notice you were using default constructor ... I must be going blind! That would explain it though :) Glad you got it working!
Post Reply