#include <dsp.h>
Collaboration diagram for Dsp:
See specification of public functions of this module in hearder file "dsp.h". Revisions:
| |
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... |
|
Function to decode a long int coded color into the RGB components (in integer values between 0 and 255).
Definition at line 192 of file dsp.h. Referenced by ShadeColor(). |
|
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(). |
|
Function to encode RGB components (in integer values between 0 and 255) into a long int coded color.
Definition at line 213 of file dsp.h. Referenced by ShadeColor(), and ZbfModel(). |
|
Given a long int coded color, get the blue component intensity from 0 to 1.
|
|
Given a long int coded color, get the green component intensity from 0 to 1.
|
|
Given a long int coded color, get the red component intensity from 0 to 1.
|
|
This function returns the maximum value between two doubles.
Definition at line 238 of file dsp.h. Referenced by SetupView(). |
|
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(). |
|
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.
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(). |
|
Change color intensity taking into account polygon normal vector orientation with respect to view vector. All computations should be performed in object coordinates.
Definition at line 124 of file dsp.cpp. References DecodeColor(), EncodeColor(), MIN_COLOR_INTENS, and VecDot(). Referenced by ZbfBeginPoly(). |
|
Function to compute the dot product between two 3D vectors.
Definition at line 178 of file dsp.h. References Dsp::Vec::x, Dsp::Vec::y, and Dsp::Vec::z. Referenced by ShadeColor(). |
|
Function to normalize a 3D vector.
Definition at line 158 of file dsp.h. References Dsp::Vec::x, Dsp::Vec::y, and Dsp::Vec::z. Referenced by ZbfModel(). |
|
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.
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(). |
|
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(). |
|
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(). |
|
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.
Definition at line 219 of file dsp.cpp. References T3d::Transform(), and Zbf::Vertex(). Referenced by DisplaySolid(). |
|
Rotation angle.
Definition at line 60 of file dsp.cpp. Referenced by RotateView(). |
|
View volume parameters.
Definition at line 116 of file dsp.cpp. Referenced by SetupView(). |
|
View volume parameters.
Definition at line 113 of file dsp.cpp. Referenced by SetupView(). |
|
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 } }
Definition at line 72 of file dsp.cpp. Referenced by DisplaySolid(). |
|
Rotation increment angle.
Definition at line 64 of file dsp.cpp. Referenced by RotateView(). |
|
Camera position parameters.
Definition at line 93 of file dsp.cpp. Referenced by RotateView(), SetupView(), and ZbfModel(). |
|
Camera position parameters.
Definition at line 94 of file dsp.cpp. Referenced by RotateView(), SetupView(), and ZbfModel(). |
|
Camera position parameters.
Definition at line 95 of file dsp.cpp. Referenced by SetupView(), and ZbfModel(). |
|
Number of frames in a complete 360 degree rotation around object.
|
|
View volume parameters.
Definition at line 115 of file dsp.cpp. Referenced by SetupView(). |
|
View volume parameters.
Definition at line 111 of file dsp.cpp. Referenced by SetupView(). |
|
The number PI.
|
|
Constant for minimum color intensity.
Definition at line 48 of file dsp.cpp. Referenced by ShadeColor(). |
|
Reference point position.
Definition at line 99 of file dsp.cpp. Referenced by RotateView(), SetupView(), and ZbfModel(). |
|
Reference point position.
Definition at line 100 of file dsp.cpp. Referenced by RotateView(), SetupView(), and ZbfModel(). |
|
Reference point position.
Definition at line 101 of file dsp.cpp. Referenced by SetupView(), and ZbfModel(). |
|
View volume parameters.
Definition at line 112 of file dsp.cpp. Referenced by SetupView(). |
|
View volume parameters.
Definition at line 114 of file dsp.cpp. Referenced by SetupView(). |
|
Current view vector.
Definition at line 68 of file dsp.cpp. Referenced by ZbfBeginPoly(), and ZbfModel(). |
|
View up-vector.
Definition at line 105 of file dsp.cpp. Referenced by SetupView(). |
|
View up-vector.
Definition at line 106 of file dsp.cpp. Referenced by SetupView(). |
|
View up-vector.
Definition at line 107 of file dsp.cpp. Referenced by SetupView(). |
|
Model bouding box.
Definition at line 85 of file dsp.cpp. Referenced by SetupView(). |
|
Model bouding box.
Definition at line 84 of file dsp.cpp. Referenced by SetupView(). |
|
Model bouding box.
Definition at line 87 of file dsp.cpp. Referenced by SetupView(). |
|
Model bouding box.
Definition at line 86 of file dsp.cpp. Referenced by SetupView(). |
|
Model bouding box.
Definition at line 89 of file dsp.cpp. Referenced by SetupView(). |
|
Model bouding box.
Definition at line 88 of file dsp.cpp. Referenced by SetupView(). |