#include "Volumizer.h"
Go to the source code of this file.
Defines | |
#define | TOOL_HEIGHT 36 |
Functions | |
INT_PTR CALLBACK | ProgressProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) |
void | ShovelData () |
void | LoadDataFile (wchar_t *fileName) |
float | bias (float _val, float _bias) |
float | gain (float _val, float _gain) |
static __inline float | OogleVal (float inp) |
static __inline float | GetSample (int x, int y, int z) |
static __inline float | GetInterpolatedSample (vect pos) |
static __inline int | GetBoxIntersection (vect &vnear, vect &vfar, vect &org, vect &dir) |
static __inline float | GetRand01 () |
static __inline vect | GetGradient (vect pos, float base) |
bool | ShadeStep (vect &dir, vect &pos, color &col, float steplen) |
color | ShootRay (vect org, vect dir) |
void | DrawRect (int x, int y, int height, int width, color c, int size, color *fbuffer) |
where the stuff should end up | |
void | RayRender () |
Variables | |
unsigned short * | rawdat |
unsigned short | rawmax |
float * | voldat |
raw volume data | |
unsigned int | volx |
normalized and treated volume data | |
unsigned int | voly |
unsigned int | volz |
HWND | wnd_main |
x, y and z size of the data | |
camera | cam |
HDC | rayHdc |
HGLRC | rayHglrc |
vect | ldir |
the camera |
#define TOOL_HEIGHT 36 |
float bias | ( | float | _val, | |
float | _bias | |||
) |
Schlick bias function. A bit like gamma, but cooler :P
Definition at line 144 of file RayEngine.cpp.
Referenced by OogleVal().
void DrawRect | ( | int | x, | |
int | y, | |||
int | height, | |||
int | width, | |||
color | c, | |||
int | size, | |||
color * | fbuffer | |||
) |
where the stuff should end up
Fill a rectangular area of pixels with a given color value.
height | x and y position of lower left corner |
c | x and y extents of the whole image |
fbuffer | color and size of the box |
Definition at line 671 of file RayEngine.cpp.
Referenced by RayRender().
float gain | ( | float | _val, | |
float | _gain | |||
) |
static __inline int GetBoxIntersection | ( | vect & | vnear, | |
vect & | vfar, | |||
vect & | org, | |||
vect & | dir | |||
) | [static] |
Take the ray defined by org and dir, and intersect it with an axis aligned box described by the two corners (0, 0, 0) and (volx, voly, volz). Return the two intersection points along the ray in vnear and vfar.
set near and far distance to something huge
intersect with x-planes the if () at the start makes sure the test only happens when the ray isn't parallel to the plane
vfar | near intersection with ray (out) |
org | far intersection with ray (out) |
dir | ray origin ray direction |
Definition at line 237 of file RayEngine.cpp.
References volx, voly, and volz.
Referenced by ShootRay().
static __inline vect GetGradient | ( | vect | pos, | |
float | base | |||
) | [static] |
Compute the (inverted) gradient at position pos, based on the value base. Don't normalize it!
base | current position value at the current position |
Definition at line 456 of file RayEngine.cpp.
References GetInterpolatedSample(), and vol_opts.
Referenced by ShadeStep().
static __inline float GetInterpolatedSample | ( | vect | pos | ) | [static] |
Get the trilinearly interpolated sample at pos.
get the position inside the current cell [0...1]
get the lower left back corner of the cell
make sure we don't fall outside the valid coordinates
interpolate along z
interpolate along y
interpolate along x
Definition at line 187 of file RayEngine.cpp.
References GetSample(), volx, voly, and volz.
Referenced by GetGradient(), ShadeStep(), and ShootRay().
static __inline float GetRand01 | ( | ) | [static] |
Return a random number between 0 and 1.
Definition at line 447 of file RayEngine.cpp.
Referenced by ShootRay().
static __inline float GetSample | ( | int | x, | |
int | y, | |||
int | z | |||
) | [static] |
Grab the sample at position x, y, z
Definition at line 179 of file RayEngine.cpp.
References voldat, volx, and voly.
Referenced by GetInterpolatedSample().
void LoadDataFile | ( | wchar_t * | fileName | ) |
Read a volume data file from disc and store it into rawdat.
open input file handle
read x y and z size
kill an old voldat if it's there
create new array
create array for reading data in
read all records at once
find the maximum
close input file
set the average x, y and z slize
initialize our camera and light
shovel data into float array
Definition at line 91 of file RayEngine.cpp.
References InitCam(), InitLight(), rawdat, rawmax, ShovelData(), voldat, volx, voly, volz, xslice, yslice, and zslice.
Referenced by GetOpenFile().
static __inline float OogleVal | ( | float | inp | ) | [static] |
Apply bias, gain and gamma to an input value
Definition at line 167 of file RayEngine.cpp.
References bias(), brightness, contrast, gain(), and gamma.
Referenced by ShovelData().
INT_PTR CALLBACK ProgressProc | ( | HWND | hwndDlg, | |
UINT | uMsg, | |||
WPARAM | wParam, | |||
LPARAM | lParam | |||
) |
Window Procedure for the little "Progress" popup after loading. Nothing amazing.
Definition at line 22 of file RayEngine.cpp.
Referenced by ShovelData().
void RayRender | ( | ) |
The main render function. Render pretty pictures!
first, create a new frame buffer
take the camera info, compute a view grill to shoot our rays through
do the whole rendering loop several times, in a progressive loop
only shoot for those rays that fit the current refinement step
calculate the ray direction
shoot a ray, and fill a whole area of pixels with whatever comes back
every few lines, blit the stuff out onto the screen
make sure to peek for messages every now and then, so the render can actually be cancelled
blit the final image out
Definition at line 689 of file RayEngine.cpp.
References cam, DrawRect(), rayHdc, rayHglrc, ShootRay(), wnd_3d, and wnd_main.
Referenced by EditTransferHandle(), HistogramProc(), OptionsProc(), RayProc(), and ShovelData().
bool ShadeStep | ( | vect & | dir, | |
vect & | pos, | |||
color & | col, | |||
float | steplen | |||
) |
Shade a step along the current ray.
break off if the contribution is less than 1 percent
get the current sample value
also grab the gradient at that position
only normalize if the gradient is actually there
get an interpolated material
scale our transparency with the gradient (if wanted), and the step length
start by placing the ambient color into our output
compute diffuse coefficient
compute specular component (simple phong)
finally, comp it into the color
pos | view direction |
col | position |
steplen | in/output color length of the step (for scaling transparency) |
Definition at line 479 of file RayEngine.cpp.
References CreateInterpolatedHandle(), GetGradient(), GetInterpolatedSample(), and ldir.
Referenced by ShootRay().
color ShootRay | ( | vect | org, | |
vect | dir | |||
) |
Shoot a ray into our scene. Return whatever color info we get.
if nsects is zero, we don't hit the volume box
if nsects is 1 we are inside the box, looking out.
if we are shading fully, do this
else, we want MIP
dir | ray start ray direction |
Definition at line 578 of file RayEngine.cpp.
References CreateInterpolatedHandle(), GetBoxIntersection(), GetInterpolatedSample(), GetRand01(), ShadeStep(), and vol_opts.
Referenced by RayRender().
void ShovelData | ( | ) |
Take the raw data, normalize it to [0, 1], treat it with bias/gain/gamma, and put it into voldat.
create progress box
and show it
grab progress bar id
setup the progress bar extent
rebuild all three slices
kill progress bar
rebuild the histogram
and render it
Definition at line 31 of file RayEngine.cpp.
References BuildOrthoSlice(), CalcHistogram(), DrawHistogram(), DrawOrtho(), hInst, IDC_PROGRESS, IDD_PROGRESS, OogleVal(), ProgressProc(), rawdat, rawmax, RayRender(), voldat, volx, voly, volz, wnd_front, wnd_histogram, wnd_left, wnd_main, and wnd_top.
Referenced by LoadDataFile(), and ToolBarProc().
camera cam |
Definition at line 12 of file RayWnd.cpp.
Referenced by DrawRay(), InitCam(), RayProc(), and RayRender().
vect ldir |
the camera
Definition at line 13 of file RayWnd.cpp.
Referenced by DrawLight(), InitLight(), RayProc(), and ShadeStep().
unsigned short* rawdat |
Implements all the heavy lifting
Definition at line 9 of file RayEngine.cpp.
Referenced by LoadDataFile(), and ShovelData().
unsigned short rawmax |
HDC rayHdc |
Implements the raycasting volume view
Definition at line 9 of file RayWnd.cpp.
Referenced by DeInitRay(), DrawRay(), InitRay(), and RayRender().
HGLRC rayHglrc |
Definition at line 10 of file RayWnd.cpp.
Referenced by DeInitRay(), DrawRay(), InitRay(), and RayRender().
float* voldat |
raw volume data
Definition at line 10 of file RayEngine.cpp.
Referenced by BuildOrthoSlice(), CalcHistogram(), DrawOrtho(), GetSample(), LoadDataFile(), OrthoProc(), and ShovelData().
unsigned int volx |
normalized and treated volume data
Definition at line 11 of file RayEngine.cpp.
Referenced by BuildOrthoSlice(), CalcHistogram(), DrawGrid(), DrawOrtho(), GetBoxIntersection(), GetInterpolatedSample(), GetSample(), InitCam(), LoadDataFile(), MoveHandle(), ShiftSlice(), and ShovelData().
unsigned int voly |
Definition at line 11 of file RayEngine.cpp.
Referenced by BuildOrthoSlice(), CalcHistogram(), DrawGrid(), DrawOrtho(), GetBoxIntersection(), GetInterpolatedSample(), GetSample(), InitCam(), LoadDataFile(), MoveHandle(), ShiftSlice(), and ShovelData().
unsigned int volz |
Definition at line 11 of file RayEngine.cpp.
Referenced by BuildOrthoSlice(), CalcHistogram(), DrawGrid(), DrawOrtho(), GetBoxIntersection(), GetInterpolatedSample(), InitCam(), LoadDataFile(), MoveHandle(), ShiftSlice(), and ShovelData().
HWND wnd_main |
x, y and z size of the data
Definition at line 16 of file Volumizer.cpp.
Referenced by _tWinMain(), GetOpenFile(), InitInstance(), RayRender(), ShovelData(), and SplitterProc().