IModel Class Reference

A geometry buffer. More...

#include <model.h>

Inheritance diagram for IModel:

CBaseModel IMeshModel CObjModel

List of all members.

Public Member Functions

virtual ~IModel (void)
 Destructor.
virtual QString getName (void)=0
 Returns the name of this model.
virtual void render (const VertexAttribLocations *attribs=NULL, const vec4_t *overrideColor=NULL)=0
 Sends the stored geometry to OpenGL via vertex arrays.
virtual void renderNormals (void)=0
 Draws the vertex normals stored in this model.
virtual void renderTangents (void)=0
 Draw vertex tangent space basis stored in this model.
virtual int getPrimitiveType (void)=0
 Returns the primitive type of this model.
virtual QString getPrimitiveTypeName (void)=0
 Returns the primitive type if this model in a human readable format.
virtual float getBoundingRadius (void)=0
 Returns the bounding radius of this model.
virtual void getBoundingBox (vec3_t &mins, vec3_t &maxs)=0
 Returns the bounding box of this model.

Static Public Member Functions

static IModelcreatePoint (void)
 Creates a model that is only a singla point located in the origin.
static IModelcreatePlane (void)
 Creates a tesselated quad located in the Z=0 plane.
static IModelcreateCube (void)
 Creates a cube model.
static IModelcreateSphere (int numRings, int numSegments, float radius)
 Creates an UV sphere.
static IModelcreateTorus (int numRings, int numSegments, float radius1, float radius2)
 Creates a torus.
static QString primitiveTypeName (int primitiveType)
 Maps OpenGL symbolic constants into strings.


Detailed Description

A geometry buffer.

This is an interface to a buffer, that stores geometry ready for rendering. This is basically a container for IVertexStream meta data. It stores a IVertexStream object and some extra infos like bounding box, bounding radius, primitive type and model name. It provides several factory methods for object creation.


Member Function Documentation

IModel * IModel::createPoint ( void   )  [static]

Creates a model that is only a singla point located in the origin.

This single point is located in the origin, with the normal (0,0,1), the texture coordinates (0,0) and the color (1,1,1,1). It is intended to be used as input for the geometry shader to make sure it will be executed only once.

IModel * IModel::createPlane ( void   )  [static]

Creates a tesselated quad located in the Z=0 plane.

The returned model has the color (1,1,1,1) and a the normal (0,0,1). The vertex coordinates range form (-1,-1,0) to (+1,+1,0). The texture coordinates cover th entire quad.

IModel * IModel::createCube ( void   )  [static]

Creates a cube model.

The model is an RGB cube, located in the volume (-1,-1,-1) to (+1,+1,+1). The colors are those of the RGB cube with X=red, Y=green, Z=blue. The components intensities increase with increasing vertex coordinate. The texture coordinates define the full texture image on every face of the cube. The face normals point out of the cube.

IModel * IModel::createSphere ( int  numRings,
int  numSegments,
float  radius 
) [static]

Creates an UV sphere.

The sphere is a list of single triangles that form a sphere. The sphere is approximated by several rings, stacked from one pole to the other. Each ring is a list of segments (quads), which are defined by two triangles. As a result, the number of vertices required for the sphere is approx. 3 * numTriangles = 3 * 2 * numQuads = 3 * 2 * numRings * numSegments. The rings at the poles are created of triangles list to avoid degenerated triangles, so the exact amount of vertices is 3 * 2 * ( numRings - 2 ) * numSegments + 3 * numSegments * ( 1 + 1 ) = 3 * 2 * numSegments * ( numRings - 1 ). The vertex colors are interpolated between the north pole (red) and the equator (green) and between the equator (green) and the south pole (blue). The shere's texture coordiantes wrap the complete 2D texture image around the sphere, which causes singularities on the poles and a seam on the edge shared by the first and the last quad of each segment. The normals point out of the sphere.

Parameters:
numRings Number of rings of the sphere.
numSegments Number of segments of the sphere.
radius Radius of the sphere.
Returns:
An IModel that represents the sphere.

IModel * IModel::createTorus ( int  numRings,
int  numSegments,
float  radius1,
float  radius2 
) [static]

Creates a torus.

The torus is a list of single triangles that form the torus. The torus is a cylinder with radius2 deformed so that the top and the bottom of the cylinder are connected. This cylinder is located on a circle with radius1 around the origin. The cylinder is a stack of several rings. Each ring is created of several segments (quads), which are defined by two triangles. The required amount of vertices is 3 * numTriangles = 3 * 2 * numQuads = 3 * 2 * numRings * numSegments. The vertex colors are interpolated between the west end (red) and the origin (green) and between the origin (green) and the east end (blue). The texture coordinates map the entire image around the cylinder. The vertex normals point out of the cylinder.

Parameters:
numRings Number of rings the torus is split into.
numSegments Number of segments each ring is split into.
radius1 Radius of the circle around the origin on which the torus lies.
radius2 Radius of the cylinder on the circle around the origin.
Returns:
An IModel representing the torus.

virtual QString IModel::getName ( void   )  [pure virtual]

Returns the name of this model.

Implemented in CBaseModel, and CObjModel.

virtual void IModel::render ( const VertexAttribLocations attribs = NULL,
const vec4_t overrideColor = NULL 
) [pure virtual]

Sends the stored geometry to OpenGL via vertex arrays.

It enables OpenGL client state, binds vertex arrays, draws them and disables the client state.

Parameters:
attribs Custom vertex attribute locations. If this model has these attributes available, they will be bound to the indexed custom vertex attributes. If one of these attributes is -1, it will not be used. If this parameters is set to NULL, no custom attributes will be used.
overrideColor If this parameters if != NULL, then this color will be used as vertex color instead of the values stored in this model.

Implemented in CBaseModel, and CObjModel.

virtual void IModel::renderNormals ( void   )  [pure virtual]

Draws the vertex normals stored in this model.

If no normal are available, this call has no effect. It loops through all vertices and draws a colored line starting at the vertex position and pointing into the normal's direction. The colors are chosen from the largest component: x == red, Y == green, Z == blue.

Implemented in CBaseModel, and CObjModel.

virtual void IModel::renderTangents ( void   )  [pure virtual]

Draw vertex tangent space basis stored in this model.

If no tangent space vectors are available, this call has no effect. Otherwise it draws a line from the vertex position in the direction of each tangent space vector. Tangent == red, Bitangent == green, Normal == blue.

Implemented in CBaseModel, and CObjModel.

virtual int IModel::getPrimitiveType ( void   )  [pure virtual]

Returns the primitive type of this model.

It assumes that the model is constructed of only one primitive type.

Returns:
OpenGL primitive type of this model.

Implemented in CBaseModel, and CObjModel.

virtual QString IModel::getPrimitiveTypeName ( void   )  [pure virtual]

Returns the primitive type if this model in a human readable format.

It assumes that the model is constructeed of only one primitive type.

Returns:
OpenGL primitive type of this model as human readable string.

Implemented in CBaseModel, and CObjModel.

virtual float IModel::getBoundingRadius ( void   )  [pure virtual]

Returns the bounding radius of this model.

Returns:
A bounding sphere radius that can be used for culling, etc.

Implemented in CBaseModel, and CObjModel.

virtual void IModel::getBoundingBox ( vec3_t mins,
vec3_t maxs 
) [pure virtual]

Returns the bounding box of this model.

The bounding box is defined by minimum and maximum coordinates.

Parameters:
mins Buffer to store the minimum coordiantes of the bounding box.
maxs Buffer to store the maximum coordiantes of the bounding box.

Implemented in CBaseModel, and CObjModel.

QString IModel::primitiveTypeName ( int  primitiveType  )  [static]

Maps OpenGL symbolic constants into strings.

Parameters:
primitiveType OpenGL primitive type. Valid types are defined in the OpenGL 2.0 specification.
Returns:
String representation of the input primitive type.


The documentation for this class was generated from the following files:
Generated on Sun Mar 2 17:12:32 2008 for Shader Maker by  doxygen 1.5.4