dreamig
15-01-2013 08:31:37
Hi,
i had problem before and i resolved it :
it was relating two point by cylinder , i resolved it by creating cylinder manually
i want now use ogreprocedural
my first code (manually is)
it work and relat the point "start" and "end " without problem
BUT when i want use ogre procedural it does not work , i changed and i used "CapsuleGenerator()"
that's my code
and that's what i see
i had problem before and i resolved it :
it was relating two point by cylinder , i resolved it by creating cylinder manually
i want now use ogreprocedural
my first code (manually is)
createCylinder( Ogre::SceneNode *start, Ogre::SceneNode *end, float R,Ogre::String nom )
{
Ogre::Vector3 from = start->_getDerivedPosition();
Ogre::Vector3 to = end->_getDerivedPosition();
Ogre::Real Length = from.distance( to );
Ogre::Real step = Ogre::Radian( Ogre::Degree( 2 ) ).valueRadians();
std::vector< Ogre::Vector3 > bottom;
std::vector< Ogre::Vector3 > top;
//precalculate
for( Ogre::Real i =0; i < Ogre::Math::PI*2; i = i+step )
{
bottom.push_back( Ogre::Vector3( Ogre::Math::Sin( i )*R, 0 , Ogre::Math::Cos( i )*R ));
top.push_back( Ogre::Vector3( Ogre::Math::Sin( i )*R, Length , Ogre::Math::Cos( i )*R ));
}
Ogre:: ManualObject *cyl_bottom = mSceneMgr->createManualObject();
Ogre:: ManualObject *cyl_top = mSceneMgr->createManualObject();
Ogre:: ManualObject *cyl_side = mSceneMgr->createManualObject();
cyl_bottom->begin( "BaseWhiteNoLightning", Ogre::RenderOperation::OT_TRIANGLE_FAN );
cyl_top->begin( "BaseWhiteNoLightning",Ogre:: RenderOperation::OT_TRIANGLE_FAN );
cyl_side->begin( "BaseWhiteNoLightning", Ogre::RenderOperation::OT_TRIANGLE_STRIP ); // Side is triangle strip
size_t size = bottom.size();
//fill points
for( int i = 0; i < size; ++i )
{
cyl_bottom->position( bottom );
cyl_top->position( top );
cyl_side->position( top[ i ] );
cyl_side->position( bottom[ i ] );
}
count++;
cyl_bottom->end();
cyl_top->end();
cyl_side->end();
Ogre::SceneNode *cylin =start->createChildSceneNode(nom);
cylin->attachObject( cyl_bottom );
cylin->attachObject( cyl_top );
cylin->attachObject( cyl_side );
cylin ->_setDerivedOrientation( Ogre::Vector3::UNIT_Y.getRotationTo( to-from ) );
it work and relat the point "start" and "end " without problem
BUT when i want use ogre procedural it does not work , i changed and i used "CapsuleGenerator()"
that's my code
Procedural::CapsuleGenerator().setRadius(40).setHeight(Length).realizeMesh("capsuleMesh");
Ogre::Entity* ent2 = mSceneMgr->createEntity("capsuleMesh");
Ogre::SceneNode* sn = /*mSceneMgr->getRootSceneNode()*/start->createChildSceneNode();
sn->attachObject(ent2);
sn->_setDerivedOrientation( Ogre::Vector3::UNIT_Y.getRotationTo( to-from ) );
and that's what i see