irrlicht + bullet: character controller

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
easy163
Posts: 24
Joined: Wed Jul 10, 2013 12:50 pm

irrlicht + bullet: character controller

Post by easy163 »

Physics plugged in, everything works. But how to create the player model which would be moved? As I understand it, we must create not visible object, create a node player and stick it in an invisible capsule. Capsule I created, throwing in her cubes face and fall. But how to attach the player model and movement?

ps After that I want to put the camera inside the capsule and it was very eye
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: irrlicht + bullet: character controller

Post by Cube_ »

Not sure what you are trying to say (tip; read through what you wrote to make sure it is possible to follow the text)

Create the bullet character controller as an irrlicht node, then parent the mesh to that node and you're kind of done
"this is not the bottleneck you are looking for"
easy163
Posts: 24
Joined: Wed Jul 10, 2013 12:50 pm

Re: irrlicht + bullet: character controller

Post by easy163 »

Forgot the code to show

Code: Select all

 
btTransform startTransform;
startTransform.setIdentity();
startTransform.setOrigin(btVector3(0.0f, 300.0f, 0.0f));
 
GhostObject = new btPairCachingGhostObject();
GhostObject->setWorldTransform(startTransform);
Capsule = new btCapsuleShape(300, 200);
GhostObject->setCollisionShape(Capsule);
GhostObject->setCollisionFlags(btCollisionObject::CF_CHARACTER_OBJECT);
 
Character = new btKinematicCharacterController(GhostObject, Capsule, btScalar(0.35));
World->addCollisionObject(GhostObject,btBroadphaseProxy::CharacterFilter, btBroadphaseProxy::StaticFilter|btBroadphaseProxy::DefaultFilter);
World->addAction(Character);
 
ISceneNode* cube_node = smgr->addCubeSceneNode(1.0f);
cube_node->setScale(vector3df(100.0f));
cube_node->setMaterialTexture(0, driver->getTexture("media/map/Chipped Bricks.jpg"));
 
But, how to get a position not visible object?
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: irrlicht + bullet: character controller

Post by Cube_ »

Okay, I don't understand what you are trying to say, none of your sentences are coherent enough for me to even begin figuring out your problem.

I get that your first language isn't English but if you have to use a translator like google translate, it's bound to at least throw something semi-legible at me.
"this is not the bottleneck you are looking for"
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: irrlicht + bullet: character controller

Post by serengeor »

To attach scene node to physics body you need to inherit from motion state and update your node positions from it.
It's all explained in bullet wiki, please look through all of those examples before you go any further.
Working on game: Marrbles (Currently stopped).
easy163
Posts: 24
Joined: Wed Jul 10, 2013 12:50 pm

Re: irrlicht + bullet: character controller

Post by easy163 »

I understand that the translator is very bad, but I figured out how to make a node that she would inherit the position of the phantom of the capsules. Post the code, but here's the problem, Ghost flies through objects, dynamic he pushes and static passes on through. Shoot a video and posted on YouTube. Please help :)

Code: Select all

 
        btTransform startTransform;
        startTransform.setIdentity();
        startTransform.setOrigin(btVector3(0.0f, 300.0f, 0.0f));
 
        GhostObject = new btPairCachingGhostObject();
        GhostObject->setWorldTransform(startTransform);
        Capsule = new btCapsuleShape(100, 200);
        GhostObject->setCollisionShape(Capsule);
        GhostObject->setCollisionFlags(btCollisionObject::CF_CHARACTER_OBJECT);
 
        Character = new btKinematicCharacterController(GhostObject, Capsule, btScalar(0.35));
 
        World->addCollisionObject(GhostObject, btBroadphaseProxy::CharacterFilter, btBroadphaseProxy::StaticFilter|btBroadphaseProxy::DefaultFilter);
 
        World->addAction(Character);
 
        player_model_node = smgr->addCubeSceneNode(1.0f);
        player_model_node->setScale(vector3df(100.0f));
        player_model_node->setMaterialTexture(0, driver->getTexture("media/map/Chipped Bricks.jpg"));
        player_model_node->setPosition(vector3df(0, 0, 0));
 
The following code in the main loop

Code: Select all

 
        btTransform my_trans;
        my_trans = GhostObject->getWorldTransform();
        matrix4 matr;
        my_trans.getOpenGLMatrix(matr.pointer());
        player_model_node->setPosition(matr.getTranslation());
 
http://youtu.be/xQL3FDcP_m8
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: irrlicht + bullet: character controller

Post by Cube_ »

Okay, so.. you want the white balls to go through the cube?
I still don't really get what your problem is, I assume the cube is supposed to go through the ground
"this is not the bottleneck you are looking for"
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: irrlicht + bullet: character controller

Post by serengeor »

did you try using addRigidBody instead of addCollisionObject?
Working on game: Marrbles (Currently stopped).
Post Reply