Version 1.0

Added management of point set, correct bug in printing on the screen,
This commit is contained in:
Paolo Cignoni 2005-11-12 06:48:47 +00:00
parent 2624c550bd
commit ae107eef60
1 changed files with 44 additions and 32 deletions

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.9 2005/01/03 13:59:54 cignoni
Resolved min/max macro conflict
Revision 1.8 2004/09/30 00:57:42 ponchio Revision 1.8 2004/09/30 00:57:42 ponchio
Reference to temporary fixed and indented. Reference to temporary fixed and indented.
@ -150,7 +153,8 @@ void glutPrintf(int x, int y, const char * f, ... )
int n = vsprintf(buf,f,marker); int n = vsprintf(buf,f,marker);
va_end( marker ); va_end( marker );
glPushAttrib(GL_ENABLE_BIT);
glDisable(GL_LIGHTING);
glColor3f(0,0,0); glColor3f(0,0,0);
glRasterPos2f(x, y); glRasterPos2f(x, y);
len = (int) strlen(buf); len = (int) strlen(buf);
@ -161,7 +165,7 @@ void glutPrintf(int x, int y, const char * f, ... )
glPopMatrix(); glPopMatrix();
glMatrixMode (GL_MODELVIEW); glMatrixMode (GL_MODELVIEW);
glPopMatrix(); glPopMatrix();
glPopAttrib();
} }
// prototypes // prototypes
@ -199,15 +203,32 @@ void DrawLightVector()
void Draw(AMesh &mm) void Draw(AMesh &mm)
{ {
AMesh::FaceIterator fi; if(mm.face.empty())
glBegin(GL_TRIANGLES); {
for(fi=mm.face.begin();fi!=mm.face.end();++fi) glPushAttrib(GL_ENABLE_BIT);
{ glDisable(GL_LIGHTING);
glNormal((*fi).V(0)->N()); if(ColorFlag) glColor((*fi).V(0)->C()); glVertex((*fi).V(0)->P()); AMesh::VertexIterator vi;
glNormal((*fi).V(1)->N()); if(ColorFlag) glColor((*fi).V(1)->C()); glVertex((*fi).V(1)->P()); glBegin(GL_POINTS);
glNormal((*fi).V(2)->N()); if(ColorFlag) glColor((*fi).V(2)->C()); glVertex((*fi).V(2)->P()); for(vi=mm.vert.begin();vi!=mm.vert.end();++vi)
} {
glEnd(); if(ColorFlag) glColor((*vi).C());
glVertex((*vi).P());
}
glEnd();
glPopAttrib();
}
else
{
AMesh::FaceIterator fi;
glBegin(GL_TRIANGLES);
for(fi=mm.face.begin();fi!=mm.face.end();++fi)
{
glNormal((*fi).V(0)->N()); if(ColorFlag) glColor((*fi).V(0)->C()); glVertex((*fi).V(0)->P());
glNormal((*fi).V(1)->N()); if(ColorFlag) glColor((*fi).V(1)->C()); glVertex((*fi).V(1)->P());
glNormal((*fi).V(2)->N()); if(ColorFlag) glColor((*fi).V(2)->C()); glVertex((*fi).V(2)->P());
}
glEnd();
}
} }
AMesh m; AMesh m;
@ -236,8 +257,8 @@ void ViewDisplay (void)
glPushMatrix(); glPushMatrix();
QL.Apply(); QL.Apply();
glutPrintf(5,5,"Diffuse %04.2f Ambient %04.2f " glutPrintf(5,5,"Diffuse %04.2f Ambient %04.2f "
" LowPass %04.2f HiPass %04.2f Gamma %04.2f ", " LowPass %04.2f HiPass %04.2f Gamma %04.2f rgb = %03i:%03i:%03i",
diff,ambi,lopass,hipass,gamma_correction); diff,ambi,lopass,hipass,gamma_correction,BaseColor[0],BaseColor[1],BaseColor[2]);
GLfloat light_position0[] = {0.0, 10.0, 300.0, 0.0}; GLfloat light_position0[] = {0.0, 10.0, 300.0, 0.0};
glLightfv(GL_LIGHT0, GL_POSITION, light_position0); glLightfv(GL_LIGHT0, GL_POSITION, light_position0);
@ -246,7 +267,7 @@ void ViewDisplay (void)
if(Q==&QL) DrawLightVector(); if(Q==&QL) DrawLightVector();
QL.GetView(); QL.GetView();
QV.GetView(); QV.GetView();
QV.Apply(); QV.Apply(false);
if(ShowDirFlag) DrawViewVector(); if(ShowDirFlag) DrawViewVector();
float d = 2.0/m.bbox.Diag(); float d = 2.0/m.bbox.Diag();
@ -350,24 +371,12 @@ void ViewKey(unsigned char key, int , int )
Vis.ComputeSingle(dir,ViewVector,cb); Vis.ComputeSingle(dir,ViewVector,cb);
UpdateVis(); UpdateVis();
} break; } break;
case 'r' : BaseColor[0]=min(255,BaseColor[0]+2); case 'r' : BaseColor[0]=min(255,BaseColor[0]+2); break;
printf("BaseColor %3i %3i %3i \n",BaseColor[0],BaseColor[1],BaseColor[2]); case 'R' : BaseColor[0]=max( 0,BaseColor[0]-2); break;
break; case 'g' : BaseColor[1]=min(255,BaseColor[1]+2); break;
case 'R' : BaseColor[0]=max( 0,BaseColor[0]-2); case 'G' : BaseColor[1]=max( 0,BaseColor[1]-2); break;
printf("BaseColor %3i %3i %3i \n",BaseColor[0],BaseColor[1],BaseColor[2]); case 'b' : BaseColor[2]=min(255,BaseColor[2]+2); break;
break; case 'B' : BaseColor[2]=max( 0,BaseColor[2]-2); break;
case 'g' : BaseColor[1]=min(255,BaseColor[1]+2);
printf("BaseColor %3i %3i %3i \n",BaseColor[0],BaseColor[1],BaseColor[2]);
break;
case 'G' : BaseColor[1]=max( 0,BaseColor[1]-2);
printf("BaseColor %3i %3i %3i \n",BaseColor[0],BaseColor[1],BaseColor[2]);
break;
case 'b' : BaseColor[2]=min(255,BaseColor[2]+2);
printf("BaseColor %3i %3i %3i \n",BaseColor[0],BaseColor[1],BaseColor[2]);
break;
case 'B' : BaseColor[2]=max( 0,BaseColor[2]-2);
printf("BaseColor %3i %3i %3i \n",BaseColor[0],BaseColor[1],BaseColor[2]);
break;
case 'v' : Toggle(ShowDirFlag); break; case 'v' : Toggle(ShowDirFlag); break;
case 'V' : case 'V' :
@ -381,6 +390,9 @@ void ViewKey(unsigned char key, int , int )
case 's' : case 's' :
Vis.SmoothVisibility(); Vis.SmoothVisibility();
UpdateVis(); break; UpdateVis(); break;
case 't' :
Vis.SmoothVisibility(true);
UpdateVis(); break;
case 'S' : case 'S' :
{ {
vcg::tri::io::PlyInfo p; vcg::tri::io::PlyInfo p;