#include <ray.h>
Inheritance diagram for Ray:
Public Methods | |
Ray () | |
~Ray () | |
bool | SetViewingCondition (VECTOR lightpos, float ambient, float diffuse, float specular, int highlight) |
definiert Lichtposition und Eigenschaften | |
bool | Initialize (Color background, Color current, float steplength, Plane *viewingplane, Data *data, Transfunc *tf) |
initialisiert Hintergrund-, Startfarbe und verwendete Schrittweite | |
bool | SetPosDir (VECTOR currentpos, VECTOR direction) |
dient zum Setzen der Startposition und der Richtung des Strahls | |
Color | GetCurrentColor () |
gibt aktuellen Farbwert des Strahls zurück | |
float | GetAlpha () |
void | SetLight (bool light) |
virtual bool | CastNext () |
bool | Reset () |
void | SetDensRange (int minDens, int maxDens) |
Protected Methods | |
virtual Color | Lighting (Color color) |
Lichtberechnung für nearest neighbour filtering. | |
Protected Attributes | |
bool | m_light |
VECTOR | m_lightpos |
VECTOR | m_currentpos |
float | m_ambient |
float | m_diffuse |
float | m_specular |
int | m_highlight |
Transfunc * | m_tf |
Data * | m_data |
Color | m_backgroundcolor |
Color | m_currentcolor |
float | m_alpha |
VECTOR | m_startpoint |
VECTOR | m_direction |
float | m_steplength |
Plane * | m_viewingplane |
int | m_minDens |
int | m_maxDens |
float | mx |
float | my |
float | mz |
float | m_radius |
|
ray.cpp implementiert 8 verschieden Klassen, die zur Berechnung des Bildes in den Rendermodes Standard Compositing, FirstHit, MaximumIntensity, XRay jeweils für trilinear und nearest neighbour Filterung. Definition at line 10 of file ray.cpp. References m_alpha, m_ambient, m_backgroundcolor, m_currentcolor, m_currentpos, m_data, m_diffuse, m_direction, m_highlight, m_light, m_maxDens, m_minDens, m_specular, m_startpoint, m_steplength, m_tf, m_viewingplane, mx, my, and mz.
00010 { 00011 // richtungsvektor 00012 m_direction = VECTOR(1,0,0); 00013 // aktuelle position am strahl 00014 m_currentpos = VECTOR(0,0,0); 00015 // Koeffizient für ambient lighting 00016 m_ambient = 0.2f; 00017 // Koeffizient für diffuses lighting 00018 m_diffuse = 0.2f; 00019 // Transferfubction 00020 m_tf = NULL; 00021 // datenvolumen 00022 m_data = NULL; 00023 // Hintergrundfarbe 00024 m_backgroundcolor = Color(0.0,0.0,0.0); 00025 // aktuelle Gesamtfarbe 00026 m_currentcolor = Color(0.0,0.0,0.0); 00027 // aktueller Alphawert 00028 m_alpha = 0.0; 00029 // Startpunkt 00030 m_startpoint = VECTOR(0,0,0); 00031 // Endpunkt 00032 m_steplength = 1.0; 00033 m_specular = 0.2f; 00034 00035 m_highlight = 8; 00036 00037 m_light = false; 00038 m_viewingplane = NULL; 00039 mx = 0.0f; 00040 my = 0.0f; 00041 mz = 0.0f; 00042 00043 m_minDens = 0; 00044 m_maxDens = 4095; 00045 } |
|
Definition at line 47 of file ray.cpp.
00047 {} |
|
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 in Trilinear, FirstHitNN, FirstHitTRI, MaxIntensityNN, MaxIntensityTRI, XRayNN, and XRayTRI. Definition at line 126 of file ray.cpp. References Data::GetDensity(), Transfunc::GetDensityColor(), Transfunc::GetOpacity(), VECTOR::length(), Lighting(), m_alpha, m_backgroundcolor, m_currentcolor, m_currentpos, m_data, m_direction, m_radius, m_startpoint, m_steplength, m_tf, mx, my, mz, ROUND, VECTOR::x, VECTOR::y, and VECTOR::z. Referenced by Raycaster::Raycast().
00126 { 00127 00128 if(m_data == NULL) return false; 00129 if(m_tf == NULL) return false; 00130 00131 bool first = true; 00132 int step_count = 0; 00133 VECTOR distancetomidpoint = VECTOR(mx/2.0f,my/2.0f,mz/2.0f)-m_currentpos; 00134 int steps = (int)((distancetomidpoint.length() + m_radius)/m_steplength); 00135 do { 00136 if(m_alpha > 0.99) break; 00137 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)) { 00138 if(first) { 00139 m_startpoint = VECTOR(m_currentpos.x,m_currentpos.y,m_currentpos.z); 00140 first = false; 00141 } 00142 int d = m_data->GetDensity((int)ROUND(m_currentpos.x),(int)ROUND(m_currentpos.y),(int)ROUND(m_currentpos.z)); 00143 00144 Color help_color = m_tf->GetDensityColor(d); 00145 float help_alpha = m_tf->GetOpacity(d); 00146 // lightning: 00147 help_color = Lighting(help_color); 00148 // calculate new currentcolor: 00149 m_currentcolor += help_color*(1-m_alpha)*help_alpha; 00150 // calculate new alphavalue 00151 m_alpha += (1-m_alpha)*help_alpha; 00152 } 00153 // calculate new position 00154 m_currentpos += m_steplength*m_direction; 00155 00156 step_count++; 00157 }while(step_count <= steps); 00158 if(m_alpha < 1.0 ) { 00159 m_currentcolor += m_backgroundcolor*(1.0f-m_alpha); 00160 } 00161 return true; 00162 } |
|
Definition at line 59 of file ray.h.
00059 { return m_alpha;}; |
|
gibt aktuellen Farbwert des Strahls zurück
Definition at line 93 of file ray.cpp. References m_currentcolor. Referenced by Raycaster::Raycast().
00093 { 00094 return m_currentcolor; 00095 } |
|
initialisiert Hintergrund-, Startfarbe und verwendete Schrittweite
Definition at line 99 of file ray.cpp. References Data::GetXDim(), Data::GetYDim(), Data::GetZDim(), m_backgroundcolor, m_currentcolor, m_data, m_radius, m_steplength, m_tf, m_viewingplane, mx, my, and mz. Referenced by Raycaster::Raycast().
00099 { 00100 m_backgroundcolor = background; 00101 m_currentcolor = current; 00102 m_data = data; 00103 m_tf = tf; 00104 m_steplength = steplength; 00105 m_viewingplane = viewingplane; 00106 mx = (float)m_data->GetXDim(); 00107 my = (float)m_data->GetYDim(); 00108 mz = (float)m_data->GetZDim(); 00109 m_radius = sqrt(pow(mx/2.0f,2)+pow(my/2.0f,2)+pow(mz/2.0f,2)); 00110 return true; 00111 } |
|
Lichtberechnung für nearest neighbour filtering.
Reimplemented in Trilinear. Definition at line 72 of file ray.cpp. References Data::CalcGrad(), VECTOR::dot(), VECTOR::length(), m_ambient, m_currentpos, m_data, m_diffuse, m_direction, m_highlight, m_lightpos, m_specular, m_startpoint, VECTOR::normalize(), ROUND, gradient_t::x, VECTOR::x, gradient_t::y, VECTOR::y, gradient_t::z, and VECTOR::z. Referenced by FirstHitNN::CastNext(), and CastNext().
00072 { 00073 gradient_t grad = m_data->CalcGrad((int)ROUND(m_currentpos.x),(int)ROUND(m_currentpos.y),(int)ROUND(m_currentpos.z)); 00074 VECTOR normal = VECTOR(grad.x, grad.y, grad.z); 00075 normal.normalize(); // normalize normal 00076 VECTOR len = m_currentpos - m_startpoint; 00077 Color ret; 00078 if(m_light) { 00079 VECTOR v = -m_direction; 00080 v.normalize(); 00081 VECTOR l = m_lightpos-m_currentpos; 00082 l.normalize(); 00083 VECTOR h = (v+l); 00084 h.normalize(); 00085 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()); 00086 } 00087 else ret = color*m_ambient + color*(m_diffuse*(normal.dot(m_direction))) + color/(4.0f+1000000.0f*len.length()); 00088 return ret; 00089 } |
|
Definition at line 62 of file ray.h. Referenced by Raycaster::Raycast().
00062 {m_alpha = 0.0; m_currentcolor = m_backgroundcolor; return true;}; |
|
Definition at line 64 of file ray.h. Referenced by Raycaster::Raycast().
|
|
Definition at line 60 of file ray.h. Referenced by Raycaster::Raycast().
00060 { m_light = light;}; |
|
dient zum Setzen der Startposition und der Richtung des Strahls
Definition at line 115 of file ray.cpp. References m_currentpos, and m_direction. Referenced by Raycaster::Raycast().
00115 { 00116 m_currentpos = currentpos; 00117 m_direction = direction; 00118 return true; 00119 } |
|
definiert Lichtposition und Eigenschaften
Definition at line 51 of file ray.cpp. References m_ambient, m_diffuse, m_highlight, and m_specular. Referenced by Raycaster::Raycast().
00051 { 00052 00053 if (ambient > 1.0) ambient = 1.0; 00054 if (ambient < 0.0) ambient = 0.0; 00055 if (diffuse > 1.0) diffuse = 1.0; 00056 if (diffuse < 0.0) diffuse = 0.0; 00057 if (specular > 1.0) specular = 1.0; 00058 if (specular < 0.0) specular = 0.0; 00059 if(highlight < 0) highlight = 0; 00060 00061 m_highlight = highlight; 00062 m_specular = specular; 00063 m_ambient = ambient; 00064 m_diffuse = diffuse; 00065 return true; 00066 } |
|
Definition at line 39 of file ray.h. Referenced by XRayNN::CastNext(), MaxIntensityTRI::CastNext(), MaxIntensityNN::CastNext(), FirstHitTRI::CastNext(), FirstHitNN::CastNext(), Trilinear::CastNext(), CastNext(), and Ray(). |
|
Definition at line 23 of file ray.h. Referenced by Trilinear::Lighting(), Lighting(), Ray(), and SetViewingCondition(). |
|
Definition at line 35 of file ray.h. Referenced by MaxIntensityTRI::CastNext(), MaxIntensityNN::CastNext(), FirstHitTRI::CastNext(), FirstHitNN::CastNext(), Trilinear::CastNext(), CastNext(), Initialize(), and Ray(). |
|
Definition at line 37 of file ray.h. Referenced by XRayTRI::CastNext(), XRayNN::CastNext(), MaxIntensityTRI::CastNext(), MaxIntensityNN::CastNext(), FirstHitTRI::CastNext(), FirstHitNN::CastNext(), Trilinear::CastNext(), CastNext(), GetCurrentColor(), Initialize(), and Ray(). |
|
Definition at line 21 of file ray.h. Referenced by XRayTRI::CastNext(), XRayNN::CastNext(), MaxIntensityTRI::CastNext(), MaxIntensityNN::CastNext(), FirstHitTRI::CastNext(), FirstHitNN::CastNext(), Trilinear::CastNext(), CastNext(), Trilinear::Lighting(), Lighting(), Ray(), and SetPosDir(). |
|
|
Definition at line 25 of file ray.h. Referenced by Trilinear::Lighting(), Lighting(), Ray(), and SetViewingCondition(). |
|
Definition at line 43 of file ray.h. Referenced by XRayTRI::CastNext(), XRayNN::CastNext(), MaxIntensityTRI::CastNext(), MaxIntensityNN::CastNext(), FirstHitTRI::CastNext(), FirstHitNN::CastNext(), Trilinear::CastNext(), CastNext(), Trilinear::Lighting(), Lighting(), Ray(), and SetPosDir(). |
|
Definition at line 29 of file ray.h. Referenced by Trilinear::Lighting(), Lighting(), Ray(), and SetViewingCondition(). |
|
Definition at line 15 of file ray.h. Referenced by MaxIntensityNN::CastNext(), and Ray(). |
|
Definition at line 16 of file ray.h. Referenced by Trilinear::Lighting(), and Lighting(). |
|
Definition at line 47 of file ray.h. Referenced by XRayTRI::CastNext(), XRayNN::CastNext(), and Ray(). |
|
Definition at line 47 of file ray.h. Referenced by XRayTRI::CastNext(), XRayNN::CastNext(), and Ray(). |
|
Definition at line 49 of file ray.h. Referenced by XRayTRI::CastNext(), XRayNN::CastNext(), MaxIntensityTRI::CastNext(), MaxIntensityNN::CastNext(), FirstHitTRI::CastNext(), FirstHitNN::CastNext(), Trilinear::CastNext(), CastNext(), and Initialize(). |
|
Definition at line 27 of file ray.h. Referenced by Trilinear::Lighting(), Lighting(), Ray(), and SetViewingCondition(). |
|
Definition at line 41 of file ray.h. Referenced by XRayTRI::CastNext(), XRayNN::CastNext(), MaxIntensityTRI::CastNext(), MaxIntensityNN::CastNext(), FirstHitTRI::CastNext(), FirstHitNN::CastNext(), Trilinear::CastNext(), CastNext(), Trilinear::Lighting(), Lighting(), and Ray(). |
|
Definition at line 44 of file ray.h. Referenced by XRayTRI::CastNext(), XRayNN::CastNext(), MaxIntensityTRI::CastNext(), MaxIntensityNN::CastNext(), FirstHitTRI::CastNext(), FirstHitNN::CastNext(), Trilinear::CastNext(), CastNext(), Initialize(), and Ray(). |
|
Definition at line 31 of file ray.h. Referenced by Trilinear::CalcAlphaTrilinear(), Trilinear::CalcColorTrilinear(), XRayTRI::CastNext(), XRayNN::CastNext(), MaxIntensityTRI::CastNext(), MaxIntensityNN::CastNext(), FirstHitTRI::CastNext(), FirstHitNN::CastNext(), Trilinear::CastNext(), CastNext(), Initialize(), and Ray(). |
|
Definition at line 45 of file ray.h. Referenced by Initialize(), and Ray(). |
|
Definition at line 49 of file ray.h. Referenced by XRayTRI::CastNext(), XRayNN::CastNext(), MaxIntensityTRI::CastNext(), MaxIntensityNN::CastNext(), FirstHitTRI::CastNext(), FirstHitNN::CastNext(), Trilinear::CastNext(), CastNext(), Initialize(), and Ray(). |
|
Definition at line 49 of file ray.h. Referenced by XRayTRI::CastNext(), XRayNN::CastNext(), MaxIntensityTRI::CastNext(), MaxIntensityNN::CastNext(), FirstHitTRI::CastNext(), FirstHitNN::CastNext(), Trilinear::CastNext(), CastNext(), Initialize(), and Ray(). |
|
Definition at line 49 of file ray.h. Referenced by XRayTRI::CastNext(), XRayNN::CastNext(), MaxIntensityTRI::CastNext(), MaxIntensityNN::CastNext(), FirstHitTRI::CastNext(), FirstHitNN::CastNext(), Trilinear::CastNext(), CastNext(), Initialize(), and Ray(). |