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

Dsp Class Reference

#include <dsp.h>

List of all members.
Date:
21-Jun-2010
Author:
Luiz F. Martha
Version:
1.0
This file contains class to display primitives of a model in current database. It also contains functions to adjust the window (visible portion of the model) for visualization.

The adopted model primitive class is described in header file "prm.h", which also contains code color definitions.

The basic graphics system used to display primitives is OpenGL. Please refer to OpenGL documentation for additional information.

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

Revisions:

  • Version 1.0 by L.F. Martha on 21-Jun-2010: Initial version. Stolen from Trab3 of CIV2801-2005.2 and modified.


static void Init (void)
 This function initializes the dsp module.
static void Help (void)
 This function displays a help list of the possible program actions and their associated keys.
static void Model (void)
 This function displays all primitives of current model using the OpenGL graphics system.
static int ZbfModel (void *zbuffer_canvas)
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 void GetPickRay (int x, int y, double *frontx, double *fronty, double *frontz, double *backx, double *backy, double *backz)
 Given a mouse location point in raster canvas coordinates, this function returns the corresponding pick ray in world coordinates (WC).
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 InvertMatrix (double mt[4][4], double imt[4][4])
 Function to invert a 4x4 matrix.
static void GetCamera (double *eyex, double *eyey, double *eyez, double *refx, double *refy, double *refz, double *vupx, double *vupy, double *vupz)
 This function obtains the camera model viewing paramaters (in WC coordinates) from the current OpenGL model view matrix.
static int GetViewVolume (double *left, double *right, double *bottom, double *top, double *front, double *back)
 This function obtains the view volume limits (in the eye coordinate system) from the current OpenGL projection matrix.
static void DisplayPrm (Prm *prm)
 Function to display a solid version of a primitive with its corresponding color.
static void HighltPrm (Prm *prm)
 Function to highlight a solid version of a primitive.
static double MIN_COLOR_INTENS = 0.50
 Constant for minimum color intensity.
static Vec view_vector = {0.0, 0.0, 0.0}
 Current view vector.
static char * help_cmd []
 Help message commands.
static char * help_msg []
 Help message actions.
static int font_list_base = 0
 OpenGL font list for text.

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.

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 175 of file dsp.h.

Referenced by ShadeColor().

void Dsp::DisplayPrm Prm prm  )  [static, private]
 

Function to display a solid version of a primitive with its corresponding color.

The solid version is a prism that has the 2D primitive as its base and height equal to the primitive height.

Parameters:
prm - pointer to target primitive (in)

Definition at line 329 of file dsp.cpp.

References Prm::DisplaySolid(), get_blue(), get_green(), get_red(), and Prm::GetColor().

Referenced by Model().

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 196 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 130 of file dsp.h.

Referenced by DisplayPrm().

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 116 of file dsp.h.

Referenced by DisplayPrm().

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 102 of file dsp.h.

Referenced by DisplayPrm().

void Dsp::GetCamera double *  eyex,
double *  eyey,
double *  eyez,
double *  refx,
double *  refy,
double *  refz,
double *  vupx,
double *  vupy,
double *  vupz
[static, private]
 

This function obtains the camera model viewing paramaters (in WC coordinates) from the current OpenGL model view matrix.

Parameters:
eyex,eyey,eyez - camera (eye) position (out)
refx,refy,refz - reference point position (out)
vupx,vupy,vupz - view up vector components (out)

Definition at line 255 of file dsp.cpp.

References InvertMatrix().

Referenced by ZbfModel().

void Dsp::GetPickRay int  x,
int  y,
double *  frontx,
double *  fronty,
double *  frontz,
double *  backx,
double *  backy,
double *  backz
[static]
 

Given a mouse location point in raster canvas coordinates, this function returns the corresponding pick ray in world coordinates (WC).

A pick ray is a line between a point on the front (near) plane and a point on the back (far) plane. These two points correspond to the given point location in raster coordinates.

Parameters:
x - x coordindate of raster point on canvas (in)
y - y coordindate of raster point on canvas (in)
frontx - x coord. of point in WC at front plane (out)
fronty - y coord. of point in WC at front plane (out)
frontz - z coord. of point in WC at front plane (out)
backx - x coord. of point in WC at back plane (out)
backy - y coord. of point in WC at back plane (out)
backz - z coord. of point in WC at back plane (out)

Definition at line 605 of file dsp.cpp.

Referenced by Prj::Raster2WorldXY().

int Dsp::GetViewVolume double *  left,
double *  right,
double *  bottom,
double *  top,
double *  front,
double *  back
[static, private]
 

This function obtains the view volume limits (in the eye coordinate system) from the current OpenGL projection matrix.

It assumes that the projection matrix has the following forms for orthographic and perspective projections:

             -                                  -
            |   2                          r + l |
            | -----      0         0     - ----- |
            | r - l                        r - l |
            |                                    |
            |            2                 t + b |
            |   0      -----       0     - ----- |
            |          t - b               t - b |
 [Ortho] =  |                                    |
            |                      2       f + n |
            |   0        0     - -----   - ----- |
            |                    f - n     f - n |
            |                                    |
            |                                    |
            |   0        0         0         1   |
            |                                    |
             -                                  -

             -                                  -
            |  2n                r + l           |
            | -----      0       -----       0   |
            | r - l              r - l           |
            |                                    |
            |           2n       t + b           |
            |   0      -----     -----       0   |
            |          t - b     t - b           |
 [Persp] =  |                                    |
            |                    f + n      fn   |
            |   0        0     - -----   - ----- |
            |                    f - n     f - n |
            |                                    |
            |                                    |
            |   0        0        -1         0   |
            |                                    |              -                                  -

Where:

l = left r = right b = bottom t = top n = near (front) f = far (back)

Parameters:
left,right - lateral view volume limits (out)
bottom,top - vertical view volume limits (out)
front,back - depth view volume limits (out)
Returns:
The function return value is a flag indicating the type of projection. In case of perspective projection, a true (1) status is returned. In case of orthographic projection, a false (0) status is returned.

Definition at line 288 of file dsp.cpp.

Referenced by ZbfModel().

void Dsp::Help void   )  [static]
 

This function displays a help list of the possible program actions and their associated keys.

Definition at line 395 of file dsp.cpp.

References font_list_base, help_cmd, and help_msg.

Referenced by Prj::Help().

void Dsp::HighltPrm Prm prm  )  [static, private]
 

Function to highlight a solid version of a primitive.

The solid version is a prism that has the 2D primitive as its base and height equal to the primitive height. This function displays the edges of the prism in red and draws red marks at its vertices.

Parameters:
prm - pointer to target primitive (in)

Definition at line 342 of file dsp.cpp.

References Prm::HighltSolid().

Referenced by Model().

void Dsp::Init void   )  [static]
 

This function initializes the dsp module.

It initializes some OpenGL parameters.

Definition at line 361 of file dsp.cpp.

References font_list_base, and Prj::Odatascreen.

Referenced by Prj::Resize().

void Dsp::InvertMatrix double  mt[4][4],
double  imt[4][4]
[static, private]
 

Function to invert a 4x4 matrix.

Parameters:
mt - given matrix (in)
imt - inverted matrix (out)

Definition at line 153 of file dsp.cpp.

Referenced by GetCamera().

void Dsp::Model void   )  [static]
 

This function displays all primitives of current model using the OpenGL graphics system.

Definition at line 491 of file dsp.cpp.

References Prm::CheckSelected(), DisplayPrm(), Prm::First(), HighltPrm(), and Prm::Next().

Referenced by Prj::BuildDisplayList().

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 125 of file dsp.cpp.

References Prm::ABS(), 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 161 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 141 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]
 

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 576 of file dsp.cpp.

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

Referenced by Quad::DisplayZbuffer(), and Circ::DisplayZbuffer().

void Dsp::ZbfEndPoly void   )  [static]
 

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

Definition at line 598 of file dsp.cpp.

References Zbf::EndPoly().

Referenced by Quad::DisplayZbuffer(), and Circ::DisplayZbuffer().

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

Definition at line 514 of file dsp.cpp.

References T3d::Camera(), Prm::DisplayZbuffer(), EncodeColor(), Prm::First(), GetCamera(), GetViewVolume(), T3d::Identity(), Prm::Next(), T3d::NormalizeView(), T3d::Perspective(), VecUnit(), view_vector, Dsp::Vec::x, Dsp::Vec::y, and Dsp::Vec::z.

Referenced by Prj::DspZbufferCanvas().

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

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 590 of file dsp.cpp.

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

Referenced by Quad::DisplayZbuffer(), and Circ::DisplayZbuffer().


Member Data Documentation

int Dsp::font_list_base = 0 [static, private]
 

OpenGL font list for text.

Definition at line 117 of file dsp.cpp.

Referenced by Help(), and Init().

char * Dsp::help_cmd [static, private]
 

Initial value:

  {
   "Tecle:",
   "H (de Help)",
   "Ctrl+Q (de Quit)",
   "Ctrl+I (de Info)",
   "Ctrl+O (de Open)",
   "Ctrl+S (de Snap shot)",
   "R (de Reset view)",
   "F (de Fit)" ,
   "P (de Perspec.)",
   "O (de Ortogr.)",
   "X (de Proj. X)",
   "Y (de Proj. Y)",
   "Z (de Proj. Z)",
   "Ctrl+M (de Manip.)",
   "Ctrl+N (de Naveg.)",
   "Ctrl+Z (de Zoom)"
  }
Help message commands.

Definition at line 73 of file dsp.cpp.

Referenced by Help().

char * Dsp::help_msg [static, private]
 

Initial value:

  {
   " ",
   "==> Exibe este help",
   "==> Sai do programa",
   "==> Informacoes sobre o programa",
   "==> Abre modelo de arquivo",
   "==> Desenha o modelo usando CD",
   "==> Inicializa projecao",
   "==> Ajusta modelo na janela" ,
   "==> Projecao conica",
   "==> Projecao cilindrica",
   "==> Projecao ortografica no plano X",
   "==> Projecao ortografica no plano Y",
   "==> Projecao ortografica no plano Z",
   "==> Mouse manipula modelo",
   "==> Mouse controla navegacao",
   "==> Mouse controla zoom"
  }
Help message actions.

Definition at line 95 of file dsp.cpp.

Referenced by Help().

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

Constant for minimum color intensity.

Definition at line 65 of file dsp.cpp.

Referenced by ShadeColor().

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

Current view vector.

Definition at line 69 of file dsp.cpp.

Referenced by ZbfBeginPoly(), and ZbfModel().


The documentation for this class was generated from the following files:
Generated on Mon Jun 21 12:45:20 2010 for Trab4 by  doxygen 1.4.2-20050421