Bright Ideas Software - Calculus Visualization Tools Click here to return to the BIS Home Page.

GLE32 Ver. 4 Manual

  Skip Navigation Links
Math ToolsExpand Math Tools
DevelopersExpand Developers
About BISExpand About BIS
  Skip Navigation LinksHome --> Developers --> GLE32 Version 4 --> GLE32 Manual --> Bump Mapped Objects Search:
Skip Navigation Links

Skip Navigation Links

OpenGL® and OpenGL|ES are trademarks of Silicon Graphics, Inc.




Bump Mapped Objects

The GLE32V4 library provides the following bump-mapped objects: sphere, torus, cylinder, box, tetrahedron, octahedron, disk, partial disk, and quad. A base CgleBumpObject class implements the rendering algorithm, while the various descendant classes set up the inherited normal, vertex, texture coordinate and tangent vector information needed to draw each shape. The public interface for each object is surprisingly small, and nearly all of it is inherited from the base class.

The bump-mapping algorithm uses the GL_ARB_texture_env_dot3, GL_ARB_texture_env_combine and GL_ARB_texture_cube_map extensions to create and use a vector normalization cube map, and the GL_ARB_multitexture extension to simultaneously apply a base color texture and then modify it based on the per-pixel dot product of the light vector and the normal vector from a user-supplied normal map. The cube map is shared between all objects, and is created and destroyed with static functions declared in the base class. A complete explanation of the technique can be found at http://www.paulsprojects.net.

The common base class public interface is documented below, followed by the additions specific to each individual object. Each object has an Init method and a SetSize method, and a constructor which requires no parameters and initializes the object to a default size/state. The object must be re-initialized if tangents are inverted or under other conditions noted below, and they must be initialized before SetSize is called.


CgleBumpObject

Methods

  

Description

static BOOL InitializeCubeMap()  Call this once on any object to set up the shared normalization cube map and initialize the multitexturing extension API.
static void ReleaseResources()  Call this once on any object to destroy the shared cube map and release the associated gl texture objects. Call this before the rendering context is destroyed.
BOOL IsInitialized()  Returns TRUE if the shared extension API AND the individual object are properly initialized.
void UpdateInverseModelViewMatrix()  Call this prior to drawing whenever an objects position or orientation change.
void SetInvertTTangents(BOOL value)  This provides a means of inverting the bump effect on the vertical texture axis, in case the normal map bumps are oriented other than you might desire. The object must be re-initialized after calling this function.
BOOL GetInvertTTangents()  Returns TRUE if TTangents are currently inverted, FALSE otherwise.
void SetInvertSTangents(BOOL value)  Set TRUE to invert the bump effect on the horizontal texture axis. The object must be re-initialized after calling this function.
BOOL GetInvertSTangents()  Returns TRUE is the STangents are currently inverted, FALSE otherwise.
void Draw(float* WorldLightPosition, CgleTexture* BumpTexture, CgleTexture* ColorTexture)  Draw the object.

CgleBumpBox

void Init()  Allocates memory and calculates tangent, normal and texture coordinates data.
BOOL SetSize(float Height, float Width, float Depth)  Object must be initialized before calling this.

CgleBumpTorus

void Init(int Complexity = 20)  Complexity must be >= 3.
BOOL SetSize(float CrossSectionDia, float Radius)   

CgleBumpSphere

void Init(int Slices=20, int Stacks=20)  Slices and Stacks must be >= 4.
BOOL SetSize(float Radius)   

CgleBumpCylinder

void Init(int Slices=20, int Stacks=3)  Slices must be >= 3; Stacks must be >= 2.
BOOL SetSize(float BaseRadius, float TopRadius, float Height)  Parameters must be >= 0.0.
void SetDoubleSided(BOOL value)  Call this to render both inside and outside of the cylinder. Default is FALSE. Object must be reinitialized after changing state of this value.
BOOL GetDoubleSided()  Returns TRUE if the object is currently double-sided; FALSE otherwise.

CgleBumpPartialDisk

void Init(int Slices=20, int Loops=3)  Slices must be >= 3; Loops must be >= 2.
BOOL SetSize(float InnerRadius, float OuterRadius, float StartAngle, float SweepAngle)  All parameters must be >= 0.0; OuterRadius must be > InnerRadius.
void SetDoubleSided(BOOL value)  Call this to render both sides of the disk. Default is FALSE. Object must be reinitialized after changing state of this value.
BOOL GetDoubleSided()  Returns TRUE if the object is currently double-sided; FALSE otherwise.

CgleBumpDisk

CgleBumpDisk descends from CgleBumpDisk; the only difference in their interfaces is SetSize.
BOOL SetSize(float InnerRadius, float OuterRadius)  All parameters must be >= 0.0; OuterRadius must be > InnerRadius.

CgleBumpQuad

void Init()   
BOOL SetSize(float Width, float Height)  All parameters must be >= 0.0.
void SetDoubleSided(BOOL value)  Call this to render both sides of the disk. Default is FALSE. Object must be reinitialized after changing state of this value.
BOOL GetDoubleSided()  Returns TRUE if the object is currently double-sided; FALSE otherwise.
void SetStretchTexWidth(BOOL value)  Set TRUE to force horizontal texture coordinates to 0.0~1.0 range regardless of quad width; otherwise texture cooordinates are based on quad vertex coordinates. SetSize must be called after changing state of this value.
BOOL GetStretchTexWidth()  Returns TRUE if horizontal coordinates are forced to 0.0~1.0 range; FALSE otherwise.
void SetStretchTexHeight(BOOL value)  Set TRUE to force the vertical texture coordinates to 0.0~1.0 range regardless of quad height; othersize they are base on vertex coordinates. SetSize must be called after changing state of this value.
BOOL GetStretchTexHeight()  Returns TRUE if vertical coordinates are forced to 0.0~1.0 range; FALSE otherwise.

CgleBumpTetrahedron

void Init()   
BOOL SetSize(float Size)  Size mut be > 0.0.

CgleBumpOctahedron

void Init()   
BOOL SetSize(float Size)  Size mut be > 0.0.

Back To Top



Copyright© 2001-2010 by Bright Ideas Software®. All rights reserved.