set procedural mesh position

dreamig

22-05-2014 09:48:34

HI,
i have the position of 4 point , that create square ,
i want use this point to create cylinder or cube , or any thing in 3D
for exemple to create cylinder with those points i can use the top and button point to get the cylinder hight , to get the rudius from the two button point
but i have problem in the position how i can set the position of the cylinder?
that's my code
Ogre::Vector3 start(-36,90,104);
Ogre::Vector3 end(-46,85,81);
Ogre::Vector3 start1(-36,0,104);
Ogre::Vector3 end1(-46,0,81);

Ogre::Vector3 mid1((start+start1/2));
Ogre::Vector3 mid2((end+end1/2));
Ogre::Vector3 center((mid1+mid2/2));


Procedural::CylinderGenerator().setRadius(/*0.5*/start.distance(end)).setHeight(start.distance(start1))/*.setPosition(0,start->length/*//*2*//*,0)*/.realizeMesh("cyl");
ebody = mSceneMgr->createEntity("cyl");

pSNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("my cube");
pSNode->scale(Ogre::Vector3(0.04, 0.04, 0.04));
pSNode->attachObject(ebody);
pSNode->setPosition(center);


but as result , the hight isn't as i want, the ruduis and to position also :!:

mikachu

04-07-2014 20:34:13

I haven't really understood what you're trying to achieve, but here :
Ogre::Vector3 mid1((start+start1/2));
Ogre::Vector3 mid2((end+end1/2));
Ogre::Vector3  center((mid1+mid2/2));

You're probably misplacing your pathensis, it should be, for example :
Ogre::Vector3  center((mid1+mid2)/2);