Utility3D.cpp File Reference

#include <PVLE/3D/Utility3D.h>
#include <PVLE/Util/TracedException.h>
#include <PVLE/Util/Math.h>
#include <PVLE/Util/Util.h>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osg/Shape>
#include <osg/Vec2>
#include <limits.h>
#include <osg/Version>
#include <osg/Endian>
#include <osg/TexGen>
#include <osg/Texture1D>
#include <osg/Material>

Include dependency graph for Utility3D.cpp:

Go to the source code of this file.


Classes

class  CartographyColorizator
 Utility class that allows colorization of points a height field according to their height, with an cartography look. More...

Namespaces

namespace  osgDB
 osgDB extensions that take a boost::filesystem::path instead of a std::string for directories and files names.

Defines

#define OSG_MIN_VERSION_REQUIRED(MAJOR, MINOR, PATCH)   ((OPENSCENEGRAPH_MAJOR_VERSION>MAJOR) || (OPENSCENEGRAPH_MAJOR_VERSION==MAJOR && (OPENSCENEGRAPH_MINOR_VERSION>MINOR || (OPENSCENEGRAPH_MINOR_VERSION==MINOR && OPENSCENEGRAPH_PATCH_VERSION>=PATCH))))

Functions

bool hasUpdateCallbackType (const osg::Node &node, const std::type_info &type)
 Add an update callback to a node, even if a callback already exists, but only if another one of the same type doesn't exist or is nested.
float computeAngle (const osg::Vec3f &v1, const osg::Vec3f &v2, const osg::Vec3f reference)
 Computes angle (in [-PI; PI]) between two vectors, using a reference vector for the sign of the angle.
double computeAngle (const osg::Vec3d &v1, const osg::Vec3d &v2, const osg::Vec3d reference)
osg::Image * createNormalMap (const osg::Image *image)
 Creates a normal map from a bump map (Image can be 2D or 3D).
osg::Image * createHeightColorization (const osg::HeightField *pHF)
 Creates a 2D image to be used as a texture for a height field.
osg::StateSet * create1DTextureHeightColorization (const osg::HeightField *pHF)
 Looks much like createHeightColorization(), but uses a Texture1D (currently in dev).
void spotLightProcessing (osg::Image *pImage, float cutoff, float exponent, float constantAttenuation, float linearAttenuation, float quadraticAttenuation, float distFactor)
 Processes an image by writing the alpha channel depending on spotlight parameters.
osg::GraphicsContext::ScreenSettings getClosestFullscreenResolution (const osg::GraphicsContext::ScreenIdentifier &si, const osg::GraphicsContext::ScreenSettings &resolution)
 Returns the closest screen resolution supported.
std::ostream & operator<< (std::ostream &stream, const osg::GraphicsContext::ScreenSettings &settings)
PVLE_EXPORT osg::Image * osgDB::readImageFile (const boost::filesystem::path &path, const osgDB::ReaderWriter::Options *options)
 Calls readImageFile(const std::string&, const ReaderWriter::Options*) with boost::filesystem::path and throws an exception if the file has not been loaded.
PVLE_EXPORT osg::Image * osgDB::readImageFile (const boost::filesystem::path &path)
 Calls readImageFile(const std::string&) with boost::filesystem::path and throws an exception if the file has not been loaded.
PVLE_EXPORT void osgDB::writeImageFile (const osg::Image &image, const boost::filesystem::path &path)
 Calls writeImageFile(const osg::Image&, const std::string&) with boost::filesystem::path and throws an exception if the file has not been loaded.
PVLE_EXPORT osg::Node * osgDB::readNodeFile (const boost::filesystem::path &path, const osgDB::ReaderWriter::Options *options)
 Calls readNodeFile(const std::string&, const ReaderWriter::Options*) with boost::filesystem::path and throws an exception if the file has not been loaded.
PVLE_EXPORT osg::Node * osgDB::readNodeFile (const boost::filesystem::path &path)
 Calls readNodeFile(const std::string&) with boost::filesystem::path and throws an exception if the file has not been loaded.
PVLE_EXPORT void osgDB::writeNodeFile (const osg::Node &node, const boost::filesystem::path &path)
 Calls writeNodeFile(const osg::Node&, const std::string&) with boost::filesystem::path and throws an exception if the file has not been loaded.


Define Documentation

#define OSG_MIN_VERSION_REQUIRED ( MAJOR,
MINOR,
PATCH   )     ((OPENSCENEGRAPH_MAJOR_VERSION>MAJOR) || (OPENSCENEGRAPH_MAJOR_VERSION==MAJOR && (OPENSCENEGRAPH_MINOR_VERSION>MINOR || (OPENSCENEGRAPH_MINOR_VERSION==MINOR && OPENSCENEGRAPH_PATCH_VERSION>=PATCH))))

Definition at line 40 of file Utility3D.cpp.


Function Documentation

double computeAngle ( const osg::Vec3d &  v1,
const osg::Vec3d &  v2,
const osg::Vec3d  reference 
)

Definition at line 61 of file Utility3D.cpp.

float computeAngle ( const osg::Vec3f &  v1,
const osg::Vec3f &  v2,
const osg::Vec3f  reference 
)

Computes angle (in [-PI; PI]) between two vectors, using a reference vector for the sign of the angle.

Definition at line 55 of file Utility3D.cpp.

osg::StateSet* create1DTextureHeightColorization ( const osg::HeightField *  pHF  ) 

Looks much like createHeightColorization(), but uses a Texture1D (currently in dev).

Definition at line 332 of file Utility3D.cpp.

References ASSERT, clampl(), and clampu().

osg::Image* createHeightColorization ( const osg::HeightField *  pHF  ) 

Creates a 2D image to be used as a texture for a height field.

This image can be modified after if necessary.

Todo:
Add parameters to customize the function (see code).

Create a similar function that sets verticies color of a height field.

Definition at line 300 of file Utility3D.cpp.

References ASSERT, clamp(), and CartographyColorizator::valsFromHF().

osg::Image* createNormalMap ( const osg::Image *  image  ) 

Creates a normal map from a bump map (Image can be 2D or 3D).

Todo:
3D Part is deprecated and now unsupported !

RGB/RGBA source formats are handled using the first encountered color channel (Endian-dependant!). Need to average the 3 source colors.

Definition at line 124 of file Utility3D.cpp.

References LOG_NOTICE, and LOG_WARN.

osg::GraphicsContext::ScreenSettings getClosestFullscreenResolution ( const osg::GraphicsContext::ScreenIdentifier &  si,
const osg::GraphicsContext::ScreenSettings &  resolution 
)

Returns the closest screen resolution supported.

It tries to find the closest width and height, and then the closest color depth, and finally the highest refresh rate.

Todo:
Move this elsewhere (that's windowing related, not 3D).

Definition at line 477 of file Utility3D.cpp.

References ASSERT, and LOG_NOTICE.

bool hasUpdateCallbackType ( const osg::Node &  node,
const std::type_info &  type 
)

Add an update callback to a node, even if a callback already exists, but only if another one of the same type doesn't exist or is nested.

Definition at line 44 of file Utility3D.cpp.

std::ostream& operator<< ( std::ostream &  stream,
const osg::GraphicsContext::ScreenSettings &  settings 
)

Definition at line 553 of file Utility3D.cpp.

void spotLightProcessing ( osg::Image *  pImage,
float  cutoff,
float  exponent,
float  constantAttenuation,
float  linearAttenuation,
float  quadraticAttenuation,
float  distFactor 
)

Processes an image by writing the alpha channel depending on spotlight parameters.

Definition at line 411 of file Utility3D.cpp.

References ASSERT, clamp_copy(), and LOG_NOTICE.


Generated on Sun Jan 17 11:39:23 2010 for PVLE (Pro-Vocation Light Engine) by  doxygen 1.5.9