Frz::Scene::Triangle Struct Reference

Container class for 3D triangle or quad polygon data. More...

#include <frz_scene.hpp>

Collaboration diagram for Frz::Scene::Triangle:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Triangle (uint16_t _ob_type, uint16_t _sh_type, uint16_t _rot_id, uint16_t _tex_id, uint32_t _color, const vvertex &_a, const vvertex &_b, const vvertex &_c, const vvertex &_d=vvertex())
 Constructor for Triangle objects.
void setThickness (uint16_t th)
 Sets extrusion mode and thickness.
void setFlatNormal (bool fn=true)
 Sets automatic normal vector generation for flat shading.
void setDoubleSided (bool ds=true)
 Sets the double sided-ness of the polygon.
void flatNormal ()
 Sets the normal vectors for flat shading.

Public Attributes

uint16_t ob_type
 Engine object type. (cf. frz_defs.h).
uint16_t sh_type
 Engine shading type. (cf. frz_defs.h).
uint16_t rot_id
 Rotation matrix number.
uint16_t tex_id
 Texture number. (not used yet).
uint16_t flags
 Flags.
uint16_t thickness
 Thickness. (for extrusion).
uint32_t color
 Color. (for flat and smooth shading).
vertex dummy
 Dummy or flags-dependent data.
vertex a
 First Triangle/Quad vertex + mapping (u,v).
vertex b
 Second Triangle/Quad vertex + mapping (u,v).
vertex c
 Third Triangle/Quad vertex + mapping (u,v).
vertex d
 Fourth Quad vertex + mapping (u,v).
svertex na
 Normal vector at first vertex.
svertex nb
 Normal vector at second vertex.
svertex nc
 Normal vector at third vertex.
svertex nd
 Normal vector at fourth vertex.

Detailed Description

Container class for 3D triangle or quad polygon data.

Triangle objects actually embed data for storing either a triangle or a quad. The class contains the four vertices necessary to produce a quad, where the fourth one is ignored when the class encodes a triangle.

The class information includes:

For each vertex, the following information is provided:

The Triangle class is designed in such a way that it exactly takes 128 bytes in memory. This is necessary to optimize PPE/SPE DMA communication. The Scene class ensures its Triangle buffer is 128-byte aligned in memory for that same purpose, using the specifically-designed alignvec aligned buffer.


Constructor & Destructor Documentation

Frz::Scene::Triangle::Triangle ( uint16_t  _ob_type,
uint16_t  _sh_type,
uint16_t  _rot_id,
uint16_t  _tex_id,
uint32_t  _color,
const vvertex &  _a,
const vvertex &  _b,
const vvertex &  _c,
const vvertex &  _d = vvertex() 
) [inline]

Constructor for Triangle objects.

Parameters:
_ob_type Object type. One of OB_TRIANGLE or OB_QUAD (see frz_defs.h)
_sh_type Shading type
_rot_id Rotation matrix identifier
_tex_id Texture identifier (currently unused)
_color 32-bit color value (ARGB binary format)
_a first triangle/quad vertex
_b second triangle/quad vertex
_c third triangle/quad vertex
_d fourth quad vertex

Member Function Documentation

void Frz::Scene::Triangle::setDoubleSided ( bool  ds = true  ) 

Sets the double sided-ness of the polygon.

Double-sided polygons can be seen from both sides, in opposite of single-sided polys which have only one visible side.

Polygons are single-sided by default. In this case, the visible side is the one for which the vertices appear in clockwise order.

Parameters:
ds if true, the polygon is considered double-sided, otherwise it is not.
void Frz::Scene::Triangle::setFlatNormal ( bool  fn = true  ) 

Sets automatic normal vector generation for flat shading.

If this mode is set, the engine automatically computes the normal vector of the polygon at each frame update, and sets the computed value to the normal vector at each vertex of the polygon.

Parameters:
fn if true, automatic normal vector generation is activated, and is deactivatd otherwise
void Frz::Scene::Triangle::setThickness ( uint16_t  th  ) 

Sets extrusion mode and thickness.

If th is zero, extrusion is deactivated. If it is nonzero, extrusion is activated for this polygon, and the th value is used as thickness value.

Polygon extrusion basically consists in generating an orthogonal revolution object using the given polygon as a base. For instance, to generate a cube, simply set the thickness of a square object to its edge length.

The generated object's faces have their normal vectors calculated for flat shading. Normal vectors cannot be generated for any other shading type.

Parameters:
th thickness value

Member Data Documentation

First Triangle/Quad vertex + mapping (u,v).

The three first elements (x, y, and z) of this vertex are the 3D x, y, and z coordinates of the triangle/quad vertex. The fourth element is a pair of 16-bit fixed point mapping coordinates, where the 0x0 value is 0 and 0xFFFF is 0.99998.

Second Triangle/Quad vertex + mapping (u,v).

The three first elements (x, y, and z) of this vertex are the 3D x, y, and z coordinates of the triangle/quad vertex. The fourth element is a pair of 16-bit fixed point mapping coordinates, where the 0x0 value is 0 and 0xFFFF is 0.99998.

Third Triangle/Quad vertex + mapping (u,v).

The three first elements (x, y, and z) of this vertex are the 3D x, y, and z coordinates of the triangle/quad vertex. The fourth element is a pair of 16-bit fixed point mapping coordinates, where the 0x0 value is 0 and 0xFFFF is 0.99998.

Fourth Quad vertex + mapping (u,v).

The three first elements (x, y, and z) of this vertex are the 3D x, y, and z coordinates of the quad vertex. The fourth element is a pair of 16-bit fixed point mapping coordinates, where the 0x0 value is 0 and 0xFFFF is 0.99998.


The documentation for this struct was generated from the following file:
 All Classes Functions Variables Friends
Generated on Thu Jun 10 17:37:47 2010 for freezer-0.1.0 by  doxygen 1.6.3