00001 /* 00002 * Copyright (c) 1998 by Tech Soft 3D, LLC. 00003 * The information contained herein is confidential and proprietary to 00004 * Tech Soft 3D, LLC., and considered a trade secret as defined under 00005 * civil and criminal statutes. Tech Soft 3D shall pursue its civil 00006 * and criminal remedies in the event of unauthorized use or misappropriation 00007 * of its trade secrets. Use of this information by anyone other than 00008 * authorized employees of Tech Soft 3D, LLC. is granted only under a 00009 * written non-disclosure agreement, expressly prescribing the scope and 00010 * manner of such use. 00011 * 00012 * $Id: phdraw_8h-source.html,v 1.29 2008-03-10 07:09:28 stage Exp $ 00013 */ 00014 00015 #ifndef PHDRAW_DEFINED 00016 00017 #ifndef HI_PROTO_DEFINED 00018 # include "hi_proto.h" 00019 #endif 00020 00021 00022 /* Various good things useful during polyhedron drawing. */ 00023 00024 #define NOMINAL_STRIP_LENGTH 1024 00025 00026 typedef char HT_Face_Orientation; 00027 #define FO_FORWARDS (HT_Face_Orientation)0 00028 #define FO_BACKWARDS (HT_Face_Orientation)1 00029 #define FO_WHOKNOWS (HT_Face_Orientation)2 00030 #define FO_CULLED (HT_Face_Orientation)3 00031 00032 /* the following is used to pass info around during polyhedron drawing */ 00033 struct HT_Polyhedron_Status { 00034 HT_Plane alter *world_vertex_planes; 00035 00036 HT_Plane alter *world_edge_planes; 00037 HT_Plane alter *world_face_planes; 00038 00039 HT_RGB alter *local_vertex_fcolors; 00040 HT_RGB alter *local_vertex_ecolors; 00041 00042 HT_RGB alter *global_face_colors; 00043 HT_RGB alter *global_edge_colors; 00044 HT_RGB alter *global_vertex_fcolors; 00045 HT_RGB alter *global_vertex_ecolors; 00046 HT_RGB alter *global_vertex_mcolors; 00047 00048 HT_DC_Point alter *dc_points; 00049 float alter *ws; 00050 unsigned char alter *clip_case; 00051 int points_within; 00052 00053 /* for silhouettes */ 00054 HT_Face_Orientation alter *face_orientations; 00055 00056 /* for environment params */ 00057 HT_Parameter *env_params; 00058 int env_param_width; 00059 HT_Transform_Rendition const *env_tr; 00060 00061 bool map_complaint_made; 00062 00063 00064 HT_Bounding const *bounding; 00065 int point_count; 00066 int edge_count; 00067 int face_count; 00068 00069 HT_Polyhedron const *polyhedron; 00070 00071 int *screen_plane_facings; 00072 00073 int refcount; 00074 }; 00075 00076 00077 00078 00079 #define NRGBMat(x) ((HT_Named_Material const *)(x)) 00080 #define ClrMap(x) ((HT_Color_Map const *)(x)) 00081 00082 #define FINDEX_TO_RGB(map, att_findex, net, interpolate, grayscale) do {\ 00083 float _frac; \ 00084 int _index; \ 00085 void *_tmp1, *_tmp2; \ 00086 _tmp2 = (void *)(map); \ 00087 if ((att_findex) == (int)(att_findex) || !interpolate) { \ 00088 _tmp1 = (void *)(ClrMap(_tmp2)->materials + \ 00089 (int)((att_findex) + 0.5f) % \ 00090 ClrMap(_tmp2)->length); \ 00091 COPY_RGB (NRGBMat(_tmp1)->diffuse_color.rgb, net); \ 00092 } \ 00093 else { \ 00094 _frac = (float)(att_findex) + \ 00095 (float)ClrMap(_tmp2)->length; /* make positive */ \ 00096 _index = (int)_frac; \ 00097 _frac -= (float)_index; \ 00098 _tmp1 = (void *)(ClrMap(_tmp2)->materials + \ 00099 _index % ClrMap(_tmp2)->length); \ 00100 _tmp2 = (void *)(ClrMap(_tmp2)->materials + (_index + 1) % \ 00101 ClrMap(_tmp2)->length); \ 00102 INTERPOLATE_RGB (NRGBMat(_tmp1)->diffuse_color.rgb, \ 00103 NRGBMat(_tmp2)->diffuse_color.rgb, _frac, net); \ 00104 } \ 00105 if (grayscale) { \ 00106 HT_RGB alter *rgbout = &net; \ 00107 rgbout->red = rgbout->green = rgbout->blue = RGB_TO_GRAY (rgbout->red, rgbout->green, rgbout->blue); \ 00108 } \ 00109 } while (0) 00110 00111 #define INDEX_TO_RGB(map, index, in_rgb) do { \ 00112 void *_tmp1 = (void *)(map); \ 00113 _tmp1 = (void *)(ClrMap(_tmp1)->materials + \ 00114 (index) % ClrMap(_tmp1)->length); \ 00115 COPY_RGB (NRGBMat(_tmp1)->diffuse_color.rgb, in_rgb); \ 00116 } while (0) 00117 00118 00119 #define GAMMA_CORRECT_RGBAS32(dc, inclr) \ 00120 do if ((dc)->options.gamma_correction) { \ 00121 HT_RGBAS32 *clr = &(inclr); \ 00122 clr->rgb.r = (dc)->physical.gamma[UNSIGNED_CHARTOINT(clr->rgb.r)]; \ 00123 clr->rgb.g = (dc)->physical.gamma[UNSIGNED_CHARTOINT(clr->rgb.g)]; \ 00124 clr->rgb.b = (dc)->physical.gamma[UNSIGNED_CHARTOINT(clr->rgb.b)]; \ 00125 } while (0) 00126 00127 00128 00129 #define INTERPOLATE_POINT(a, b, frac, out) do { \ 00130 HT_Point const *tmpa = (HT_Point const *)&(a); \ 00131 HT_Point const *tmpb = (HT_Point const *)&(b); \ 00132 (out).x = tmpa->x + (tmpb->x - tmpa->x) * (frac); \ 00133 (out).y = tmpa->y + (tmpb->y - tmpa->y) * (frac); \ 00134 (out).z = tmpa->z + (tmpb->z - tmpa->z) * (frac); \ 00135 } while (0) 00136 00137 00138 #define VECTORTMP(tmp) ((HT_Vector const *)(tmp)) 00139 #define INTERPOLATE_NORMAL(in0, in1, frac, out) do { \ 00140 HT_Vector result; \ 00141 HT_Vector const *tmpa = (HT_Vector *)&(in0); \ 00142 HT_Vector const *tmpb = (HT_Vector *)&(in1); \ 00143 result.x = tmpa->x + (tmpb->x - tmpa->x) * (frac); \ 00144 result.y = tmpa->y + (tmpb->y - tmpa->y) * (frac); \ 00145 result.z = tmpa->z + (tmpb->z - tmpa->z) * (frac); \ 00146 (void)HI_Normalize (&result); \ 00147 COPY_VECTOR (result, out); \ 00148 } while (0) 00149 00150 00151 #define P_NVC_NFC_VN_NFN 0x10010010 00152 #define P_NVC_NFC_VN_NFN_FIXUP 0x10F10010 00153 #define P_NVC_NFC_VN_NFN_BUMPMAP 0x10B10010 00154 #define P_NVC_NFC_NVN_FN 0x10010001 /*face*/ 00155 #define P_NVC_NFC_NVN_NFN 0x10010000 00156 #define NP_VC_NFC_VN_NFN 0x10001010 00157 #define NP_VC_NFC_NVN_FN 0x10001001 /*face*/ 00158 #define NP_VC_NFC_NVN_NFN 0x10001000 00159 #define NP_NVC_FC_VN_NFN 0x10000110 /*face*/ 00160 #define NP_NVC_FC_NVN_FN 0x10000101 /*face*/ 00161 #define NP_NVC_FC_NVN_NFN 0x10000100 /*face*/ 00162 #define NP_NVC_NFC_VN_NFN 0x10000010 00163 #define NP_NVC_NFC_NVN_FN 0x10000001 /*face*/ 00164 #define NP_NVC_NFC_NVN_NFN 0x10000000 00165 00166 00167 #define PHDRAW_DEFINED TRUE 00168 #endif /* PHDRAW_DEFINED */ 00169