Encapsulates an appearance preserving simplification algorithm. More...
#include <FXViz/APS/SoAppearancePreserver.h>
Public Types | |
typedef void | SoAppearancePreserverProgressCB (void *userData, SoAppearancePreserver *aps, int percent) |
Public Member Functions | |
SoAppearancePreserver () | |
~SoAppearancePreserver () | |
void | setSceneGraphs (SoNode *original, SoNode *simplified) |
void | setTextureSize (int width, int height) |
void | setTriangleMinSize (int size) |
void | setProgressCallback (SoAppearancePreserverProgressCB *cb, void *data=NULL) |
SoNONUNICODE SoTexture2 * | getNormalMapTexture (const char *filename=NULL) |
SoTexture2 * | getNormalMapTexture (const SbString &filename="") |
SoNONUNICODE SoTexture2 * | getDisplacementMapTexture (const char *filename=NULL) |
SoTexture2 * | getDisplacementMapTexture (const SbString &filename="") |
SoTextureCoordinate2 * | getBumpCoords () |
This technique computes, from a highly detailed model and its corresponding simplified model obtained with the decimation tools (see SoSimplifyAction, SoSimplify...), a normal map texture and texture coordinates for this texture to be applied to the simplified model. For each triangle in the simplified model, there is a triangular area in the normal map texture that contains normal vectors derived from the original complex model. Using the bump mapping technique with the generated normal map, the rendering of the simplified model will appear with the details of the original model but using much fewer triangles.
Note 1: The time for generating the normal map depends on the size of the original model, the size of the simplified model, and also the size of the normal map texture. This process could take several minutes.
Note 2: The quality of the final rendering using the bump mapping technique is closely linked to the size of the normal map texture.
Limitations: The size of the normal map texture limits the number of possible triangles for the simplified model. This is because the minimum size for a triangle in the normal map texture is at least 3 pixels. So for a 256*256 texture size, a maximum of 22,000 triangles can be stored. If necessary, specify a larger texture (see setTextureSize) or a more aggressive simplification of the model.
SoBumpMappingProperty, SoTextureUnit.
typedef void SoAppearancePreserver::SoAppearancePreserverProgressCB(void *userData, SoAppearancePreserver *aps, int percent) |
Progress callback prototype.
SoAppearancePreserver::SoAppearancePreserver | ( | ) |
Constructor.
SoAppearancePreserver::~SoAppearancePreserver | ( | ) |
Destructor.
SoTextureCoordinate2* SoAppearancePreserver::getBumpCoords | ( | ) |
Computes the texture coordinates and creates an SoTextureCoordinate2 node.
The texture coordinates are stored in the texture coordinate point field. They can be applied with the bump mapping technique to the simplified model. NULL is returned if the texture coordinates could not be computed, generally due to there being more triangles than could be stored in the normal map.
SoTexture2* SoAppearancePreserver::getDisplacementMapTexture | ( | const SbString & | filename = "" |
) |
Computes the displacement map texture and creates an SoTexture2 node.
If no file name is specified, the texture is stored in the SoTexture2 image field. Otherwise the file name is stored in the SoTexture2 filename field and the texture is written to a PNG format file. NULL is returned if the texture could not be computed, generally due to there being more triangles than could be stored in the normal map.
SoNONUNICODE SoTexture2* SoAppearancePreserver::getDisplacementMapTexture | ( | const char * | filename = NULL |
) |
Computes the displacement map texture and creates an SoTexture2 node.
If no file name is specified, the texture is stored in the SoTexture2 image field. Otherwise the file name is stored in the SoTexture2 filename field and the texture is written to a PNG format file. NULL is returned if the texture could not be computed, generally due to there being more triangles than could be stored in the normal map.
SoTexture2* SoAppearancePreserver::getNormalMapTexture | ( | const SbString & | filename = "" |
) |
Computes the normal map texture and creates an SoTexture2 node.
If no file name is specified, the texture is stored in the SoTexture2 image field. Otherwise the file name is stored in the SoTexture2 filename field and the texture is written to a PNG format file. NULL is returned if the texture could not be computed, generally due to there being more triangles than could be stored in the normal map.
SoNONUNICODE SoTexture2* SoAppearancePreserver::getNormalMapTexture | ( | const char * | filename = NULL |
) |
Computes the normal map texture and creates an SoTexture2 node.
If no file name is specified, the texture is stored in the SoTexture2 image field. Otherwise the file name is stored in the SoTexture2 filename field and the texture is written to a PNG format file. NULL is returned if the texture could not be computed, generally due to there being more triangles than could be stored in the normal map.
void SoAppearancePreserver::setProgressCallback | ( | SoAppearancePreserverProgressCB * | cb, | |
void * | data = NULL | |||
) |
Sets a progress callback.
This callback will be called at each percentage of completion, e.g., 1%, 2%...
Specifies the original scene graph and the simplified scene graph.
void SoAppearancePreserver::setTextureSize | ( | int | width, | |
int | height | |||
) |
Specifies the texture size to be generated.
If the specified dimensions are not powers of two, the nearest powers of two will be used. Default size is 256 * 256 texels.
void SoAppearancePreserver::setTriangleMinSize | ( | int | size | ) |
Specifies the mininum size for a triangle stored within the normal map texture.
Default size is 4 texels.