Answer the question
In order to leave comments, you need to log in
OpenGl traversal issue (reverse matrix multiplication and review of results)
Actually, there is a code:
paintGL() {
//Clear color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
//Drawing constant objects
matrixManipulation(0, 0);
drawRoom(light0Position, light1Position, viewPosition, GL_TRUE);
}
matrixManipulation(int manipulationMode, int x) {
glLoadIdentity();
//For right translate on x axis
glRotated(180.0f, 0.0f, 1.0f, 0.0f);
//Manipulation translate
glTranslatef(coorX, coorY, coorZ);
if(manipulationMode != 0) {
glGetFloatv(GL_MODELVIEW_MATRIX, currentMatrix);
glLoadIdentity();
qDebug() << "x" << xOld << x;
glRotated((xOld - x)/5, 0.0f, 1.0f, 0.0f);
glMultMatrixf(currentMatrix);
}
}
mousePressEvent(QMouseEvent *me) {
if(me->button() == Qt::LeftButton) {
xOld = me->x();
yOld = me->y();
mouseRotate = true;
} else mouseRotate = false;
}
mouseMoveEvent(QMouseEvent *me) {
if(mouseRotate) {
qDebug() << " mouseRotate" << "\n";
float x = me->x();
matrixManipulation(1, x);
xOld = x;
updateGL();
}
}
matrixManipulation(int manipulationMode, int x) {
glGetFloatv(GL_MODELVIEW_MATRIX, currentMatrix);
glLoadIdentity();
//For right translate on x axis
glRotated(180.0f, 0.0f, 1.0f, 0.0f);
//Manipulation translate
glTranslatef(coorX, coorY, coorZ);
if(manipulationMode != 0) {
glLoadIdentity();
qDebug() << "x" << xOld << x;
glRotated((xOld - x)/5, 0.0f, 1.0f, 0.0f);
}
glMultMatrixf(currentMatrix);
}
glLoadIdentity();
//For right translate on x axis
glRotated(180.0f, 0.0f, 1.0f, 0.0f);
//Manipulation translate
glTranslatef(coorX, coorY, coorZ);
if(manipulationMode != 0) {
glGetFloatv(GL_MODELVIEW_MATRIX, currentMatrix);
glLoadIdentity();
qDebug() << "x" << xOld << x;
glRotated((xOld - x)/5, 0.0f, 1.0f, 0.0f);
glMultMatrixf(currentMatrix);
}
matrixManipulation(int manipulationMode, int x) {
glGetFloatv(GL_MODELVIEW_MATRIX, currentMatrix);
glLoadIdentity();
//For right translate on x axis
glRotated(180.0f, 0.0f, 1.0f, 0.0f);
//Manipulation translate
glTranslatef(coorX, coorY, coorZ);
if(manipulationMode != 0) {
glLoadIdentity();
qDebug() << "x" << xOld << x;
glRotated((xOld - x)/5, 0.0f, 1.0f, 0.0f);
}
glMultMatrixf(currentMatrix);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question