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

PainterMultipass Class Reference

Implements the Painter visitor to draw a Model with detail and bumpmapping on the screen. More...

#include <PainterMultipass.h>

Inheritance diagram for PainterMultipass:

Painter List of all members.

Public Methods

 PainterMultipass ()
 Initialize the object with defaults.

virtual void paintMesh (const Mesh &mesh, const Vector &eye, const Vector &light) const
 Draw the Mesh in multiple passes.

virtual void paintTriangle (const Triangle &triangle, const Vector &eye, const Vector &light) const
 Draw a Triangle taking into account the texture coordinate perturbation.


Private Attributes

bool m_perturbTextureCoordinates
 If true, perturb the current texture coordinates towards the light.


Detailed Description

Implements the Painter visitor to draw a Model with detail and bumpmapping on the screen.

The drawing process uses multiple passes and blending between them (instead of multitexture facilities).


Member Function Documentation

void PainterMultipass::paintMesh const Mesh   mesh,
const Vector   eye,
const Vector   light
const [virtual]
 

Draw the Mesh in multiple passes.

This method does not use the multitexture facilities of the card: it only uses regular blending effects:

  1. The first pass draws the regular bumpmap.
  2. The second pass draws the inverted bumpmap perturbed on top of it (effectively subtracts it at an offset): this generates the normal map.
  3. The third pass blends the detail texture with the normal map.

Reimplemented from Painter.

void PainterMultipass::paintTriangle const Triangle   triangle,
const Vector   eye,
const Vector   light
const [virtual]
 

Draw a Triangle taking into account the texture coordinate perturbation.

For every vertex, compute the Vector connecting that vertex to the light. Bring that Vector into tangent space using Triangle#getObjectToTangentSpaceMatrix. Once in tangent space, the X and Y coordinates represent the amount by which the bumpmap texture should be perturbed before subtracted from itself in order to compute the normalmap.

This can be intuitively understood as follows: if the light is perpendicular to our texture (colinear with the face normal) at the current vertex, then the texture should not be perturbed at all: when the light (=normal) is brought into tangent space, it corresponds to the Z axis, that is to the vector (0, 0, 1). The X and Y coordinates of the light (=normal) do not perturb the texture.

Reimplemented from Painter.


Member Data Documentation

bool PainterMultipass::m_perturbTextureCoordinates [mutable, private]
 

If true, perturb the current texture coordinates towards the light.

This value is set to true in paintMesh in order to perturb the current layer towards the light in such a way that, when it is blended against the layer underneath, it adds or subtracts to produce a normalmap.


The documentation for this class was generated from the following files:
Generated on Sat Mar 22 15:12:08 2003 for Bumpmap by doxygen1.3-rc2