Hi!
First of all i wish all of you a happy new year!
And now to my problem. I'm a kind of 3d Desktop and use QGLWidget (OpenGL) and ode for realizing it. I did everything well, but now i ask me how to pick objects with the mouse.
I call only these two transformations in paintGL:
glTranslatef(0.0, 0.0, -80.0);
glRotatef(90, 1.0, 0.0, 0.0);
glTranslatef(0.0, 0.0, -80.0);
glRotatef(90, 1.0, 0.0, 0.0);
To copy to clipboard, switch view to plain text mode
The Z-Axis doesn't matter for me i only need the x/y coordinates of one object (or x/z because of the rotation).
Now i tried following to translate the coordinates of the objects to normal paint coordinates, but somehow it doesn't work.......
float *geoPos = (float*)dGeomGetPosition(objs[i].geom);
QPoint bodyPos
= QPoint((geoPos
[2]+8)*80,
(geoPos
[0]+8)*80);
QRegion bodyRegion
(bodyPos.
x(), bodyPos.
y(),
80,
80);
if(bodyRegion.contains(mousePos))
qDebug("contains");
float *geoPos = (float*)dGeomGetPosition(objs[i].geom);
QPoint bodyPos = QPoint((geoPos[2]+8)*80, (geoPos[0]+8)*80);
QRegion bodyRegion(bodyPos.x(), bodyPos.y(), 80, 80);
if(bodyRegion.contains(mousePos))
qDebug("contains");
To copy to clipboard, switch view to plain text mode
Can anyone help me and say how i translate the object coordinates into the same format as the mouse coordinates are?
Bookmarks