From 43e54a347d3706c5cabda8aa7bb4929f05206f38 Mon Sep 17 00:00:00 2001 From: Oliver Wang Date: Tue, 14 Oct 2003 22:30:52 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=2458 --- api/gutil.C | 161 ++++++++++++++++++++++++++++++++++++-------------- api/gutil.h | 14 ++--- api/reduce.C | 20 ++++--- checkin_notes | 14 ++++- 4 files changed, 146 insertions(+), 63 deletions(-) diff --git a/api/gutil.C b/api/gutil.C index 75f9ae4607..5714e74858 100755 --- a/api/gutil.C +++ b/api/gutil.C @@ -325,13 +325,18 @@ GLfloat text_width(char* text) { return sum/STROKE_SCALE; } -GLfloat text_width_new(char* text) { - GLfloat sum=0; - char* p; - float w = .01; - for(p=text;*p;p++) { - sum += w; +#ifdef _WIN32 +extern float get_char_width(unsigned char c); +#endif + +float text_width_new(char* text) { + float sum=0; +#ifdef _WIN32 + char* p; + for(p=text;*p;p++) { + sum += get_char_width(p[0]); } +#endif return sum; } @@ -489,13 +494,49 @@ void draw_text_new_right( strcpy(buf,text); p=buf; float l; +#if 0 + strcpy(buf2,text); + strcpy(buf3,text); + t=buf2; + a=buf3; + int lines=0; + while(*t) + { + u = strchr(t, '\n'); + if (u) *u = 0; + lines++; + if (!u) break; + t = u+1; + } + float* line_ratios; + line_ratios = (float*)malloc(sizeof(float)*lines); + int count=0; + float total_length=0; + while(*a) + { + b = strchr(a, '\n'); + if (b) *b = 0; + line_ratios[count]=text_width_new(a); + total_length+=line_ratios[count]; + count++; + if (!b) break; + a = b+1; + } + + + for(int i=0;i0 && dotProd(eye[0],eye[1],eye[2],stars[i].x,stars[i].y,stars[i].z)>0) { - replace_star(i,false); + if(speed>0 && dotProd(eye[0],eye[1],eye[2],d[0],d[1],d[2])<0) { + replace_star(i,false,eye,up,right,camera); continue; } else if(speed <=0 && dist>2000) { - replace_star(i,true); + replace_star(i,true,eye,up,right,camera); continue; } @@ -877,9 +948,9 @@ void STARFIELD::update_stars(int size, float speed, float dt) stars[i].z+=(eye[2])*stars[i].v*speed*dt; - //grow objects as the approach you - if(dist>900) glPointSize(1.0f); - else if(dist>600) glPointSize(2.0f); + //grow objects as they approach you + if(dist>800) glPointSize(1); + else glPointSize(2); glBegin(GL_POINTS); glVertex3f(stars[i].x,stars[i].y,stars[i].z); @@ -890,20 +961,18 @@ void STARFIELD::update_stars(int size, float speed, float dt) glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, no_mat ); } -void STARFIELD::replace_star(int i, bool front) { - int viewport[4]; - get_viewport(viewport); +void STARFIELD::replace_star(int i, bool front,float eye[3], float up[3], float right[3], float camera[3]) { + if(front) { - float z = 0; - float alpha = 2.0*PI*(float)((rand()%359)/359.0) ; - float beta = asin(z/1000.0f); - float x = 1000.0f * cos(beta) * cos(alpha); - float y = 1000.0f * cos(beta) * sin(alpha); - stars[i].x=x; - stars[i].y=y; - stars[i].z=z; - float v = (float)((rand()%1000)/1000.0f); - stars[i].v=v; + float x = frand()*500.0f; + float y = frand()*500.0f; + float z = frand()*100.0f; + + x-=250.f; + y-=250.f; + stars[i].x=eye[0]*z + up[0]*y + right[0]*x; + stars[i].y=eye[1]*z + up[1]*y + right[1]*x; + stars[i].z=eye[2]*z + up[2]*y + right[2]*x; } else { float z = -frand()*2000; @@ -913,10 +982,12 @@ void STARFIELD::replace_star(int i, bool front) { x-=-z*TAN22_5; y-=-z*TAN22_5; - stars[i].x=x; - stars[i].y=y; - stars[i].z=z; + stars[i].x=eye[0]*z + up[0]*y + right[0]*x; + stars[i].y=eye[1]*z + up[1]*y + right[1]*x; + stars[i].z=eye[2]*z + up[2]*y + right[2]*x; } + float v = frand(); + stars[i].v=v; } // ------------ TEXTURE STUFF -------------------- diff --git a/api/gutil.h b/api/gutil.h index aa6cd0e4c8..91050622e4 100755 --- a/api/gutil.h +++ b/api/gutil.h @@ -133,18 +133,18 @@ public: // a colored panel with some text, that can move cyclically // class MOVING_TEXT_PANEL { - float base_pos[3]; - float size[3]; + float base_pos[3]; float theta; float dtheta; - float char_height; - float line_width; - float line_spacing; - double margin; COLOR color; public: + float char_height; + float line_width; + float line_spacing; char text[1024]; float pos[3]; + float size[3]; + double margin; void init(float* pos, float* size, COLOR& color, double dtheta, double ch, double lw, double ls, double margin); void draw(); static void sort(MOVING_TEXT_PANEL* tp, int n); @@ -160,7 +160,7 @@ struct STAR { }; class STARFIELD { - void replace_star(int, bool); + void replace_star(int, bool,float[3],float[3],float[3],float[3]); STAR* stars; public: void build_stars(int, float); diff --git a/api/reduce.C b/api/reduce.C index f45602f605..15558a6bda 100644 --- a/api/reduce.C +++ b/api/reduce.C @@ -649,6 +649,8 @@ void REDUCED_ARRAY::draw_axes() { //float adj2=-.18f; float adj2=-(draw_size[2]*1)/rdimy; float adj=0.0f; + + float adj3=0; // box mode_unshaded(); @@ -717,16 +719,16 @@ void REDUCED_ARRAY::draw_axes() { glVertex3f(draw_pos[0]+draw_size[0], draw_pos[1], draw_pos[2]+draw_size[2]+adj2); glVertex3f(draw_pos[0], draw_pos[1], draw_pos[2]+draw_size[2]+adj2); - glEnd(); - - glBegin(GL_QUADS); - glColor4d(1,1,1,.2); - - glVertex3f(draw_pos[0], draw_pos[1], draw_pos[2]+adj); - glVertex3f(draw_pos[0]+draw_size[0], draw_pos[1], draw_pos[2]+adj); - glVertex3f(draw_pos[0]+draw_size[0], draw_pos[1], draw_pos[2]+draw_size[2]+adj2); - glVertex3f(draw_pos[0], draw_pos[1], draw_pos[2]+draw_size[2]+adj2); + glEnd(); + + glColor4d(1,1,1,.2); + glBegin(GL_QUADS); + glVertex3f(draw_pos[0], draw_pos[1]-adj3, draw_pos[2]+draw_size[2]+adj2); + glVertex3f(draw_pos[0]+draw_size[0], draw_pos[1]-adj3, draw_pos[2]+draw_size[2]+adj2); + glVertex3f(draw_pos[0]+draw_size[0], draw_pos[1]-adj3, draw_pos[2]+adj); + glVertex3f(draw_pos[0], draw_pos[1]-adj3, draw_pos[2]+adj); glEnd(); + glDisable(GL_LINE_SMOOTH); } diff --git a/checkin_notes b/checkin_notes index 152fc59c32..c285cb7605 100755 --- a/checkin_notes +++ b/checkin_notes @@ -6738,11 +6738,12 @@ Karl 2003-10-13 Makefile.am Oliver Oct 13 2003 - - stars now draw in visible pyramid + - stars now draw in visible pyramid api/ gutil.C,h + David Oct 14 2003 - don't call boinc_finish_opengl() in boinc_finish()!! - max frame rate and max graphics CPU are accessible to app @@ -6757,4 +6758,13 @@ David Oct 14 2003 boinc_api.C graphics_api.C,h gutil.C - windows_opengl.C \ No newline at end of file + windows_opengl.C + +Oliver Oct 14 2003 + - stars now draw in visible pyramid with original coordinate system + - axis draws vertices in correct CCW order + + api/ + gutil.C,h + reduce.c +