Game Development Community

dev|Pro Game Development Curriculum

Slight improvement to world editor axis gizmo

by Orion Elenzil · 06/07/2007 (11:11 am) · 3 comments

this is based on TGE 1.3.5, but is probably pretty similar thru 1.5+.

worldEditor.cc:
in WorldEditor::renderAxisGizmo(),
find the line "ColorI selectColor( 0x00, 0xff, 0xff ); // Bright teal", and insert the following after it.
//----------------------------------
   // render axes all the way out.

   S32  widths[] = {6   , 1    };
   S32  alphas[] = {0.3f, 0.3f };
   bool depths[] = {true, false};

   glEnable(GL_LINE_STIPPLE);
   for (S32 n = 0; n < 2; n++)
   {
      if (depths[n])
      {
         glEnable(GL_CULL_FACE);
         glEnable(GL_DEPTH_TEST);
         glLineStipple(1, 0xffff);
      }
      else
      {
         glDisable(GL_CULL_FACE);
         glDisable(GL_DEPTH_TEST);
         glLineStipple(1, 0xfffe);
      }

      glLineWidth(widths[n]);

      glBegin(GL_LINES);
      for(U32 i = 0; i < 3; i++)
      {
         Point3F & centroid = mAxisGizmoCenter;

         switch(i)
         {
         case 0:
            glColor4f( 1.0f, 0.0f, 0.0f, 0.3f ); //x
            break;
         case 1:
            glColor4f( 0.0f, 1.0f, 0.0f, 0.3f ); //y
            break;
         case 2:
            glColor4f( 0.0f, 0.0f, 1.0f, 0.3f ); //z
            break;
         }

         glVertex3f(centroid.x, centroid.y, centroid.z);
         glVertex3f(centroid.x - mAxisGizmoVector[i].x * 1000.0f,
                    centroid.y - mAxisGizmoVector[i].y * 1000.0f,
                    centroid.z - mAxisGizmoVector[i].z * 1000.0f);

         glVertex3f(centroid.x, centroid.y, centroid.z);
         glVertex3f(centroid.x + mAxisGizmoVector[i].x * 1000.0f,
                    centroid.y + mAxisGizmoVector[i].y * 1000.0f,
                    centroid.z + mAxisGizmoVector[i].z * 1000.0f);
      }
      glEnd();
   }

   glDisable(GL_LINE_STIPPLE);
   //----------------------------------

all done!

elenzil.com/gg/images/axisgizmo.jpg

#1
06/20/2007 (5:44 am)
I'm going to call you Mr. Perfection. I've read your posts in the past, and it seems you love to fine tune. I thank you for your attention to detail.
#2
06/20/2007 (7:44 am)
thanks!
#3
08/29/2007 (8:18 pm)
Orion, you are a lifesaver. This is just what I need. I hate those tiny little gizmo lines. Thankyou. :-)