Rendering classes


Files

file  CRenderObj.cpp
 This file contains the implementation of the CRenderObj class.
file  CRenderObj.h
 This file contains the declaration of the CRenderObj class,.
file  CVectBase.cpp
 This file contains the implementation of the CVectBase class.
file  CVectBase.h
 This file contains the declaration of the CVectBase class.

Classes

class  CRenderObj
 This class holds all the necessary data to render the mathematical surface. More...
class  CVectBase
 This class represents a normalized vector base which will be used to ray-trace. More...

Defines

#define OPTION_PERSPECTIVE   (1 << 0)
 With or without perspective.
#define OPTION_BOUNDINGBOX   (1 << 1)
 With or without the bounding box drawn.
#define OPTION_SIGN   (1 << 2)
 With or without knowing that a point is part of the surface is done by the change in the sign of the expression.
#define OPTION_OPENGLSPECULAR   (1 << 3)
 With or without OpenGL specular lightning.

Functions

 CRenderObj::CRenderObj ()
 This is the default constructor.
void CRenderObj::Copy (const CRenderObj &obj)
 This function copies a CRenderObj.
void CRenderObj::Update (void)
 This function recalculates what depends on other parameters.
std::string CRenderObj::Validate () const
 This function makes sure all the parameters are valid.
CVector3f CRenderObj::GetDirection (int x, int y) const
 This function returns the direction of the ray corresponding to a pixel.
CVector3f CRenderObj::GetStartingPoint (int x, int y) const
 This function returns the starting point of the ray corresponding to a pixel.
void CRenderObj::GetCloseToBoundingBox (CVector3f &StartingPoint, const CVector3f &Direction) const
 This function gets the starting point as close as possible to the bounding box.
CColor CRenderObj::GetPixelColor (int x, int y) const
 This function returns the color of a pixel in a given direction.
 CVectBase::CVectBase ()
 The CVectBase default constructor.
 CVectBase::CVectBase (const CVector3f &viewerpos, const CVector3f &boxpos, float radius, bool update=true)
 The CVectBase constructor by parameters.
void CVectBase::Update (void)
 This function recalculate the three vectors of the base.

Detailed Description


Define Documentation

#define OPTION_BOUNDINGBOX   (1 << 1)

With or without the bounding box drawn.

Definition at line 27 of file CRenderObj.h.

Referenced by CRenderObj::CRenderObj(), CCommandExecutor::Execute(), and CRenderObj::GetPixelColor().

#define OPTION_OPENGLSPECULAR   (1 << 3)

With or without OpenGL specular lightning.

Definition at line 38 of file CRenderObj.h.

Referenced by CCommandExecutor::Execute(), and CRenderObj::GetPixelColor().

#define OPTION_PERSPECTIVE   (1 << 0)

With or without perspective.

Definition at line 22 of file CRenderObj.h.

Referenced by CRenderObj::CRenderObj(), CCommandExecutor::Execute(), CRenderObj::GetDirection(), and CRenderObj::GetStartingPoint().

#define OPTION_SIGN   (1 << 2)

With or without knowing that a point is part of the surface is done by the change in the sign of the expression.

Definition at line 33 of file CRenderObj.h.

Referenced by CRenderObj::CRenderObj(), CCommandExecutor::Execute(), CRenderObj::GetCloseToBoundingBox(), and CRenderObj::GetPixelColor().


Function Documentation

void CRenderObj::Copy ( const CRenderObj obj  )  [private, inherited]

This function copies a CRenderObj.

This function is used in the copy constructor and in the assignment operator.

Definition at line 72 of file CRenderObj.cpp.

References CRenderObj::m_BackgroundColor, CRenderObj::m_BoxAmbientColor, CRenderObj::m_BoxDiffuseColor, CRenderObj::m_BoxSpecularColor, CRenderObj::m_BoxSpecularExponent, CRenderObj::m_CenterPos, CRenderObj::m_FormulaString, CRenderObj::m_Height, CRenderObj::m_LightDirection, CRenderObj::m_MaxVector, CRenderObj::m_MinVector, CRenderObj::m_NoSignIncrement, CRenderObj::m_NoSignPrecision, CRenderObj::m_Options, CRenderObj::m_SignIncrement, CRenderObj::m_SurfaceAmbientColor, CRenderObj::m_SurfaceDiffuseColor, CRenderObj::m_SurfaceSpecularColor, CRenderObj::m_SurfaceSpecularExponent, CRenderObj::m_ViewerPos, CRenderObj::m_Width, CRenderObj::m_Zoom, and CRenderObj::Update().

Referenced by CRenderObj::CRenderObj(), and CRenderObj::operator=().

CRenderObj::CRenderObj (  )  [inherited]

This is the default constructor.

It sets all the settings to their default value.

Definition at line 34 of file CRenderObj.cpp.

References CRenderObj::m_BoxSpecularExponent, CRenderObj::m_Height, CRenderObj::m_NoSignIncrement, CRenderObj::m_NoSignPrecision, CRenderObj::m_Options, CRenderObj::m_pFormula, CRenderObj::m_pFormulaDx, CRenderObj::m_pFormulaDy, CRenderObj::m_pFormulaDz, CRenderObj::m_SignIncrement, CRenderObj::m_SurfaceSpecularExponent, CRenderObj::m_Width, CRenderObj::m_Zoom, OPTION_BOUNDINGBOX, OPTION_PERSPECTIVE, and OPTION_SIGN.

CVectBase::CVectBase ( const CVector3f viewerpos,
const CVector3f boxpos,
float  radius,
bool  update = true 
) [inherited]

The CVectBase constructor by parameters.

This constructor calculates the vectors of the base.

Definition at line 42 of file CVectBase.cpp.

References CVectBase::m_Radius, and CVectBase::Update().

CVectBase::CVectBase (  )  [inherited]

The CVectBase default constructor.

This constructor does not calculate the vectors of the base.

Definition at line 33 of file CVectBase.cpp.

References CVectBase::m_Radius.

void CRenderObj::GetCloseToBoundingBox ( CVector3f StartingPoint,
const CVector3f Direction 
) const [private, inherited]

This function gets the starting point as close as possible to the bounding box.

It does (a maximum of) three iterations of finding the closest plan to the direction, until it gets on the bounding box.

Definition at line 366 of file CRenderObj.cpp.

References CRenderObj::m_CenterPos, CRenderObj::m_MaxVector, CRenderObj::m_MinVector, CRenderObj::m_NoSignIncrement, CRenderObj::m_Options, CRenderObj::m_SignIncrement, OPTION_SIGN, CVector3f::x, CVector3f::y, and CVector3f::z.

Referenced by CRenderObj::GetPixelColor().

CVector3f CRenderObj::GetDirection ( int  x,
int  y 
) const [private, inherited]

This function returns the direction of the ray corresponding to a pixel.

It calculates (if perspective is on) the vector going from the viewer to the (x,y) point on a plane described by the second and third vector of the base, which are perpendicular to the first vector. This plane contains the center of the bounding box and is a square that contains the sphere that contains the bounding box. If there is no perspective, the direction is simply the first vector of the base.

Definition at line 314 of file CRenderObj.cpp.

References CVectBase::getB1(), CVectBase::getB2(), CVectBase::getB3(), CVectBase::getRadius(), CRenderObj::m_Height, CRenderObj::m_Options, CRenderObj::m_VectorBase, CRenderObj::m_Width, and OPTION_PERSPECTIVE.

Referenced by CRenderObj::GetPixelColor().

CColor CRenderObj::GetPixelColor ( int  x,
int  y 
) const [inherited]

This function returns the color of a pixel in a given direction.

It uses raytracing to get the color.

Definition at line 439 of file CRenderObj.cpp.

References CRenderObj::GetCloseToBoundingBox(), CRenderObj::GetDirection(), CRenderObj::GetStartingPoint(), CMathExpression::GetValue(), CRenderObj::InBoundingBox(), CRenderObj::m_BackgroundColor, CRenderObj::m_BoxAmbientColor, CRenderObj::m_BoxDiffuseColor, CRenderObj::m_BoxSpecularColor, CRenderObj::m_BoxSpecularExponent, CRenderObj::m_LightDirection, CRenderObj::m_MaxVector, CRenderObj::m_MinVector, CRenderObj::m_NoSignIncrement, CRenderObj::m_NoSignPrecision, CRenderObj::m_Options, CRenderObj::m_pFormula, CRenderObj::m_pFormulaDx, CRenderObj::m_pFormulaDy, CRenderObj::m_pFormulaDz, CRenderObj::m_SignIncrement, CRenderObj::m_SurfaceAmbientColor, CRenderObj::m_SurfaceDiffuseColor, CRenderObj::m_SurfaceSpecularColor, CRenderObj::m_SurfaceSpecularExponent, CVector3f::Norm(), CVector3f::Normalize(), OPTION_BOUNDINGBOX, OPTION_OPENGLSPECULAR, OPTION_SIGN, CVector3f::x, CVector3f::y, and CVector3f::z.

Referenced by CCommandExecutor::Execute().

CVector3f CRenderObj::GetStartingPoint ( int  x,
int  y 
) const [private, inherited]

This function returns the starting point of the ray corresponding to a pixel.

It calculates (if perspective is off) the position of the starting point of the ray, which is the position in the picture that is taken. If there is perspective, then the starting point is always the same: the position of the viewer, but it can be put back a little bit to see all the surface, according to the zoom. If the zoom is set to 0, the viewer will be left it its position; if the zoom is set to 1, the viewer will be placed so that all the surface is seen.

Definition at line 341 of file CRenderObj.cpp.

References CVectBase::getB1(), CVectBase::getB2(), CVectBase::getB3(), CVectBase::getRadius(), CRenderObj::m_Height, CRenderObj::m_Options, CRenderObj::m_VectorBase, CRenderObj::m_ViewerPos, CRenderObj::m_Width, CRenderObj::m_Zoom, CVector3f::Norm(), and OPTION_PERSPECTIVE.

Referenced by CRenderObj::GetPixelColor().

void CVectBase::Update ( void   )  [inherited]

This function recalculate the three vectors of the base.

This is the function that builds the base.

The first vector is simply a vector going from the eye of the viewer to the center of the bounding box of the surface. The third one is obtained by substracting from the vector $ \vec{k} $ the component that is parallel to the first vector. If the first vector is parallel to $ \vec{k} $, $ \vec{j} $ is taken instead. The second vector is the cross product of the first one and the third one. Note that this base is not direct, meaning that $ \vec{B1} \times \vec{B2} = - \vec{B3} $

Definition at line 67 of file CVectBase.cpp.

References CVectBase::m_B1, CVectBase::m_B2, CVectBase::m_B3, CVectBase::m_BoxPos, CVectBase::m_ViewerPos, CVector3f::Normalize(), CVector3f::x, and CVector3f::y.

Referenced by CVectBase::CVectBase(), CVectBase::setBoxPos(), CVectBase::setViewerPos(), and CRenderObj::UpdateVectorBase().

void CRenderObj::Update ( void   )  [inherited]

This function recalculates what depends on other parameters.

It builds the expression tree for the formula itself and for its derivatives according to x, y and z.

Definition at line 105 of file CRenderObj.cpp.

References CMathExpression::GetDerivative(), CRenderObj::m_CenterPos, CRenderObj::m_FormulaString, CRenderObj::m_MaxVector, CRenderObj::m_MinVector, CRenderObj::m_pFormula, CRenderObj::m_pFormulaDx, CRenderObj::m_pFormulaDy, CRenderObj::m_pFormulaDz, CRenderObj::m_VectorBase, CRenderObj::m_ViewerPos, CVectBase::setBoxPos(), CVectBase::setRadius(), CVectBase::setViewerPos(), CValue::TYPE_X, CValue::TYPE_Y, CValue::TYPE_Z, and CMathExpression::Validate().

Referenced by CRenderObj::Copy(), and CCommandExecutor::Execute().

std::string CRenderObj::Validate (  )  const [inherited]

This function makes sure all the parameters are valid.

It returns a string containing the error message to display, or "" if all parameters are valid.

Definition at line 162 of file CRenderObj.cpp.

References CRenderObj::m_BackgroundColor, CRenderObj::m_BoxAmbientColor, CRenderObj::m_BoxDiffuseColor, CRenderObj::m_BoxSpecularColor, CRenderObj::m_BoxSpecularExponent, CRenderObj::m_FormulaString, CRenderObj::m_Height, CRenderObj::m_MaxVector, CRenderObj::m_MinVector, CRenderObj::m_NoSignIncrement, CRenderObj::m_NoSignPrecision, CRenderObj::m_SignIncrement, CRenderObj::m_SurfaceAmbientColor, CRenderObj::m_SurfaceDiffuseColor, CRenderObj::m_SurfaceSpecularColor, CRenderObj::m_SurfaceSpecularExponent, CRenderObj::m_Width, CMathExpression::Validate(), CVector3f::x, CVector3f::y, and CVector3f::z.

Referenced by CCommandExecutor::Execute().


Generated on Fri Dec 5 03:20:33 2008 for Mathematical Ray-tracer by  doxygen 1.5.4