Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

sglTexGen Class Reference

#include <sglTexGen.hpp>

Inheritance diagram for sglTexGen::

sglTexturingStatelet sglStatelet sglObject List of all members.

Public Types

enum  TexCoordEnum {
  eS = GL_S,
  eT = GL_T,
  eR = GL_R,
  eQ = GL_Q
enum  ModeEnum {
  eOFF = -1,

Public Methods

 sglTexGen ()
virtual ~sglTexGen ()
void setMode (TexCoordEnum coord, ModeEnum mode)
ModeEnum getMode (TexCoordEnum coord) const
void setPlane (TexCoordEnum coord, float x, float y, float z, float w)
void getPlane (TexCoordEnum coord, float &x, float &y, float &z, float &w) const
void applyToUnit (sglCurrState *, unsigned int) const
virtual bool getSorted () const
virtual void printInfo (ostream &ostrm, const char *indent_string) const

Detailed Description

This statelet encapsulates OpenGL's glTexGen*() functions which specify functions for automatically generating texture coordinates to create effects such as reflections or making contours on the models. A separate function for each of the four texture cooredinates (S, T, R, and Q) can be specified as one of three different functions: object linear, eye linear, and sphere map. If the GL_ARB_texture_cube_map extension is supported, this class also supports the reflection map and normal map modes.

When object linear or eye linear mode is used for any of the coordinates then the generated coordinate is a linear combination of the vertex (x, y, z, w) a reference plane can be defined for each coordinate to define the coefficients of the linear combination. In the case of the object linear mode these planes are defined with respect to the object's coordinate system; therefore, the texture coordinates will be fixed with respect to the object. In the case of eye linear mode, the planes are defined with respect to the view point coordinate system so they will move with the view point. Planes are only used by the object and eye linear modes.

Texture coordinate generation can be disabled by calling setMode for all the texture coordinate generation with sglTexGen::eOFF for the mode parameter.


   sglTexGen *tgen = new sglTexGen;  // default mode is OFF

   tgen->setMode(sglTexGen::S, sglTexGen::OBJECT_LINEAR);
   tgen->setPlane(sglTexGen::S, 1.0f, 0.0f, 0.0f, 0.0f);
   tgen->setMode(sglTexGen::T, sglTexGen::OBJECT_LINEAR);
   tgen->setPlane(sglTexGen::T, 0.0f, 1.0f, 0.0f, 0.0f);

   // OR sphere map which ignores plane equations.

   tgen->setMode(sglTexGen::eS, sglTexGen::eSPHERE_MAP);
   tgen->setMode(sglTexGen::eT, sglTexGen::eSPHERE_MAP);

Definition at line 74 of file sglTexGen.hpp.

Member Enumeration Documentation

enum sglTexGen::TexCoordEnum

Tokens that wrap OpenGLs texture coordinate specification.

Enumeration values:
eS   The "x" coordinate.
eT   The "y" coordinate.
eR   The "z" coordinate.
eQ   The "w" coordinate.

Definition at line 78 of file sglTexGen.hpp.

enum sglTexGen::ModeEnum

The tokens for the various texture generation functions.

Enumeration values:
eOFF   disable texture generation for this coordinate.
eOBJECT_LINEAR   Use object linear function (fixed to object).
eEYE_LINEAR   Use eye linear function (fixed wrt viewpoint).
eSPHERE_MAP   Use environment mapping.
eREFLECTION_MAP   reflection map (if cube map extension supported).
eNORMAL_MAP   normal map (if cube map extension supported).

Definition at line 94 of file sglTexGen.hpp.

Constructor & Destructor Documentation

sglTexGen::sglTexGen ( )

Default constructor. All texture coordinate generation is disabled.

sglTexGen::~sglTexGen ( ) [virtual]

Virtual destructor.

Member Function Documentation

void sglTexGen::setMode ( TexCoordEnum coord,
ModeEnum mode )

Set the texture coordinate generation functions for a specified coordinate

coord   One of the TexCoordEnum tokens (eS, eT, eR, or eQ).
mode   The function for the specified coord parameter. The default is OFF for all four coordinates.

ModeEnum sglTexGen::getMode ( TexCoordEnum coord ) const

Query the current generation function for the specifed coordinate.

coord   One of the TexCoordEnum tokens (eS, eT, eR, or eQ).
The current mode token corresponding to the function for the coordinate specified by coord.

void sglTexGen::setPlane ( TexCoordEnum coord,
float x,
float y,
float z,
float w )

Define the planes for either object linear or eye linear mode. The default planes are perpendicular to their respective dimensions and intersecting the origin. Note a single set of four planes are stored in this object and are used in either object or eye linear modes. Switching modes will retain the previous planes.

coord   One of the TexCoordEnum tokens (eS, eT, eR, or eQ).
x   X component of the plane equation.
y   Y component of the plane equation.
z   Z component of the plane equation.
w   W component of the plane equation (displacement?).

void sglTexGen::getPlane ( TexCoordEnum coord,
float & x,
float & y,
float & z,
float & w ) const

Query the current plane for the given coordinate.

coord   One of the TexCoordEnum tokens (eS, eT, eR, or eQ).
x   On return, contains X component of the plane equation.
y   On return, contains Y component of the plane equation.
z   On return, contains Z component of the plane equation.
w   On return, contains W component of the plane equation.

void sglTexGen::applyToUnit ( sglCurrState * curr_state,
unsigned int unit ) const [virtual]

Apply this state change to the current rendering state for the given texture unit.

curr_state   Required for statelets that affect one another. For example the sglTransparency sets up depth mask and blending modes which interact with the sglBlending and sglDepthMask statelets, and the curr_state object is used to resolve these internal issues.
unit   Index for the texture unit (0 is the first).

Reimplemented from sglTexturingStatelet.

bool sglTexGen::getSorted ( ) const [inline, virtual]

Query the sorting mode for this statelet.

true if this type of statelet should be sorted by pointer rather than using m_index to index into an array. The defualt implementation is the latter, but if a statelet can take on an inordinate number of states (e.g. a floating point parameter) then true should be returned.

Reimplemented from sglStatelet.

Definition at line 165 of file sglTexGen.hpp.

virtual void sglTexGen::printInfo ( ostream & ostrm,
const char * indent_string ) const [virtual]

Output the state of this node to the specified ostream.

ostrm   the ostream to which the output is sent
indent_string   the string (usually spaces) that is output at the beginning of every line of output

Reimplemented from sglStatelet.

The documentation for this class was generated from the following file:
Generated at Mon Jul 1 18:00:10 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001