Directional and orientation problem

Posted by Ahmed Saleh on Game Development See other posts from Game Development or by Ahmed Saleh
Published on 2012-04-21T21:31:36Z Indexed on 2012/06/07 22:48 UTC
Read the original article Hit count: 288

Filed under:
|
|

I have drawn 5 tentacles which are shown in red. I have drew those tentacles on a 2D Circle, and positioned them on 5 vertices of the that circle. BTW, The circle is never be drawn, I have used it to simplify the problem. Now I wanted to attached that circle with tentacles underneath the jellyfish. There is a problem with the current code but I don't know what is it.

You can see that the circle is parallel to the base of the jelly fish. I want it to be shifted so that it be inside the jelly fish. but I don't know how. I tried to multiply the direction vector to extend it but that didn't work.

// One tentacle is constructed from nodes
// Get the direction of the first tentacle's node 0 to node 39 of that tentacle;
   Vec3f dir = m_tentacle[0]->geNodesPos()[0] -  m_tentacle[0]->geNodesPos()[39];

    // Draw the circle with tentacles on it

    Vec3f pos = m_SpherePos;

    drawCircle(pos,dir,30,m_tentacle.size());

    for (int i=0; i<m_tentacle.size(); i++)
    {
        m_tentacle[i]->Draw();

    }


 // Draw the jelly fish, and orient it on the 2D Circle
    gl::pushMatrices();
    Quatf q;
    // assign quaternion to rotate the jelly fish around the tentacles
    q.set(Vec3f(0,-1,0),Vec3f(dir.x,dir.y,dir.z));
    // tanslate it to the position of the whole creature per every frame
    gl::translate(m_SpherePos.x,m_SpherePos.y,m_SpherePos.z);
    gl::rotate(q);

    // draw the jelly fish at center 0,0,0 
    drawHemiSphere(Vec3f(0,0,0),m_iRadius,90);

    gl::popMatrices();

© Game Development or respective owner

Related posts about opengl

Related posts about 3d