[Git]Generating an Ogre3D Body. 2 Questions

KyleKatarn

24-09-2009 04:34:35

Hello again.

I've got a question about generating an Ogre3D Bodies around a mesh. I'm trying to write up code which will allow my character to collide with my environment, but when I write up a test body, I get this:



As you can see, the capsule is generated around her feet. Is this meant to happen? Or does it all depend on the exported object's modelling axis? i.e. if I export my mesh with the modelling axis not in the center, and load it into code and generate a physics mesh around it, does it generate around the modelling axis and not the object?

Also, is it possible to generate a cylinder body, instead of a capsule? If not, can I somehow freeze the capsule in the y axis so it wont roll around?

betajaen

24-09-2009 10:26:34

Yes, your pivot for your character's mesh is to high. It should be in the middle.

You can use a convex with a mesh that is cylinder-like, but it would be more slower on the solver than a capsule. Normally people use capsules for characters.

You can stop the capsule tipping over by adding a frozen flag in the RigidBodyDescription, when you create it.

RigidBodyDescription desc;

desc.mBodyFlags |= BodyFlags_FreezePositionY;

mCharacter = mOgreRenderSystem->createBody(...., desc);


You may want "BodyFlags_FreezeRotation" as well, to stop it turning around when you hit something, friction causes it to turn.

KyleKatarn

24-09-2009 17:20:54

Thanks for the reply, I'll have to talk to the gfx artist who exported it lol.

Also I've noticed that when I use the FreezePositionY, it freezes all movement in the Y direction. If I wanted my character to jump, would I have to somehow turn this off, then back on after the character lands?

betajaen

24-09-2009 17:34:30

Doh!

I meant;

desc.mBodyFlags |= BodyFlags_FreezeRotationX;
desc.mBodyFlags |= BodyFlags_FreezeRotationZ;

KyleKatarn

25-09-2009 03:31:11

Thanks man.

I know I've been asking too much, but I may as well drop all pretense. I'm flying blind. I've got no idea what I'm doing when it comes to making the character a physics mesh, I know I need to create a body and apply forces to it for movement, etc, but Im not sure what to do when it comes to state changing, i.e. walking animation, if I initialise the mesh in the createBody function, how do I change its animations etc. If anyone could be so kind as to help push me in the right direction, it would be massively appreciated, because right now it's like groping around in a dark room where your eyes dont adjust, lol.