Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ns_vu1112112::vu1112112 Class Reference

This class performs raycasting using a spectral colour model. More...

#include <spectral.h>

Inheritance diagram for ns_vu1112112::vu1112112:

Inheritance graph
[legend]
Collaboration diagram for ns_vu1112112::vu1112112:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 vu1112112 ()
 Default constructor creating an empty instance.
 vu1112112 (const vu1112112 &inst)
 Copy constructor which does a deep copy.
virtual ~vu1112112 ()
 Destructor.
vu1112112operator= (const vu1112112 &rhs)
 Assignment operator which does a deep copy.
void setViewVectors (const vuVector &pos, const vuVector &vrp, const vuVector &up)
 Sets the camera viewing position for the render method.
void initOpenGL (void)
 Initializes open gl for rendering the volume data.
void render ()
 Implements the abstract render() method of the vuVolume base class.
virtual bool read ()
 Reimplements the read() method to do some extra volume data processing.
virtual bool readRaw (void)
 This method reads volume data stored using the .raw data type.
bool add_material (Material &mat)
 adds a new material (scattering and absorption information) to the renderer
bool add_light (ColourType &lc)
 adds a light (just a colour)
bool load_scene (const char *filename)
 loads a scene setup (materials, lights, camera resolution...)
bool load_volume (char *name)
 load data
void setLight (const vuColour31a &light)
 adjust light between source 1 and 2; w E [0,1], l intensity scaling
void setImageSize (dword sx, dword sy)
 set size of the canvas to render to
void doRefresh ()
 tell that the data should be rerendered on next glRender
vuVector getCenter ()
 returns the center of the dataset
vuImagegetImage ()
void setDoSpecular (bool doit=true)
 Set whether to do specular illumination. (default true).
bool getDoSpecular ()
 Is specular illumination calculated?
void setDrawPreview (bool doit=true)
 Set whether to draw a preview. (default true).
bool getDrawPreview ()
 Will a preview be drawn?
floatgetShininess ()
 Returns handle to Shininess.
floatgetGloss ()
 Returns handle to Gloss (intensity of specular reflection).
void setObserverLight (bool moveit=true)
 Tell whether to move the light with the observer.
void setLightDir (const vuVector &lightdir)
 Set the direction of the light.
const vuVectorgetLightDir () const
 return the direction of the light

Private Member Functions

void run (int whatsup, void *data)
 Overrides virtual vuThread::run().
void shootRays (int xofs=0, int xinc=1, int yofs=0, int yinc=1)
 Renders the scene by casting the rays from the camera.
void preprocess (void)
 Preprocesses volume data for rendering once it's been read.
ColourType Cast (vuSampleRay &Vray)
 Cast a ray through the scene used by render().

Private Attributes

vuVector center
 center to rotate about
DatGrid Grid
 the grid to be rendered
ColourType Background
 Background colour.
vuColour31a Ambient
 Ambient colour for normaliztion.
ColourType m_Light [NUM_LIGHTS]
 different colours for light source
ColourType TFLUT_scatt [255]
 own internal look-up-table for scattering (color) Hopefully substituted by spectral transfer function panel.
ColourType TFLUT_absor [255]
 own internal look-up-table for absorption Hopefully substituted by spectral transfer function panel.
int numlights
 number of light sources
Material mat [MAT_NUM_MATERIALS]
 list of materials
int nummat
 number of materials
vuSpectralImage spimg
 image with spectral information for each pixel
vuImage rgbimg
 The rgb image that will be displayed onto the screen.
vuVector m_LightDir
 direction of light vector
bool m_ObserverLight
 move the light with the viewpoint?
float brightness
 scalar to toogle brightness of light source
float diffuse
 weight for diffuse gradient shading
float light_scale
 max value for the brightness slider
bool re_light
bool re_render
 refresh tags
byteimgbuf
 buffer for the image.
bool use_flat_absorption
 optimize using plain alpha blending
bool pp_gradients
 gradients already preprocessed?
vuMutex m_Mutex [2]
bool m_DoSpecular
 do specular illumination?
bool m_DrawPreview
 draw preview?
float m_Shininess
 shininess for specular reflection
float m_Gloss
 intensity of specular reflection

Friends

class Parser
class DatGrid
class DatPnt

Detailed Description

This class performs raycasting using a spectral colour model.

This allows modelling special physical properties of light like spectral absorption and metamerism. long name: vuVolumeRegularUnimodal3d1B1ValSpectral

Author:
Steven Bergner (using color models implemented by Steve Kilthau)

Definition at line 38 of file spectral.h.


Constructor & Destructor Documentation

ns_vu1112112::vu1112112::vu1112112  ) 
 

Default constructor creating an empty instance.

Definition at line 29 of file spectral.cpp.

References brightness, ColourType, diffuse, imgbuf, light_scale, m_DoSpecular, m_DrawPreview, m_Gloss, m_LightDir, m_ObserverLight, m_Shininess, vuColour< S >::nComponents(), numlights, nummat, re_light, re_render, vuTFIntensity::resize(), vuCamera::setHeight(), and vuCamera::setWidth().

Here is the call graph for this function:

ns_vu1112112::vu1112112::vu1112112 const vu1112112 inst  ) 
 

Copy constructor which does a deep copy.

Definition at line 56 of file spectral.cpp.

References operator=().

Here is the call graph for this function:

ns_vu1112112::vu1112112::~vu1112112  )  [virtual]
 

Destructor.

Definition at line 65 of file spectral.cpp.

References imgbuf.


Member Function Documentation

bool ns_vu1112112::vu1112112::add_light ColourType lc  ) 
 

adds a light (just a colour)

Definition at line 553 of file spectral.cpp.

References ColourType, m_Light, and numlights.

Referenced by ns_vu1112112::Parser::ReadLight().

bool ns_vu1112112::vu1112112::add_material Material mat  ) 
 

adds a new material (scattering and absorption information) to the renderer

Definition at line 562 of file spectral.cpp.

References nummat.

Referenced by ns_vu1112112::Parser::ReadMaterial().

ColourType ns_vu1112112::vu1112112::Cast vuSampleRay Vray  )  [private]
 

Cast a ray through the scene used by render().

Definition at line 389 of file spectral.cpp.

References ns_vu1112112::Material::absorption, ns_vu1112112::vuSampleRay::advanceRay(), ns_vu1112112::vuSampleRay::attachToGrid(), Background, ColourType, ns_vu1112112::DatPnt::data, vuVector::dot, ns_vu1112112::vuSampleRay::getSamplePoint(), ns_vu1112112::vuSampleRay::getSamplePointWithGradient(), ns_vu1112112::DatPnt::grad, Grid, ns_vu1112112::DatPnt::illum, ns_vu1112112::DatPnt::length, vuRay::m_Direction, m_DoSpecular, m_LightDir, vuVector::makeUnit(), mat, vuColour< S >::maxComponent(), vuColour< S >::oneMinus(), pow(), ns_vu1112112::vuSampleRay::SamplingDistance(), ns_vu1112112::Material::scattering, TFLUT_absor, TFLUT_scatt, use_flat_absorption, and ns_vu1112112::Material::xray.

Referenced by shootRays().

Here is the call graph for this function:

void ns_vu1112112::vu1112112::doRefresh  ) 
 

tell that the data should be rerendered on next glRender

default behaviour is to just blit the intermediate framebuffer

Definition at line 571 of file spectral.cpp.

References re_render.

Referenced by vuSpectral::DrawAgain(), and vuSpectral::OnButtonRender().

vuVector ns_vu1112112::vu1112112::getCenter  ) 
 

returns the center of the dataset

Definition at line 576 of file spectral.cpp.

Referenced by vuSpectral::OnButtonLightPos().

bool ns_vu1112112::vu1112112::getDoSpecular  )  [inline]
 

Is specular illumination calculated?

Definition at line 95 of file spectral.h.

bool ns_vu1112112::vu1112112::getDrawPreview  )  [inline]
 

Will a preview be drawn?

Definition at line 99 of file spectral.h.

float& ns_vu1112112::vu1112112::getGloss  )  [inline]
 

Returns handle to Gloss (intensity of specular reflection).

Definition at line 103 of file spectral.h.

vuImage * ns_vu1112112::vu1112112::getImage  ) 
 

Definition at line 581 of file spectral.cpp.

References imgbuf, rgbimg, and vuImage::set_data().

Referenced by vuSpectral::getCurrentImage().

Here is the call graph for this function:

const vuVector& ns_vu1112112::vu1112112::getLightDir  )  const [inline]
 

return the direction of the light

Definition at line 113 of file spectral.h.

float& ns_vu1112112::vu1112112::getShininess  )  [inline]
 

Returns handle to Shininess.

Definition at line 101 of file spectral.h.

void ns_vu1112112::vu1112112::initOpenGL void   ) 
 

Initializes open gl for rendering the volume data.

Definition at line 383 of file spectral.cpp.

Referenced by vuSpectral::glInit().

bool ns_vu1112112::vu1112112::load_scene const char *  filename  ) 
 

loads a scene setup (materials, lights, camera resolution...)

The function is intended to be piecewise replaced by additional features of vuVolume (e.g. spectral transfer function panel with load and save...)

Definition at line 535 of file spectral.cpp.

References center, imgbuf, vuCamera::init(), numlights, nummat, ns_vu1112112::Parser::Parse(), preprocess(), vuCamera::setPosition(), and vuCamera::translateXYZ().

Referenced by vuSpectral::OnButtonLoadSetup().

Here is the call graph for this function:

bool ns_vu1112112::vu1112112::load_volume char *  name  ) 
 

load data

This function copies the entire volume into a seperate DatGrid structure.

vu1112112 & ns_vu1112112::vu1112112::operator= const vu1112112 rhs  ) 
 

Assignment operator which does a deep copy.

Definition at line 79 of file spectral.cpp.

References Grid, vu1112::operator=(), re_light, and re_render.

Referenced by vu1112112().

Here is the call graph for this function:

void ns_vu1112112::vu1112112::preprocess void   )  [private]
 

Preprocesses volume data for rendering once it's been read.

Definition at line 197 of file spectral.cpp.

References ns_vu1112112::Material::absorption, ns_vu1112112::DatGrid::calculate_gradients(), ns_vu1112112::DatGrid::classify(), ColourType, data, Grid, ns_vu1112112::Material::high_th, ns_vu1112112::Material::low_th, mat, pp_gradients, ns_vu1112112::Material::scattering, ns_vu1112112::DatGrid::shade(), TFLUT_absor, and TFLUT_scatt.

Referenced by load_scene(), read(), and readRaw().

Here is the call graph for this function:

bool ns_vu1112112::vu1112112::read  )  [virtual]
 

Reimplements the read() method to do some extra volume data processing.

Reimplemented from vu11121.

Definition at line 121 of file spectral.cpp.

References center, Grid, imgbuf, ns_vu1112112::DatGrid::load_vol(), pp_gradients, preprocess(), re_light, re_render, vu11121::read(), setImageSize(), vuCamera::setPosition(), and vuCamera::translateXYZ().

Referenced by vuSpectral::init().

Here is the call graph for this function:

bool ns_vu1112112::vu1112112::readRaw void   )  [virtual]
 

This method reads volume data stored using the .raw data type.

Definition at line 150 of file spectral.cpp.

References byte, center, dword, Grid, imgbuf, vuCamera::init(), ns_vu1112112::DatGrid::load_vol(), pp_gradients, preprocess(), re_light, re_render, setImageSize(), vuCamera::setPosition(), and vuCamera::translateXYZ().

Here is the call graph for this function:

void ns_vu1112112::vu1112112::render  )  [virtual]
 

Implements the abstract render() method of the vuVolume base class.

Reimplemented from vu11121.

Definition at line 319 of file spectral.cpp.

References byte, ns_vu1112112::DatGrid::classify(), vuSpectralImage::create_black_mask(), ns_vu1112112::Material::flat_absorption, vuSpectralImage::get_extents(), vuSpectralImage::get_rgb(), vuCamera::getLookAtVector(), vuCamera::getPosition(), GL_RGB, GL_UNPACK_ALIGNMENT, GL_UNSIGNED_BYTE, glDrawPixels(), glPixelStorei(), glRasterPos2i(), Grid, imgbuf, vuMutex::lock(), m_Mutex, mat, nummat, re_light, re_render, shootRays(), spimg, vuThread::startThread(), vuMutex::unlock(), and use_flat_absorption.

Referenced by vuSpectral::glRender().

Here is the call graph for this function:

void ns_vu1112112::vu1112112::run int  whatsup,
void *  data
[private, virtual]
 

Overrides virtual vuThread::run().

Calls shootRays to distribute rendering to two different threads.

Implements vuThread.

Definition at line 300 of file spectral.cpp.

References dword, vuCamera::getHeight(), m_Mutex, shootRays(), and vuMutex::unlock().

Here is the call graph for this function:

void ns_vu1112112::vu1112112::setDoSpecular bool  doit = true  )  [inline]
 

Set whether to do specular illumination. (default true).

Definition at line 93 of file spectral.h.

Referenced by vuSpectral::addRight(), and vuSpectral::handleGUIevent().

void ns_vu1112112::vu1112112::setDrawPreview bool  doit = true  )  [inline]
 

Set whether to draw a preview. (default true).

Definition at line 97 of file spectral.h.

Referenced by vuSpectral::addRight(), and vuSpectral::handleGUIevent().

void ns_vu1112112::vu1112112::setImageSize dword  sx,
dword  sy
 

set size of the canvas to render to

Definition at line 91 of file spectral.cpp.

References byte, vuCamera::getHeight(), vuCamera::getWidth(), imgbuf, vuSpectralImage::init(), vuCamera::init(), vuCamera::setHeight(), vuCamera::setWidth(), and spimg.

Referenced by vuSpectral::glResize(), read(), and readRaw().

Here is the call graph for this function:

void ns_vu1112112::vu1112112::setLight const vuColour31a light  ) 
 

adjust light between source 1 and 2; w E [0,1], l intensity scaling

Definition at line 511 of file spectral.cpp.

References ColourType, ns_vu1112112::light, re_light, vuSpectralImage::set_light(), and spimg.

Referenced by vuSpectral::glRender().

Here is the call graph for this function:

void ns_vu1112112::vu1112112::setLightDir const vuVector lightdir  )  [inline]
 

Set the direction of the light.

Definition at line 108 of file spectral.h.

Referenced by vuSpectral::OnButtonLightPos().

void ns_vu1112112::vu1112112::setObserverLight bool  moveit = true  )  [inline]
 

Tell whether to move the light with the observer.

Definition at line 105 of file spectral.h.

void ns_vu1112112::vu1112112::setViewVectors const vuVector pos,
const vuVector vrp,
const vuVector up
[virtual]
 

Sets the camera viewing position for the render method.

Reimplemented from vu11121.

Definition at line 108 of file spectral.cpp.

References vuCamera::init(), vuCamera::setLookAtVector(), vuCamera::setPosition(), and vuCamera::setUpVector().

Here is the call graph for this function:

void ns_vu1112112::vu1112112::shootRays int  xofs = 0,
int  xinc = 1,
int  yofs = 0,
int  yinc = 1
[private]
 

Renders the scene by casting the rays from the camera.

The parameters can be used to render only specific pixels. That can be used for progressive rendering or rendering distributed to different processes. The default values setup for full rendering.

Parameters:
xofs pixel offset in each line
xinc increment determining the space between two pixels on one line
yofs line to start with
yinc step size to next line

Definition at line 242 of file spectral.cpp.

References Cast(), vuColour< S >::clampTo01(), ColourType, vuColourRGBa::from(), vuColourXYZa::from(), vuSpectralImage::get_light(), vuCamera::getHeight(), vuCamera::getRay(), vuCamera::getWidth(), GL_POINTS, glBegin(), vuColourRGBa::glColor(), glEnd(), glVertex2f(), re_light, vuSpectralImage::set_xy(), and spimg.

Referenced by render(), and run().

Here is the call graph for this function:


Friends And Related Function Documentation

friend class DatGrid [friend]
 

Definition at line 41 of file spectral.h.

friend class DatPnt [friend]
 

Definition at line 42 of file spectral.h.

friend class Parser [friend]
 

Definition at line 40 of file spectral.h.


Member Data Documentation

vuColour31a ns_vu1112112::vu1112112::Ambient [private]
 

Ambient colour for normaliztion.

Definition at line 138 of file spectral.h.

ColourType ns_vu1112112::vu1112112::Background [private]
 

Background colour.

Definition at line 137 of file spectral.h.

Referenced by Cast(), and ns_vu1112112::Parser::ReadGeneral().

float ns_vu1112112::vu1112112::brightness [private]
 

scalar to toogle brightness of light source

Definition at line 156 of file spectral.h.

Referenced by ns_vu1112112::Parser::ReadGeneral(), ns_vu1112112::DatPnt::shade(), and vu1112112().

vuVector ns_vu1112112::vu1112112::center [private]
 

center to rotate about

Definition at line 134 of file spectral.h.

Referenced by load_scene(), read(), and readRaw().

float ns_vu1112112::vu1112112::diffuse [private]
 

weight for diffuse gradient shading

Definition at line 157 of file spectral.h.

Referenced by ns_vu1112112::Parser::ReadGeneral(), ns_vu1112112::DatPnt::shade(), and vu1112112().

DatGrid ns_vu1112112::vu1112112::Grid [private]
 

the grid to be rendered

Definition at line 136 of file spectral.h.

Referenced by Cast(), operator=(), preprocess(), read(), readRaw(), and render().

byte* ns_vu1112112::vu1112112::imgbuf [private]
 

buffer for the image.

This expires when we have more sophisticated vuDrawTools

Definition at line 162 of file spectral.h.

Referenced by getImage(), load_scene(), read(), readRaw(), render(), setImageSize(), vu1112112(), and ~vu1112112().

float ns_vu1112112::vu1112112::light_scale [private]
 

max value for the brightness slider

Definition at line 158 of file spectral.h.

Referenced by ns_vu1112112::Parser::ReadGeneral(), and vu1112112().

bool ns_vu1112112::vu1112112::m_DoSpecular [private]
 

do specular illumination?

Definition at line 167 of file spectral.h.

Referenced by Cast(), and vu1112112().

bool ns_vu1112112::vu1112112::m_DrawPreview [private]
 

draw preview?

Definition at line 168 of file spectral.h.

Referenced by vu1112112().

float ns_vu1112112::vu1112112::m_Gloss [private]
 

intensity of specular reflection

Definition at line 170 of file spectral.h.

Referenced by vu1112112().

ColourType ns_vu1112112::vu1112112::m_Light[NUM_LIGHTS] [private]
 

different colours for light source

Definition at line 139 of file spectral.h.

Referenced by add_light().

vuVector ns_vu1112112::vu1112112::m_LightDir [private]
 

direction of light vector

Definition at line 154 of file spectral.h.

Referenced by Cast(), ns_vu1112112::Parser::ReadGeneral(), ns_vu1112112::DatPnt::shade(), and vu1112112().

vuMutex ns_vu1112112::vu1112112::m_Mutex[2] [private]
 

Definition at line 165 of file spectral.h.

Referenced by render(), and run().

bool ns_vu1112112::vu1112112::m_ObserverLight [private]
 

move the light with the viewpoint?

Definition at line 155 of file spectral.h.

Referenced by vu1112112().

float ns_vu1112112::vu1112112::m_Shininess [private]
 

shininess for specular reflection

Definition at line 169 of file spectral.h.

Referenced by vu1112112().

Material ns_vu1112112::vu1112112::mat[MAT_NUM_MATERIALS] [private]
 

list of materials

Definition at line 150 of file spectral.h.

Referenced by Cast(), ns_vu1112112::DatPnt::classify(), preprocess(), and render().

int ns_vu1112112::vu1112112::numlights [private]
 

number of light sources

Definition at line 149 of file spectral.h.

Referenced by add_light(), load_scene(), and vu1112112().

int ns_vu1112112::vu1112112::nummat [private]
 

number of materials

Definition at line 151 of file spectral.h.

Referenced by add_material(), ns_vu1112112::DatPnt::classify(), load_scene(), render(), and vu1112112().

bool ns_vu1112112::vu1112112::pp_gradients [private]
 

gradients already preprocessed?

Definition at line 164 of file spectral.h.

Referenced by preprocess(), read(), and readRaw().

bool ns_vu1112112::vu1112112::re_light [private]
 

Definition at line 159 of file spectral.h.

Referenced by operator=(), read(), readRaw(), render(), setLight(), shootRays(), and vu1112112().

bool ns_vu1112112::vu1112112::re_render [private]
 

refresh tags

Definition at line 159 of file spectral.h.

Referenced by doRefresh(), operator=(), read(), readRaw(), render(), and vu1112112().

vuImage ns_vu1112112::vu1112112::rgbimg [private]
 

The rgb image that will be displayed onto the screen.

Definition at line 153 of file spectral.h.

Referenced by getImage().

vuSpectralImage ns_vu1112112::vu1112112::spimg [private]
 

image with spectral information for each pixel

Definition at line 152 of file spectral.h.

Referenced by render(), setImageSize(), setLight(), and shootRays().

ColourType ns_vu1112112::vu1112112::TFLUT_absor[255] [private]
 

own internal look-up-table for absorption Hopefully substituted by spectral transfer function panel.

Definition at line 147 of file spectral.h.

Referenced by Cast(), and preprocess().

ColourType ns_vu1112112::vu1112112::TFLUT_scatt[255] [private]
 

own internal look-up-table for scattering (color) Hopefully substituted by spectral transfer function panel.

Definition at line 143 of file spectral.h.

Referenced by Cast(), and preprocess().

bool ns_vu1112112::vu1112112::use_flat_absorption [private]
 

optimize using plain alpha blending

Definition at line 163 of file spectral.h.

Referenced by Cast(), and render().


The documentation for this class was generated from the following files:
Generated on Wed Dec 15 21:22:12 2004 for vuVolume by  doxygen 1.3.9.1