Back to bsyte

Map Class Reference

Container fuer die Map. More...

#include <Map.h>

Collaboration diagram for Map:

List of all members.

Public Member Functions

virtual ~Map ()
 Destruktor.
ZonegetZone (int zoneID)
void calcLightMaps ()
 Berechnet alle Lightmaps Es wird fuer jede Tile eine statische Lightmap erzeugt. Das geschieht genau einmal waehrend der Startup-Phase der Engine, noch bevor das erste Frame gerendert wird. In einer Lightmap wird nicht nur die Lichtintensität eingebacken, sondern es werden auch Abschattungen von anderen Tiles mit hineingerechnet (Schatten ist nix anderes als die Abwesentheit von Licht). Es handelt sich also streng genommen um eine Light- und Shadowmap.
void toggleAmbientLight ()
 Schaltet das Ambient Light ein oder aus.
void toggleDirectionalLight ()
 Schaltet das Directional Light ein oder aus.
void toggleLightMap ()
 Schaltet das Directional Light ein oder aus.
bool isAmbientON ()
 Info ob AmbientLight ON oder OFF.
bool isDirectionalON ()
 Info ob DirectionalLight ON oder OFF.
bool isLightMapON ()
 Info ob LightMaps ON oder OFF.
void calcGamma (float gamma)
 Berechnet die Gamma-Rampe.
void stepGamma (bool up)
 Korrigiert den Gammawert.
void loadLights (DataInputStream &dataIn)
 Liest alle Lichteigenschaften und Pointlights aus dem Inputstream.
void saveLights (DataOutputStream dataOut)
 Serialisiert das Light-Objekt in den Outputstream.
void dump ()
 Dump der Map.

Static Public Member Functions

static MapgetInstance ()
 Liefert die Singleton-Instanz.

Public Attributes

std::vector< Zone * > zoneList
float m_gamma
int m_gammaR [256]
int m_gammaG [256]
int m_gammaB [256]

Protected Member Functions

 Map ()

Private Member Functions

void addTile (Tile *tile)
void calcLightMap (Tile &tile)
 Erzeugt aus der Lightmap-Grid eine vollauflˆsende Lightmap.
void Tangentspace (Matrix &matWT, Matrix &matTR, float width, float height, Vertex &v0, Vertex &v1, Vertex &v3)
 Tangentspace.
void setLight (int zoneID, float ambient, float directionalMax, float pointMax)
 Setzt die allgemeinen Lichteigenschaften einer Zone Es gilt: (ambientMax + directionalMax + pointMax) <= 1.0.
void setDirectionalLight (int zoneID, float dirX, float dirY, float dirZ)
 Setzt den DirectionalLight-Richtungsvektor fuer eine Zone.
void addPointLight (int zoneID, float x, float y, float z, bool castShadows, float range, float intensity, float constant, float linear, float quadratic)
 Fuegt ein PointLight hinzu.
float calcDirectional (Tile &tile, Zone &le)
 Berechnet die Lichtintensitaet fuer eine Tile. Weil das Directional Light unabhaengig von der Cameraposition ist, muss die Lichtintensitaet pro Tile nur einmal berechnet werden. Das passiert sinnvoller weise nachden die Richtung der Lichtquelle gesetzt wurde, und bevor die Map zum ersten mal transformiert, bzw. gerendert wird.
BYTE biInterpolate (int A, int B, int C, int D, float w, float h)
 Bilineare interpolation.
void trimLine (Vec &start, Vec &end, float epsilon)
 Verkuerzt eine Linie um epsilon.
void TangentspaceTest (Matrix &matWT, Matrix &matTR, Tile &tile)
 Dump der Map.
bool isEqual (float a, float b)
 Dump der Map.

Private Attributes

char m_mapfile [255]
bool m_AmbientON
bool m_DirectionalON
bool m_LightMapON

Static Private Attributes

static Map_instance = 0

Detailed Description

Container fuer die Map.


Constructor & Destructor Documentation

Map::Map ( ) [protected]

Here is the call graph for this function:

Here is the caller graph for this function:

Map::~Map ( ) [virtual]

Destruktor.


Member Function Documentation

void Map::addPointLight ( int  zoneID,
float  x,
float  y,
float  z,
bool  castShadows,
float  range,
float  intensity,
float  constant,
float  linear,
float  quadratic 
) [private]

Fuegt ein PointLight hinzu.

Parameters:
zoneIDZonen-Nr, bzw. Zonen-ID
xPosition
yPosition
zPosition
castShadows
range
intensity
constant
linear
quadratic

Here is the call graph for this function:

Here is the caller graph for this function:

void Map::addTile ( Tile tile) [private]

Here is the call graph for this function:

BYTE Map::biInterpolate ( int  A,
int  B,
int  C,
int  D,
float  w,
float  h 
) [private]

Bilineare interpolation.

Parameters:
A
B
C
D
w
h

Here is the caller graph for this function:

float Map::calcDirectional ( Tile tile,
Zone le 
) [private]

Berechnet die Lichtintensitaet fuer eine Tile. Weil das Directional Light unabhaengig von der Cameraposition ist, muss die Lichtintensitaet pro Tile nur einmal berechnet werden. Das passiert sinnvoller weise nachden die Richtung der Lichtquelle gesetzt wurde, und bevor die Map zum ersten mal transformiert, bzw. gerendert wird.

Parameters:
tiledie Tile welche das Licht reflektiert
leLightEnvironment

Here is the call graph for this function:

Here is the caller graph for this function:

void Map::calcGamma ( float  gamma)

Berechnet die Gamma-Rampe.

Parameters:
gamma

Here is the caller graph for this function:

void Map::calcLightMap ( Tile tile) [private]

Erzeugt aus der Lightmap-Grid eine vollauflˆsende Lightmap.

Parameters:
tile

Here is the call graph for this function:

Here is the caller graph for this function:

void Map::calcLightMaps ( )

Berechnet alle Lightmaps Es wird fuer jede Tile eine statische Lightmap erzeugt. Das geschieht genau einmal waehrend der Startup-Phase der Engine, noch bevor das erste Frame gerendert wird. In einer Lightmap wird nicht nur die Lichtintensität eingebacken, sondern es werden auch Abschattungen von anderen Tiles mit hineingerechnet (Schatten ist nix anderes als die Abwesentheit von Licht). Es handelt sich also streng genommen um eine Light- und Shadowmap.

Bei einer naiven Herangehensweise wird von jeder Punktlichtquelle aus ein Strahl ausgesendet der eine Tile abtastet. Die Helligkeit ist dann umgekehrt (quadratisch) proportional zur Distanz. Befindet sich ein Hindernis zwischen Punktlicht und Tile, ist die auftreffende Lichtinensitaet gleich 0 (also Abschattung). Dort wirken nur noch Anteile vom Ambient- bzw. Directional Light. Dieser Vorgehensweise ist korrekt, aber zu langsam!! Dashalb wird folgender Algorithmus implementiert:

Ausgehend von einer Lichquelle wird ueber alle Tiles einer Zone iteriert. Mit den Vertices der Lichtquelle und einer Tile wird ein Frustum erzeugt. Alle (anderen) Tiles, die sich im Frustum befinden, koennen potentiell einen Schatten werfen und werden deshalb in eine Collisionlist eingetragen.

Im zweiten Schritt wird auf die zu beleuchtede Tile ein UV-Grid mit 32 mal 32 Stuetzstellen gespannt. Durch Berechnung von Binormal- Tangent- und Normalenvektor kann zu jeder UV-Koordinate die Raumkoordinate ermittelt werden. Zusammen mit der Postion der Punktlichquelle wird daruas ein Stahl konstuiert, dessen Läenge das Mass fuer die Lidhtintensitaet an der UV-GRID-Koordinate ist.

Vorher aber wird geprueft, ob der Stahl eine Tile aus der Collisionlist schneidet. Ist das der Fall, ist die Ausleuchtung gleich 0.

Im dritten und letzten Schritt, wird aus der UV-Grid die vollaufloesende Lightmap generiert. Hoehe und Breite der zugewiesenen Textur bestimmen dabei die Ausdehnung der Lightmap. Die Projektion der (kleinen) Gridmap auf die (grosse) Lightmap erfolgt durch bilineare Interpolation.

Here is the call graph for this function:

Here is the caller graph for this function:

void Map::dump ( void  )

Dump der Map.

Map * Map::getInstance ( ) [static]

Liefert die Singleton-Instanz.

Returns:
Pointer auf die Instanz

Here is the call graph for this function:

Here is the caller graph for this function:

Zone * Map::getZone ( int  zoneID)

Here is the caller graph for this function:

bool Map::isAmbientON ( )

Info ob AmbientLight ON oder OFF.

Returns:
true->ON, false-->OFF

Here is the caller graph for this function:

bool Map::isDirectionalON ( )

Info ob DirectionalLight ON oder OFF.

Returns:
true->ON, false-->OFF

Here is the caller graph for this function:

bool Map::isEqual ( float  a,
float  b 
) [private]

Dump der Map.

Here is the caller graph for this function:

bool Map::isLightMapON ( )

Info ob LightMaps ON oder OFF.

Returns:
true->ON, false-->OFF

Here is the caller graph for this function:

void Map::loadLights ( DataInputStream dataIn)

Liest alle Lichteigenschaften und Pointlights aus dem Inputstream.

Parameters:
dataInDataInputStream

Here is the call graph for this function:

Here is the caller graph for this function:

void Map::saveLights ( DataOutputStream  dataOut)

Serialisiert das Light-Objekt in den Outputstream.

Parameters:
dataOutDataOutputStream
Exceptions:
IOException

Here is the call graph for this function:

Here is the caller graph for this function:

void Map::setDirectionalLight ( int  zoneID,
float  dirX,
float  dirY,
float  dirZ 
) [private]

Setzt den DirectionalLight-Richtungsvektor fuer eine Zone.

Parameters:
zoneIDzone-Nr, bzw. zone-ID
dirXX-Richtungskomponente fuer das Direktional Light
dirYY-Richtungskomponente fuer das Direktional Light
dirZZ-Richtungskomponente fuer das Direktional Light

Here is the call graph for this function:

void Map::setLight ( int  zoneID,
float  ambientMax,
float  directionalMax,
float  pointMax 
) [private]

Setzt die allgemeinen Lichteigenschaften einer Zone Es gilt: (ambientMax + directionalMax + pointMax) <= 1.0.

Parameters:
zoneIDdie Zone
ambientMaxWert fuer das ambiente Licht (= const)
directionalMaxMaximalwert fuer direktes Licht
pointMaxMaximalwert fuer Punktlicht

Here is the call graph for this function:

Here is the caller graph for this function:

void Map::stepGamma ( bool  up)

Korrigiert den Gammawert.

Parameters:
uptrue, false

Here is the call graph for this function:

Here is the caller graph for this function:

void Map::Tangentspace ( Matrix matWT,
Matrix matTR,
float  width,
float  height,
Vertex vv0,
Vertex vv1,
Vertex vv2 
) [private]

Tangentspace.

Parameters:
matWT
matTR
width
height
vv0
vv1
vv2

Here is the call graph for this function:

Here is the caller graph for this function:

void Map::TangentspaceTest ( Matrix matWT,
Matrix matTR,
Tile tile 
) [private]

Dump der Map.

Here is the call graph for this function:

Here is the caller graph for this function:

void Map::toggleAmbientLight ( )

Schaltet das Ambient Light ein oder aus.

Here is the caller graph for this function:

void Map::toggleDirectionalLight ( )

Schaltet das Directional Light ein oder aus.

Here is the caller graph for this function:

void Map::toggleLightMap ( )

Schaltet das Directional Light ein oder aus.

Here is the caller graph for this function:

void Map::trimLine ( Vec start,
Vec end,
float  epsilon 
) [private]

Verkuerzt eine Linie um epsilon.

Parameters:
startStartvektor
endEndvektor
epsilon

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Map * Map::_instance = 0 [static, private]
bool Map::m_AmbientON [private]
bool Map::m_DirectionalON [private]
float Map::m_gamma
int Map::m_gammaB[256]
int Map::m_gammaG[256]
int Map::m_gammaR[256]
bool Map::m_LightMapON [private]
char Map::m_mapfile[255] [private]
std::vector<Zone*> Map::zoneList

The documentation for this class was generated from the following files: