Files Classes Functions Hierarchy
00001 00002 00003 #include <GL/glut.h> 00004 00005 #include <cpsphere.h> 00006 #include <gobj.h> 00007 //#include <graphmisc.h> 00008 #include <tetrahedron.h> 00009 #include <tetrahedrondraw.h> 00010 00011 00012 void cpsphere::stateinc() 00013 { 00014 //cout << "state=" << state << endl; 00015 ++state; 00016 state %= vi.size(); 00017 00018 update(); 00019 } 00020 00021 void cpsphere::statedec() 00022 { 00023 uint sz = vi.size(); 00024 if (sz==0) 00025 return; 00026 00027 state += (sz-1); 00028 state %= sz; 00029 00030 update(); 00031 } 00032 00033 void cpsphere::update() 00034 { 00035 current->nuke(); 00036 00037 uintc imax = vi.size(); 00038 00039 if ((state<imax)==false) 00040 return; 00041 00042 // Calculate the spheres details. 00043 00044 uintc slices=30; 00045 uintc stacks=30; 00046 00047 point3<double> const & P1( pts[ vi[state].x ] ); 00048 point3<double> const & P2( pts[ vi[state].y ] ); 00049 point3<double> const & P3( pts[ vi[state].z ] ); 00050 point3<double> const & P4( pts[ vi[state].w ] ); 00051 00052 tetrahedron<point3<double>,double> const t(P1,P2,P3,P4); 00053 point3<double> c0; 00054 t.circumcenter(c0); 00055 point3<double> const c(c0); 00056 doublec radius = (c-P1).distance(); 00057 00058 // Write the graphics. 00059 00060 current->push( new gobjglPushMatrix() ); 00061 00062 00063 current->push( new gobjglEnable(GL_LIGHTING) ); 00064 00065 /* 00066 current->push( new gobjglColor3f(1.0,0.0,0.0) ); 00067 00068 00069 current->push( new gobjglTranslatef(c) ); 00070 current->push( 00071 new gobjglutSolidSphere(radius,slices,stacks) ); 00072 */ 00073 00074 00075 00076 current->push( new gobjglDisable(GL_DEPTH_TEST) ); 00077 current->push( new gobjglEnable(GL_BLEND) ); 00078 current->push( 00079 new gobjglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ); 00080 00081 current->push( new gobjglColor4f(1.0,0.0,0.0,0.8) ); 00082 00083 current->push( new gobjglTranslatef(c) ); 00084 current->push( 00085 new gobjglutSolidSphere(radius,slices,stacks) ); 00086 00087 00088 current->push( new gobjglPopMatrix() ); 00089 00090 00091 //glerrordisplay(); 00092 } 00093 00094 cpsphere::cpsphere 00095 ( 00096 vector< point3<double> > const & pts_, 00097 vector< point4<uint> > const & vi_ 00098 ) 00099 : pts(pts_), vi(vi_), state(0) 00100 { 00101 current = new gobjContainer(); 00102 } 00103 00104 cpsphere::~cpsphere() 00105 { 00106 delete current; 00107 } 00108 00109 00110 00111
1.5.8