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: ANARIDisplayDevice.h,v $ 00013 * $Author: johns $ $Locker: $ $State: Exp $ 00014 * $Revision: 1.2 $ $Date: 2020年10月01日 18:34:53 $ 00015 * 00016 ***************************************************************************/ 00037 #ifndef LIBANARIDISPLAYDEVICE 00038 #define LIBANARIDISPLAYDEVICE 00039 00040 #include <stdio.h> 00041 #include "Matrix4.h" 00042 #include "FileRenderer.h" 00043 #include "WKFUtils.h" // timers 00044 00046 class ANARIRender; 00047 00049 class ANARIDisplayDevice: public FileRenderer { 00050 private: 00051 int isinteractive; 00052 ANARIRender * ort; 00053 wkf_timerhandle ort_timer; 00054 00055 void reset_vars(void); 00056 void write_lights(void); 00057 void write_materials(void); 00058 void add_material(void); 00059 00060 #if 0 00061 // state tracking for volumetric texturing 00062 int involtex; 00063 int voltexID; 00064 float xplaneeq[4]; 00065 float yplaneeq[4]; 00066 float zplaneeq[4]; 00067 00068 // state tracking for user-defined clipping planes 00069 int inclipgroup; 00070 #endif 00071 00072 #if 0 00073 // storage and state variables needed to aggregate lone cylinders 00074 // with common color and material state into a larger buffer for 00075 // transmission to ANARI 00076 int cylinder_matindex; 00077 Matrix4 *cylinder_xform; 00078 float cylinder_radius_scalefactor; 00079 ResizeArray<float> cylinder_vert_buffer; 00080 ResizeArray<float> cylinder_radii_buffer; 00081 ResizeArray<float> cylinder_color_buffer; 00082 // cylinder end caps, made from rings 00083 ResizeArray<float> cylcap_vert_buffer; 00084 ResizeArray<float> cylcap_norm_buffer; 00085 ResizeArray<float> cylcap_radii_buffer; 00086 ResizeArray<float> cylcap_color_buffer; 00087 00089 void reset_cylinder_buffer() { 00090 cylinder_matindex = -1; 00091 cylinder_xform = NULL; 00092 cylinder_radius_scalefactor=1.0f; 00093 cylinder_vert_buffer.clear(); 00094 cylinder_radii_buffer.clear(); 00095 cylinder_color_buffer.clear(); 00096 00097 cylcap_vert_buffer.clear(); 00098 cylcap_norm_buffer.clear(); 00099 cylcap_radii_buffer.clear(); 00100 cylcap_color_buffer.clear(); 00101 }; 00102 #endif 00103 00104 // storage and state variables needed to aggregate lone triangles 00105 // with common color and material state into a larger buffer for 00106 // transmission to ANARI 00107 int triangle_cindex; 00108 int triangle_matindex; 00109 Matrix4 *triangle_xform; 00110 ResizeArray<float> triangle_vert_buffer; 00111 ResizeArray<float> triangle_norm_buffer; 00112 00114 void reset_triangle_buffer() { 00115 triangle_cindex = -1; 00116 triangle_matindex = -1; 00117 triangle_xform = NULL; 00118 triangle_vert_buffer.clear(); 00119 triangle_norm_buffer.clear(); 00120 }; 00121 00122 protected: 00123 #if 0 00124 void send_cylinder_buffer(void); 00125 void cylinder(float *, float *, float rad, int filled); 00126 void text(float *pos, float size, float thickness, const char *str); 00127 #endif 00128 00130 void comment(const char *); 00131 00132 #if 0 00133 void sphere(float *spdata); 00134 #endif 00135 void sphere_array(int num, int res, float *centers, 00136 float *radii, float *colors); 00137 void send_triangle_buffer(void); 00138 void triangle(const float *, const float *, const float *, 00139 const float *, const float *, const float *); 00140 void tricolor(const float * xyz1, const float * xyz2, const float * xyz3, 00141 const float * n1, const float * n2, const float * n3, 00142 const float * c1, const float * c2, const float * c3); 00143 void trimesh_c4u_n3b_v3f(unsigned char *c, signed char *n, float *v, int numfacets); 00144 void trimesh_c4u_n3f_v3f(unsigned char *c, float *n, float *v, int numfacets); 00145 void trimesh_c4n3v3(int numverts, float * cnv, int numfacets, int * facets); 00146 void trimesh_n3b_v3f(signed char *n, float *v, int numfacets); 00147 void trimesh_n3f_v3f(float *n, float *v, int numfacets); 00148 #if 0 00149 void trimesh_n3fopt_v3f(float *n, float *v, int numfacets); 00150 #endif 00151 void tristrip(int numverts, const float * cnv, 00152 int numstrips, const int *vertsperstrip, 00153 const int *facets); 00154 00155 public: 00156 static void ANARI_Global_Init(void); 00157 static void ANARI_Global_Shutdown(void); 00158 ANARIDisplayDevice(VMDApp *, int interactive); 00159 virtual ~ANARIDisplayDevice(void); 00160 void write_header(void); 00161 void write_trailer(void); 00162 }; 00163 00164 #endif 00165