Moving left and right without rotating

This topic is 4835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi, I have a 3d model into the scene. With a simple code called when the user presses Key_Left or Right I decrement / increment a flot variable:
void ItemDialogClass::Xpos_dec()
{
GlWindowClass->Model [ ChoosedModel ].x -= 0.1f;
Xpos_label->setText ( QString("%1").arg ( GlWindowClass->Model [ ChoosedModel ].x ) );
GlWindowClass->updateGL();
}

void ItemDialogClass::Xpos_inc()
{
GlWindowClass->Model [ ChoosedModel ].x += 0.1f;
Xpos_label->setText ( QString("%1").arg ( GlWindowClass->Model [ ChoosedModel ].x ) );
GlWindowClass->updateGL();
}


and this is the OpenGL drawing routine:
void GLWidget::paintGL()
{
switch (mode)
{
case Normal:
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glMatrixMode( GL_MODELVIEW );
CameraLook();
for ( std::map< unsigned int , string >::iterator i= GlWindowClass->DisplayList.begin(); i != GlWindowClass->DisplayList.end(); i++)
{
unsigned int index = i->first;
glPushMatrix();
glTranslatef ( Model[ index-1 ].x , Model[ index-1 ].y  , Model[ index-1 ].z );
glScalef ( Model[ index-1 ].sx , Model[ index-1 ].sy  , Model[ index-1 ].sz );
glCallList ( index );
glPopMatrix();
printf ("%d\t%f\t%f\t%f\n" , index-1, Model[index-1].x , Model[index-1].y , Model[ index-1 ].z);
}
break;

case Select:
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glMatrixMode( GL_MODELVIEW );
CameraLook();
break;
}
}


but the result is not a simple translation, while I move the model it rotates as soon as it reaches the border left or border right of the window. Do I need some maths ?

Share on other sites
if you can't debug that yourself, then we'll have to see more code my man : ) cus nothing there has to do with rotation, the window edges, or the model.

Share on other sites
Quote:
 Original post by Anonymous Posterif you can't debug that yourself, then we'll have to see more code my man : ) cus nothing there has to do with rotation, the window edges, or the model.

Are you sure Mr ? I pasted the code who increases / decreases the x value of the model selected and pasted the opengl drawing commands who draw the model selected at the position x, ,y ,z. What else do you need ? Also on the newsgroup have replied me wihout pasting the code !

Bye,

Share on other sites

This topic is 4835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

This topic is now closed to further replies.

• Forum Statistics

• Total Topics
628651
• Total Posts
2984043

• 10
• 9
• 9
• 10
• 21