Classes | Public Member Functions | Static Public Member Functions | Friends

sp::tool::LightmapGenerator Class Reference

The lightmap generator class is a utility actually only used in a world editor. More...

#include <spLightmapGenerator.hpp>

List of all members.

Classes

struct  SInternalState

Public Member Functions

 LightmapGenerator ()
 ~LightmapGenerator ()
bool generateLightmaps (const std::list< SCastShadowObject > &CastShadowObjects, const std::list< SGetShadowObject > &GetShadowObjects, const std::list< SLightmapLight > &LightSources, const video::color &AmbientColor=DEF_LIGHTMAP_AMBIENT, const u32 MaxLightmapSize=DEF_LIGHTMAP_SIZE, const f32 DefaultDensity=DEF_LIGHTMAP_DENSITY, const u8 TexelBlurRadius=DEF_LIGHTMAP_BLURRADIUS, const u8 ThreadCount=0, const s32 Flags=0)
void clearScene ()
bool updateBluring (u8 TexelBlurRadius)
bool updateAmbientColor (const video::color &AmbientColor)
scene::MeshgetFinalModel () const
const std::list< scene::Mesh * > & getSingleModels () const
const std::list
< video::Texture * > & 
getLightmapTextures () const
 Returns the list with all generated final lightmap textures.
void setStateCallback (const LightmapStateCallback &Callback)
s32 getFlags () const
 Returns the generation flags.
u8 getTexelBlurRadius () const
 Returns the texel blur radius which has been set the last time lightmap generation was used.
u8 getThreadCount () const
 Returns the count of threads used for lightmap generation.
bool hasGeneratedSuccessful () const
 Returns true if the lightmap generation has been completed successful when started last time.
const video::colorgetAmbientColor () const
 Returns the lightmap ambient color. By default (20, 20, 20, 255).

Static Public Member Functions

static void setProgressCallback (const LightmapProgressCallback &Callback)

Friends

struct LightmapGen::SAxisData
struct LightmapGen::SModel
void LMapRasterizePixelCallback (s32 x, s32 y, const LightmapGen::SRasterizerVertex &Vertex, void *UserData)
void LMapBlurPixelCallback (s32 x, s32 y, void *UserData)

Detailed Description

The lightmap generator class is a utility actually only used in a world editor.


Constructor & Destructor Documentation

sp::tool::LightmapGenerator::LightmapGenerator (  ) 
sp::tool::LightmapGenerator::~LightmapGenerator (  ) 

Member Function Documentation

void sp::tool::LightmapGenerator::clearScene (  ) 

Clears the internal objects and states. This will be called automatically when "generateLightmaps" is called.

bool sp::tool::LightmapGenerator::generateLightmaps ( const std::list< SCastShadowObject > &  CastShadowObjects,
const std::list< SGetShadowObject > &  GetShadowObjects,
const std::list< SLightmapLight > &  LightSources,
const video::color AmbientColor = DEF_LIGHTMAP_AMBIENT,
const u32  MaxLightmapSize = DEF_LIGHTMAP_SIZE,
const f32  DefaultDensity = DEF_LIGHTMAP_DENSITY,
const u8  TexelBlurRadius = DEF_LIGHTMAP_BLURRADIUS,
const u8  ThreadCount = 0,
const s32  Flags = 0 
)

Generates the lightmaps for each get-shadow-object. This is a very time-consuming procedure which has been created for a level editor. Only simple-shadows are supported and no radiosity.

Parameters:
[in] CastShadowObjects List of all 3D models which cast shadows.
[in] GetShadowObjects List of all 3D models which get shadows. Only these objects build the resulting model.
[in] LightSources List of all light sources which are to be used in the lightmap generation process.
[in] AmbientColor Darkest color for each lightmap texel. Normally (in radiosity) those parameters are not used because the light calculations are physicially correct and the light rays can arrive into dark rooms where no light sources is placed. But in this case (with just simple-shadows) the texels are complete black when it has no direct connection to the light source. This happens when a cast-shadow-object stands in the texel's way. So this parameter makes sure that a texel is not darker than AmbientColor. It is an adjustment.
[in] MaxLightmapSize Size of each lightmap texture. By default 512. Consider that the lightmap textures should not be too large and not too small. If they are too large the memory costs are higher because the MIP-map sub-textures are also generated. If they are too small more surfaces must be created for the resulting 3d model which makes the application slower.
[in] DefaultDensity Density specifies the size for generating the texture space from the world space. By this procedure larger triangle faces get larger texture faces in the lightmap. When a calculated texture face is larger then "MaxLightmapSize" it is clamped to it.
[in] TexelBlurRadius Blur factor for the lightmaps. This is also a balance for none-radiosity technic. This reduces hard-shadows and changes it to soft-shadows. The lightmap textures are not only blured completly. This technic is a little bit more complicate but can however cause some unbeautiful areas on the lightmaps. Mostly in the edges of a room. Be default 2 which causes a nice smooth light scene. If the blur factor is 0 no bluring computations will proceeded.
[in] ThreadCount Specifies the count of threads which are to be used when the lightmap texels will be computed for every light source. This has been added with version 3.2. This value must be greater than 1 to has any effect. By default 0.
[in] Flags Specifies additional options for the generation process. For more information see the ELightmapGenerationsFlags enumeration.
Returns:
True if the lightmap generation has been completed successful. Otherwise it has been canceled.
Note:
Since version 3.2 this function does no longer return a pointer to the final model which forms the whole lightmap-generated scene. From now you need to get this pointer by the "getFinalModel" function. More over multi-threading has been addded since version 3.2.
See also:
getFinalModel
ELightmapGenerationsFlags
const video::color& sp::tool::LightmapGenerator::getAmbientColor (  )  const [inline]

Returns the lightmap ambient color. By default (20, 20, 20, 255).

scene::Mesh* sp::tool::LightmapGenerator::getFinalModel (  )  const [inline]

Returns a pointer to the final lightmap-generated scene model. This is a static object, so it should not be used for animations. Dynamic objects - when "StayAlone" in the "SGetShadowObject" structure is true - has this resulting object as parent. 'StayAlone' objects are objects which also got a lightmap but which shall be further movable (e.g. doors or other movable objects).

See also:
SGetShadowObject
s32 sp::tool::LightmapGenerator::getFlags (  )  const [inline]

Returns the generation flags.

const std::list<video::Texture*>& sp::tool::LightmapGenerator::getLightmapTextures (  )  const [inline]

Returns the list with all generated final lightmap textures.

const std::list<scene::Mesh*>& sp::tool::LightmapGenerator::getSingleModels (  )  const [inline]
u8 sp::tool::LightmapGenerator::getTexelBlurRadius (  )  const [inline]

Returns the texel blur radius which has been set the last time lightmap generation was used.

u8 sp::tool::LightmapGenerator::getThreadCount (  )  const [inline]

Returns the count of threads used for lightmap generation.

bool sp::tool::LightmapGenerator::hasGeneratedSuccessful (  )  const [inline]

Returns true if the lightmap generation has been completed successful when started last time.

static void sp::tool::LightmapGenerator::setProgressCallback ( const LightmapProgressCallback Callback  )  [static]

Sets the callback function. This function is called several times in during the lightmap generation process. With this you can control the progress and maybe cancel. Try to process not so much in this function because the time costs will grow!

Parameters:
Callback,: Callback function in the form of "bool Callback(f32 Progress)" where Progress is between 0.0 and 1.0.
See also:
LightmapProgressCallback
void sp::tool::LightmapGenerator::setStateCallback ( const LightmapStateCallback Callback  )  [inline]

Sets the state callback. This function is called every time the current generation state changes.

Parameters:
[in] Callback Specifies the callback function identifier.
See also:
LightmapStateCallback
bool sp::tool::LightmapGenerator::updateAmbientColor ( const video::color AmbientColor  ) 

Updates the lightmap ambient color. This has no effect if the given color is equal to the last set ambient color or the lightmaps has not yet generated.

Returns:
True if the ambient color has been updated. Otherwise there is nothing to do.
bool sp::tool::LightmapGenerator::updateBluring ( u8  TexelBlurRadius  ) 

Updates the texel bluring. This has no effect if the given radius is equal to the last set radius or the lightmaps has not yet generated.

Returns:
True if the bluring has been updated. Otherwise there is nothing to do.

Friends And Related Function Documentation

friend struct LightmapGen::SAxisData [friend]
friend struct LightmapGen::SModel [friend]
void LMapBlurPixelCallback ( s32  x,
s32  y,
void *  UserData 
) [friend]
void LMapRasterizePixelCallback ( s32  x,
s32  y,
const LightmapGen::SRasterizerVertex Vertex,
void *  UserData 
) [friend]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines