Results 1 to 2 of 2

Thread: How do I display a 3D orientation axis (XYZ)

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2003
    Posts
    7

    How do I display a 3D orientation axis (XYZ)

    Does anyone know how to display a 3D orientation axis that will rotate with your model but stay in front of the model in a particular corner of the screen? Or know where I can go to find information on doing this?

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Adelaide, South Australia, Australia
    Posts
    763

    Re: How do I display a 3D orientation axis (XYZ)

    Hello,

    the easiest way to get the effect you want is to take a copy of the modelview matrix and put zeros in the first three rows of the fourth column. That will orientate your axis by the world rotation but not translate it, so you can translate the axis indepenendly. Some pseudo-code:

    Code :
    drawAxis()
    {
      GLdouble mv[16]=getModelviewMatrix();
      mv[3]=mv[3+4]=mv[3+8]=0.0;
      glPushMatrix();
      glLoadIdentity();
      glTranslatef(-5.0, -5.0, 0.0); // position on screen
      glMultMatrix(mv); // orientation
      glBegin(GL_LINES);
      glVertex3f(0.0, 0.0, 0.0);
      glVertex3f(1.0, 0.0, 0.0);
      glVertex3f(0.0, 0.0, 0.0);
      glVertex3f(0.0, 1.0, 0.0);
      glVertex3f(0.0, 0.0, 0.0);
      glVertex3f(0.0, 0.0, 1.0);
      glEnd();
      glPopMatrix();
    }
    the alternative way is to draw the orientated vectors by pulling them out of the matrix (whcih is how I do it), but this has the same effect.

    cheers
    John

Similar Threads

  1. How to rotate objects around global axis not local axis
    By silvermeteor in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 12-04-2017, 11:10 AM
  2. model axis and camera orientation
    By Rogeeeer in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 04-25-2013, 03:29 AM
  3. Local Axis Orientation Position & Rotation
    By ColacX in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 12-03-2009, 02:08 PM
  4. XY axis run time values display based on the mouse
    By SANTOS_GL in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-27-2009, 02:35 AM
  5. axis display
    By ThunderSoul in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-04-2005, 05:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean