Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

FileRenderer.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr                                                                       
00003  *cr            (C) Copyright 1995-2019 The Board of Trustees of the           
00004  *cr                        University of Illinois                       
00005  *cr                         All Rights Reserved                        
00006  *cr                                                                   
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  * RCS INFORMATION:
00011  *
00012  *      $RCSfile: FileRenderer.h,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.130 $      $Date: 2021/05/14 22:51:35 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  *
00019  * The FileRenderer class implements the data and functions needed to 
00020  * render a scene to a file in some format (postscript, raster3d, etc.)
00021  *
00022  ***************************************************************************/
00023 #ifndef FILERENDERER_H
00024 #define FILERENDERER_H
00025 
00026 #include <stdio.h>
00027 
00028 #include "DisplayDevice.h"
00029 #include "Scene.h"
00030 #include "NameList.h"
00031 #include "Inform.h"
00032 
00033 #define FILERENDERER_NOWARNINGS    0
00034 #define FILERENDERER_NOMISCFEATURE 1
00035 #define FILERENDERER_NOCLIP        2
00036 #define FILERENDERER_NOCUEING      4
00037 #define FILERENDERER_NOTEXTURE     8
00038 #define FILERENDERER_NOGEOM       16
00039 #define FILERENDERER_NOTEXT       32
00040 
00044 class FileRenderer : public DisplayDevice {
00045 protected:
00046   char *publicName;         
00047   char *publicPrettyName;   
00048   char *defaultFilename;    
00049   char *defaultCommandLine; 
00050 
00051   char *execCmd;     
00052   FILE *outfile;     
00053   int isOpened;      
00054   char *my_filename; 
00055   int has_aa;        
00056   int aasamples;     
00057   int aosamples;     
00058   int has_imgsize;   
00059 
00060   int warningflags;  
00061 
00062 
00063   int imgwidth, imgheight;  
00064   float aspectratio;        
00065   NameList<int> formats;    
00066   int curformat;     
00067 
00070   virtual void update_exec_cmd() {}
00071 
00073   struct LightState {
00074     float color[3];             
00075     float pos[3];               
00076     int on;                     
00077   };
00078   LightState lightState[DISP_LIGHTS]; 
00079 
00081   struct AdvancedLightState {
00082     float color[3];             
00083     float pos[3];               
00084     float constfactor;          
00085     float linearfactor;         
00086     float quadfactor;           
00087     float spotdir[3];           
00088     float fallstart;            
00089     float fallend;              
00090     int spoton;                 
00091     int on;                     
00092   };
00093   AdvancedLightState advLightState[DISP_LIGHTS]; 
00094 
00096   float matData[MAXCOLORS][3];
00097   virtual void do_use_colors();
00098 
00100   float backColor[3];
00101 
00102   float backgradientenabled;      
00103   float backgradienttopcolor[3];  
00104   float backgradientbotcolor[3];  
00105  
00106 public:
00108   FileRenderer(const char *public_name, 
00109                const char *public_pretty_name,
00110                const char *default_file_name,
00111                const char *default_command_line);
00112   virtual ~FileRenderer(void);
00113 
00114   const char *visible_name(void) const { return publicName;}
00115   const char *pretty_name(void) const { return publicPrettyName;}
00116   const char *default_filename(void) const {return defaultFilename;}
00117   const char *default_exec_string(void) const {return defaultCommandLine;}
00118   const char *saved_exec_string(void) const { return execCmd; }
00119 
00120   void set_exec_string(const char *);
00121 
00123   int has_antialiasing() const { return has_aa; }
00124 
00126   int set_aasamples(int newval) {
00127     if (has_aa && (newval >= 0)) {
00128       aasamples = newval;
00129       update_exec_cmd();
00130     }
00131     return aasamples;
00132   }
00133 
00135   int set_aosamples(int newval) {
00136     if (newval >= 0) {
00137       aosamples = newval;
00138       update_exec_cmd();
00139     }
00140     return aosamples;
00141   }
00142 
00144   int has_imagesize() const { return has_imgsize; }
00145 
00150   int set_imagesize(int *w, int *h);
00151 
00154   float set_aspectratio(float aspect);
00155   
00157   int numformats() const { return formats.num(); }
00158   
00160   const char *format(int i) const { return formats.name(i); }
00161   const char *format() const { return formats.name(curformat); }
00162   int set_format(const char *format) {
00163     int ind = formats.typecode(format);
00164     if (ind < 0) return FALSE;
00165     if (curformat != ind) {
00166       curformat = ind;
00167       update_exec_cmd();
00168     }
00169     return TRUE;
00170   }
00171 
00173   virtual void set_background(const float *);
00174 
00176   virtual void set_backgradient(const float *top, const float *bot);
00177 
00182   virtual int open_file(const char *filename);
00183 
00184   virtual int do_define_light(int n, float *color, float *position);
00185   virtual int do_activate_light(int n, int turnon);
00186 
00187   virtual int do_define_adv_light(int n, float *color, float *position,
00188                                   float constant, float linear, float quad,
00189                                   float *spotdir, float fallstart, 
00190                                   float fallend, int spoton); 
00191   virtual int do_activate_adv_light(int n, int turnon);
00192 
00193 private:
00194   int sph_nverts;   
00195   float *sph_verts; 
00196 
00197 protected:
00199   virtual void write_header(void) {};
00200   void reset_state(void);
00201 
00202 public:
00203   virtual int prepare3D(int); 
00204   virtual void render(const VMDDisplayList *); // render the display list
00205 
00206 protected:
00208   virtual void write_trailer(void) {};
00209 
00213   virtual void close_file(void);
00214 
00215 public:
00217   virtual void update(int) {
00218     if (isOpened) {
00219       write_trailer();
00220       close_file();
00221       isOpened = FALSE;
00222   
00223       // Emit any pending warning messages for missing or unsupported
00224       // geometric primitives.
00225       if (warningflags & FILERENDERER_NOCLIP)
00226         msgWarn << "User-defined clipping planes not exported for this renderer" << sendmsg;
00227 
00228       if (warningflags & FILERENDERER_NOTEXT)
00229         msgWarn << "Text not exported for this renderer" << sendmsg;
00230 
00231       if (warningflags & FILERENDERER_NOTEXTURE)
00232         msgWarn << "Texture mapping not exported for this renderer" << sendmsg;
00233 
00234       if (warningflags & FILERENDERER_NOCUEING)
00235         msgWarn << "Depth cueing not exported for this renderer" << sendmsg;
00236 
00237       if (warningflags & FILERENDERER_NOGEOM)
00238         msgWarn << "One or more geometry types not exported for this renderer" << sendmsg;
00239 
00240       if (warningflags != FILERENDERER_NOWARNINGS)
00241         msgWarn << "Unimplemented features may negatively affect the appearance of the scene" << sendmsg;
00242     }
00243   }
00244 
00245 protected:
00247   // (for those that do not want to take care of it themselves)
00248   // the 'super_' version is called by render to set the matrix.  It
00249   // then calls the non-super version
00250   Stack<Matrix4> transMat;
00251   void super_load(float *cmdptr);
00252   virtual void load(const Matrix4& /*mat*/) {}
00253   void super_multmatrix(const float *cmdptr);
00254   virtual void multmatrix(const Matrix4& /*mat*/) {}
00255   void super_translate(float *cmdptr);
00256   virtual void translate(float /*x*/, float /*y*/, float /*z*/) {}
00257   void super_rot(float *cmdptr);
00258   virtual void rot(float /*ang*/, char /*axis*/) {}
00259   void super_scale(float *cmdptr);
00260   void super_scale(float);
00261   virtual void scale(float /*scalex*/, float /*scaley*/, 
00262                      float /*scalez*/) {}
00263 
00264   float scale_factor(void);         
00265 
00266   float scale_radius(float);        
00267 
00268   // change the color definitions
00269   int colorIndex;                   
00270   void super_set_color(int index);  
00271   virtual void set_color(int) {}    
00272   
00277   int nearest_index(float r, float g, float b) const;
00278 
00279   // change the material definition
00280   int materialIndex;                    
00281   float mat_ambient;                    
00282   float mat_diffuse;                    
00283   float mat_specular;                   
00284   float mat_shininess;                  
00285   float mat_mirror;                     
00286   float mat_opacity;                    
00287   float mat_outline;                    
00288   float mat_outlinewidth;               
00289   float mat_transmode;                  
00290   void super_set_material(int index);   
00291   virtual void set_material(int) {}     
00292 
00293   float clip_center[VMD_MAX_CLIP_PLANE][3]; 
00294   float clip_normal[VMD_MAX_CLIP_PLANE][3]; 
00295   float clip_color[VMD_MAX_CLIP_PLANE][3];  
00296   int clip_mode[VMD_MAX_CLIP_PLANE];        
00297 
00298   virtual void start_clipgroup();       
00299   virtual void end_clipgroup() {}       
00300 
00301   // change the line definitions
00302   int lineWidth, lineStyle, pointSize;
00303   virtual void set_line_width(int new_width) {
00304     lineWidth = new_width;
00305   }
00306   virtual void set_line_style(int /*new_style*/) {}  
00307 
00308   // change the sphere definitions
00309   int sphereResolution, sphereStyle;
00310   virtual void set_sphere_res(int /*res*/) {}        
00311   virtual void set_sphere_style(int /*style*/) {}    
00312 
00313   int materials_on;
00314   void super_materials(int on_or_off);
00315   virtual void activate_materials(void) {}           
00316   virtual void deactivate_materials(void) {}         
00317   
00318 
00320 
00322   virtual void cone(float * xyz1, float * xyz2, float radius, int resolution) { 
00323     // if not overridden by the subclass, we just call the truncated cone
00324     // method with a 0.0 radius for the tip
00325     cone_trunc(xyz1, xyz2, radius, 0.0f, resolution);
00326   }
00327 
00329   virtual void cone_trunc(float * /*xyz1*/, float * /*xyz2*/, 
00330                           float /* radius*/, float /* radius2 */, 
00331                           int /*resolution*/);
00332 
00333 
00335   virtual void cylinder(float * base, float * apex, float radius, int filled);
00336 
00337 #if defined(VMDOPTIXRTRT)
00338 
00339   virtual void cylinder_array(int num, int res, int caps,
00340                               float *points, float *radii, float *colors);
00341 #endif
00342 
00344   virtual void line(float * a, float * b);
00345 
00347   virtual void line_array(int num, float thickness, float *points);
00348 
00350   virtual void polyline_array(int num, float thickness, float *points);
00351 
00352 
00354   virtual void point(float * xyz) {
00355     float xyzr[4];
00356     vec_copy(xyzr, xyz);
00357     xyzr[3] = lineWidth * 0.002f; // hack for renderers that don't have points
00358   }
00359 
00361   virtual void point_array(int num, float size, float *xyz, float *colors);
00362 
00364   virtual void point_array_lit(int num, float size, 
00365                                float *xyz, float *norm, float *colors);
00366 
00368   virtual void cube_array(int num, float *centers, float *radii, float *colors);
00369 
00371   virtual void sphere(float * xyzr);
00372 
00374   virtual void sphere_array(int num, int res, float *centers, float *radii, float *colors);
00375 
00377   virtual void square(float * norm, float * a, float * b, 
00378                       float * c, float * d) {
00379     // draw as two triangles, with correct winding order etc
00380     triangle(a, b, c, norm, norm, norm);
00381     triangle(a, c, d, norm, norm, norm);
00382   }
00383 
00385   virtual void cube(float * xyzr) {
00386     // coordinates of unit cube
00387     float v0[] = {-1.0, -1.0, -1.0}; 
00388     float v1[] = { 1.0, -1.0, -1.0}; 
00389     float v2[] = {-1.0,  1.0, -1.0}; 
00390     float v3[] = { 1.0,  1.0, -1.0}; 
00391     float v4[] = {-1.0, -1.0,  1.0}; 
00392     float v5[] = { 1.0, -1.0,  1.0}; 
00393     float v6[] = {-1.0,  1.0,  1.0}; 
00394     float v7[] = { 1.0,  1.0,  1.0}; 
00395 
00396     float n0[] = {0, 0,  1};
00397     float n1[] = {0, 0,  1};
00398     float n2[] = {0, -1, 0};
00399     float n3[] = {0, -1, 0};
00400     float n4[] = {1, 0, 0};
00401     float n5[] = {1, 0, 0};
00402 
00403     vec_triad(v0, xyzr, xyzr[3], v0);
00404     vec_triad(v1, xyzr, xyzr[3], v1);
00405     vec_triad(v2, xyzr, xyzr[3], v2);
00406     vec_triad(v3, xyzr, xyzr[3], v3);
00407     vec_triad(v4, xyzr, xyzr[3], v4);
00408     vec_triad(v5, xyzr, xyzr[3], v5);
00409     vec_triad(v6, xyzr, xyzr[3], v6);
00410     vec_triad(v7, xyzr, xyzr[3], v7);
00411 
00412     square(n0, v0, v1, v3, v2);
00413     square(n1, v4, v5, v7, v6);
00414     square(n2, v0, v1, v5, v4);
00415     square(n3, v2, v3, v7, v6);
00416     square(n4, v0, v2, v6, v4);
00417     square(n5, v1, v3, v7, v5);
00418   }
00419 
00420 
00422   virtual void triangle(const float * /*xyz1*/, const float * /*xyz2*/, const float * /*xyz3*/, 
00423                         const float * /*n1*/, const float * /*n2*/, const float * /*n3*/) {
00424     warningflags |= FILERENDERER_NOGEOM; // no triangles written
00425   }
00426 
00427 
00429   virtual void tricolor(const float * xyz1, const float * xyz2, const float * xyz3, 
00430                         const float * n1, const float * n2, const float * n3,
00431                         const float *c1, const float *c2, const float *c3) {
00432     int index = 1;
00433     float r, g, b;
00434     r = (c1[0] + c2[0] + c3[0]) / 3.0f; // average three vertex colors 
00435     g = (c1[1] + c2[1] + c3[1]) / 3.0f;
00436     b = (c1[2] + c2[2] + c3[2]) / 3.0f;
00437 
00438     index = nearest_index(r,g,b); // lookup nearest color here.
00439     super_set_color(index); // use the closest color
00440 
00441     triangle(xyz1, xyz2, xyz3, n1, n2, n3); // draw a regular triangle   
00442   }
00443 
00444 
00446   virtual void trimesh_n3f_v3f(float *n, float *v, int numfacets) { 
00447     int i;
00448     for (i=0; i<numfacets*9; i+=9) {
00449       triangle(v + i    , 
00450                v + i + 3, 
00451                v + i + 6,
00452                n + i    , 
00453                n + i + 3, 
00454                n + i + 6); 
00455     }           
00456   }
00457 
00458 
00465   virtual void trimesh_n3fopt_v3f(float *n, float *v, int numfacets) { 
00466     trimesh_n3f_v3f(n, v, numfacets); 
00467   }
00468 
00469 
00470   virtual void trimesh_n3b_v3f(signed char *n, float *v, int numfacets) { 
00471     int i;
00472     const float cn2f = 1.0f / 127.5f;
00473     const float ci2f = 1.0f / 255.0f; 
00474 
00475     for (i=0; i<numfacets*9; i+=9) {
00476       float norm[9];
00477 
00478       // conversion from GLbyte format, Table 2.6, p. 44 of OpenGL spec 1.2.1
00479       // float = (2c+1)/(2^8-1)
00480       norm[0] = n[i    ] * cn2f + ci2f;
00481       norm[1] = n[i + 1] * cn2f + ci2f;
00482       norm[2] = n[i + 2] * cn2f + ci2f;
00483       norm[3] = n[i + 3] * cn2f + ci2f;
00484       norm[4] = n[i + 4] * cn2f + ci2f;
00485       norm[5] = n[i + 5] * cn2f + ci2f;
00486       norm[6] = n[i + 6] * cn2f + ci2f;
00487       norm[7] = n[i + 7] * cn2f + ci2f;
00488       norm[8] = n[i + 8] * cn2f + ci2f;
00489 
00490       triangle(v + i    ,
00491                v + i + 3, 
00492                v + i + 6, 
00493                &norm[0],
00494                &norm[3], 
00495                &norm[6]);
00496     }           
00497   }
00498 
00500   virtual void trimesh_c3f_n3f_v3f(float *c, float *n, float *v, int numfacets) { 
00501     int i;
00502     for (i=0; i<numfacets*9; i+=9) {
00503       tricolor(v + i    ,
00504                v + i + 3, 
00505                v + i + 6, 
00506                n + i    , 
00507                n + i + 3, 
00508                n + i + 6, 
00509                c + i    , 
00510                c + i + 3, 
00511                c + i + 6);
00512     }           
00513   }
00514 
00516   virtual void trimesh_c4n3v3(int /* numverts */, float * cnv, 
00517                               int numfacets, int * facets) { 
00518     int i;
00519     for (i=0; i<numfacets*3; i+=3) {
00520       int v0 = facets[i    ] * 10;
00521       int v1 = facets[i + 1] * 10;
00522       int v2 = facets[i + 2] * 10;
00523       tricolor(cnv + v0 + 7, // vertices 0, 1, 2
00524                cnv + v1 + 7, 
00525                cnv + v2 + 7,
00526                cnv + v0 + 4, // normals 0, 1, 2
00527                cnv + v1 + 4, 
00528                cnv + v2 + 4,
00529                cnv + v0,     // colors 0, 1, 2
00530                cnv + v1, 
00531                cnv + v2);
00532     }           
00533   }
00534 
00536   virtual void trimesh_c4u_n3f_v3f(unsigned char *c, float *n, float *v, 
00537                                    int numfacets) { 
00538     int i, j;
00539     const float ci2f = 1.0f / 255.0f;
00540     for (i=0,j=0; i<numfacets*9; i+=9,j+=12) {
00541       float col[9];
00542 
00543       // conversion from GLubyte format, Table 2.6, p. 44 of OpenGL spec 1.2.1
00544       // float = c/(2^8-1)
00545       col[0] = c[j     ] * ci2f;
00546       col[1] = c[j +  1] * ci2f;
00547       col[2] = c[j +  2] * ci2f;
00548       col[3] = c[j +  4] * ci2f;
00549       col[4] = c[j +  5] * ci2f;
00550       col[5] = c[j +  6] * ci2f;
00551       col[6] = c[j +  8] * ci2f;
00552       col[7] = c[j +  9] * ci2f;
00553       col[8] = c[j + 10] * ci2f;
00554 
00555       tricolor(v + i    ,
00556                v + i + 3, 
00557                v + i + 6, 
00558                n + i    , 
00559                n + i + 3, 
00560                n + i + 6, 
00561                &col[0],
00562                &col[3], 
00563                &col[6]);
00564     }           
00565   }
00566 
00568   virtual void trimesh_c4u_n3b_v3f(unsigned char *c, signed char *n, float *v, 
00569                                    int numfacets) { 
00570     int i, j;
00571     const float ci2f = 1.0f / 255.0f; // used for uchar2float and normal conv
00572     const float cn2f = 1.0f / 127.5f;
00573     for (i=0,j=0; i<numfacets*9; i+=9,j+=12) {
00574       float col[9], norm[9];
00575 
00576       // conversion from GLubyte format, Table 2.6, p. 44 of OpenGL spec 1.2.1
00577       // float = c/(2^8-1)
00578       col[0] = c[j     ] * ci2f;
00579       col[1] = c[j +  1] * ci2f;
00580       col[2] = c[j +  2] * ci2f;
00581       col[3] = c[j +  4] * ci2f;
00582       col[4] = c[j +  5] * ci2f;
00583       col[5] = c[j +  6] * ci2f;
00584       col[6] = c[j +  8] * ci2f;
00585       col[7] = c[j +  9] * ci2f;
00586       col[8] = c[j + 10] * ci2f;
00587 
00588       // conversion from GLbyte format, Table 2.6, p. 44 of OpenGL spec 1.2.1
00589       // float = (2c+1)/(2^8-1)
00590       norm[0] = n[i    ] * cn2f + ci2f;
00591       norm[1] = n[i + 1] * cn2f + ci2f;
00592       norm[2] = n[i + 2] * cn2f + ci2f;
00593       norm[3] = n[i + 3] * cn2f + ci2f;
00594       norm[4] = n[i + 4] * cn2f + ci2f;
00595       norm[5] = n[i + 5] * cn2f + ci2f;
00596       norm[6] = n[i + 6] * cn2f + ci2f;
00597       norm[7] = n[i + 7] * cn2f + ci2f;
00598       norm[8] = n[i + 8] * cn2f + ci2f;
00599 
00600       tricolor(v + i    ,
00601                v + i + 3, 
00602                v + i + 6, 
00603                &norm[0],
00604                &norm[3], 
00605                &norm[6],
00606                &col[0],
00607                &col[3], 
00608                &col[6]);
00609     }           
00610   }
00611 
00612 
00614   virtual void trimesh_singlecolor(int cindex, int /* numverts */, float * nv, 
00615                                    int numfacets, int * facets) { 
00616     super_set_color(cindex); // set current color
00617 
00618     int i;
00619     for (i=0; i<numfacets*3; i+=3) {
00620       int v0 = facets[i    ] * 6;
00621       int v1 = facets[i + 1] * 6; 
00622       int v2 = facets[i + 2] * 6;
00623       triangle(nv + v0 + 3, // vertices 0, 1, 2
00624                nv + v1 + 3, 
00625                nv + v2 + 3,
00626                nv + v0,     // normals 0, 1, 2
00627                nv + v1, 
00628                nv + v2);
00629     }           
00630   }
00631 
00632 
00634   virtual void tristrip(int /* numverts */, const float * cnv, 
00635                         int numstrips, const int *vertsperstrip, 
00636                         const int *facets) { 
00637     // render triangle strips one triangle at a time
00638     // triangle winding order is:
00639     //   v0, v1, v2, then v2, v1, v3, then v2, v3, v4, etc.
00640     int strip, t, v = 0;
00641     int stripaddr[2][3] = { {0, 1, 2}, {1, 0, 2} };
00642  
00643     // loop over all of the triangle strips
00644     for (strip=0; strip < numstrips; strip++) {       
00645       // loop over all triangles in this triangle strip
00646       for (t = 0; t < (vertsperstrip[strip] - 2); t++) {
00647         // render one triangle, using lookup table to fix winding order
00648         int v0 = facets[v + (stripaddr[t & 0x01][0])] * 10;
00649         int v1 = facets[v + (stripaddr[t & 0x01][1])] * 10;
00650         int v2 = facets[v + (stripaddr[t & 0x01][2])] * 10;
00651  
00652         tricolor(cnv + v0 + 7, // vertices 0, 1, 2
00653                  cnv + v1 + 7, 
00654                  cnv + v2 + 7,
00655                  cnv + v0 + 4, // normals 0, 1, 2
00656                  cnv + v1 + 4, 
00657                  cnv + v2 + 4,
00658                  cnv + v0,     // colors 0, 1, 2
00659                  cnv + v1, 
00660                  cnv + v2);
00661         v++; // move on to next vertex
00662       }
00663       v+=2; // last two vertices are already used by last triangle
00664     }
00665   }
00666 
00667 
00670   virtual void tristrip_singlecolor(int /* numverts */, const float * nv, 
00671                                     int numstrips, const int *stripcolindex,
00672                                     const int *vertsperstrip, const int *facets) { 
00673     // render triangle strips one triangle at a time
00674     // triangle winding order is:
00675     //   v0, v1, v2, then v2, v1, v3, then v2, v3, v4, etc.
00676     int strip, t, v = 0;
00677     int stripaddr[2][3] = { {0, 1, 2}, {1, 0, 2} };
00678  
00679     // loop over all of the triangle strips
00680     for (strip=0; strip < numstrips; strip++) {       
00681       super_set_color(stripcolindex[strip]); // set current color
00682       
00683       // loop over all triangles in this triangle strip
00684       for (t = 0; t < (vertsperstrip[strip] - 2); t++) {
00685         // render one triangle, using lookup table to fix winding order
00686         int v0 = facets[v + (stripaddr[t & 0x01][0])] * 6;
00687         int v1 = facets[v + (stripaddr[t & 0x01][1])] * 6;
00688         int v2 = facets[v + (stripaddr[t & 0x01][2])] * 6;
00689  
00690         triangle(nv + v0 + 3, // vertices 0, 1, 2
00691                  nv + v1 + 3, 
00692                  nv + v2 + 3,
00693                  nv + v0, // normals 0, 1, 2
00694                  nv + v1, 
00695                  nv + v2);
00696         v++; // move on to next vertex
00697       }
00698       v+=2; // last two vertices are already used by last triangle
00699     }
00700   }
00701 
00702 
00705   virtual void trifan_singlecolor(int /* numverts */, const float * nv,
00706                                   int numfans, const int *fancolindex,
00707                                   const int *vertsperfan, const int *facets) {
00708     // render triangle fans one triangle at a time
00709     // triangle winding order is:
00710     //   v0, v1, v2, then v0, v2, v3, then v0, v3, v4, etc.
00711     int fan, t, v = 0;
00712 
00713     // loop over all of the triangle fans
00714     for (fan=0; fan < numfans; fan++) {
00715       super_set_color(fancolindex[fan]); // set current color
00716 
00717       // loop over all triangles in this triangle fan
00718       int v0 = facets[v] * 6;
00719       v++;
00720       for (t = 1; t < (vertsperfan[fan] - 1); t++) {
00721         // render one triangle with correct winding order
00722         int v1 = facets[v    ] * 6;
00723         int v2 = facets[v + 1] * 6;
00724 
00725         triangle(nv + v0 + 3, // vertices 0, 1, 2
00726                  nv + v1 + 3,
00727                  nv + v2 + 3,
00728                  nv + v0, // normals 0, 1, 2
00729                  nv + v1,
00730                  nv + v2);
00731         v++; // move on to next vertex
00732       }
00733       v++; // last vertex is already used by last triangle
00734     }
00735   }
00736 
00737 
00739   virtual void define_volume_texture(int ID, int xs, int ys, int zs,
00740                                      const float *xplaneeq, 
00741                                      const float *yplaneeq,
00742                                      const float *zplaneeq,
00743                                      unsigned char *texmap) {
00744     warningflags |= FILERENDERER_NOTEXTURE;
00745   }
00746 
00747 
00749   virtual void volume_texture_on(int texmode) {
00750     warningflags |= FILERENDERER_NOTEXTURE;
00751   }
00752 
00753 
00755   virtual void volume_texture_off(void) {
00756     warningflags |= FILERENDERER_NOTEXTURE;
00757   }
00758 
00759 
00761   virtual void wiremesh(int /* numverts */, float * cnv, 
00762                        int numlines, int * lines) { 
00763     int i;
00764     int index = 1;
00765 
00766     for (i=0; i<numlines; i++) {
00767       float r, g, b;
00768       int ind = i * 2;
00769       int v0 = lines[ind    ] * 10;
00770       int v1 = lines[ind + 1] * 10;
00771 
00772       r = cnv[v0 + 0] + cnv[v1 + 0] / 2.0f;
00773       g = cnv[v0 + 1] + cnv[v1 + 1] / 2.0f;
00774       b = cnv[v0 + 2] + cnv[v1 + 2] / 2.0f;
00775 
00776       index = nearest_index(r,g,b); // lookup nearest color here.
00777       super_set_color(index); // use the closest color
00778 
00779       line(cnv + v0 + 7, cnv + v1 + 7); 
00780     }           
00781   }
00782 
00786   virtual void beginrepgeomgroup(const char *) {}
00787 
00789   virtual void comment(const char *) {}
00790 
00792   virtual void text(float *pos, float size, float thickness, const char *str);
00793 
00795   virtual void pick_point(float * /*xyz*/, int /*id*/) {}
00796 
00797 };
00798 
00799 #endif
00800 

Generated on Thu Mar 28 02:43:13 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002