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

OSPRayDisplayDevice.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: OSPRayDisplayDevice.h,v $
00013 *      $Author: johns $      $Locker:  $               $State: Exp $
00014 *      $Revision: 1.19 $         $Date: 2021/12/13 07:41:23 $
00015 *
00016 ***************************************************************************/
00038 #ifndef LIBOSPRAYDISPLAYDEVICE
00039 #define LIBOSPRAYDISPLAYDEVICE
00040 
00041 #include <stdio.h>
00042 #include "Matrix4.h"
00043 #include "FileRenderer.h"
00044 #include "WKFUtils.h" // timers
00045 
00047 class OSPRayRenderer;
00048 
00050 class OSPRayDisplayDevice: public FileRenderer {
00051 private:
00052   int isinteractive;
00053   OSPRayRenderer * ort;
00054   wkf_timerhandle ort_timer;
00055 
00056   void reset_vars(void); 
00057   void write_lights(void);
00058   void write_materials(void);
00059   void add_material(void);
00060 
00061   int inclipgroup;            
00062 #if 0
00063   int involtex;               
00064   int voltexID;               
00065   float xplaneeq[4];          
00066   float yplaneeq[4];
00067   float zplaneeq[4];
00068 #endif
00069 
00070   // storage and state variables needed to aggregate lone cylinders
00071   // with common color and material state into a larger buffer for
00072   // transmission to OSPRay
00073   int cylinder_matindex;
00074   Matrix4 *cylinder_xform;
00075   float cylinder_radius_scalefactor;
00076   ResizeArray<float> cylinder_vert_buffer;
00077   ResizeArray<float> cylinder_radii_buffer;
00078   ResizeArray<float> cylinder_color_buffer;
00079   // cylinder end caps, made from rings
00080   ResizeArray<float> cylcap_vert_buffer;
00081   ResizeArray<float> cylcap_norm_buffer;
00082   ResizeArray<float> cylcap_radii_buffer;
00083   ResizeArray<float> cylcap_color_buffer;
00084 
00086   void reset_cylinder_buffer() {
00087     cylinder_matindex = -1;
00088     cylinder_xform = NULL;
00089     cylinder_radius_scalefactor=1.0f;
00090     cylinder_vert_buffer.clear();
00091     cylinder_radii_buffer.clear();
00092     cylinder_color_buffer.clear();
00093 
00094     cylcap_vert_buffer.clear();
00095     cylcap_norm_buffer.clear();
00096     cylcap_radii_buffer.clear();
00097     cylcap_color_buffer.clear();
00098   };
00099 
00100   // storage and state variables needed to aggregate lone triangles
00101   // with common color and material state into a larger buffer for
00102   // transmission to OSPRay
00103   int triangle_cindex;
00104   int triangle_matindex;
00105   Matrix4 *triangle_xform;
00106   ResizeArray<float> triangle_vert_buffer;
00107   ResizeArray<float> triangle_norm_buffer;
00108 
00110   void reset_triangle_buffer() {
00111     triangle_cindex = -1;   
00112     triangle_matindex = -1; 
00113     triangle_xform = NULL;
00114     triangle_vert_buffer.clear();
00115     triangle_norm_buffer.clear();
00116   };
00117 
00118 protected:
00119   void send_cylinder_buffer(void);
00120 #if 1
00121   // XXX OSPRay 1.1.1 and earlier have code that computes 
00122   //     bad surface normals for cylinders when the cylinders
00123   //     have a small radius, which can result in black-colored
00124   //     cylinders.  When compiling on these versions of OSPRay,
00125   //     VMD must supress the use of OSPRay cylinder primitives.
00126   // XXX Starting with OSPRay version 1.1.2 and later, and with 
00127   //     patched versions of OSPRay 1.1.1 the cylinder bugs
00128   //     are fixed, and VMD can safely use them. 
00129   #define VMDOSPRAY_ENABLE_CYLINDERS 1
00130   void cylinder(float *, float *, float rad, int filled);
00131   void text(float *pos, float size, float thickness, const char *str);
00132 #endif
00133 
00134 #if 0
00135   void sphere(float *spdata);
00136 #endif
00137   void sphere_array(int num, int res, float *centers, 
00138                     float *radii, float *colors);
00139   void send_triangle_buffer(void);
00140   void triangle(const float *, const float *, const float *,
00141                 const float *, const float *, const float *);
00142   void tricolor(const float * xyz1, const float * xyz2, const float * xyz3,
00143                 const float * n1,   const float * n2,   const float * n3,
00144                 const float * c1,   const float * c2,   const float * c3);
00145   void trimesh_c4u_n3b_v3f(unsigned char *c, signed char *n, float *v, int numfacets);
00146   void trimesh_c4u_n3f_v3f(unsigned char *c, float *n, float *v, int numfacets);
00147   void trimesh_c4n3v3(int numverts, float * cnv, int numfacets, int * facets);
00148   void trimesh_n3b_v3f(signed char *n, float *v, int numfacets);
00149   void trimesh_n3f_v3f(float *n, float *v, int numfacets);
00150 #if 0
00151   void trimesh_n3fopt_v3f(float *n, float *v, int numfacets);
00152 #endif
00153   void tristrip(int numverts, const float * cnv,
00154                 int numstrips, const int *vertsperstrip,
00155                 const int *facets);
00156 
00157 #if 0
00158   // define a volumetric texture map
00159   virtual void define_volume_texture(int ID, int xs, int ys, int zs,
00160                                      const float *xplaneeq,
00161                                      const float *yplaneeq,
00162                                      const float *zplaneeq,
00163                                      unsigned char *texmap);
00164 
00165   // enable volumetric texturing, either in "replace" or "modulate" mode
00166   virtual void volume_texture_on(int texmode);
00167 
00168   // disable volumetric texturing
00169   virtual void volume_texture_off(void);
00170 
00171   // begin a group of objects to be clipped by the same set of
00172   // clipping planes
00173   void start_clipgroup(void);
00174   void end_clipgroup(void);
00175 #endif
00176 
00177 public: 
00178   static int OSPRay_Global_Init(void);      
00179   static void OSPRay_Global_Shutdown(void); 
00180   OSPRayDisplayDevice(VMDApp *, int interactive);
00181   virtual ~OSPRayDisplayDevice(void);
00182   void write_header(void); 
00183   void write_trailer(void);
00184 }; 
00185 
00186 #endif
00187 

Generated on Tue Apr 23 04:23:49 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002