![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 TAPsModelDeformableCPU_Visualization_RTGenMesh.cpp 00003 ******************************************************************************/ 00008 /****************************************************************************** 00009 SUKITTI PUNAK (08/04/2007) 00010 UPDATE (08/05/2007) 00011 ******************************************************************************/ 00012 #include "TAPsModelDeformableCPU_Visualization_RTGenMesh.hpp" 00013 // Using Inclusion Model (i.e. definitions are included in declarations) 00014 // (this name.cpp is included in name.hpp) 00015 // Each friend is defined directly inside its declaration. 00016 00017 BEGIN_NAMESPACE_TAPs__OpenGL 00018 //============================================================================= 00019 // Static Data 00020 //=============================================================== 00021 // Marching Cube Tables (EdgeTable & TriTable) 00022 //--------------------------------------------------------------- 00023 // Adapted from "Polygonising a scalar field" by Paul Bourke (1994) 00024 // http://local.wasp.uwa.edu.au/~pbourke/geometry/polygonise/ 00025 //--------------------------------------------------------------- 00026 //----------------------------------------------------------------------------- 00027 // Vertex & Edge Index 00028 // 3------2------2 00029 // /| /| 00030 // 11 | 10 | 00031 // / 3 / 1 00032 // 7------6------6 | 00033 // | | | | 00034 // | 0------0--|---1 00035 // 7 / 5 / 00036 // | 8 | 9 00037 // |/ |/ 00038 // 4------4------5 00039 //--------------------------------- 00040 // Edge Table [256] & Triangle Table [256][16] 00048 // V = V1 + (isovalue - s1) (V2 - V1) / (s2 - s1) 00049 //----------------------------------------------------------------------------- 00050 template <typename T> unsigned short 00051 ModelDeformableCPU_Visualization_RTGenMesh<T>::EdgeTable[256] = { 00052 // 0-127 00053 0x0 , 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c, 00054 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00, 00055 0x190, 0x99 , 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c, 00056 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90, 00057 0x230, 0x339, 0x33 , 0x13a, 0x636, 0x73f, 0x435, 0x53c, 00058 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30, 00059 0x3a0, 0x2a9, 0x1a3, 0xaa , 0x7a6, 0x6af, 0x5a5, 0x4ac, 00060 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0, 00061 0x460, 0x569, 0x663, 0x76a, 0x66 , 0x16f, 0x265, 0x36c, 00062 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60, 00063 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff , 0x3f5, 0x2fc, 00064 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0, 00065 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55 , 0x15c, 00066 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950, 00067 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc , 00068 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0, 00069 00070 // 128-255 00071 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc, 00072 0xcc , 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0, 00073 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c, 00074 0x15c, 0x55 , 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650, 00075 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc, 00076 0x2fc, 0x3f5, 0xff , 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0, 00077 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c, 00078 0x36c, 0x265, 0x16f, 0x66 , 0x76a, 0x663, 0x569, 0x460, 00079 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac, 00080 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa , 0x1a3, 0x2a9, 0x3a0, 00081 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c, 00082 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33 , 0x339, 0x230, 00083 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c, 00084 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99 , 0x190, 00085 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c, 00086 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0 00087 }; 00088 //------------------------------------------------------------------- 00089 template <typename T> char 00090 ModelDeformableCPU_Visualization_RTGenMesh<T>::TriTable[256][16] = { 00091 // 0-9 00092 {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00093 {0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00094 {0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00095 {1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00096 {1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00097 {0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00098 {9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00099 {2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1}, 00100 {3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00101 {0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00102 // 10-19 00103 {1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00104 {1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1}, 00105 {3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00106 {0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1}, 00107 {3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1}, 00108 {9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00109 {4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00110 {4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00111 {0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00112 {4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1}, 00113 // 20-29 00114 {1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00115 {3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1}, 00116 {9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1}, 00117 {2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1}, 00118 {8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00119 {11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1}, 00120 {9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1}, 00121 {4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1}, 00122 {3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1}, 00123 {1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1}, 00124 // 30-39 00125 {4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1}, 00126 {4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1}, 00127 {9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00128 {9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00129 {0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00130 {8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1}, 00131 {1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00132 {3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1}, 00133 {5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1}, 00134 {2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1}, 00135 // 40-49 00136 {9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00137 {0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1}, 00138 {0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1}, 00139 {2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1}, 00140 {10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1}, 00141 {4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1}, 00142 {5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1}, 00143 {5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1}, 00144 {9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00145 {9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1}, 00146 // 50-59 00147 {0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1}, 00148 {1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00149 {9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1}, 00150 {10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1}, 00151 {8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1}, 00152 {2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1}, 00153 {7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1}, 00154 {9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1}, 00155 {2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1}, 00156 {11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1}, 00157 // 60-69 00158 {9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1}, 00159 {5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1}, 00160 {11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1}, 00161 {11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00162 {10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00163 {0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00164 {9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00165 {1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1}, 00166 {1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00167 {1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1}, 00168 // 70-79 00169 {9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1}, 00170 {5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1}, 00171 {2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00172 {11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1}, 00173 {0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1}, 00174 {5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1}, 00175 {6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1}, 00176 {0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1}, 00177 {3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1}, 00178 {6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1}, 00179 // 80-89 00180 {5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00181 {4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1}, 00182 {1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1}, 00183 {10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1}, 00184 {6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1}, 00185 {1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1}, 00186 {8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1}, 00187 {7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1}, 00188 {3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1}, 00189 {5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1}, 00190 // 90-99 00191 {0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1}, 00192 {9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1}, 00193 {8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1}, 00194 {5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1}, 00195 {0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1}, 00196 {6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1}, 00197 {10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00198 {4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1}, 00199 {10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1}, 00200 {8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1}, 00201 // 100-109 00202 {1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1}, 00203 {3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1}, 00204 {0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00205 {8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1}, 00206 {10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1}, 00207 {0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1}, 00208 {3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1}, 00209 {6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1}, 00210 {9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1}, 00211 {8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1}, 00212 // 110-119 00213 {3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1}, 00214 {6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00215 {7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1}, 00216 {0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1}, 00217 {10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1}, 00218 {10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1}, 00219 {1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1}, 00220 {2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1}, 00221 {7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1}, 00222 {7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00223 // 120-129 00224 {2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1}, 00225 {2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1}, 00226 {1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1}, 00227 {11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1}, 00228 {8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1}, 00229 {0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00230 {7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1}, 00231 {7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00232 {7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00233 {3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00234 // 130-139 00235 {0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00236 {8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1}, 00237 {10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00238 {1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1}, 00239 {2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1}, 00240 {6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1}, 00241 {7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00242 {7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1}, 00243 {2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1}, 00244 {1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1}, 00245 // 140-149 00246 {10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1}, 00247 {10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1}, 00248 {0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1}, 00249 {7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1}, 00250 {6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00251 {3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1}, 00252 {8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1}, 00253 {9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1}, 00254 {6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1}, 00255 {1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1}, 00256 // 150-159 00257 {4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1}, 00258 {10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1}, 00259 {8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1}, 00260 {0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00261 {1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1}, 00262 {1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1}, 00263 {8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1}, 00264 {10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1}, 00265 {4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1}, 00266 {10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00267 // 160-169 00268 {4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00269 {0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1}, 00270 {5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1}, 00271 {11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1}, 00272 {9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1}, 00273 {6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1}, 00274 {7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1}, 00275 {3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1}, 00276 {7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1}, 00277 {9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1}, 00278 // 170-179 00279 {3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1}, 00280 {6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1}, 00281 {9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1}, 00282 {1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1}, 00283 {4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1}, 00284 {7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1}, 00285 {6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1}, 00286 {3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1}, 00287 {0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1}, 00288 {6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1}, 00289 // 180-189 00290 {1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1}, 00291 {0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1}, 00292 {11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1}, 00293 {6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1}, 00294 {5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1}, 00295 {9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1}, 00296 {1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1}, 00297 {1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00298 {1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1}, 00299 {10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1}, 00300 // 190-199 00301 {0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00302 {10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00303 {11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00304 {11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1}, 00305 {5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1}, 00306 {10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1}, 00307 {11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1}, 00308 {0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1}, 00309 {9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1}, 00310 {7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1}, 00311 // 200-209 00312 {2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1}, 00313 {8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1}, 00314 {9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1}, 00315 {9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1}, 00316 {1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00317 {0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1}, 00318 {9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1}, 00319 {9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00320 {5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1}, 00321 {5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1}, 00322 // 210-219 00323 {0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1}, 00324 {10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1}, 00325 {2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1}, 00326 {0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1}, 00327 {0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1}, 00328 {9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00329 {2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1}, 00330 {5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1}, 00331 {3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1}, 00332 {5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1}, 00333 // 220-229 00334 {8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1}, 00335 {0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00336 {8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1}, 00337 {9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00338 {4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1}, 00339 {0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1}, 00340 {1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1}, 00341 {3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1}, 00342 {4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1}, 00343 {9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1}, 00344 // 230-239 00345 {11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1}, 00346 {11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1}, 00347 {2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1}, 00348 {9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1}, 00349 {3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1}, 00350 {1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00351 {4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1}, 00352 {4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1}, 00353 {4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00354 {4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00355 // 240-249 00356 {9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00357 {3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1}, 00358 {0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1}, 00359 {3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00360 {1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1}, 00361 {3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1}, 00362 {0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00363 {3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00364 {2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1}, 00365 {9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00366 // 250-255 00367 {2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1}, 00368 {1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00369 {1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00370 {0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00371 {0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 00372 {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1} 00373 }; 00374 //----------------------------------------------------------------------------- 00375 //============================================================================= 00376 //============================================================================= 00377 //----------------------------------------------------------------------------- 00378 // default constructor 00379 /* 00380 template <typename T> 00381 ModelDeformableGLSL_Visualization_RTGenMesh<T>:: 00382 ModelDeformableGLSL_Visualization_RTGenMesh () 00383 : m_SimDomain( NULL ) 00384 { 00385 //--------------------------------------------------------------- 00386 // Since Microsoft gl.h is version 1.1, 00387 // So this fn calls glewInit() for latest OpenGL version 00388 // and initialize GLSL. 00389 GFnInitGLSL(); 00390 Default(); 00391 //--------------------------------------------------------------- 00392 #ifdef TAPs_DEBUG_MODE 00393 std::cout << "ModelDeformableGLSL_Visualization_RTGenMesh<" 00394 << typeid(T).name() << "> Constructor\n"; 00395 #endif 00396 } 00397 //*/ 00398 //----------------------------------------------------------------------------- 00399 // constructor 00400 template <typename T> 00401 ModelDeformableCPU_Visualization_RTGenMesh<T>:: 00402 ModelDeformableCPU_Visualization_RTGenMesh ( 00403 ModelDeformableCPU<T> * simDomain 00404 ) 00405 { 00406 m_SimDomain = simDomain; 00407 //--------------------------------------------------------------- 00408 // Since Microsoft gl.h is version 1.1, 00409 // So this fn calls glewInit() for latest OpenGL version 00410 // and initialize GLSL. 00411 // GFnInitGLSL(); 00412 Default(); 00413 //--------------------------------------------------------------- 00414 #ifdef TAPs_DEBUG_MODE 00415 std::cout << "ModelDeformableCPU_Visualization_RTGenMesh<" 00416 << typeid(T).name() << "> Constructor\n"; 00417 #endif 00418 } 00419 //----------------------------------------------------------------------------- 00420 // Destructor 00421 template <typename T> 00422 ModelDeformableCPU_Visualization_RTGenMesh<T>:: 00423 ~ModelDeformableCPU_Visualization_RTGenMesh () 00424 { 00425 Clear(); 00426 //--------------------------------------------------------------- 00427 #ifdef TAPs_DEBUG_MODE 00428 std::cout << "ModelDeformableCPU_Visualization_RTGenMesh<" 00429 << typeid(T).name() << "> Destructor\n"; 00430 #endif 00431 } 00432 //----------------------------------------------------------------------------- 00433 // Default 00434 template <typename T> 00435 void ModelDeformableCPU_Visualization_RTGenMesh<T>::Default () 00436 { 00437 #ifdef TAPs_MODEL_DEFORMABLE_VISUALIZATION_RT_GEN_MESH_USE_BUFFERS 00438 //------------------------------------------- 00439 // For Rendering 00440 //m_vboVerticesAsTexCoords = 0; 00441 #endif // TAPs_MODEL_DEFORMABLE_VISUALIZATION_RT_GEN_MESH_USE_BUFFERS 00442 //------------------------------------------- 00443 // For GLSL 00444 //m_glslProgramObject = NULL; 00445 //------------------------------------------- 00446 // For Textures 00447 m_3DTexture = 0; 00448 //------------------------------------------- 00449 // Adjustable Parameters 00450 m_bUseGlobalInterpolationVal = false; 00451 m_tGlobalInterpolationVal = 0.1; 00452 m_bDrawPNTriangle = false; 00453 m_PNTriangleSmoothness = 4; 00454 //------------------------------------------- 00455 } 00456 //----------------------------------------------------------------------------- 00457 // Clear 00458 template <typename T> 00459 void ModelDeformableCPU_Visualization_RTGenMesh<T>::Clear () 00460 { 00461 #ifdef TAPs_MODEL_DEFORMABLE_VISUALIZATION_RT_GEN_MESH_USE_BUFFERS 00462 //--------------------------------------------------------------- 00463 // Clear Vertex Buffer for Rendering 00464 //if ( m_vboVerticesAsTexCoords > 0 ) { 00465 // glDeleteBuffers( 1, &m_vboVerticesAsTexCoords ); 00466 //} 00467 #endif // TAPs_MODEL_DEFORMABLE_VISUALIZATION_RT_GEN_MESH_USE_BUFFERS 00468 //--------------------------------------------------------------- 00469 // Clear GLSL 00470 // if ( m_glslProgramObject ) { 00471 // m_glslShaderManager.Delete( m_glslProgramObject ); 00472 // } 00473 //--------------------------------------------------------------- 00474 // Clear Textures 00475 //if ( m_3DTextureVisualization ) delete m_3DTextureVisualization; 00476 //m_3DTexture = 0; 00477 //--------------------------------------------------------------- 00478 Default(); 00479 } 00480 //----------------------------------------------------------------------------- 00481 //============================================================================= 00482 00483 00484 //============================================================================= 00485 // SetupVisualization 00486 //----------------------------------------------------------------------------- 00487 template <typename T> 00488 bool ModelDeformableCPU_Visualization_RTGenMesh<T>:: 00489 SetupVisualization ( 00490 int resolutionX, int resolutionY, int resolutionZ, 00491 enum GridGenerator<T>::VertexFlag *** pFlagDataForXYZVoxels 00492 ) 00493 { 00494 //--------------------------------------- 00495 // DEBUG for 3D Texture Setup 00496 // if ( !Setup3DTexture( 00497 // resolutionX, resolutionY, resolutionZ, 00498 // pFlagDataForXYZVoxels 00499 // ) ) { 00500 // return false; 00501 // } 00502 //--------------------------------------- 00503 #ifdef TAPs_MODEL_DEFORMABLE_VISUALIZATION_RT_GEN_MESH_USE_BUFFERS 00504 //if ( !GenerateTheVBOForTextureCoordinates( 00505 // Vector3<int>( resolutionX, resolutionY, resolutionZ ) ) 00506 //) { 00507 // std::cout << "GenerateTheVBOForTextureCoordinates returns false!\n"; 00508 // return false; 00509 //} 00510 #endif // TAPs_MODEL_DEFORMABLE_VISUALIZATION_RT_GEN_MESH_USE_BUFFERS 00511 //--------------------------------------- 00512 //if ( !SetupShadersForDrawing() ) { 00513 // std::cout << "SetupShadersForDrawing returns false!\n"; 00514 // return false; 00515 //} 00516 //--------------------------------------- 00517 return true; 00518 } 00519 //----------------------------------------------------------------------------- 00520 // END: SetupVisualization 00521 //============================================================================= 00522 00523 00524 //============================================================================= 00525 // Setup a 3D Texture for Visualization 00526 //----------------------------------------------------------------------------- 00527 /* 00528 template <typename T> 00529 bool ModelDeformableCPU_Visualization_RTGenMesh<T>:: 00530 Setup3DTexture ( 00531 // int resolutionX, int resolutionY, int resolutionZ, 00532 // enum GridGenerator<T>::VertexFlag *** pFlagDataForXYZVoxels 00533 ) 00534 { 00535 //--------------------------------------------------------------- 00536 return true; 00537 } 00538 //*/ 00539 //----------------------------------------------------------------------------- 00540 // END: Setup3DTexture 00541 //============================================================================= 00542 00543 00544 //============================================================================= 00545 // Setup Shaders for Drawing (3D) Object-Aligned Slices 00546 //----------------------------------------------------------------------------- 00547 //template <typename T> 00548 //bool ModelDeformableCPU_Visualization_RTGenMesh<T>:: 00549 //SetupShadersForDrawing () 00550 //{ 00551 // //--------------------------------------------------------------- 00552 // m_glslProgramObject = 00553 // m_glslShaderManager.LoadFromFile( 00554 // "Resource/Shader/DefModelDrawByGenMesh.vert", 00555 // "Resource/Shader/DefModelDrawByGenMesh.frag" 00556 // ); 00557 // if ( !m_glslProgramObject ) { 00558 // Clear(); 00559 // return false; 00560 // } 00561 // //--------------------------------------------------------------- 00562 // return true; 00563 //} 00564 //----------------------------------------------------------------------------- 00565 // END: SetupShadersForDrawing 00566 //============================================================================= 00567 00568 //============================================================================= 00569 //----------------------------------------------------------------------------- 00570 //----------------------------------------------------------------------------- 00571 //============================================================================= 00572 00573 //============================================================================= 00574 //----------------------------------------------------------------------------- 00575 //----------------------------------------------------------------------------- 00576 //============================================================================= 00577 00578 //***************************************************************************** 00579 // BEGIN: DrawByGL 00580 //----------------------------------------------------------------------------- 00581 template <typename T> 00582 void ModelDeformableCPU_Visualization_RTGenMesh<T>:: 00583 DrawByGL ( int iSubdivision ) 00584 { 00585 //* 00586 //--------------------------------------------------------------- 00587 #ifdef TAPs_DEBUG_MODE 00588 if ( !m_SimDomain ) return; 00589 //--------------------------------------------------------------- 00590 //if ( !m_SimDomain->RetObject3DTexturePosition() ) return; 00591 //--------------------------------------------------------------- 00592 #endif 00593 //=============================================================== 00594 // Use data from CPU -- Positions 00595 //--------------------------------------------------------------- 00596 T * const dataForPosition = m_SimDomain->ReturnPositionPointer(); // size is w*h*d*4 for (x,y,z,w) 00597 //--------------------------------------------------------------- 00598 //=============================================================== 00599 00600 /* 00601 //=============================================================== 00602 // Read data from GPU -- Positions 00603 //--------------------------------------------------------------- 00604 //Texture * texture3DPosition = m_SimDomain->RetObject3DTexturePosition(); 00605 //--------------------------------------------------------------- 00606 glPushAttrib( GL_ALL_ATTRIB_BITS ); 00607 //----------------------------------------------------- 00608 GLsizei sizeForPosition = 00609 texture3DPosition->GetWidth() * 00610 texture3DPosition->GetHeight() * 00611 texture3DPosition->GetDepth() * 00612 texture3DPosition->GetInternalFormatNumberOfComponents(); 00613 GLfloat * dataForPosition = new GLfloat[ sizeForPosition ]; 00614 { 00615 int i = 0; 00616 //================================================= 00617 // Read data for positions from a texture to memory 00618 glBindBuffer( GL_PIXEL_PACK_BUFFER, 0 ); 00619 texture3DPosition->BindTexture(0); 00620 glGetTexImage( 00621 texture3DPosition->GetTarget(), 00622 texture3DPosition->GetLevel(), 00623 texture3DPosition->GetPixelFormat(), 00624 texture3DPosition->GetDataType(), 00625 dataForPosition 00626 ); 00627 TAPs::OpenGL::Fn::CHECK_GL_ERROR(); 00628 //================================================= 00629 } 00630 //--------------------------------------------------------------- 00631 TAPs::OpenGL::Fn::CHECK_GL_ERROR(); 00632 //----------------------------------------------------- 00633 glPopAttrib(); 00634 //--------------------------------------------------------------- 00635 //=============================================================== 00636 //*/ 00637 00638 /* 00639 //=============================================================== 00640 // Read data from GPU -- Ellipsoid Influence 00641 //--------------------------------------------------------------- 00642 Texture * texture3DEllipsoidInfluence = m_SimDomain->RetObject3DTextureEllipsoidInfluence(); 00643 //--------------------------------------------------------------- 00644 glPushAttrib( GL_ALL_ATTRIB_BITS ); 00645 //----------------------------------------------------- 00646 GLsizei sizeForEllipsoidInfluence = 00647 texture3DEllipsoidInfluence->GetWidth() * 00648 texture3DEllipsoidInfluence->GetHeight() * 00649 texture3DEllipsoidInfluence->GetDepth() * 00650 texture3DEllipsoidInfluence->GetInternalFormatNumberOfComponents(); 00651 //std::cout << "sizeForEllipsoidInfluence: " << sizeForEllipsoidInfluence << "\n"; 00652 GLfloat * dataForEllipsoidInfluence = new GLfloat[ sizeForEllipsoidInfluence ]; 00653 { 00654 int i = 0; 00655 //================================================= 00656 // Read data for ellipsoid influences from a texture to memory 00657 glBindBuffer( GL_PIXEL_PACK_BUFFER, 0 ); 00658 texture3DEllipsoidInfluence->BindTexture(0); 00659 glGetTexImage( 00660 texture3DEllipsoidInfluence->GetTarget(), 00661 texture3DEllipsoidInfluence->GetLevel(), 00662 texture3DEllipsoidInfluence->GetPixelFormat(), 00663 texture3DEllipsoidInfluence->GetDataType(), 00664 dataForEllipsoidInfluence 00665 ); 00666 TAPs::OpenGL::Fn::CHECK_GL_ERROR(); 00667 //================================================= 00668 } 00669 //--------------------------------------------------------------- 00670 TAPs::OpenGL::Fn::CHECK_GL_ERROR(); 00671 //----------------------------------------------------- 00672 glPopAttrib(); 00673 //--------------------------------------------------------------- 00674 //=============================================================== 00675 //*/ 00676 00677 //--------------------------------- 00678 Vector3<int> gridResolution = m_SimDomain->GetGridResolution(); 00679 Vector3<T> gridDimension = m_SimDomain->GetGridDimension(); 00680 //--------------------------------- 00681 00682 //* 00683 //=============================================================== 00684 // Draw by Marching Cube 00685 //--------------------------------------------------------------- 00686 // Adapted from "Polygonising a scalar field" by Paul Bourke (1994) 00687 // http://local.wasp.uwa.edu.au/~pbourke/geometry/polygonise/ 00688 //--------------------------------------------------------------- 00689 glPushAttrib( GL_ALL_ATTRIB_BITS ); 00690 //glLineWidth( 3 ); 00691 //glLineWidth( 3 ); 00692 00693 glColor3ub( 240, 220, 130 ); 00694 //glColor3ub( 240/8, 220/8, 130/8 ); 00695 //glColor3ub( 65, 65, 65 ); 00696 //glColor3ub( 80, 80, 80 ); 00697 //glColor3ub( 150, 150, 150 ); 00698 //glColor3ub( 255, 255, 255 ); 00699 glEnable( GL_COLOR_MATERIAL ); 00700 00701 glEnable( GL_LIGHTING ); 00702 //--------------------------------------------------------------- 00703 // Texture Parameter Setup 00704 //glEnable( GL_BLEND ); 00705 glBindTexture( GL_TEXTURE_3D, m_3DTexture ); 00706 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); 00707 glEnable( GL_TEXTURE_3D ); 00708 glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND ); 00709 00710 //static GLfloat constColor[4] = { 0.0, 0.0, 0.0, 0.0 }; 00711 //constColor[3] = 0.2; 00712 //glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constColor ); 00713 //glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE ); 00714 //glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE ); 00715 //glTexEnvf( GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE ); 00716 //glTexEnvf( GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR ); 00717 //glTexEnvf( GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS ); 00718 //glTexEnvf( GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR ); 00719 //glTexEnvf( GL_TEXTURE_ENV, GL_SRC2_RGB, GL_PREVIOUS ); 00720 //glTexEnvf( GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA ); 00721 00722 //--------------------------------------------------------------- 00723 int iOffsetSlice = gridResolution[1] * gridResolution[0] * 4; 00724 int iOffsetRow = gridResolution[0] * 4; 00725 int iOffsetCol = 4; 00726 //--------------------------------- 00727 // Vertex & Edge Index 00728 // 3------2------2 00729 // /| /| 00730 // 11 | 10 | 00731 // / 3 / 1 00732 // 7------6------6 | 00733 // | | | | 00734 // | 0------0--|---1 00735 // 7 / 5 / 00736 // | 8 | 9 00737 // |/ |/ 00738 // 4------4------5 00739 //--------------------------------- 00740 // Edge Table [256] & Triangle Table [256][16] 00748 // V = V1 + (isovalue - s1) (V2 - V1) / (s2 - s1) 00749 //--------------------------------- 00750 //unsigned char cubeClass = 0; 00751 //if ( grid.val[0] < isolevel ) cubeClass |= 1; 00752 //if ( grid.val[1] < isolevel ) cubeClass |= 2; 00753 //if ( grid.val[2] < isolevel ) cubeClass |= 4; 00754 //if ( grid.val[3] < isolevel ) cubeClass |= 8; 00755 //if ( grid.val[4] < isolevel ) cubeClass |= 16; 00756 //if ( grid.val[5] < isolevel ) cubeClass |= 32; 00757 //if ( grid.val[6] < isolevel ) cubeClass |= 64; 00758 //if ( grid.val[7] < isolevel ) cubeClass |= 128; 00759 //--------------------------------- 00760 int numOfTrisPerCell = 0; // number of triangles in the cell 00761 int triIndices[15]; // at most 5 triangles 00762 Vector3<T> V[8]; // vertices of the cell 00763 Vector3<T> VTC[8]; // texture coordinates of the vertices 00764 Vector3<T> texCoordList[12]; // since 12 edges 00765 Vector3<T> vertexList[12]; // since 12 edges 00766 int bV[12]; // >=0 if the vertex is counted (e.g. on boundary, existing, etc.) 00767 Vector3<T> grad[12]; // gradients of vertices 00768 //Vector3<T> texCoords[12]; // 00769 Vector3<T> Center, nE, nW, nN, nS, nF, nB; // center and its neighbors for gradient computation 00770 //--------------------------------- 00771 int idx[8], d, i; 00772 unsigned char cubeClass = 0; 00773 T threshold = 250; 00774 // 00775 T tc[3]; 00776 T tcStep[3] = { 00777 1.0 / static_cast<T>( gridResolution[0]-1 ), 00778 1.0 / static_cast<T>( gridResolution[1]-1 ), 00779 1.0 / static_cast<T>( gridResolution[2]-1 ) 00780 }; 00781 // 00782 00783 //----------------------------------------------------- 00784 // For Interpolation Data used by Marching Cube 00785 int iOffsetSliceIntp = gridResolution[1] * gridResolution[0] * 3; 00786 int iOffsetRowIntp = gridResolution[0] * 3; 00787 int iOffsetColIntp = 3; 00788 int intpIdx[8]; 00789 Vector3<T> VIntp[8]; // Interpolation Data (XYZ) 00790 //----------------------------------------------------- 00791 00792 // DEBUG 00793 //m_tGlobalInterpolationVal = static_cast<T>( rand() / static_cast<T>( RAND_MAX ) ); 00794 00795 //--------------------------------- 00796 for ( int Z = 0; Z < gridResolution[2]-1; ++Z ) { 00797 // 00798 // For Interpolation Data 00799 int offsetZIntp = Z * iOffsetSliceIntp; 00800 // 00801 int offsetZ = Z * iOffsetSlice; 00802 // 00803 // Texture Coordinates -- Z 00804 tc[2] = static_cast<T>( Z ) / static_cast<T>( gridResolution[2]-1 ); 00805 VTC[0].SetZ( tc[2] ); 00806 VTC[1].SetZ( tc[2] ); 00807 VTC[2].SetZ( tc[2] ); 00808 VTC[3].SetZ( tc[2] ); 00809 tc[2] += tcStep[2]; 00810 VTC[4].SetZ( tc[2] ); 00811 VTC[5].SetZ( tc[2] ); 00812 VTC[6].SetZ( tc[2] ); 00813 VTC[7].SetZ( tc[2] ); 00814 // 00815 for ( int Y = 0; Y < gridResolution[1]-1; ++Y ) { 00816 // 00817 // Set Indices for Interpolation Data 00818 int offsetYZIntp = Y * iOffsetRowIntp + offsetZIntp; 00819 intpIdx[0] = offsetYZIntp;; 00820 intpIdx[1] = intpIdx[0] + iOffsetColIntp; 00821 intpIdx[2] = intpIdx[1] + iOffsetRowIntp; 00822 intpIdx[3] = intpIdx[0] + iOffsetRowIntp; 00823 intpIdx[4] = intpIdx[0] + iOffsetSliceIntp; 00824 intpIdx[5] = intpIdx[4] + iOffsetColIntp; 00825 intpIdx[6] = intpIdx[5] + iOffsetRowIntp; 00826 intpIdx[7] = intpIdx[4] + iOffsetRowIntp; 00827 // 00828 // Set Indices for Cube Vertices 00829 int offsetYZ = Y * iOffsetRow + offsetZ; 00830 idx[0] = offsetYZ; 00831 idx[1] = idx[0] + iOffsetCol; 00832 idx[2] = idx[1] + iOffsetRow; 00833 idx[3] = idx[0] + iOffsetRow; 00834 idx[4] = idx[0] + iOffsetSlice; 00835 idx[5] = idx[4] + iOffsetCol; 00836 idx[6] = idx[5] + iOffsetRow; 00837 idx[7] = idx[4] + iOffsetRow; 00838 // 00839 // Texture Coordinates -- Y 00840 tc[1] = static_cast<T>( Y ) / static_cast<T>( gridResolution[1]-1 ); 00841 VTC[0].SetY( tc[1] ); 00842 VTC[1].SetY( tc[1] ); 00843 VTC[4].SetY( tc[1] ); 00844 VTC[5].SetY( tc[1] ); 00845 tc[1] += tcStep[1]; 00846 VTC[2].SetY( tc[1] ); 00847 VTC[3].SetY( tc[1] ); 00848 VTC[6].SetY( tc[1] ); 00849 VTC[7].SetY( tc[1] ); 00850 // 00851 for ( int X = 0; X < gridResolution[0]-1; ++X ) { 00852 // 00853 // Texture Coordinates -- X 00854 tc[0] = static_cast<T>( X ) / static_cast<T>( gridResolution[0]-1 ); 00855 VTC[0].SetX( tc[0] ); 00856 VTC[3].SetX( tc[0] ); 00857 VTC[4].SetX( tc[0] ); 00858 VTC[7].SetX( tc[0] ); 00859 tc[0] += tcStep[0]; 00860 VTC[1].SetX( tc[0] ); 00861 VTC[2].SetX( tc[0] ); 00862 VTC[5].SetX( tc[0] ); 00863 VTC[6].SetX( tc[0] ); 00864 // 00865 //------------------------------- 00866 // Determine the threshold of each vertex of the cube 00867 cubeClass = 0; 00868 if ( dataForPosition[idx[0] + 3] > threshold ) cubeClass |= 1; 00869 if ( dataForPosition[idx[1] + 3] > threshold ) cubeClass |= 2; 00870 if ( dataForPosition[idx[2] + 3] > threshold ) cubeClass |= 4; 00871 if ( dataForPosition[idx[3] + 3] > threshold ) cubeClass |= 8; 00872 if ( dataForPosition[idx[4] + 3] > threshold ) cubeClass |= 16; 00873 if ( dataForPosition[idx[5] + 3] > threshold ) cubeClass |= 32; 00874 if ( dataForPosition[idx[6] + 3] > threshold ) cubeClass |= 64; 00875 if ( dataForPosition[idx[7] + 3] > threshold ) cubeClass |= 128; 00876 //------------------------------- 00877 00878 //------------------------------- 00879 // Cell is entirely in/out of the surface 00880 if ( EdgeTable[cubeClass] == 0 ) { 00881 numOfTrisPerCell = 0; 00882 } 00883 else { 00884 //------------------------------- 00885 // Cell contains part of the surface 00886 //----------------- 00887 for ( i = 0; i < 8; ++i ) { 00888 V[i].SetXYZ( 00889 dataForPosition[idx[i] ], 00890 dataForPosition[idx[i] + 1], 00891 dataForPosition[idx[i] + 2] 00892 ); 00893 } 00894 //----------------- 00895 // Reset list of existing vertices 00896 for ( i = 0; i < 12; ++i ) { 00897 bV[i] = -1; 00898 } 00899 00900 //----------------- 00901 // Interpolation Data 00902 for ( i = 0; i < 8; ++i ) { 00903 VIntp[i].SetXYZ( 00904 //dataForEllipsoidInfluence[intpIdx[i] ], 00905 //dataForEllipsoidInfluence[intpIdx[i] + 1], 00906 //dataForEllipsoidInfluence[intpIdx[i] + 2] 00907 0.5, 0.5, 0.5 00908 ); 00909 } 00910 00911 //=============================================== 00912 // Calculate Gradients 00913 //----------------------------------------------- 00914 Vector3<T> G[8]; 00915 int index; 00916 for ( int vID = 0; vID < 8; ++vID ) { 00917 Center.SetXYZ( dataForPosition[idx[vID] ], 00918 dataForPosition[idx[vID]+1], 00919 dataForPosition[idx[vID]+2] ); 00920 G[vID].SetXYZ( 0, 0, 0 ); 00921 //--- East -------------- 00922 if ( X < gridResolution[0]-2 ) { 00923 index = idx[vID] + iOffsetCol; 00924 if ( dataForPosition[index+3] > threshold ) { 00925 nE.SetXYZ( dataForPosition[index], dataForPosition[index+1], dataForPosition[index+2] ); 00926 G[vID] += Center - nE; 00927 } 00928 //else { 00929 // nE.SetXYZ( 0, 0, 0 ); 00930 //} 00931 } 00932 //else { 00933 // nE.SetXYZ( 0, 0, 0 ); 00934 //} 00935 //--- West -------------- 00936 if ( X > 0 ) { 00937 index = idx[vID] - iOffsetCol; 00938 if ( dataForPosition[index+3] > threshold ) { 00939 nW.SetXYZ( dataForPosition[index], dataForPosition[index+1], dataForPosition[index+2] ); 00940 G[vID] += Center - nW; 00941 } 00942 //else { 00943 // nW.SetXYZ( 0, 0, 0 ); 00944 //} 00945 } 00946 //else { 00947 // nW.SetXYZ( 0, 0, 0 ); 00948 //} 00949 //--- North ------------- 00950 if ( Y < gridResolution[1]-2 ) { 00951 index = idx[vID] + iOffsetRow; 00952 if ( dataForPosition[index+3] > threshold ) { 00953 nN.SetXYZ( dataForPosition[index], dataForPosition[index+1], dataForPosition[index+2] ); 00954 G[vID] += Center - nN; 00955 } 00956 //else { 00957 // nN.SetXYZ( 0, 0, 0 ); 00958 //} 00959 } 00960 //else { 00961 // nN.SetXYZ( 0, 0, 0 ); 00962 //} 00963 //--- South ------------- 00964 if ( Y > 0 ) { 00965 index = idx[vID] - iOffsetRow; 00966 if ( dataForPosition[index+3] > threshold ) { 00967 nS.SetXYZ( dataForPosition[index], dataForPosition[index+1], dataForPosition[index+2] ); 00968 G[vID] += Center - nS; 00969 } 00970 //else { 00971 // nS.SetXYZ( 0, 0, 0 ); 00972 //} 00973 } 00974 //else { 00975 // nS.SetXYZ( 0, 0, 0 ); 00976 //} 00977 //--- Front ------------- 00978 if ( Z < gridResolution[2]-2 ) { 00979 index = idx[vID] + iOffsetSlice; 00980 if ( dataForPosition[index+3] > threshold ) { 00981 nF.SetXYZ( dataForPosition[index], dataForPosition[index+1], dataForPosition[index+2] ); 00982 G[vID] += Center - nF; 00983 } 00984 //else { 00985 // nF.SetXYZ( 0, 0, 0 ); 00986 //} 00987 } 00988 //else { 00989 // nF.SetXYZ( 0, 0, 0 ); 00990 //} 00991 //--- Back -------------- 00992 if ( Z > 0 ) { 00993 index = idx[vID] - iOffsetSlice; 00994 if ( dataForPosition[index+3] > threshold ) { 00995 nB.SetXYZ( dataForPosition[index], dataForPosition[index+1], dataForPosition[index+2] ); 00996 G[vID] += Center - nB; 00997 } 00998 //else { 00999 // nB.SetXYZ( 0, 0, 0 ); 01000 //} 01001 } 01002 //else { 01003 // nB.SetXYZ( 0, 0, 0 ); 01004 //} 01005 //----------------------- 01006 //G[vID] = (nW - nE) + (nS - nN) + (nB - nF); 01007 01008 //G[vID] = (nW - nE); 01009 //G[vID] = (nS - nN); 01010 //G[vID] = (nB - nF); 01011 } 01012 //----------------------------------------------- 01013 // END: Calculate Gradients 01014 //=============================================== 01015 01016 //=============================================== 01017 // Marching Cube Interpolation 01018 // V = V1 + (isovalue - s1) (V2 - V1) / (s2 - s1) 01019 //----------------------------------------------- 01020 // RUNTIME ERROR CAN OCCURS -- DEPENDING ON THE DATA 01021 // SINCE IT DOES NOT HAVE BOUNDARY PROTECTION -- ARRAY INDEX OUT OF BOUND ERROR 01022 //----------------------------------------------- 01023 // Use Global Interpolation Value -- all elements have the same interpolation value 01024 if ( !m_bUseGlobalInterpolationVal ) { 01025 //------------------------------------- 01026 // Marching Cube Interpolation 01027 T interpolationValPlus;// = m_tGlobalInterpolationVal; 01028 T interpolationValNeg;// = 1.0 - m_tGlobalInterpolationVal; 01029 //------------------------------------- 01030 // Edge# 0 to 11 <==> [ 1, 2, 4, ... , 2048 ] 01031 if ( EdgeTable[cubeClass] & 1 ) { 01032 if ( dataForPosition[idx[0] + 3] > threshold ) { 01033 // 01034 // Interpotation Data 01035 interpolationValPlus = VIntp[0].GetX(); 01036 // 01037 vertexList[ 0] = V[0] + interpolationValPlus*(V[1] - V[0]); 01038 grad[0] = G[0] + interpolationValPlus*(G[1] - G[0]); 01039 texCoordList[0] = VTC[0] + interpolationValPlus*(VTC[1] - VTC[0]); 01040 } 01041 else { 01042 // 01043 // Interpotation Data 01044 interpolationValNeg = 1.0 - VIntp[1].GetX(); 01045 // 01046 vertexList[ 0] = V[0] + interpolationValNeg*(V[1] - V[0]); 01047 grad[0] = G[0] + interpolationValNeg*(G[1] - G[0]); 01048 texCoordList[0] = VTC[0] + interpolationValNeg*(VTC[1] - VTC[0]); 01049 //grad[0] *= -1.0; 01050 } 01051 grad[0].Normalized(); 01052 } 01053 if ( EdgeTable[cubeClass] & 2 ) { 01054 if ( dataForPosition[idx[1] + 3] > threshold ) { 01055 // 01056 // Interpotation Data 01057 interpolationValPlus = VIntp[1].GetY(); 01058 // 01059 vertexList[ 1] = V[1] + interpolationValPlus*(V[2] - V[1]); 01060 grad[1] = G[1] + interpolationValPlus*(G[2] - G[1]); 01061 texCoordList[1] = VTC[1] + interpolationValPlus*(VTC[2] - VTC[1]); 01062 } 01063 else { 01064 // 01065 // Interpotation Data 01066 interpolationValNeg = 1.0 - VIntp[2].GetY(); 01067 // 01068 vertexList[ 1] = V[1] + interpolationValNeg*(V[2] - V[1]); 01069 grad[1] = G[1] + interpolationValNeg*(G[2] - G[1]); 01070 texCoordList[1] = VTC[1] + interpolationValNeg*(VTC[2] - VTC[1]); 01071 //grad[1] *= -1.0; 01072 } 01073 grad[1].Normalized(); 01074 } 01075 if ( EdgeTable[cubeClass] & 4 ) { 01076 if ( dataForPosition[idx[2] + 3] > threshold ) { 01077 // 01078 // Interpotation Data 01079 interpolationValPlus = VIntp[2].GetX(); 01080 // 01081 vertexList[ 2] = V[2] + interpolationValPlus*(V[3] - V[2]); 01082 grad[2] = G[2] + interpolationValPlus*(G[3] - G[2]); 01083 texCoordList[2] = VTC[2] + interpolationValPlus*(VTC[3] - VTC[2]); 01084 //grad[2] *= -1.0; 01085 } 01086 else { 01087 // 01088 // Interpotation Data 01089 interpolationValNeg = 1.0 - VIntp[3].GetX(); 01090 // 01091 vertexList[ 2] = V[2] + interpolationValNeg*(V[3] - V[2]); 01092 grad[2] = G[2] + interpolationValNeg*(G[3] - G[2]); 01093 texCoordList[2] = VTC[2] + interpolationValNeg*(VTC[3] - VTC[2]); 01094 } 01095 grad[2].Normalized(); 01096 } 01097 if ( EdgeTable[cubeClass] & 8 ) { 01098 if ( dataForPosition[idx[0] + 3] > threshold ) { 01099 // 01100 // Interpotation Data 01101 interpolationValPlus = VIntp[0].GetY(); 01102 // 01103 vertexList[ 3] = V[0] + interpolationValPlus*(V[3] - V[0]); 01104 grad[3] = G[0] + interpolationValPlus*(G[3] - G[0]); 01105 texCoordList[3] = VTC[0] + interpolationValPlus*(VTC[3] - VTC[0]); 01106 //grad[3][1] *= -1.0; 01107 } 01108 else { 01109 // 01110 // Interpotation Data 01111 interpolationValNeg = 1.0 - VIntp[3].GetY(); 01112 // 01113 vertexList[ 3] = V[0] + interpolationValNeg*(V[3] - V[0]); 01114 grad[3] = G[0] + interpolationValNeg*(G[3] - G[0]); 01115 texCoordList[3] = VTC[0] + interpolationValNeg*(VTC[3] - VTC[0]); 01116 } 01117 grad[3].Normalized(); 01118 } 01119 if ( EdgeTable[cubeClass] & 16 ) { 01120 if ( dataForPosition[idx[4] + 3] > threshold ) { 01121 // 01122 // Interpotation Data 01123 interpolationValPlus = VIntp[4].GetX(); 01124 // 01125 vertexList[ 4] = V[4] + interpolationValPlus*(V[5] - V[4]); 01126 grad[4] = G[4] + interpolationValPlus*(G[5] - G[4]); 01127 texCoordList[4] = VTC[4] + interpolationValPlus*(VTC[5] - VTC[4]); 01128 } 01129 else { 01130 // 01131 // Interpotation Data 01132 interpolationValNeg = 1.0 - VIntp[5].GetX(); 01133 // 01134 vertexList[ 4] = V[4] + interpolationValNeg*(V[5] - V[4]); 01135 grad[4] = G[4] + interpolationValNeg*(G[5] - G[4]); 01136 texCoordList[4] = VTC[4] + interpolationValNeg*(VTC[5] - VTC[4]); 01137 //grad[4] *= -1.0; 01138 } 01139 grad[4].Normalized(); 01140 } 01141 if ( EdgeTable[cubeClass] & 32 ) { 01142 if ( dataForPosition[idx[5] + 3] > threshold ) { 01143 // 01144 // Interpotation Data 01145 interpolationValPlus = VIntp[5].GetY(); 01146 // 01147 vertexList[ 5] = V[5] + interpolationValPlus*(V[6] - V[5]); 01148 grad[5] = G[5] + interpolationValPlus*(G[6] - G[5]); 01149 texCoordList[5] = VTC[5] + interpolationValPlus*(VTC[6] - VTC[5]); 01150 } 01151 else { 01152 // 01153 // Interpotation Data 01154 interpolationValNeg = 1.0 - VIntp[6].GetY(); 01155 // 01156 vertexList[ 5] = V[5] + interpolationValNeg*(V[6] - V[5]); 01157 grad[5] = G[5] + interpolationValNeg*(G[6] - G[5]); 01158 texCoordList[5] = VTC[5] + interpolationValNeg*(VTC[6] - VTC[5]); 01159 //grad[5][1] *= -1.0; 01160 } 01161 grad[5].Normalized(); 01162 } 01163 if ( EdgeTable[cubeClass] & 64 ) { 01164 if ( dataForPosition[idx[6] + 3] > threshold ) { 01165 // 01166 // Interpotation Data 01167 interpolationValPlus = VIntp[6].GetX(); 01168 // 01169 vertexList[ 6] = V[6] + interpolationValPlus*(V[7] - V[6]); 01170 grad[6] = G[6] + interpolationValPlus*(G[7] - G[6]); 01171 texCoordList[6] = VTC[6] + interpolationValPlus*(VTC[7] - VTC[6]); 01172 } 01173 else { 01174 // 01175 // Interpotation Data 01176 interpolationValNeg = 1.0 - VIntp[7].GetX(); 01177 // 01178 vertexList[ 6] = V[6] + interpolationValNeg*(V[7] - V[6]); 01179 grad[6] = G[6] + interpolationValNeg*(G[7] - G[6]); 01180 texCoordList[6] = VTC[6] + interpolationValNeg*(VTC[7] - VTC[6]); 01181 //grad[6] *= -1.0; 01182 } 01183 grad[6].Normalized(); 01184 } 01185 if ( EdgeTable[cubeClass] & 128 ) { 01186 if ( dataForPosition[idx[4] + 3] > threshold ) { 01187 // 01188 // Interpotation Data 01189 interpolationValPlus = VIntp[4].GetY(); 01190 // 01191 vertexList[ 7] = V[4] + interpolationValPlus*(V[7] - V[4]); 01192 grad[7] = G[4] + interpolationValPlus*(G[7] - G[4]); 01193 texCoordList[7] = VTC[4] + interpolationValPlus*(VTC[7] - VTC[4]); 01194 //grad[7][1] *= -1.0; 01195 } 01196 else { 01197 // 01198 // Interpotation Data 01199 interpolationValNeg = 1.0 - VIntp[7].GetY(); 01200 // 01201 vertexList[ 7] = V[4] + interpolationValNeg*(V[7] - V[4]); 01202 grad[7] = G[4] + interpolationValNeg*(G[7] - G[4]); 01203 texCoordList[7] = VTC[4] + interpolationValNeg*(VTC[7] - VTC[4]); 01204 } 01205 grad[7].Normalized(); 01206 } 01207 if ( EdgeTable[cubeClass] & 256 ) { 01208 if ( dataForPosition[idx[0] + 3] > threshold ) { 01209 // 01210 // Interpotation Data 01211 interpolationValPlus = VIntp[0].GetZ(); 01212 // 01213 vertexList[ 8] = V[0] + interpolationValPlus*(V[4] - V[0]); 01214 grad[8] = G[0] + interpolationValPlus*(G[4] - G[0]); 01215 texCoordList[8] = VTC[0] + interpolationValPlus*(VTC[4] - VTC[0]); 01216 } 01217 else { 01218 // 01219 // Interpotation Data 01220 interpolationValNeg = 1.0 - VIntp[4].GetZ(); 01221 // 01222 vertexList[ 8] = V[0] + interpolationValNeg*(V[4] - V[0]); 01223 grad[8] = G[0] + interpolationValNeg*(G[4] - G[0]); 01224 texCoordList[8] = VTC[0] + interpolationValNeg*(VTC[4] - VTC[0]); 01225 //grad[8][2] *= -1.0; 01226 } 01227 grad[8].Normalized(); 01228 } 01229 if ( EdgeTable[cubeClass] & 512 ) { 01230 if ( dataForPosition[idx[1] + 3] > threshold ) { 01231 // 01232 // Interpotation Data 01233 interpolationValPlus = VIntp[1].GetZ(); 01234 // 01235 vertexList[ 9] = V[1] + interpolationValPlus*(V[5] - V[1]); 01236 grad[9] = G[1] + interpolationValPlus*(G[5] - G[1]); 01237 texCoordList[9] = VTC[1] + interpolationValPlus*(VTC[5] - VTC[1]); 01238 } 01239 else { 01240 // 01241 // Interpotation Data 01242 interpolationValNeg = 1.0 - VIntp[5].GetZ(); 01243 // 01244 vertexList[ 9] = V[1] + interpolationValNeg*(V[5] - V[1]); 01245 grad[9] = G[1] + interpolationValNeg*(G[5] - G[1]); 01246 texCoordList[9] = VTC[1] + interpolationValNeg*(VTC[5] - VTC[1]); 01247 //grad[9][2] *= -1.0; 01248 } 01249 grad[9].Normalized(); 01250 } 01251 if ( EdgeTable[cubeClass] & 1024 ) { 01252 if ( dataForPosition[idx[2] + 3] > threshold ) { 01253 // 01254 // Interpotation Data 01255 interpolationValPlus = VIntp[2].GetZ(); 01256 // 01257 vertexList[10] = V[2] + interpolationValPlus*(V[6] - V[2]); 01258 grad[10] = G[2] + interpolationValPlus*(G[6] - G[2]); 01259 texCoordList[10] = VTC[2] + interpolationValPlus*(VTC[6] - VTC[2]); 01260 } 01261 else { 01262 // 01263 // Interpotation Data 01264 interpolationValNeg = 1.0 - VIntp[6].GetZ(); 01265 // 01266 vertexList[10] = V[2] + interpolationValNeg*(V[6] - V[2]); 01267 grad[10] = G[2] + interpolationValNeg*(G[6] - G[2]); 01268 texCoordList[10] = VTC[2] + interpolationValNeg*(VTC[6] - VTC[2]); 01269 //grad[10][2] *= -1.0; 01270 } 01271 grad[10].Normalized(); 01272 } 01273 if ( EdgeTable[cubeClass] & 2048 ) { 01274 if ( dataForPosition[idx[3] + 3] > threshold ) { 01275 // 01276 // Interpotation Data 01277 interpolationValPlus = VIntp[3].GetZ(); 01278 // 01279 vertexList[11] = V[3] + interpolationValPlus*(V[7] - V[3]); 01280 grad[11] = G[3] + interpolationValPlus*(G[7] - G[3]); 01281 texCoordList[11] = VTC[3] + interpolationValPlus*(VTC[7] - VTC[3]); 01282 } 01283 else { 01284 // 01285 // Interpotation Data 01286 interpolationValNeg = 1.0 - VIntp[7].GetZ(); 01287 // 01288 vertexList[11] = V[3] + interpolationValNeg*(V[7] - V[3]); 01289 grad[11] = G[3] + interpolationValNeg*(G[7] - G[3]); 01290 texCoordList[11] = VTC[3] + interpolationValNeg*(VTC[7] - VTC[3]); 01291 //grad[11][2] *= -1.0; 01292 } 01293 grad[11].Normalized(); 01294 } 01295 } // END: Use Global Interpolation Value 01296 //----------------------------------------------- 01297 // Not Use Global Interpolation Value -- each element has its own xyz interpolation values 01298 //----------------------------------------------- 01299 else { 01300 //------------------------------------- 01301 // Marching Cube Interpolation 01302 T interpolationValPlus = m_tGlobalInterpolationVal; 01303 T interpolationValNeg = 1.0 - m_tGlobalInterpolationVal; 01304 //------------------------------------- 01305 // Edge# 0 to 11 <==> [ 1, 2, 4, ... , 2048 ] 01306 if ( EdgeTable[cubeClass] & 1 ) { 01307 if ( dataForPosition[idx[0] + 3] > threshold ) { 01308 // 01309 // Interpotation Data 01310 //interpolationValPlus = VIntp[0].GetX(); 01311 // 01312 vertexList[ 0] = V[0] + interpolationValPlus*(V[1] - V[0]); 01313 grad[0] = G[0] + interpolationValPlus*(G[1] - G[0]); 01314 texCoordList[0] = VTC[0] + interpolationValPlus*(VTC[1] - VTC[0]); 01315 } 01316 else { 01317 // 01318 // Interpotation Data 01319 //interpolationValNeg = 1.0 - VIntp[1].GetX(); 01320 // 01321 vertexList[ 0] = V[0] + interpolationValNeg*(V[1] - V[0]); 01322 grad[0] = G[0] + interpolationValNeg*(G[1] - G[0]); 01323 texCoordList[0] = VTC[0] + interpolationValNeg*(VTC[1] - VTC[0]); 01324 //grad[0] *= -1.0; 01325 } 01326 grad[0].Normalized(); 01327 } 01328 if ( EdgeTable[cubeClass] & 2 ) { 01329 if ( dataForPosition[idx[1] + 3] > threshold ) { 01330 // 01331 // Interpotation Data 01332 //interpolationValPlus = VIntp[1].GetY(); 01333 // 01334 vertexList[ 1] = V[1] + interpolationValPlus*(V[2] - V[1]); 01335 grad[1] = G[1] + interpolationValPlus*(G[2] - G[1]); 01336 texCoordList[1] = VTC[1] + interpolationValPlus*(VTC[2] - VTC[1]); 01337 } 01338 else { 01339 // 01340 // Interpotation Data 01341 //interpolationValNeg = 1.0 - VIntp[2].GetY(); 01342 // 01343 vertexList[ 1] = V[1] + interpolationValNeg*(V[2] - V[1]); 01344 grad[1] = G[1] + interpolationValNeg*(G[2] - G[1]); 01345 texCoordList[1] = VTC[1] + interpolationValNeg*(VTC[2] - VTC[1]); 01346 //grad[1] *= -1.0; 01347 } 01348 grad[1].Normalized(); 01349 } 01350 if ( EdgeTable[cubeClass] & 4 ) { 01351 if ( dataForPosition[idx[2] + 3] > threshold ) { 01352 // 01353 // Interpotation Data 01354 //interpolationValPlus = VIntp[2].GetX(); 01355 // 01356 vertexList[ 2] = V[2] + interpolationValPlus*(V[3] - V[2]); 01357 grad[2] = G[2] + interpolationValPlus*(G[3] - G[2]); 01358 texCoordList[2] = VTC[2] + interpolationValPlus*(VTC[3] - VTC[2]); 01359 //grad[2] *= -1.0; 01360 } 01361 else { 01362 // 01363 // Interpotation Data 01364 //interpolationValNeg = 1.0 - VIntp[3].GetX(); 01365 // 01366 vertexList[ 2] = V[2] + interpolationValNeg*(V[3] - V[2]); 01367 grad[2] = G[2] + interpolationValNeg*(G[3] - G[2]); 01368 texCoordList[2] = VTC[2] + interpolationValNeg*(VTC[3] - VTC[2]); 01369 } 01370 grad[2].Normalized(); 01371 } 01372 if ( EdgeTable[cubeClass] & 8 ) { 01373 if ( dataForPosition[idx[0] + 3] > threshold ) { 01374 // 01375 // Interpotation Data 01376 //interpolationValPlus = VIntp[0].GetY(); 01377 // 01378 vertexList[ 3] = V[0] + interpolationValPlus*(V[3] - V[0]); 01379 grad[3] = G[0] + interpolationValPlus*(G[3] - G[0]); 01380 texCoordList[3] = VTC[0] + interpolationValPlus*(VTC[3] - VTC[0]); 01381 //grad[3][1] *= -1.0; 01382 } 01383 else { 01384 // 01385 // Interpotation Data 01386 //interpolationValNeg = 1.0 - VIntp[3].GetY(); 01387 // 01388 vertexList[ 3] = V[0] + interpolationValNeg*(V[3] - V[0]); 01389 grad[3] = G[0] + interpolationValNeg*(G[3] - G[0]); 01390 texCoordList[3] = VTC[0] + interpolationValNeg*(VTC[3] - VTC[0]); 01391 } 01392 grad[3].Normalized(); 01393 } 01394 if ( EdgeTable[cubeClass] & 16 ) { 01395 if ( dataForPosition[idx[4] + 3] > threshold ) { 01396 // 01397 // Interpotation Data 01398 //interpolationValPlus = VIntp[4].GetX(); 01399 // 01400 vertexList[ 4] = V[4] + interpolationValPlus*(V[5] - V[4]); 01401 grad[4] = G[4] + interpolationValPlus*(G[5] - G[4]); 01402 texCoordList[4] = VTC[4] + interpolationValPlus*(VTC[5] - VTC[4]); 01403 } 01404 else { 01405 // 01406 // Interpotation Data 01407 //interpolationValNeg = 1.0 - VIntp[5].GetX(); 01408 // 01409 vertexList[ 4] = V[4] + interpolationValNeg*(V[5] - V[4]); 01410 grad[4] = G[4] + interpolationValNeg*(G[5] - G[4]); 01411 texCoordList[4] = VTC[4] + interpolationValNeg*(VTC[5] - VTC[4]); 01412 //grad[4] *= -1.0; 01413 } 01414 grad[4].Normalized(); 01415 } 01416 if ( EdgeTable[cubeClass] & 32 ) { 01417 if ( dataForPosition[idx[5] + 3] > threshold ) { 01418 // 01419 // Interpotation Data 01420 //interpolationValPlus = VIntp[5].GetY(); 01421 // 01422 vertexList[ 5] = V[5] + interpolationValPlus*(V[6] - V[5]); 01423 grad[5] = G[5] + interpolationValPlus*(G[6] - G[5]); 01424 texCoordList[5] = VTC[5] + interpolationValPlus*(VTC[6] - VTC[5]); 01425 } 01426 else { 01427 // 01428 // Interpotation Data 01429 //interpolationValNeg = 1.0 - VIntp[6].GetY(); 01430 // 01431 vertexList[ 5] = V[5] + interpolationValNeg*(V[6] - V[5]); 01432 grad[5] = G[5] + interpolationValNeg*(G[6] - G[5]); 01433 texCoordList[5] = VTC[5] + interpolationValNeg*(VTC[6] - VTC[5]); 01434 //grad[5][1] *= -1.0; 01435 } 01436 grad[5].Normalized(); 01437 } 01438 if ( EdgeTable[cubeClass] & 64 ) { 01439 if ( dataForPosition[idx[6] + 3] > threshold ) { 01440 // 01441 // Interpotation Data 01442 //interpolationValPlus = VIntp[6].GetX(); 01443 // 01444 vertexList[ 6] = V[6] + interpolationValPlus*(V[7] - V[6]); 01445 grad[6] = G[6] + interpolationValPlus*(G[7] - G[6]); 01446 texCoordList[6] = VTC[6] + interpolationValPlus*(VTC[7] - VTC[6]); 01447 } 01448 else { 01449 // 01450 // Interpotation Data 01451 //interpolationValNeg = 1.0 - VIntp[7].GetX(); 01452 // 01453 vertexList[ 6] = V[6] + interpolationValNeg*(V[7] - V[6]); 01454 grad[6] = G[6] + interpolationValNeg*(G[7] - G[6]); 01455 texCoordList[6] = VTC[6] + interpolationValNeg*(VTC[7] - VTC[6]); 01456 //grad[6] *= -1.0; 01457 } 01458 grad[6].Normalized(); 01459 } 01460 if ( EdgeTable[cubeClass] & 128 ) { 01461 if ( dataForPosition[idx[4] + 3] > threshold ) { 01462 // 01463 // Interpotation Data 01464 //interpolationValPlus = VIntp[4].GetY(); 01465 // 01466 vertexList[ 7] = V[4] + interpolationValPlus*(V[7] - V[4]); 01467 grad[7] = G[4] + interpolationValPlus*(G[7] - G[4]); 01468 texCoordList[7] = VTC[4] + interpolationValPlus*(VTC[7] - VTC[4]); 01469 //grad[7][1] *= -1.0; 01470 } 01471 else { 01472 // 01473 // Interpotation Data 01474 //interpolationValNeg = 1.0 - VIntp[7].GetY(); 01475 // 01476 vertexList[ 7] = V[4] + interpolationValNeg*(V[7] - V[4]); 01477 grad[7] = G[4] + interpolationValNeg*(G[7] - G[4]); 01478 texCoordList[7] = VTC[4] + interpolationValNeg*(VTC[7] - VTC[4]); 01479 } 01480 grad[7].Normalized(); 01481 } 01482 if ( EdgeTable[cubeClass] & 256 ) { 01483 if ( dataForPosition[idx[0] + 3] > threshold ) { 01484 // 01485 // Interpotation Data 01486 //interpolationValPlus = VIntp[0].GetZ(); 01487 // 01488 vertexList[ 8] = V[0] + interpolationValPlus*(V[4] - V[0]); 01489 grad[8] = G[0] + interpolationValPlus*(G[4] - G[0]); 01490 texCoordList[8] = VTC[0] + interpolationValPlus*(VTC[4] - VTC[0]); 01491 } 01492 else { 01493 // 01494 // Interpotation Data 01495 //interpolationValNeg = 1.0 - VIntp[4].GetZ(); 01496 // 01497 vertexList[ 8] = V[0] + interpolationValNeg*(V[4] - V[0]); 01498 grad[8] = G[0] + interpolationValNeg*(G[4] - G[0]); 01499 texCoordList[8] = VTC[0] + interpolationValNeg*(VTC[4] - VTC[0]); 01500 //grad[8][2] *= -1.0; 01501 } 01502 grad[8].Normalized(); 01503 } 01504 if ( EdgeTable[cubeClass] & 512 ) { 01505 if ( dataForPosition[idx[1] + 3] > threshold ) { 01506 // 01507 // Interpotation Data 01508 //interpolationValPlus = VIntp[1].GetZ(); 01509 // 01510 vertexList[ 9] = V[1] + interpolationValPlus*(V[5] - V[1]); 01511 grad[9] = G[1] + interpolationValPlus*(G[5] - G[1]); 01512 texCoordList[9] = VTC[1] + interpolationValPlus*(VTC[5] - VTC[1]); 01513 } 01514 else { 01515 // 01516 // Interpotation Data 01517 //interpolationValNeg = 1.0 - VIntp[5].GetZ(); 01518 // 01519 vertexList[ 9] = V[1] + interpolationValNeg*(V[5] - V[1]); 01520 grad[9] = G[1] + interpolationValNeg*(G[5] - G[1]); 01521 texCoordList[9] = VTC[1] + interpolationValNeg*(VTC[5] - VTC[1]); 01522 //grad[9][2] *= -1.0; 01523 } 01524 grad[9].Normalized(); 01525 } 01526 if ( EdgeTable[cubeClass] & 1024 ) { 01527 if ( dataForPosition[idx[2] + 3] > threshold ) { 01528 // 01529 // Interpotation Data 01530 //interpolationValPlus = VIntp[2].GetZ(); 01531 // 01532 vertexList[10] = V[2] + interpolationValPlus*(V[6] - V[2]); 01533 grad[10] = G[2] + interpolationValPlus*(G[6] - G[2]); 01534 texCoordList[10] = VTC[2] + interpolationValPlus*(VTC[6] - VTC[2]); 01535 } 01536 else { 01537 // 01538 // Interpotation Data 01539 //interpolationValNeg = 1.0 - VIntp[6].GetZ(); 01540 // 01541 vertexList[10] = V[2] + interpolationValNeg*(V[6] - V[2]); 01542 grad[10] = G[2] + interpolationValNeg*(G[6] - G[2]); 01543 texCoordList[10] = VTC[2] + interpolationValNeg*(VTC[6] - VTC[2]); 01544 //grad[10][2] *= -1.0; 01545 } 01546 grad[10].Normalized(); 01547 } 01548 if ( EdgeTable[cubeClass] & 2048 ) { 01549 if ( dataForPosition[idx[3] + 3] > threshold ) { 01550 // 01551 // Interpotation Data 01552 //interpolationValPlus = VIntp[3].GetZ(); 01553 // 01554 vertexList[11] = V[3] + interpolationValPlus*(V[7] - V[3]); 01555 grad[11] = G[3] + interpolationValPlus*(G[7] - G[3]); 01556 texCoordList[11] = VTC[3] + interpolationValPlus*(VTC[7] - VTC[3]); 01557 } 01558 else { 01559 // 01560 // Interpotation Data 01561 //interpolationValNeg = 1.0 - VIntp[7].GetZ(); 01562 // 01563 vertexList[11] = V[3] + interpolationValNeg*(V[7] - V[3]); 01564 grad[11] = G[3] + interpolationValNeg*(G[7] - G[3]); 01565 texCoordList[11] = VTC[3] + interpolationValNeg*(VTC[7] - VTC[3]); 01566 //grad[11][2] *= -1.0; 01567 } 01568 grad[11].Normalized(); 01569 } 01570 } // END: Use Global Interpolation Value 01571 //----------------------------------------------- 01572 // END: if/else statement for MC Interpolation 01573 //=============================================== 01574 01575 //=============================================== 01576 //----------------------------------------------- 01577 // Generate Triangle Index 01578 numOfTrisPerCell = 0; 01579 for ( d = 0; TriTable[cubeClass][d] != -1; ++d ) { 01580 triIndices[d] = TriTable[cubeClass][d]; 01581 } 01582 numOfTrisPerCell = d / 3; 01583 //----------------------------------------------- 01584 //=============================================== 01585 } 01586 01587 //------------------------------- 01588 // Draw (Gradient) Normals 01589 if ( false ) { 01590 glPushAttrib( GL_ALL_ATTRIB_BITS ); 01591 glBegin( GL_LINES ); 01592 for ( int i = 0; i < numOfTrisPerCell*3; i+=3 ) { 01593 glColor3f( 1, 0, 0 ); 01594 glVertex3fv( vertexList[triIndices[i+2]].GetDataFloat() ); 01595 glVertex3fv( ( vertexList[triIndices[i+2]] + grad[triIndices[i+2]]*0.15 ).GetDataFloat() ); 01596 glColor3f( 0, 1, 0 ); 01597 glVertex3fv( vertexList[triIndices[i+1]].GetDataFloat() ); 01598 glVertex3fv( ( vertexList[triIndices[i+1]] + grad[triIndices[i+1]]*0.15 ).GetDataFloat() ); 01599 glColor3f( 0, 0, 1 ); 01600 glVertex3fv( vertexList[triIndices[i+0]].GetDataFloat() ); 01601 glVertex3fv( ( vertexList[triIndices[i+0]] + grad[triIndices[i+0]]*0.15 ).GetDataFloat() ); 01602 } 01603 glEnd(); 01604 glPopAttrib(); 01605 } 01606 //------------------------------- 01607 01608 //------------------------------- 01609 // Draw PN-Triangles generated 01610 // from Marching Cube Triangles 01611 if ( m_bDrawPNTriangle ) { 01612 int i = 0; 01613 while ( numOfTrisPerCell > 0 ) { 01614 PNTriangle<T>::DrawByOpenGL( 01615 vertexList[triIndices[i+2]], 01616 vertexList[triIndices[i+1]], 01617 vertexList[triIndices[i+0]], 01618 grad[triIndices[i+2]], 01619 grad[triIndices[i+1]], 01620 grad[triIndices[i+0]], 01621 texCoordList[triIndices[i+2]], 01622 texCoordList[triIndices[i+1]], 01623 texCoordList[triIndices[i+0]], 01624 m_PNTriangleSmoothness 01625 ); 01626 --numOfTrisPerCell; 01627 i += 3; 01628 } 01629 } 01630 // DEBUG for PNTri Drawing 01631 //glUseProgramObjectARB( g_PNTriProg ); 01632 // 01633 // DEBUG for PNTri Drawing 01634 //glUseProgramObjectARB( NULL ); 01635 01636 //------------------------------- 01637 // Draw Marching Cube Triangles 01638 else { 01639 glBegin( GL_TRIANGLES ); 01640 int i = 0; 01641 while ( numOfTrisPerCell > 0 ) { 01642 glTexCoord3fv( texCoordList[triIndices[i+2]].GetDataFloat() ); 01643 glNormal3fv( grad[triIndices[i+2]].GetDataFloat() ); 01644 glVertex3fv( vertexList[triIndices[i+2]].GetDataFloat() ); 01645 // 01646 glTexCoord3fv( texCoordList[triIndices[i+1]].GetDataFloat() ); 01647 glNormal3fv( grad[triIndices[i+1]].GetDataFloat() ); 01648 glVertex3fv( vertexList[triIndices[i+1]].GetDataFloat() ); 01649 // 01650 glTexCoord3fv( texCoordList[triIndices[i+0]].GetDataFloat() ); 01651 glNormal3fv( grad[triIndices[i+0]].GetDataFloat() ); 01652 glVertex3fv( vertexList[triIndices[i+0]].GetDataFloat() ); 01653 // 01654 --numOfTrisPerCell; 01655 i += 3; 01656 } 01657 glEnd(); 01658 } 01659 //------------------------------- 01660 // Next Cell 01661 for ( int i = 0; i < 8; ++i ) { 01662 idx[i] += 4; 01663 // 01664 intpIdx[i] += 3; 01665 } 01666 //------------------------------- 01667 } 01668 } 01669 } 01670 glPopAttrib(); 01671 //--------------------------------------------------------------- 01672 //=============================================================== 01673 01674 //--------------------------------------------------------------- 01675 //=============================================================== 01676 //delete [] dataForPosition; 01677 //delete [] dataForEllipsoidInfluence; 01678 //delete [] dataForConnectivity; 01679 //*/ 01680 } 01681 //----------------------------------------------------------------------------- 01682 // END: DrawByGL 01683 //***************************************************************************** 01684 01685 //----------------------------------------------------------------------------- 01686 //============================================================================= 01687 END_NAMESPACE_TAPs__OpenGL 01688 //----------------------------------------------------------------------------- 01689 //34567890123456789012345678901234567890123456789012345678901234567890123456789 01690 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----