gde230

03-29-2017, 08:50 AM

Hello,

i have a model that is painted roated an then translaten:

// rotate

glRotatef(x_rot, 1.0, 0.0, 0.0);

glRotatef(y_rot, 0.0, 1.0, 0.0);

glRotatef(z_rot, 0.0, 0.0, 1.0);

// x y z switched since rotated.

glTranslated(z_pos, -y_pos, +x_pos);

now i want to move the view by mouse which is done by this function

void View3D::mouseMoveEvent(QMouseEvent *event)

{

if(event->buttons() == Qt::LeftButton)

{

int dx = event->x() - last_pos.x();

int dy = event->y() - last_pos.y();

x_pos += dx/(80.0*zoom);

y_pos += dy/(80.0*zoom);

updateGL();

}

}

The problem here is that now the movement is done along the "old" unrotated axis and not the rotated ones. Therefore i want to somehow get the unit vectors of the painted model in the actual view.

(and then apply a dot product to the global unitvectors to get the movement)

Is there a out of the box openGl function for this or do i need to calculate them from the angles myself?

i have a model that is painted roated an then translaten:

// rotate

glRotatef(x_rot, 1.0, 0.0, 0.0);

glRotatef(y_rot, 0.0, 1.0, 0.0);

glRotatef(z_rot, 0.0, 0.0, 1.0);

// x y z switched since rotated.

glTranslated(z_pos, -y_pos, +x_pos);

now i want to move the view by mouse which is done by this function

void View3D::mouseMoveEvent(QMouseEvent *event)

{

if(event->buttons() == Qt::LeftButton)

{

int dx = event->x() - last_pos.x();

int dy = event->y() - last_pos.y();

x_pos += dx/(80.0*zoom);

y_pos += dy/(80.0*zoom);

updateGL();

}

}

The problem here is that now the movement is done along the "old" unrotated axis and not the rotated ones. Therefore i want to somehow get the unit vectors of the painted model in the actual view.

(and then apply a dot product to the global unitvectors to get the movement)

Is there a out of the box openGl function for this or do i need to calculate them from the angles myself?