openGL limited 3D space
I'm having problem with my drawing code..I have to display some arrows,
but when they are too far from the origin of the axis they disappear..
Here I post my relevant code:
static void drawArrow( double trans[3][4] , double **d, int num, double
*altitude)
{
int i;
double c_min=0.3;
double gl_para[16];
GLfloat mat_ambient[] = {0.0, 0.0, 1.0, 1.0};
GLfloat mat_flash[] = {0.0, 0.0, 1.0, 1.0};
GLfloat mat_flash_shiny[] = {50.0};
GLfloat light_position[] = {100.0,-200.0,200.0,0.0};
GLfloat ambi[] = {0.1, 0.1, 0.1, 0.1};
GLfloat lightZeroColor[] = {0.9, 0.9, 0.9, 0.1};
argDrawMode3D();
argDraw3dCamera( 0, 0 );
glClearDepth( 1.0 );
glClear(GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
argConvGlpara(trans, gl_para);
glMatrixMode(GL_PROJECTION);
glLoadMatrixd( gl_para );
glRotated(-90,0,1,0);
glRotated(az-90,0,0,1);
for (i=0;i<num;i++)
{
if (altitude[i]>=quota && altitude[i]<quota+STEP_ALTITUDE){
if ( mode == 1 )
glColor3d((mod[1]-d[i][3])/(mod[1]-mod[0]),(d[i][3]-mod[0])/(mod[1]-mod[0]),0);
else
glColor3f((c_min*(d[i][3]-mod[0])+(mod[1]-d[i][3]))/(mod[1]-mod[0]),0,0);
glTranslated(d[i][0],d[i][1],d[i][2]);
glRotated(-d[i][5],0,0,1);
glRotated(d[i][4],1,0,0);
glRotated(-90,1,0,0);
glTranslated(0,0,d[i][3]*arrow_factor*(1-cone_para1));
glutSolidCone(d[i][3]*arrow_factor*cone_para1*cone_para2,
d[i][3]*arrow_factor*cone_para1,10,10);
glBegin(GL_LINES);
glVertex3d(0,0,0);
glVertex3d(0,0,-d[i][3]*arrow_factor*(1-cone_para1));
glEnd();
glTranslated(0,0,-d[i][3]*arrow_factor*(1-cone_para1));
glRotated(90,1,0,0);
glRotated(-d[i][4],1,0,0);
glRotated(d[i][5],0,0,1);
glTranslated(-d[i][0],-d[i][1],-d[i][2]);}
}
glDisable( GL_LIGHTING );
glDisable( GL_DEPTH_TEST );
}
I suppose I have to use GL_PROJECTION matrix mode, but I belive that if
there is a better way to let it work without change it at all..
No comments:
Post a Comment