Main Page | Alphabetical List | Class List | File List | Class Members | File Members

Dsp Class Reference

#include <dsp.h>

Collaboration diagram for Dsp:

[legend]
List of all members.
Date:
20-Jun-2011
Author:
Luiz F. Martha
Version:
1.0
This file contains class definition of the module of current project that displays a solid box.

See specification of public functions of this module in hearder file "dsp.h".

Revisions:

  • Version 1.0 by L.F. Martha on 20-Jun-2011: Initial version. Incomplete version, to be complete as part of current assignment.


static void SetupView (cdCanvas *zbuffer_canvas)
 This function adjusts the initial camera model parameters (camera position, reference point position, and view up-vector) and view volume parameters according to current model bounding box.
static void RotateView (void)
 This function recalculates the camera position based on a increment of a rotation around the reference point.
static void ZbfModel (cdCanvas *zbuffer_canvas)
static long int ShadeColor (Vec *normal, Vec *view, long int color)
 Change color intensity taking into account polygon normal vector orientation with respect to view vector.
static void DisplaySolid (void)
 This function displays a box object with faces normal to x axis in green color, faces normal to y axis in cyan color, and faces normato to z axis in yellow color.
static void ZbfBeginPoly (long int color, double nx, double ny, double nz)
 This function starts to send a new polygon to the zbuffer module to display.
static void ZbfVertex (double x, double y, double z)
 This function project a polygon vertex and send it to the zbuffer module in the process of displaying a face.
static void ZbfEndPoly (void)
 This function finishes the specification of a polygon to be displayed in zbuffer module.
static double MIN_COLOR_INTENS = 0.50
 Constant for minimum color intensity.
static int FRAMES = 720
 Number of frames in a complete 360 degree rotation around object.
static double M_PI = 3.141592654
 The number PI.
static double alpha = 0.0
 Rotation angle.
static double delta = 2.0*Dsp::M_PI/Dsp::FRAMES
 Rotation increment angle.
static Vec view_vector = { 0.0, 0.0, 0.0 }
 Current view vector.
static Vec box [8]
 Current solid to display.
static double xmin = 0.0
 Model bouding box.
static double xmax = 1.0
 Model bouding box.
static double ymin = 0.0
 Model bouding box.
static double ymax = 2.0
 Model bouding box.
static double zmin = 0.0
 Model bouding box.
static double zmax = 3.0
 Model bouding box.
static double eyex = 0.0
 Camera position parameters.
static double eyey = 0.0
 Camera position parameters.
static double eyez = 0.0
 Camera position parameters.
static double refx = 0.0
 Reference point position.
static double refy = 0.0
 Reference point position.
static double refz = 0.0
 Reference point position.
static double vupx = 0.0
 View up-vector.
static double vupy = 0.0
 View up-vector.
static double vupz = 0.0
 View up-vector.
static double left = 0.0
 View volume parameters.
static double right = 0.0
 View volume parameters.
static double bottom = 0.0
 View volume parameters.
static double top = 0.0
 View volume parameters.
static double front = 0.0
 View volume parameters.
static double back = 0.0
 View volume parameters.

Static Private Member Functions

static double get_red (long int color)
 Given a long int coded color, get the red component intensity from 0 to 1.
static double get_green (long int color)
 Given a long int coded color, get the green component intensity from 0 to 1.
static double get_blue (long int color)
 Given a long int coded color, get the blue component intensity from 0 to 1.
static void VecUnit (Vec *a, Vec *b)
 Function to normalize a 3D vector.
static double VecDot (Vec *a, Vec *b)
 Function to compute the dot product between two 3D vectors.
static void DecodeColor (long int color, unsigned char *red, unsigned char *green, unsigned char *blue)
 Function to decode a long int coded color into the RGB components (in integer values between 0 and 255).
static long int EncodeColor (unsigned char red, unsigned char green, unsigned char blue)
 Function to encode RGB components (in integer values between 0 and 255) into a long int coded color.
static double MAX (double a, double b)
 This function returns the maximum value between two doubles.

Classes

struct  Vec
 3D vector struct More...

Member Function Documentation

static void Dsp::DecodeColor long int  color,
unsigned char *  red,
unsigned char *  green,
unsigned char *  blue
[inline, static, private]
 

Function to decode a long int coded color into the RGB components (in integer values between 0 and 255).

Parameters:
color - coded color (in)
red - red component of given color (out)
green - green component of given color (out)
blue - blue component of given color (out)

Definition at line 192 of file dsp.h.

Referenced by ShadeColor().

void Dsp::DisplaySolid void   )  [static, private]
 

This function displays a box object with faces normal to x axis in green color, faces normal to y axis in cyan color, and faces normato to z axis in yellow color.

Definition at line 152 of file dsp.cpp.

References box, ZbfBeginPoly(), ZbfEndPoly(), and ZbfVertex().

Referenced by ZbfModel().

static long int Dsp::EncodeColor unsigned char  red,
unsigned char  green,
unsigned char  blue
[inline, static, private]
 

Function to encode RGB components (in integer values between 0 and 255) into a long int coded color.

Parameters:
red - red component of color (out)
green - green component of color (out)
blue - blue component of color (out)
Returns:
Coded color.

Definition at line 213 of file dsp.h.

Referenced by ShadeColor(), and ZbfModel().

static double Dsp::get_blue long int  color  )  [inline, static, private]
 

Given a long int coded color, get the blue component intensity from 0 to 1.

Parameters:
color - coded color (in)
Returns:
Blue intensity (between 0 and 1) of given coded color.

Definition at line 147 of file dsp.h.

static double Dsp::get_green long int  color  )  [inline, static, private]
 

Given a long int coded color, get the green component intensity from 0 to 1.

Parameters:
color - coded color (in)
Returns:
Green intensity (between 0 and 1) of given coded color.

Definition at line 133 of file dsp.h.

static double Dsp::get_red long int  color  )  [inline, static, private]
 

Given a long int coded color, get the red component intensity from 0 to 1.

Parameters:
color - coded color (in)
Returns:
Red intensity (between 0 and 1) of given coded color.

Definition at line 119 of file dsp.h.

static double Dsp::MAX double  a,
double  b
[inline, static, private]
 

This function returns the maximum value between two doubles.

Definition at line 238 of file dsp.h.

Referenced by SetupView().

void Dsp::RotateView void   )  [static]
 

This function recalculates the camera position based on a increment of a rotation around the reference point.

Definition at line 300 of file dsp.cpp.

References alpha, delta, eyex, eyey, refx, and refy.

Referenced by Prj::DspRotateView().

void Dsp::SetupView cdCanvas *  zbuffer_canvas  )  [static]
 

This function adjusts the initial camera model parameters (camera position, reference point position, and view up-vector) and view volume parameters according to current model bounding box.

Parameters:
zbuffer_canvas - CD handle to zbuffer canvas (in)

Definition at line 239 of file dsp.cpp.

References back, bottom, eyex, eyey, eyez, front, left, MAX(), refx, refy, refz, right, top, vupx, vupy, vupz, xmax, xmin, ymax, ymin, zmax, and zmin.

Referenced by Prj::Init().

long int Dsp::ShadeColor Vec normal,
Vec view,
long int  color
[static, private]
 

Change color intensity taking into account polygon normal vector orientation with respect to view vector.

All computations should be performed in object coordinates.

Parameters:
normal - polygon normal vector (in)
view - view vector (in)
Returns:
Changed color with shaded intensitity.

Definition at line 124 of file dsp.cpp.

References DecodeColor(), EncodeColor(), MIN_COLOR_INTENS, and VecDot().

Referenced by ZbfBeginPoly().

static double Dsp::VecDot Vec a,
Vec b
[inline, static, private]
 

Function to compute the dot product between two 3D vectors.

Parameters:
a,b - given vectors (in)
Returns:
Dot product of two given vectors.

Definition at line 178 of file dsp.h.

References Dsp::Vec::x, Dsp::Vec::y, and Dsp::Vec::z.

Referenced by ShadeColor().

static void Dsp::VecUnit Vec a,
Vec b
[inline, static, private]
 

Function to normalize a 3D vector.

Parameters:
a - given vector (in)
b - normalized vector (out)

Definition at line 158 of file dsp.h.

References Dsp::Vec::x, Dsp::Vec::y, and Dsp::Vec::z.

Referenced by ZbfModel().

void Dsp::ZbfBeginPoly long int  color,
double  nx,
double  ny,
double  nz
[static, private]
 

This function starts to send a new polygon to the zbuffer module to display.

It displays with the given coded color and changes the color intensity taking into account the given polygon normal vector orientation with respect to view vector.

Parameters:
color - polygon coded color (in)
nx - x component to polygon normal (in)
ny - y component to polygon normal (in)
nz - z component to polygon normal (in)

Definition at line 205 of file dsp.cpp.

References Zbf::BeginPoly(), ShadeColor(), view_vector, Dsp::Vec::x, Dsp::Vec::y, and Dsp::Vec::z.

Referenced by DisplaySolid().

void Dsp::ZbfEndPoly void   )  [static, private]
 

This function finishes the specification of a polygon to be displayed in zbuffer module.

Definition at line 227 of file dsp.cpp.

References Zbf::EndPoly().

Referenced by DisplaySolid().

void Dsp::ZbfModel cdCanvas *  zbuffer_canvas  )  [static]
 

Definition at line 321 of file dsp.cpp.

References DisplaySolid(), EncodeColor(), eyex, eyey, eyez, T3d::Identity(), refx, refy, refz, VecUnit(), view_vector, Dsp::Vec::x, Dsp::Vec::y, and Dsp::Vec::z.

Referenced by Prj::DspRotateView(), and Prj::DspZbufferCanvas().

void Dsp::ZbfVertex double  x,
double  y,
double  z
[static, private]
 

This function project a polygon vertex and send it to the zbuffer module in the process of displaying a face.

To project a vertex means to transform it from modeling (object) coordinates to normalized screen coordinates.

Parameters:
x - x coordinate of polygon vertex (in)
y - y coordinate of polygon vertex (in)
z - z coordinate of polygon vertex (in)

Definition at line 219 of file dsp.cpp.

References T3d::Transform(), and Zbf::Vertex().

Referenced by DisplaySolid().


Member Data Documentation

double Dsp::alpha = 0.0 [static, private]
 

Rotation angle.

Definition at line 60 of file dsp.cpp.

Referenced by RotateView().

double Dsp::back = 0.0 [static, private]
 

View volume parameters.

Definition at line 116 of file dsp.cpp.

Referenced by SetupView().

double Dsp::bottom = 0.0 [static, private]
 

View volume parameters.

Definition at line 113 of file dsp.cpp.

Referenced by SetupView().

Dsp::Vec Dsp::box [static, private]
 

Initial value:

         { { 0.0, 0.0, 0.0 },
           { 1.0, 0.0, 0.0 },
           { 1.0, 2.0, 0.0 },
           { 0.0, 2.0, 0.0 },
           { 0.0, 0.0, 3.0 },
           { 1.0, 0.0, 3.0 },
           { 1.0, 2.0, 3.0 },
           { 0.0, 2.0, 3.0 } }
Current solid to display.

Definition at line 72 of file dsp.cpp.

Referenced by DisplaySolid().

double Dsp::delta = 2.0*Dsp::M_PI/Dsp::FRAMES [static, private]
 

Rotation increment angle.

Definition at line 64 of file dsp.cpp.

Referenced by RotateView().

double Dsp::eyex = 0.0 [static, private]
 

Camera position parameters.

Definition at line 93 of file dsp.cpp.

Referenced by RotateView(), SetupView(), and ZbfModel().

double Dsp::eyey = 0.0 [static, private]
 

Camera position parameters.

Definition at line 94 of file dsp.cpp.

Referenced by RotateView(), SetupView(), and ZbfModel().

double Dsp::eyez = 0.0 [static, private]
 

Camera position parameters.

Definition at line 95 of file dsp.cpp.

Referenced by SetupView(), and ZbfModel().

int Dsp::FRAMES = 720 [static, private]
 

Number of frames in a complete 360 degree rotation around object.

Definition at line 52 of file dsp.cpp.

double Dsp::front = 0.0 [static, private]
 

View volume parameters.

Definition at line 115 of file dsp.cpp.

Referenced by SetupView().

double Dsp::left = 0.0 [static, private]
 

View volume parameters.

Definition at line 111 of file dsp.cpp.

Referenced by SetupView().

double Dsp::M_PI = 3.141592654 [static, private]
 

The number PI.

Definition at line 56 of file dsp.cpp.

double Dsp::MIN_COLOR_INTENS = 0.50 [static, private]
 

Constant for minimum color intensity.

Definition at line 48 of file dsp.cpp.

Referenced by ShadeColor().

double Dsp::refx = 0.0 [static, private]
 

Reference point position.

Definition at line 99 of file dsp.cpp.

Referenced by RotateView(), SetupView(), and ZbfModel().

double Dsp::refy = 0.0 [static, private]
 

Reference point position.

Definition at line 100 of file dsp.cpp.

Referenced by RotateView(), SetupView(), and ZbfModel().

double Dsp::refz = 0.0 [static, private]
 

Reference point position.

Definition at line 101 of file dsp.cpp.

Referenced by SetupView(), and ZbfModel().

double Dsp::right = 0.0 [static, private]
 

View volume parameters.

Definition at line 112 of file dsp.cpp.

Referenced by SetupView().

double Dsp::top = 0.0 [static, private]
 

View volume parameters.

Definition at line 114 of file dsp.cpp.

Referenced by SetupView().

Dsp::Vec Dsp::view_vector = { 0.0, 0.0, 0.0 } [static, private]
 

Current view vector.

Definition at line 68 of file dsp.cpp.

Referenced by ZbfBeginPoly(), and ZbfModel().

double Dsp::vupx = 0.0 [static, private]
 

View up-vector.

Definition at line 105 of file dsp.cpp.

Referenced by SetupView().

double Dsp::vupy = 0.0 [static, private]
 

View up-vector.

Definition at line 106 of file dsp.cpp.

Referenced by SetupView().

double Dsp::vupz = 0.0 [static, private]
 

View up-vector.

Definition at line 107 of file dsp.cpp.

Referenced by SetupView().

double Dsp::xmax = 1.0 [static, private]
 

Model bouding box.

Definition at line 85 of file dsp.cpp.

Referenced by SetupView().

double Dsp::xmin = 0.0 [static, private]
 

Model bouding box.

Definition at line 84 of file dsp.cpp.

Referenced by SetupView().

double Dsp::ymax = 2.0 [static, private]
 

Model bouding box.

Definition at line 87 of file dsp.cpp.

Referenced by SetupView().

double Dsp::ymin = 0.0 [static, private]
 

Model bouding box.

Definition at line 86 of file dsp.cpp.

Referenced by SetupView().

double Dsp::zmax = 3.0 [static, private]
 

Model bouding box.

Definition at line 89 of file dsp.cpp.

Referenced by SetupView().

double Dsp::zmin = 0.0 [static, private]
 

Model bouding box.

Definition at line 88 of file dsp.cpp.

Referenced by SetupView().


The documentation for this class was generated from the following files:
Generated on Mon Jun 20 18:09:55 2011 for Trab8 by  doxygen 1.4.2-20050421