#include #include #include "points.h" extern short sector_isoaxis(double delta,double alfa, Point3D *aux); extern double GetAlfa( double delta ); void draw_axis(void); static Point3D pos[10]; static Point3D norm[10] , aux1, aux2; static int vertices[30]={ 0,2,4, 8,9,4, 0,5,1, 7,5,9, 1,5,6, 6,5,7, 0,4,5, 4,9,5, 2,3,4, 3,8,4 }; Matrix Identity={1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 }; Matrix object={1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 }; void draw_geom(Angle alfa, Angle beta, Angle gamma, double i_d, int reset) { int i,j; Point3D *a,*b,*c; static double LastID=100.0; float mat[] = { AMBIENT, .7, .1, .1, DIFFUSE, 1.0, 0.123, 0.100, SPECULAR, 0.2, 0.2, 0.2, SHININESS, 5, LMNULL }; static float lm[] = { AMBIENT, .1, .1, .1, /* LOCALVIEWER, 1,*/ TWOSIDE, 1, LMNULL }; static float lt[] = { AMBIENT, 0.3,0.3,0.3, LCOLOR, 1, 1, 1, POSITION, 0, 0, 1, 1, SPOTDIRECTION, 0,0,-1, LMNULL }; static float lt2[] = { AMBIENT, 0.3,0.3,0.3, LCOLOR, 1, 1, 1, POSITION, 1, 0, 0, 1, SPOTDIRECTION, -1,0,0, LMNULL }; static float lt3[] = { AMBIENT, 0.3,0.3,0.3, LCOLOR, 1, 1, 1, POSITION, 0, 1, 0, 1, SPOTDIRECTION, 0,-1,0, LMNULL }; lmdef(DEFMATERIAL, 1, 0, mat); lmdef(DEFLIGHT, 1, 0, lt); lmdef(DEFLIGHT, 2, 0, lt2); lmdef(DEFLIGHT, 3, 0, lt3); lmdef(DEFLMODEL, 1, 0, lm); lmbind(MATERIAL, 1); lmbind(LMODEL, 1); lmbind(LIGHT0, 1); lmbind(LIGHT0, 2); lmbind(LIGHT0, 3); if (i_d != LastID ) { sector_isoaxis(i_d,GetAlfa(i_d),pos); for(i=0;i<10;i++) { /* calculate normals */ a=&pos[vertices[i*3+0]]; b=&pos[vertices[i*3+1]]; c=&pos[vertices[i*3+2]]; ResV(*b, *a, aux1); ResV(*c, *a, aux2); ProdvV(aux1, aux2, norm[i]); NormV(aux1, norm[i]); } LastID = i_d; } pushmatrix(); loadmatrix(Identity); perspective( 500, 1, 0.1, 10 ); lookat( 5,0,0, 0,0,0, 900); if (reset) memcpy( object, Identity, sizeof( Matrix)); pushmatrix(); loadmatrix(Identity); rotate(beta,'z'); rotate(gamma,'y'); rotate(alfa,'x'); multmatrix(object); getmatrix(object); popmatrix(); multmatrix(object); /* draw_axis();*/ for(j=0; j<6; j++) { for(i=0;i<10;i++) { bgntmesh(); n3f(norm[i]); v3f(pos[vertices[i*3+0]]); v3f(pos[vertices[i*3+1]]); v3f(pos[vertices[i*3+2]]); endtmesh(); } rotate(600 ,'z'); } popmatrix(); } void draw_axis(void) { long ejes[4][3]= { { 0, 0, 0}, { 2, 0, 0}, { 0, 2, 0}, { 0, 0, 2} }; cpack(0x000000FF); bgnline(); v3i(ejes[0]); v3i(ejes[1]); endline(); cpack(0x0000FF00); bgnline(); v3i(ejes[0]); v3i(ejes[2]); endline(); cpack(0x00FF0000); bgnline(); v3i(ejes[0]); v3i(ejes[3]); endline(); }