Hi,
My name is Romain and I’m new on this forum.
Little presentation :
I’m a french developper and I use openGL in my software for points, polygon and polyhedron representation.
I develop in c++ with Qt for 10 years for geological application. My formation is geophysics that is a mix between geology and physics.
On my new software, I have to show on screen several polygons, but I have a problem of understanding the parameters of gluPErpestective and gluLookAt.
In fact my 3d objects are not center on (0;0;0). The Box that contains all my objects in (-50;-50;-600) for the top-left corner of the box and (50;50;-800) for the bottom-right corner.
My objects are under the sea-level, so negative (depth in meters under the ground)
Here is my code :
glDisable(GL_LIGHTING);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glLineWidth(1.0f);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0.0, 0.0,_width, _height); //(800x800)
gluLookAt(-50.0,0.0,-700.0,0.0,0.0,-700.0,0.0,0.0,1.0);
gluPerspective(180.0, 1.0, -50.0, 50.0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
foreach (RSolid3d* solid, _listSolid) { //iterates all solids (list of facets)
glColor3ub(solid->color().red(), solid->color().green(), solid->color().blue());
foreach (RFacet3d* facet, solid->facets()) { //iterates all facets in the solid
glBegin(GL_POLYGON) ;
if (facet->p1()) glVertex3f(facet->p1()->x(),facet->p1()->y(), facet->p1()->z()); //facet->p1() is the first point of the facet (0,37,-600) for example
if (facet->p2()) glVertex3f(facet->p2()->x(),facet->p2()->y(), facet->p2()->z());//facet->p2() is the second point of the facet (0,36,-600) for example
if (facet->p3()) glVertex3f(facet->p3()->x(),facet->p3()->y(), facet->p3()->z());//facet->p3() is the third point of the facet (0,37,-601) for example
if (facet->p4()) glVertex3f(facet->p4()->x(),facet->p4()->y(), facet->p4()->z());//facet->p4() is the fourth point of the facet (0,36,-601) for example
glEnd() ;
}
}
glFlush();
With this code, nothing appears on screen.
I have made some test with objects coordinates divided by 10 and other parameters of projection that show the polygon.
I think I am not so far. Maybe I do a confusion between real x,y,z cartesian axis and x,y,z camera coordinates.
Thanks a lot for a little explanation.