Friday, April 20, 2012

orient a circle under an object?

I would like to orient a 2D circle underneath or aligned a 3D Object as it appears that the circle is a base to the to hemisphere.
Kindly find the attached picture for more clarification.
enter image description here



I use the following code that gives wrong orientation.



    gl::pushMatrices();
Quatf q;
Vec3f dir = m_tentacle[0]->geNodesPos()[0] - m_tentacle[0]->geNodesPos()[8];
q.set(Vec3f(0,-1,0),Vec3f(dir.x,dir.y,dir.z));

gl::translate(m_SpherePos);
gl::rotate(q);

drawHemiSphere(m_iRadius,90);

gl::popMatrices();

gl::pushMatrices();

Vec3f axis = q.getAxis();
float angle = q.getAngle();
Quatf incQuat(dir,angle);
gl::translate(m_SpherePos);
gl::rotate(incQuat);
gl::drawStrokedCircle(Vec2f(0,0),100);

gl::popMatrices();




No comments:

Post a Comment