/* queue.c ** ** create the billard-queue display lists ** Copyright (C) 2001 Florian Berger ** Email: harpin_floh@yahoo.de, florian.berger@jk.uni-linz.ac.at ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License Version 2 as ** published by the Free Software Foundation; ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ** */ #include #include #include #include #include #include #include "billard.h" #include "queue.h" #include "png_loader.h" #include "options.h" static GLfloat col_shad [4] = {0.1, 0.1, 0.1, 1.0}; static double cue_shad_w = 0.07; static double cue_shad_w2 = 0.014; static int queuetexbind; double rfunc(double x) { return(cos(x*M_PI)); } int create_queue(double (*rfunc)(double)) { int queue_obj, i,j; int sidenr=16; GLfloat dl1=0.004; GLfloat dl2=0.001; double ph; VMvect v1,v2,n1,n2; int segnr=5; /* number of segments along the cue */ double r1,r2,dr1,dr2; queue_obj = glGenLists(1); glNewList(queue_obj, GL_COMPILE); for(j=0;j, p2=<%f,%f,%f>\n",i,p1.x,p1.y,p1.z,p2.x,p2.y,p2.z); vn = vec_diff(p2,p1); vn = vec_unit(vec_xyz(-vn.y,vn.x,0.0)); col_shad[0]=0.7-0.4*vec_abs(vec_diff(lightpos[i],p1)); col_shad[1]=col_shad[0]; col_shad[2]=col_shad[0]; col_shad[3]=1.0; glMaterialfv(GL_FRONT, GL_DIFFUSE, col_shad); glPushMatrix(); glBindTexture(GL_TEXTURE_2D,queueshadowbind); glBegin(GL_QUADS); glNormal3f(0.0,0.0,1.0); glTexCoord2f(0.0,0.0); glVertex3f(p1.x-vn.x*cue_shad_w2,p1.y-vn.y*cue_shad_w2,p1.z); glNormal3f(0.0,0.0,1.0); glTexCoord2f(1.0,0.0); glVertex3f(p1.x+vn.x*cue_shad_w2,p1.y+vn.y*cue_shad_w2,p1.z); glNormal3f(0.0,0.0,1.0); glTexCoord2f(1.0,1.0); glVertex3f(p2.x+vn.x*cue_shad_w2,p2.y+vn.y*cue_shad_w2,p2.z); glNormal3f(0.0,0.0,1.0); glTexCoord2f(0.0,1.0); glVertex3f(p2.x-vn.x*cue_shad_w2,p2.y-vn.y*cue_shad_w2,p2.z); glEnd(); glPopMatrix(); } glDisable(GL_BLEND); glDepthMask (GL_TRUE); } } if( options_avatar_on ){ #define upperarm_l 0.30 #define forearm_l 0.35 #define shoulder_l 0.35 #define shoulder1_h 0.50 VMvect shoulder1, shoulder2, shoulder_dir, hand1, hand2, elbow1, elbow2, xdir, ydir; double x1,x; hand2 = vec_add(pos0,hitpoint); hand2 = vec_add(hand2,vec_scale(dir,0.3)); shoulder1 = vec_add(pos0,hitpoint); shoulder1 = vec_add(shoulder1,vec_scale(dir,1.25)); shoulder1.z = shoulder1_h; shoulder_dir = vec_unit(vec_add(vec_add(vec_scale(nx,-0.4),vec_scale(ny,0.4)),vec_scale(dir,-0.7))); shoulder2 = vec_add(shoulder1,vec_scale(shoulder_dir,shoulder_l)); hand1 = vec_add(pos,vec_scale(dir,1.2)); xdir = vec_unit(vec_diff(shoulder1,hand1)); ydir = vec_unit(vec_cross(nx,xdir)); x = vec_abs(vec_diff(shoulder1,hand1)); x1 = x/2.0 + (upperarm_l*upperarm_l - forearm_l*forearm_l)/x; elbow1 = vec_add(vec_scale(xdir,-x1),vec_scale(ydir,sqrt(upperarm_l*upperarm_l-x1*x1))); elbow1 = vec_add(elbow1,shoulder1); xdir = vec_unit(vec_diff(shoulder2,hand2)); ydir = vec_unit(vec_cross(nx,xdir)); x = vec_abs(vec_diff(shoulder2,hand2)); x1 = x/2.0 + (upperarm_l*upperarm_l - forearm_l*forearm_l)/x; elbow2 = vec_add(vec_scale(xdir,-x1),vec_scale(ydir,sqrt(upperarm_l*upperarm_l-x1*x1))); elbow2 = vec_add(elbow2,shoulder2); // elbow2 = vec_add(vec_scale(xdir,x2),vec_scale(ydir,sqrt(forearm_l*forearm_l-x2*x2))); glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); glColor3f(1.0,1.0,1.0); glBegin(GL_LINE_STRIP); glVertex3f( hand1.x, hand1.y, hand1.z ); glVertex3f( elbow1.x, elbow1.y, elbow1.z ); glVertex3f( shoulder1.x, shoulder1.y, shoulder1.z ); glVertex3f( shoulder2.x, shoulder2.y, shoulder2.z ); // glVertex3f( elbow2.x, elbow2.y, elbow2.z ); glVertex3f( hand2.x, hand2.y, hand2.z ); glEnd(); glEnable(GL_TEXTURE_2D); glEnable(GL_LIGHTING); } }