create character using cylinders and .skeleton

dreamig

12-02-2014 09:57:19

HI,
my aim is to use ogreprocedural and .skeleton file to create my character
with cylinders

for that first i ake like that
for all the bones of the .skeleton

create_joint_list(skel->getBone(i)->getParent(),skel->getBone(i),30.5,skel->getBone(i)->getName());

where the function "create_joint_list" tend to create shapes (cylinder) for the arm,legs...
we give the first bone, the father bone, the name and the cylinders ruduis

Now in create_joint_list i make like that

Ogre::Vector3 from = start->_getDerivedPosition()/*getPosition()*/;
Ogre::Vector3 to = end->/*getPosition()*/_getDerivedPosition();
Ogre::Real Length = from.distance( to );

cout<<"length"<<length;

Ogre::Real height = Length - 2*40;

Procedural::CapsuleGenerator().setRadius(40).setHeight(height).setPosition(0,Length/2,0).realizeMesh(nom);
Ogre::Entity* ent2 = mSceneMgr->createEntity(nom);
ent2->setMaterial(material3);
Ogre::SceneNode* sn =start->createChildSceneNode();
material = Ogre::MaterialManager::getSingleton().create("green"+nb_cam, "General");


material->getTechnique( 0 )->getPass( 0 )->setAmbient(0.5,0.5,0.5);
/*ent_marker*/ent2->setMaterial(material);
sn->attachObject(ent2);

sn->_setDerivedOrientation( Ogre::Vector3::UNIT_Y.getRotationTo( to-from ) );


nb_cam++;
////////////////

}


the problem is in thsi line
Ogre::SceneNode* sn =start->createChildSceneNode();
Because for the bones there is not create childscenode;

mikachu

12-02-2014 13:51:23

To attach an entity to a bone, you cannot use a SceneNode, because bones inherit Node directly.

Instead, look at this extract from Ogre Character sample :
mSword1 = sceneMgr->createEntity("SinbadSword1", "Sword.mesh");
mSword2 = sceneMgr->createEntity("SinbadSword2", "Sword.mesh");
mBodyEnt->attachObjectToBone("Sheath.L", mSword1);
mBodyEnt->attachObjectToBone("Sheath.R", mSword2);

dreamig

12-02-2014 14:06:39

HI,
but using this intruction
stay the problem of orientation
sn->_setDerivedOrientation( Ogre::Vector3::UNIT_Y.getRotationTo( to-from ) );

mikachu

12-02-2014 14:18:14

You can use the offsetOrientation attribute : http://www.ogre3d.org/docs/api/1.9/clas ... a6c1a30fb6
or use setOrientation in the CapsuleGenerator..

dreamig

12-02-2014 14:18:46

Hi again i used tagPoint like that

Ogre::Quaternion rot = Ogre::Quaternion::IDENTITY;
Ogre::TagPoint* pTagPoint=entcharacter->attachObjectToBone(start->getName(),ent2,rot,Ogre::Vector3::ZERO);
pTagPoint->_setDerivedOrientation(Ogre::Vector3::UNIT_Y.getRotationTo( to-from ));

it work but i have in this case another problem
in the length or the hight of the capsule
i set them like that

Procedural::CapsuleGenerator().setRadius(3).setHeight(length).setPosition(0,Length/2,0).realizeMesh(nom);

but
the capsul is i the midel of the limb not recover or the limb (it's in the white)
[attachment=0]caapq.jpg[/attachment]