Hi!
I am working on a simple 3D editor and I am trying to reproduce the “grab, scale, rotate” handle like in blender, or maya… To let the user manipulate a specific object on a specific axis…I try many thing but I don’t know what Im doing wrong but its just not looking right…
Please help!!!
Tks in advance,
glMatrixMode( GL_PROJECTION );
glPushMatrix();
glLoadIdentity();
glOrtho( 0.0f,
(GLfloat)widget->allocation.width,
0.0f,
(GLfloat)widget->allocation.height,
-100.0f, 100.0f );
glMatrixMode( GL_MODELVIEW );
glPushMatrix();
glLoadIdentity();
glDisable( GL_DEPTH_TEST );
glDepthMask( GL_FALSE );
{
if( object_selection )
{
glPushMatrix();
{
glTranslatef( ( float )sx, ( float )sy, 0.0f );
glRotatef( 35.0f, 0.0f, 1.0f, 0.0f );
// X
glColor4f( 1.0f, 0.0f, 0.0f, 1.0f );
glBegin( GL_LINES );
glVertex3f( 0.0f, 0.0f, 0.0f );
glVertex3f( 50.0f, 0.0f, 0.0f );
glEnd();
// Z
glColor4f( 0.0f, 0.0f, 1.0f, 1.0f );
glBegin( GL_LINES );
glVertex3f( 0.0f, 0.0f, 0.0f );
glVertex3f( 0.0f, 50.0f, 0.0f );
glEnd();
// Y
glColor4f( 0.0f, 1.0f, 0.0f, 1.0f );
glBegin( GL_LINES );
glVertex3f( 0.0f, 0.0f, 0.0f );
glVertex3f( 0.0f, 0.0f, 50.0f );
glEnd();
}
glPopMatrix();
}
}
glMatrixMode( GL_PROJECTION );
glPopMatrix();
glMatrixMode( GL_MODELVIEW );
glPopMatrix();
glEnable( GL_DEPTH_TEST );
glDepthMask( GL_TRUE );