#include <ray.h>
Inheritance diagram for Trilinear:
Public Methods | |
Trilinear () | |
bool | CastNext () |
Protected Methods | |
Color | CalcColorTrilinear (VECTOR pos) |
Trilineare Berechnung des Farbwertes. | |
gradient_t | CalcGradTrilinear (VECTOR pos) |
trilineare Berechnung des Gradienten | |
float | CalcAlphaTrilinear (VECTOR pos) |
Trilineare Berechnung des Alphawertes. | |
Color | Lighting (Color color) |
Beleuchtungsberechnung mit Hilfe von trilinear berechneten Gradienten. |
|
Definition at line 75 of file ray.h.
00075 {}; |
|
Trilineare Berechnung des Alphawertes.
Definition at line 166 of file ray.cpp. References Data::GetDensity(), Transfunc::GetOpacity(), Ray::m_data, Ray::m_tf, VECTOR::x, VECTOR::y, and VECTOR::z. Referenced by FirstHitTRI::CastNext(), and CastNext().
00166 { 00167 00168 float a000 = m_tf->GetOpacity(m_data->GetDensity(floorf(pos.x),floorf(pos.y),floorf(pos.z))); 00169 float a001 = m_tf->GetOpacity(m_data->GetDensity(floorf(pos.x),floorf(pos.y),ceilf(pos.z))); 00170 float a010 = m_tf->GetOpacity(m_data->GetDensity(floorf(pos.x),ceilf(pos.y),floorf(pos.z))); 00171 float a011 = m_tf->GetOpacity(m_data->GetDensity(floorf(pos.x),ceilf(pos.y),ceilf(pos.z))); 00172 float a100 = m_tf->GetOpacity(m_data->GetDensity(ceilf(pos.x),floorf(pos.y),floorf(pos.z))); 00173 float a101 = m_tf->GetOpacity(m_data->GetDensity(ceilf(pos.x),floorf(pos.y),ceilf(pos.z))); 00174 float a110 = m_tf->GetOpacity(m_data->GetDensity(ceilf(pos.x),ceilf(pos.y),floorf(pos.z))); 00175 float a111 = m_tf->GetOpacity(m_data->GetDensity(ceilf(pos.x),ceilf(pos.y),ceilf(pos.z))); 00176 00177 float difX = abs(pos.x - floorf(pos.x)); 00178 float difY = abs(pos.y - floorf(pos.y)); 00179 float difZ = abs(pos.z - floorf(pos.z)); 00180 00181 float aA = a000*difX + a100*abs(1.0f-difX); 00182 float aB = a010*difX + a110*abs(1.0f-difX); 00183 float aC = a011*difX + a111*abs(1.0f-difX); 00184 float aD = a001*difX + a101*abs(1.0f-difX); 00185 00186 float aE = aA*difZ + aD*abs(1.0f-difZ); 00187 float aF = aB*difZ + aC*abs(1.0f-difZ); 00188 00189 float a = aE*difY + aF*abs(1.0f-difY); 00190 return a; 00191 } |
|
Trilineare Berechnung des Farbwertes.
Definition at line 223 of file ray.cpp. References Data::GetDensity(), Transfunc::GetDensityColor(), Ray::m_data, Ray::m_tf, VECTOR::x, VECTOR::y, and VECTOR::z. Referenced by FirstHitTRI::CastNext(), and CastNext().
00223 { 00224 Color col000 = m_tf->GetDensityColor(m_data->GetDensity(floorf(pos.x),floorf(pos.y),floorf(pos.z))); 00225 Color col001 = m_tf->GetDensityColor(m_data->GetDensity(floorf(pos.x),floorf(pos.y),ceilf(pos.z))); 00226 Color col010 = m_tf->GetDensityColor(m_data->GetDensity(floorf(pos.x),ceilf(pos.y),floorf(pos.z))); 00227 Color col011 = m_tf->GetDensityColor(m_data->GetDensity(floorf(pos.x),ceilf(pos.y),ceilf(pos.z))); 00228 Color col100 = m_tf->GetDensityColor(m_data->GetDensity(ceilf(pos.x),floorf(pos.y),floorf(pos.z))); 00229 Color col101 = m_tf->GetDensityColor(m_data->GetDensity(ceilf(pos.x),floorf(pos.y),ceilf(pos.z))); 00230 Color col110 = m_tf->GetDensityColor(m_data->GetDensity(ceilf(pos.x),ceilf(pos.y),floorf(pos.z))); 00231 Color col111 = m_tf->GetDensityColor(m_data->GetDensity(ceilf(pos.x),ceilf(pos.y),ceilf(pos.z))); 00232 00233 00234 float difX = abs(pos.x - floorf(pos.x)); 00235 float difY = abs(pos.y - floorf(pos.y)); 00236 float difZ = abs(pos.z - floorf(pos.z)); 00237 00238 Color colA = col000*difX + col100*abs(1.0f-difX); 00239 Color colB = col010*difX + col110*abs(1.0f-difX); 00240 Color colC = col011*difX + col111*abs(1.0f-difX); 00241 Color colD = col001*difX + col101*abs(1.0f-difX); 00242 00243 Color colE = colA*difZ + colD*abs(1.0f-difZ); 00244 Color colF = colB*difZ + colC*abs(1.0f-difZ); 00245 00246 Color col = colE*difY + colF*abs(1.0f-difY); 00247 return col; 00248 } |
|
trilineare Berechnung des Gradienten
Definition at line 195 of file ray.cpp. References Data::CalcGrad(), Ray::m_data, VECTOR::x, VECTOR::y, and VECTOR::z. Referenced by Lighting().
00195 { 00196 gradient_t grad000 = m_data->CalcGrad(floorf(pos.x),floorf(pos.y),floorf(pos.z)); 00197 gradient_t grad001 = m_data->CalcGrad(floorf(pos.x),floorf(pos.y),ceilf(pos.z)); 00198 gradient_t grad010 = m_data->CalcGrad(floorf(pos.x),ceilf(pos.y),floorf(pos.z)); 00199 gradient_t grad011 = m_data->CalcGrad(floorf(pos.x),ceilf(pos.y),ceilf(pos.z)); 00200 gradient_t grad100 = m_data->CalcGrad(ceilf(pos.x),floorf(pos.y),floorf(pos.z)); 00201 gradient_t grad101 = m_data->CalcGrad(ceilf(pos.x),floorf(pos.y),ceilf(pos.z)); 00202 gradient_t grad110 = m_data->CalcGrad(ceilf(pos.x),ceilf(pos.y),floorf(pos.z)); 00203 gradient_t grad111 = m_data->CalcGrad(ceilf(pos.x),ceilf(pos.y),ceilf(pos.z)); 00204 00205 float difX = abs(pos.x - floorf(pos.x)); 00206 float difY = abs(pos.y - floorf(pos.y)); 00207 float difZ = abs(pos.z - floorf(pos.z)); 00208 00209 gradient_t gradA = grad000*difX + grad100*abs(1.0f-difX); 00210 gradient_t gradB = grad010*difX + grad110*abs(1.0f-difX); 00211 gradient_t gradC = grad011*difX + grad111*abs(1.0f-difX); 00212 gradient_t gradD = grad001*difX + grad101*abs(1.0f-difX); 00213 00214 gradient_t gradE = gradA*difZ + gradD*abs(1.0f-difZ); 00215 gradient_t gradF = gradB*difZ + gradC*abs(1.0f-difZ); 00216 00217 gradient_t grad = gradE*difY + gradF*abs(1.0f-difY); 00218 return grad; 00219 } |
|
berechnet den farbwert eines Strahls indem er das Volumen an diskreten Punkten abtastet, dort einen Dichtewert erhält, und diesen dichtewert in eine Farbe umwandelt und dann im Volumen vorwärts geht bis das Ende des Volumens erreicht ist oder die Opazität eins ist Reimplemented from Ray. Reimplemented in FirstHitTRI, MaxIntensityTRI, and XRayTRI. Definition at line 279 of file ray.cpp. References CalcAlphaTrilinear(), CalcColorTrilinear(), VECTOR::length(), Lighting(), Ray::m_alpha, Ray::m_backgroundcolor, Ray::m_currentcolor, Ray::m_currentpos, Ray::m_data, Ray::m_direction, Ray::m_radius, Ray::m_startpoint, Ray::m_steplength, Ray::m_tf, Ray::mx, Ray::my, Ray::mz, VECTOR::x, VECTOR::y, and VECTOR::z.
00279 { 00280 00281 if(m_data == NULL) return false; 00282 if(m_tf == NULL) return false; 00283 00284 int step_count = 0; 00285 bool first = true; 00286 VECTOR distancetomidpoint = VECTOR(mx/2.0f,my/2.0f,mz/2.0f)-m_currentpos; 00287 int steps = (int)((distancetomidpoint.length() + m_radius)/m_steplength); 00288 00289 do { 00290 if(m_alpha > 0.99) break; 00291 if((m_currentpos.x >= 0.0)&&(m_currentpos.y >= 0.0)&&(m_currentpos.z >= 0.0)&&(m_currentpos.x < mx)&&(m_currentpos.y < my)&&(m_currentpos.z < mz)) { 00292 if(first) { 00293 m_startpoint = VECTOR(m_currentpos.x,m_currentpos.y,m_currentpos.z); 00294 first = false; 00295 } 00296 Color help_color = CalcColorTrilinear(m_currentpos); 00297 float help_alpha = CalcAlphaTrilinear(m_currentpos); 00298 // lightning: 00299 help_color = Lighting(help_color); 00300 // calculate new currentcolor: 00301 m_currentcolor += help_color*(1-m_alpha)*help_alpha; 00302 // calculate new alphavalue 00303 m_alpha += (1-m_alpha)*help_alpha; 00304 } 00305 // calculate new position 00306 m_currentpos += m_steplength*m_direction; 00307 00308 step_count++; 00309 }while(step_count <= steps); 00310 if(m_alpha < 1.0 ) { 00311 m_currentcolor += m_backgroundcolor*(1.0-m_alpha); 00312 } 00313 return true; 00314 } |
|
Beleuchtungsberechnung mit Hilfe von trilinear berechneten Gradienten.
Reimplemented from Ray. Definition at line 252 of file ray.cpp. References CalcGradTrilinear(), VECTOR::dot(), VECTOR::length(), Ray::m_ambient, Ray::m_currentpos, Ray::m_diffuse, Ray::m_direction, Ray::m_highlight, Ray::m_lightpos, Ray::m_specular, Ray::m_startpoint, VECTOR::normalize(), gradient_t::x, gradient_t::y, and gradient_t::z. Referenced by FirstHitTRI::CastNext(), and CastNext().
00252 { 00253 gradient_t g = CalcGradTrilinear(m_currentpos); 00254 VECTOR normal = VECTOR(g.x, g.y, g.z); 00255 normal.normalize(); // normalize normal 00256 00257 VECTOR len = m_currentpos-m_startpoint; 00258 Color ret; 00259 if(m_light) { 00260 VECTOR v = -m_direction; 00261 v.normalize(); 00262 VECTOR l = m_lightpos-m_currentpos; 00263 l.normalize(); 00264 VECTOR h = (v+l); 00265 h.normalize(); 00266 ret = color*m_ambient + color*((m_diffuse*(normal.dot(m_direction))) + (m_specular*pow(normal.dot(h),m_highlight)))+ color/(4.0f+1000000.0f*len.length()); 00267 } 00268 else ret = color*m_ambient + color*(m_diffuse*(normal.dot(m_direction))) + color/(4.0f+1000000.0f*len.length()); 00269 return ret; 00270 } |