Ogre and bullet implementation

Post Reply
hyyou
Posts: 96
Joined: Wed Mar 16, 2016 10:11 am

Re: Ogre and bullet implementation

Post by hyyou »

Here is my an subjective and arguable propose ...

You should have to be able to do basic things in both engine BEFORE try to integrate them.

The basic things :-
  • Ogre3d = camera, light, entity and sceneNode.
    Bullet = dynamic world, (set/get) (velocity, position), rigidbody (simple shape like plane & cube)
Binding two engines is basically just get location & orientation from btRigidBody and set to the sceneNode of Ogre3D.

It is not hard to make it happen, but for me it is really hard to make the code not messy and usable as an utility for game.

I recommends to encapsulate both engines, at least their basic features.
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: .

Post by benelot »

Whatever the original question was (I can guess based on the answer). I wrote a simulator based on Ogre3D and Bullet without using OgreBullet. If you need directions on how to do that, ask me anything!
hyyou
Posts: 96
Joined: Wed Mar 16, 2016 10:11 am

Re: .

Post by hyyou »

Benelot, in your top level of program, how you encapsulate Bullet Engine?

I am creating physic object like this :-

Code: Select all

MyRigidBody* rigid = physicFactory()->createCube( position, halfSize , mass, mask );
My bullet world is encapsulated in Physic_Room that has a duty to maintain each type of physic object.
I create a custom array to store each type of them (constraint , rigid, compound, empty ).
I have to code function for allocate new physic object of each type.

Code: Select all

class Physic_Room{
     MyConstraint* allocateConstraint(){   ....     }
     MyRigidBody* allocateRigidbody(){   ....     }
     ...
     void addToTheBulletWorld(MyConstraint*){   ....     }
     void addToTheBulletWorld(MyRigidBody*){   ....     }
     ...
     void destroyConstraint(MyConstraint*){   ....     }
     void destroyRigidBody(MyRigidBody*){   ....     }
     ...
};
I think it is error-prone.
Would you mind to share how you did?
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

Re: .

Post by benelot »

So basically I created a model view controller pattern, having an environment encapsulating the world, creature consisting of limbs encapsulating rigidbodies, joints encapsulating joint constraints. Each controller class then reads the model state from the physics and updates its view to represent the state. Your physics room would be similar to my environment, except that I would store creatures in a std::vector instead of storing all things separately.

This is what this generally looks like:
-A single limb:
https://github.com/benelot/minemonics/b ... y/Limb.cpp

https://github.com/benelot/minemonics/b ... y/Limb.hpp

A creature (consisting of a phenotype which in turn consists of limbs and joints):

https://github.com/benelot/minemonics/b ... eature.cpp

https://github.com/benelot/minemonics/b ... eature.hpp
Last edited by benelot on Sat Aug 13, 2016 1:08 pm, edited 1 time in total.
Post Reply