Rotate the actor of a character

ylliac

03-12-2008 09:40:34

Hello,

I have a little problem in my current project which is a boat race simulation.
I have a character : the boat.
I have a static body : any other element of the world.

Initially, the boat is oriented along the Z-axis.

When I approach an object with the boat oriented along the Z-axis, the boat stop when he hit the object. All is normal, no problem as you can see on the following image :

http://www.hiboox.fr/go/images/divers/capt2,b8f335e9193612e54da6f186d5d18da7.png.html

But when I approach the boat along the X-axis, it react like if the representation of the boat was well oriented and if the actor was still oriented along the Z-axis. I'm not very clear but maybe this image will help :

http://www.hiboox.fr/go/images/divers/capt1,490d9bfcc7ad9a51379f3a1fb7dc69d7.png.html
On this image, the boat can't go lower, that is the problem.

To rotate the boat I tried two solutions that do the same :


pNxCharacter->getNode()->yaw(Ogre::Degree(-characterSpeed/10));
pNxCharacter->setDirection(pNxCharacter->getNode()->getOrientation());



Ogre::Quaternion q;
q.FromAngleAxis(Ogre::Degree(-characterSpeed/10),pNxCharacter->getGlobalOrientation() * Ogre::Vector3::UNIT_Y);
q = pNxCharacter->getGlobalOrientation() * q;
pNxCharacter->setDirection(q);


Hope someone knows a solution :D and excuse me for my english

betajaen

03-12-2008 10:27:02

Unfortunately you can't rotate the Character. It's not designed to do that; instead you would rotate the node, and keep a copy of the angle handy for later when you want to move again.

May I ask, why you are using a character for a boat? I would presume a normal actor would be much better to use.

ylliac

03-12-2008 18:06:49

Thank you for your answer.
Maybe I will try to do it without using a character ...

But I think it's weird that a character can't rotate :(
How can we simulate a realistic movement and collision if the character can't rotate ?

betajaen

03-12-2008 19:01:31

Generally characters are capsules in shape, which doesn't need vertical rotation.

Although technically you could add rotation into the character code. It's streamlined so the character is just a set of "extents" plus direction, if you add rotation into the mix. It gets a little complicated, as you have to rotate those extents as well. But since it's usually a capsule there is no need.

ylliac

03-12-2008 19:34:38

And what are you suggesting for a boat that doesn't feel gravity because his altitude is determinated by the waves of the water and that has a realistic movement (not as classic dynamic bodies with forces that make them pitch) ?
I thought about kinematic body maybe ...

betajaen

03-12-2008 19:36:30

That may work, but you may have trouble later with collisions with other boats and other debris in the water.

I have tried buoyancy with dynamic actors, it did work - but it does require tweaking.

kungfoomasta

03-12-2008 20:45:36

What do you mean by "When I approach the boat"? Are you moving some object into the boat to see what happens? Or maybe the boat model's initial facing is the Z axis and you change it to the X axis? (like the Ogre Ninja vs Robot)

ylliac

03-12-2008 22:57:43

If I understand what you're asking, it must be the second choice. On the pictures, I move the boat until I'm blocked by the object.

I think I will try with kinematic bodies because I don't really know what is buoyancy and because it appears to be almost the same as character.

I will let you know if it worked :wink:

Thank you for your answers, maybe I will come back soon with others questions :D

betajaen

03-12-2008 23:31:22

Well if you want to know how to apply it to a dynamic actor:

It's; g * mass * wave height. (If my memory serves me correctly).

But try it with a kinematic actor first; it will be easier and much more predictable, but you will loose collision and responses with it. You will also need to write your own physics for when something bigger hits the boat. :D

ylliac

03-12-2008 23:34:16

Thank you for this tip, maybe I'll try it later, depend on time :wink:

There are no other boat and nothing move except the boat so I haven't to handle collision with the boat. So I think kinematic will do it.

Thank you again.