Reference to temporary fixed and indented.

This commit is contained in:
Federico Ponchio 2004-09-30 00:57:42 +00:00
parent a9780d57e9
commit 4277711874
1 changed files with 222 additions and 169 deletions

View File

@ -1,29 +1,32 @@
/**************************************************************************** /****************************************************************************
* VCGLib o o * * VCGLib o o *
* Visual and Computer Graphics Library o o * * Visual and Computer Graphics Library o o *
* _ O _ * * _ O _ *
* Copyright(C) 2004 \/)\/ * * Copyright(C) 2004 \/)\/ *
* Visual Computing Lab /\/| * * Visual Computing Lab /\/| *
* ISTI - Italian National Research Council | * * ISTI - Italian National Research Council | *
* \ * * \ *
* All rights reserved. * * All rights reserved. *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * * the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
* * * *
* This program is distributed in the hope that it will be useful, * * This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. * * for more details. *
* * * *
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.7 2004/09/28 09:46:51 cignoni
Added MapFalseColor
Revision 1.6 2004/09/16 14:08:35 ponchio Revision 1.6 2004/09/16 14:08:35 ponchio
gamma is a math function. gamma is a math function.
@ -110,8 +113,8 @@ vector<Point3f> ViewVector;
bool cb(const char *buf) bool cb(const char *buf)
{ {
printf(buf); printf(buf);
return true; return true;
} }
void BuildOnePixelTexture(Color4b c, unsigned int &TexInd) void BuildOnePixelTexture(Color4b c, unsigned int &TexInd)
@ -163,9 +166,9 @@ void DrawViewVector()
glColor3f(0,0,1); glColor3f(0,0,1);
glBegin(GL_LINES); glBegin(GL_LINES);
for(unsigned int i=0;i<ViewVector.size();++i) for(unsigned int i=0;i<ViewVector.size();++i)
{ {
glVertex3f(0,0,0);glVertex(ViewVector[i]); glVertex3f(0,0,0);glVertex(ViewVector[i]);
} }
glEnd(); glEnd();
} }
void DrawLightVector() void DrawLightVector()
@ -192,11 +195,11 @@ void Draw(AMesh &mm)
AMesh::FaceIterator fi; AMesh::FaceIterator fi;
glBegin(GL_TRIANGLES); glBegin(GL_TRIANGLES);
for(fi=mm.face.begin();fi!=mm.face.end();++fi) 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(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(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()); glNormal((*fi).V(2)->N()); if(ColorFlag) glColor((*fi).V(2)->C()); glVertex((*fi).V(2)->P());
} }
glEnd(); glEnd();
} }
@ -211,7 +214,7 @@ string OutNameMsh;
*/ */
void ViewReshape(GLsizei w, GLsizei h) void ViewReshape(GLsizei w, GLsizei h)
{ {
ScreenW=w; ScreenH=h; ScreenW=w; ScreenH=h;
glViewport(0,0,w,h); glViewport(0,0,w,h);
} }
@ -225,9 +228,12 @@ void ViewDisplay (void)
glLoadIdentity (); glLoadIdentity ();
glPushMatrix(); glPushMatrix();
QL.Apply(); QL.Apply();
glutPrintf(5,5,"Diffuse %04.2f Ambient %04.2f LowPass %04.2f HiPass %04.2f Gamma %04.2f ",diff,ambi,lopass,hipass,gamma_correction); glutPrintf(5,5,"Diffuse %04.2f Ambient %04.2f "
" LowPass %04.2f HiPass %04.2f Gamma %04.2f ",
diff,ambi,lopass,hipass,gamma_correction);
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);
glPopMatrix(); glPopMatrix();
glTranslatef(0,0,-4); glTranslatef(0,0,-4);
if(Q==&QL) DrawLightVector(); if(Q==&QL) DrawLightVector();
@ -241,11 +247,12 @@ void ViewDisplay (void)
glColor3f(diff,diff,diff); glColor3f(diff,diff,diff);
glTranslate(-m.bbox.Center()); glTranslate(-m.bbox.Center());
if(LightFlag) glEnable(GL_LIGHTING); if(LightFlag) glEnable(GL_LIGHTING);
else glDisable(GL_LIGHTING); else glDisable(GL_LIGHTING);
if(ColorFlag) glEnable(GL_COLOR_MATERIAL); if(ColorFlag) glEnable(GL_COLOR_MATERIAL);
else glDisable(GL_COLOR_MATERIAL); else glDisable(GL_COLOR_MATERIAL);
if(FalseColorFlag) glColorMaterial(GL_FRONT,GL_DIFFUSE); if(FalseColorFlag) glColorMaterial(GL_FRONT,GL_DIFFUSE);
else glColorMaterial(GL_FRONT,GL_AMBIENT); else glColorMaterial(GL_FRONT,GL_AMBIENT);
glMateriali(GL_FRONT,GL_SHININESS,0); glMateriali(GL_FRONT,GL_SHININESS,0);
float spec[4]={0,0,0,1}; float spec[4]={0,0,0,1};
float ambientV[4]={ambi,ambi,ambi,1}; float ambientV[4]={ambi,ambi,ambi,1};
@ -270,50 +277,62 @@ void ViewSpecialKey(int , int , int )
void Toggle(bool &flag) {flag = !flag;} void Toggle(bool &flag) {flag = !flag;}
void UpdateVis() void UpdateVis()
{ {
if( LightFlag && !FalseColorFlag) Vis.MapVisibility(gamma_correction,lopass,hipass,ambi); if( LightFlag && !FalseColorFlag)
if(!LightFlag && !FalseColorFlag) Vis.MapVisibility(gamma_correction,lopass,hipass,1.0); Vis.MapVisibility(gamma_correction,lopass,hipass,ambi);
if(FalseColorFlag) Vis.MapFalseColor(); if(!LightFlag && !FalseColorFlag)
Vis.MapVisibility(gamma_correction,lopass,hipass,1.0);
if(FalseColorFlag)
Vis.MapFalseColor();
} }
/*********************************************************************/ /*********************************************************************/
/*********************************************************************/ /*********************************************************************/
/*********************************************************************/ /*********************************************************************/
void ViewKey(unsigned char key, int , int ) void ViewKey(unsigned char key, int , int )
{ {
Point3f dir; Point3f dir;
switch (key) { switch (key) {
case 27: exit(0); break; case 27: exit(0); break;
case 9: if(Q==&QV) Q=&QL;else Q=&QV; break; case 9: if(Q==&QV) Q=&QL;else Q=&QV; break;
case 'l' : case 'l' :
lopass=lopass+.05; printf("Lo %f, Hi %f Gamma %f\n",lopass,hipass,gamma_correction); lopass=lopass+.05;
UpdateVis(); printf("Lo %f, Hi %f Gamma %f\n",lopass,hipass,gamma_correction);
break; UpdateVis(); break;
case 'L' : case 'L' :
lopass=lopass-.05; printf("Lo %f, Hi %f Gamma %f\n",lopass,hipass,gamma_correction); lopass=lopass-.05;
UpdateVis(); break; printf("Lo %f, Hi %f Gamma %f\n",lopass,hipass,gamma_correction);
case 'h' : UpdateVis(); break;
hipass=hipass-.05; printf("Lo %f, Hi %f Gamma %f\n",lopass,hipass,gamma_correction); case 'h' :
UpdateVis(); break; hipass=hipass-.05;
case 'H' : printf("Lo %f, Hi %f Gamma %f\n",lopass,hipass,gamma_correction);
hipass=hipass+.05; printf("Lo %f, Hi %f Gamma %f\n",lopass,hipass,gamma_correction); UpdateVis(); break;
UpdateVis(); break; case 'H' :
hipass=hipass+.05;
printf("Lo %f, Hi %f Gamma %f\n",lopass,hipass,gamma_correction);
UpdateVis(); break;
case 'd' : diff+=.05; printf("Ambient %f Diffuse %f, \n",ambi,diff); UpdateVis(); break; case 'd' : diff+=.05; printf("Ambient %f Diffuse %f, \n",ambi,diff); UpdateVis(); break;
case 'D' : diff-=.05; printf("Ambient %f Diffuse %f, \n",ambi,diff); UpdateVis(); break; case 'D' : diff-=.05; printf("Ambient %f Diffuse %f, \n",ambi,diff); UpdateVis(); break;
case 'a' : ambi+=.05; printf("Ambient %f Diffuse %f, \n",ambi,diff); UpdateVis(); break; case 'a' : ambi+=.05; printf("Ambient %f Diffuse %f, \n",ambi,diff); UpdateVis(); break;
case 'A' : ambi-=.05; printf("Ambient %f Diffuse %f, \n",ambi,diff); UpdateVis(); break; case 'A' : ambi-=.05; printf("Ambient %f Diffuse %f, \n",ambi,diff); UpdateVis(); break;
case 'e' : ambi+=.05; diff-=.05; printf("Ambient %f Diffuse %f, \n",ambi,diff); UpdateVis(); break; case 'e' : ambi+=.05; diff-=.05;
case 'E' : ambi-=.05; diff+=.05; printf("Ambient %f Diffuse %f, \n",ambi,diff); UpdateVis(); break; printf("Ambient %f Diffuse %f, \n",ambi,diff);
UpdateVis(); break;
case 'p' : case 'E' : ambi-=.05; diff+=.05;
gamma_correction=gamma_correction-.05; printf("Lo %f, Hi %f Gamma %f\n",lopass,hipass,gamma_correction); printf("Ambient %f Diffuse %f, \n",ambi,diff);
UpdateVis(); break; UpdateVis(); break;
case 'P' : case 'p' :
gamma_correction=gamma_correction+.05; printf("Lo %f, Hi %f Gamma %f\n",lopass,hipass,gamma_correction); gamma_correction=gamma_correction-.05;
UpdateVis(); break; printf("Lo %f, Hi %f Gamma %f\n",lopass,hipass,gamma_correction);
case 13 : UpdateVis(); break;
//Vis.ComputeUniform(SampleNum,ViewVector,cb); case 'P' :
gamma_correction=gamma_correction+.05;
printf("Lo %f, Hi %f Gamma %f\n",lopass,hipass,gamma_correction);
UpdateVis(); break;
case 13 :
//Vis.ComputeUniform(SampleNum,ViewVector,cb);
Vis.ComputeUniformCone(SampleNum,ViewVector, ConeAngleRad,ConeDir,cb); Vis.ComputeUniformCone(SampleNum,ViewVector, ConeAngleRad,ConeDir,cb);
UpdateVis(); break; UpdateVis(); break;
case ' ' : { case ' ' : {
Point3f dir = Q->camera.ViewPoint(); Point3f dir = Q->camera.ViewPoint();
printf("ViewPoint %f %f %f\n",dir[0],dir[1],dir[2]); printf("ViewPoint %f %f %f\n",dir[0],dir[1],dir[2]);
@ -321,16 +340,28 @@ void ViewKey(unsigned char key, int , int )
dir=Inverse(Q->track.Matrix())*dir; dir=Inverse(Q->track.Matrix())*dir;
printf("ViewPoint %f %f %f\n",dir[0],dir[1],dir[2]); printf("ViewPoint %f %f %f\n",dir[0],dir[1],dir[2]);
dir.Normalize(); dir.Normalize();
Vis.ComputeSingle(dir,ViewVector,cb); Vis.ComputeSingle(dir,ViewVector,cb);
UpdateVis(); UpdateVis();
} break; } break;
case 'r' : BaseColor[0]=min(255,BaseColor[0]+2); printf("BaseColor %3i %3i %3i \n",BaseColor[0],BaseColor[1],BaseColor[2]); break; case 'r' : BaseColor[0]=min(255,BaseColor[0]+2);
case 'R' : BaseColor[0]=max( 0,BaseColor[0]-2); printf("BaseColor %3i %3i %3i \n",BaseColor[0],BaseColor[1],BaseColor[2]); break; printf("BaseColor %3i %3i %3i \n",BaseColor[0],BaseColor[1],BaseColor[2]);
case 'g' : BaseColor[1]=min(255,BaseColor[1]+2); printf("BaseColor %3i %3i %3i \n",BaseColor[0],BaseColor[1],BaseColor[2]); break; break;
case 'G' : BaseColor[1]=max( 0,BaseColor[1]-2); printf("BaseColor %3i %3i %3i \n",BaseColor[0],BaseColor[1],BaseColor[2]); break; case 'R' : BaseColor[0]=max( 0,BaseColor[0]-2);
case 'b' : BaseColor[2]=min(255,BaseColor[2]+2); printf("BaseColor %3i %3i %3i \n",BaseColor[0],BaseColor[1],BaseColor[2]); break; printf("BaseColor %3i %3i %3i \n",BaseColor[0],BaseColor[1],BaseColor[2]);
case 'B' : BaseColor[2]=max( 0,BaseColor[2]-2); printf("BaseColor %3i %3i %3i \n",BaseColor[0],BaseColor[1],BaseColor[2]); break; 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' :
{ {
@ -340,30 +371,35 @@ void ViewKey(unsigned char key, int , int )
sprintf(buf,"Snap%03i.ppm",imgcnt++); sprintf(buf,"Snap%03i.ppm",imgcnt++);
snapC.SavePPM(buf); snapC.SavePPM(buf);
} }
case 's' : case 's' :
Vis.SmoothVisibility(); Vis.SmoothVisibility();
UpdateVis(); break; UpdateVis(); break;
case 'S' : case 'S' :
{ {
vcg::tri::io::PlyInfo p; vcg::tri::io::PlyInfo p;
p.mask|=vcg::ply::PLYMask::PM_VERTCOLOR /* | vcg::ply::PLYMask::PM_VERTQUALITY*/ ; p.mask|=vcg::ply::PLYMask::PM_VERTCOLOR /* | vcg::ply::PLYMask::PM_VERTQUALITY*/ ;
tri::io::ExporterPLY<AMesh>::Save(m,OutNameMsh.c_str(),false,p); tri::io::ExporterPLY<AMesh>::Save(m,OutNameMsh.c_str(),false,p);
} }
break; break;
case 'C' : LightFlag = !LightFlag; printf("Toggled Light %s\n",LightFlag?"on":"off"); UpdateVis(); break; case 'C' : LightFlag = !LightFlag;
case 'c' : ColorFlag = !ColorFlag; printf("Toggled Color %s\n",ColorFlag?"on":"off"); break; printf("Toggled Light %s\n",LightFlag?"on":"off");
case 'f' : FalseColorFlag = !FalseColorFlag; printf("Toggled FalseColor %s\n",ColorFlag?"on":"off"); UpdateVis(); break; UpdateVis(); break;
case 'c' : ColorFlag = !ColorFlag;
printf("Toggled Color %s\n",ColorFlag?"on":"off"); break;
case 'f' : FalseColorFlag = !FalseColorFlag;
printf("Toggled FalseColor %s\n",ColorFlag?"on":"off");
UpdateVis(); break;
case '1' : diff=0.80f; ambi=0.10f; gamma_correction=1.0; lopass=0.00f; hipass=1.00f; ColorFlag=false; UpdateVis(); break; case '1' : diff=0.80f; ambi=0.10f; gamma_correction=1.0; lopass=0.00f; hipass=1.00f; ColorFlag=false; UpdateVis(); break;
case '2' : diff=0.65f; ambi=0.30f; gamma_correction=1.0; lopass=0.15f; hipass=0.80f; ColorFlag=true; UpdateVis(); break; case '2' : diff=0.65f; ambi=0.30f; gamma_correction=1.0; lopass=0.15f; hipass=0.80f; ColorFlag=true; UpdateVis(); break;
case '3' : diff=0.45f; ambi=0.50f; gamma_correction=1.0; lopass=0.20f; hipass=0.75f; ColorFlag=true; UpdateVis(); break; case '3' : diff=0.45f; ambi=0.50f; gamma_correction=1.0; lopass=0.20f; hipass=0.75f; ColorFlag=true; UpdateVis(); break;
case '4' : diff=0.35f; ambi=0.60f; gamma_correction=1.0; lopass=0.25f; hipass=0.70f; ColorFlag=true; UpdateVis(); break; case '4' : diff=0.35f; ambi=0.60f; gamma_correction=1.0; lopass=0.25f; hipass=0.70f; ColorFlag=true; UpdateVis(); break;
} }
glutPostRedisplay(); ; glutPostRedisplay(); ;
} }
void ViewMenu(int val) void ViewMenu(int val)
{ {
ViewKey(val, 0, 0); ViewKey(val, 0, 0);
} }
/*********************************************************************/ /*********************************************************************/
// TrackBall Functions // TrackBall Functions
@ -396,8 +432,8 @@ void ViewMouse(int button, int state, int x, int y)
void ViewMouseMotion(int x, int y) void ViewMouseMotion(int x, int y)
{ {
Q->MouseMove(x,ScreenH-y); Q->MouseMove(x,ScreenH-y);
glutPostRedisplay(); glutPostRedisplay();
} }
void SetLight() void SetLight()
@ -405,87 +441,101 @@ void SetLight()
GLfloat light_ambient0[] = {0.0, 0.0, 0.0, 1.0}; GLfloat light_ambient0[] = {0.0, 0.0, 0.0, 1.0};
GLfloat light_diffuse0[] = {1.0, 1.0, 1.0, 1.0}; GLfloat light_diffuse0[] = {1.0, 1.0, 1.0, 1.0};
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);
glLightfv(GL_LIGHT0, GL_AMBIENT, light_diffuse0); glLightfv(GL_LIGHT0, GL_AMBIENT, light_diffuse0);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse0); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse0);
glEnable(GL_LIGHT0); glEnable(GL_LIGHT0);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,light_ambient0); glLightModelfv(GL_LIGHT_MODEL_AMBIENT,light_ambient0);
} }
void ViewInit (void) { void ViewInit (void) {
SetLight(); SetLight();
Q->Reset(); Q->Reset();
Q->radius= 1; Q->radius= 1;
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL); glDepthFunc(GL_LEQUAL);
glClearColor (0.8, 0.8, 0.8, 0.0); glClearColor (0.8, 0.8, 0.8, 0.0);
glEnable(GL_NORMALIZE); glEnable(GL_NORMALIZE);
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
// glEnable(GL_BLEND); // glEnable(GL_BLEND);
glShadeModel(GL_SMOOTH); glShadeModel(GL_SMOOTH);
// glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); // glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
glCullFace(GL_BACK); glCullFace(GL_BACK);
} }
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
if(argc<2) { if(argc<2) {
printf( printf(
"shadevis 1.0 \n"__DATE__"\n" "shadevis 1.0 \n"__DATE__"\n"
"Copyright 2003-2004 Visual Computing Lab I.S.T.I. C.N.R.\n" "Copyright 2003-2004 Visual Computing Lab I.S.T.I. C.N.R.\n"
"Paolo Cignoni (cignoni@isti.cnr.it)\n\n" "Paolo Cignoni (cignoni@isti.cnr.it)\n\n"
"Usage: shadevis file.ply [options]\n" "Usage: shadevis file.ply [options]\n"
"Options:\n" "Options:\n"
" -w# WindowResolution (default 600)\n" " -w# WindowResolution (default 600)\n"
" -n# Sample Directions (default 64)\n" " -n# Sample Directions (default 64)\n"
" -z# z offset (default 1e-3)\n" " -z# z offset (default 1e-3)\n"
" -c assume that the mesh is closed (slightly faster, default false)\n" " -c assume that the mesh is closed (slightly faster, default false)\n"
" -f Flip normal of the model\n" " -f Flip normal of the model\n"
" -da # Cone Direction Angle in degree (default 180)\n" " -da # Cone Direction Angle in degree (default 180)\n"
" -dv # # # Cone Direction vector (default 0 0 1)\n" " -dv # # # Cone Direction vector (default 0 0 1)\n"
); );
return 1; return 1;
} }
srand(time(0)); srand(time(0));
int i=1; int i=1;
while(i<argc && (argv[i][0]=='-')) while(i<argc && (argv[i][0]=='-'))
{ {
switch(argv[i][1]) switch(argv[i][1])
{ {
case 'd' : if(argv[i][2] == 'a') { ConeAngleRad = math::ToRad(atof(argv[i+1])); ++i; break; } case 'd' :
if(argv[i][2] == 'v') { ConeDir = Normalize(Point3f(atof(argv[i+1]),atof(argv[i+2]),atof(argv[i+3]))); i+=3; break; } if(argv[i][2] == 'a') {
printf("Error unable to parse option '%s'\n",argv[i]); exit(0); ConeAngleRad = math::ToRad(atof(argv[i+1])); ++i; break;
break; }
case 'n' : SampleNum = atoi(argv[i]+2); break; if(argv[i][2] == 'v') {
case 'f' : SwapFlag=false; break; Point3f p(atof(argv[i+1]),atof(argv[i+2]),atof(argv[i+3]));
case 'c' : ClosedFlag=true; break; ConeDir = Normalize(p);
case 'w' : WindowRes= atoi(argv[i]+2); printf("Set WindowRes to %i\n",WindowRes ); break; i+=3; break;
case 's' : Vis.SplitNum= atoi(argv[i]+2); printf("Set SplitNum to %i\n",Vis.SplitNum ); break; }
case 'z' : Vis.ZTWIST = atof(argv[i]+2); printf("Set ZTWIST to %f\n",Vis.ZTWIST ); break; printf("Error unable to parse option '%s'\n",argv[i]);
default: {printf("Error unable to parse option '%s'\n",argv[i]); exit(0);} exit(0);
} break;
case 'n' : SampleNum = atoi(argv[i]+2); break;
++i; case 'f' : SwapFlag=false; break;
} case 'c' : ClosedFlag=true; break;
case 'w' : WindowRes= atoi(argv[i]+2);
printf("Set WindowRes to %i\n",WindowRes ); break;
case 's' : Vis.SplitNum= atoi(argv[i]+2);
printf("Set SplitNum to %i\n",Vis.SplitNum ); break;
case 'z' : Vis.ZTWIST = atof(argv[i]+2);
printf("Set ZTWIST to %f\n",Vis.ZTWIST ); break;
default: {
printf("Error unable to parse option '%s'\n",argv[i]);
exit(0);
}
}
++i;
}
string basename = argv[i]; string basename = argv[i];
if(!(basename.substr(basename.length()-4)==".ply")) { if(!(basename.substr(basename.length()-4)==".ply")) {
printf("Error: Unknown file extension %s\n",basename.c_str()); printf("Error: Unknown file extension %s\n",basename.c_str());
return 1; return 1;
} }
// loading original mesh // loading original mesh
int ret=tri::io::ImporterPLY<AMesh>::Open(m,argv[i]); int ret=tri::io::ImporterPLY<AMesh>::Open(m,argv[i]);
if(ret) {printf("Error unable to open mesh %s\n",argv[i]);exit(-1);} if(ret) {printf("Error unable to open mesh %s\n",argv[i]);exit(-1);}
tri::UpdateNormals<AMesh>::PerVertexNormalized(m); tri::UpdateNormals<AMesh>::PerVertexNormalized(m);
tri::UpdateBounding<AMesh>::Box(m); tri::UpdateBounding<AMesh>::Box(m);
tri::UpdateColor<AMesh>::VertexConstant(m,Color4b::White); tri::UpdateColor<AMesh>::VertexConstant(m,Color4b::White);
@ -493,30 +543,33 @@ int main(int argc, char** argv)
Vis.Init(); Vis.Init();
UpdateVis(); UpdateVis();
printf("Mesh bbox (%f %f %f)-(%f %f %f)\n\n",m.bbox.min[0],m.bbox.min[1],m.bbox.min[2],m.bbox.max[0],m.bbox.max[1],m.bbox.max[2]); printf("Mesh bbox (%f %f %f)-(%f %f %f)\n\n",
m.bbox.min[0],m.bbox.min[1],m.bbox.min[2],
m.bbox.max[0],m.bbox.max[1],m.bbox.max[2]);
OutNameMsh=(string(argv[i]).substr(0,strlen(argv[i])-4)); OutNameMsh=(string(argv[i]).substr(0,strlen(argv[i])-4));
OutNameMsh+="_vis.ply"; OutNameMsh+="_vis.ply";
printf("Mesh Output filename %s\n",OutNameMsh.c_str()); printf("Mesh Output filename %s\n",OutNameMsh.c_str());
printf("Mesh %iv %if bbox Diag %g\n",m.vn,m.fn,m.bbox.Diag()); printf("Mesh %iv %if bbox Diag %g\n",m.vn,m.fn,m.bbox.Diag());
glutInit(&argc, argv); glutInit(&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutInitWindowSize(WindowRes, WindowRes); glutInitWindowSize(WindowRes, WindowRes);
glutInitWindowPosition (10,10); glutInitWindowPosition (10,10);
glutCreateWindow ("shadevis - Visual Computing Lab - vcg.isti.cnr.it "); glutCreateWindow ("shadevis - Visual Computing Lab - vcg.isti.cnr.it ");
glutDisplayFunc(ViewDisplay); glutDisplayFunc(ViewDisplay);
glutReshapeFunc(ViewReshape); glutReshapeFunc(ViewReshape);
glutKeyboardFunc(ViewKey); glutKeyboardFunc(ViewKey);
glutSpecialFunc(ViewSpecialKey); glutSpecialFunc(ViewSpecialKey);
glutMouseFunc(ViewMouse); glutMouseFunc(ViewMouse);
glutMotionFunc(ViewMouseMotion); glutMotionFunc(ViewMouseMotion);
ViewInit(); ViewInit();
glewInit(); glewInit();
glutMainLoop(); glutMainLoop();
return(0); return(0);
} }