00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
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" 
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   
00071   
00072   
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   
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   
00101   
00102   
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   
00122   
00123   
00124   
00125   
00126   
00127   
00128   
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   
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   
00166   virtual void volume_texture_on(int texmode);
00167 
00168   
00169   virtual void volume_texture_off(void);
00170 
00171   
00172   
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