Character yaw, TPP.

misiek

17-02-2009 22:57:18

Hello!
I'm working on character controller for simple tpp game. I have problem with rotating character along Y axis with setting torque (it is quite abstract for me). Another way to do it I've tried is to keep angle and rotate body in customForceAndTorqueCallback by setPositionOrientation. It works, but character is moving very slowly in strange directions on non-flat ground (?). Finally, I used setOmega, but I need help to construct valid customForceAndTorqueCallback function.
Which way is the best? TIA.

Sorry of my language.

PJani

18-02-2009 10:22:13

first of all i suggest you you should use basic vectorup joint look in documentation is quite simple you need world body of your char pos and pin i think. and then you could construct a callback

misiek

18-02-2009 17:34:39

I've already created upvector joint to character body. I'm just looking for simple solution to rotate body.
Character's constructor should clear up something:
Character::Character(SceneManager *smgr, OgreNewt::World *w, Camera *cam, const OgreNewt::MaterialID *mat) :
_angle(0), world(w), material(mat)
{
Entity *ent = smgr->createEntity("character", "ellipsoid.mesh");
ent->setMaterialName("Simple/Character");
cNode = smgr->getRootSceneNode()->createChildSceneNode();
cNode->attachObject(ent);
cNode->scale(Vector3(1, 2, 1));

camNode = cNode->createChildSceneNode();
camNode->createChildSceneNode(Vector3(0, 4, -10))->attachObject(cam);
cam->setAutoTracking(true, cNode);
cam->setNearClipDistance(2);

OgreNewt::Collision *col = new OgreNewt::CollisionPrimitives::Ellipsoid(world, Vector3(1, 2, 1));
body = new OgreNewt::Body(world, col);
delete col;
Vector3 inertia = OgreNewt::MomentOfInertia::CalcEllipsoidSolid(20, Vector3(1, 2, 1));
body->setMassMatrix(20, inertia);
body->attachToNode(cNode);
body->setMaterialGroupID(material);
body->setCustomForceAndTorqueCallback<Character>( &Character::CustomForceCallback, this );
body->setPositionOrientation(Vector3(0, 50, 0), Quaternion::IDENTITY);

OgreNewt::Joint *joint_y = new OgreNewt::BasicJoints::UpVector( world, body, Vector3(Vector3::UNIT_Y));

body->setAutoFreeze(0);
}


Edit: About strange slowly move - it was my fault, it's not problem any more. But still looking for any tips how to use setTorque and setOmega functions.