#include <PVLE/3D/Commons.h>
#include <PVLE/3D/Utility3D.h>
#include <osg/Vec4>
#include <osg/Geode>
#include <osg/Drawable>
#include <osg/Texture2D>
#include <osg/Image>
#include <osg/ShapeDrawable>
#include <osg/CullFace>
#include <osg/MatrixTransform>
#include <osg/Projection>
#include <osg/Material>
#include <osgDB/ReadFile>
#include <osg/Geometry>
#include <osg/LineWidth>
#include <osgText/Text>
#include <osg/BlendFunc>
#include <osg/Depth>
#include <boost/cast.hpp>
#include <PVLE/3D/MoveWithEyePointTransform.h>
#include <PVLE/Util/TracedException.h>
#include <PVLE/Util/Util.h>
#include <PVLE/Util/Rand.h>
Go to the source code of this file.
Functions | |
osg::Transform * | createSkySphere (const boost::filesystem::path &texturePath, float detailRatio) |
Creates a sky sphere at an "infinite distance" (actually use a MoveWithEyePointTransform to do as-if). | |
osg::Geometry * | createAxisDrawable (const osg::Vec3 &corner, const osg::Vec3 &xdir, const osg::Vec3 &ydir, const osg::Vec3 &zdir) |
Creates a drawable that represent 3 axis. | |
osg::Geometry * | createSegmentDrawable (const osg::Vec3 &p1, const osg::Vec3 &p2, float width, const osg::Vec4 &color1, const osg::Vec4 &color2) |
Creates a segment drawable. | |
osg::Geode * | createAxis (float axisSize) |
Convinience function that creates a node with 3 axis. | |
osg::Geode * | createSegment (const osg::Vec3 &p1, const osg::Vec3 &p2, float width, const osg::Vec4 &color1, const osg::Vec4 &color2) |
Convinience function that creates a segment. | |
osg::Geometry * | createSquare (const osg::Vec3 &corner, const osg::Vec3 &width, const osg::Vec3 &height, osg::Image *image, UINT nbTextureCoords, bool invertYTexCoords) |
Creates a quad at a given position. | |
void | updateSquare (osg::Geometry *pGeometry, const osg::Vec3 &width, const osg::Vec3 &height) |
Updates a quad created by createSquare() with new dimensions, generally to use it as a progress bar. | |
void | updateSquare (osg::Geometry *pGeometry, const osg::Vec3 &corner, const osg::Vec3 &width, const osg::Vec3 &height) |
Redifines a quad created by createSquare() with new dimensions and position, generally to use it as a progress bar. | |
std::pair< osg::Projection *, osg::MatrixTransform * > | create2DProjection (const osg::Matrix &orthoProjectionMatrix) |
Creates a 2D projection, return that projection node and its first children (a MatrixTransform to which nodes can be added). | |
osg::Projection * | encapsulateIn2DProjection (osg::Node *pNode, const osg::Matrix &orthoProjectionMatrix) |
Sets the given node to be child of a 2D projection, and return that projection node. | |
void | setHudStatset (osg::StateSet *pStateset) |
void | setColor (osg::StateSet *pStateSet, const osg::Vec4 &color) |
Convinience function for setting diffuse and ambiant parameters. Creates a material and add it to the given stateset, or modifies the existing one. | |
void | setColor (osg::Node *pNode, const osg::Vec4 &color) |
Convinience function for setting diffuse and ambiant parameters. Creates a material and add it to the stateset of the node, or modifies the existing one. | |
osg::MatrixTransform * | createShapeGeode (osg::Shape *shape, float tesselationDetailRatio) |
Creates a geode with a ShapeDrawable encapsulated in a MatrixTransform. | |
osg::MatrixTransform * | createShapeGeodeBox (const osg::Vec3 &size) |
Creates a box (geode with a ShapeDrawable) encapsulated in a MatrixTransform. | |
osg::MatrixTransform * | createShapeGeodeSphere (const float radius, float tesselationDetailRatio) |
Creates a sphere (geode with a ShapeDrawable) encapsulated in a MatrixTransform. | |
osg::MatrixTransform * | createShapeGeodeCapsule (const float radius, const float length, float tesselationDetailRatio) |
Creates a capsule (geode with a ShapeDrawable) encapsulated in a MatrixTransform. | |
osg::MatrixTransform * | createShapeGeodeCylinder (const float radius, const float length, float tesselationDetailRatio) |
Creates a cylinder (geode with a ShapeDrawable) encapsulated in a MatrixTransform. | |
osg::HeightField * | readHeightMap (const boost::filesystem::path &path, const float vScale, const float hScale) |
Loads a heightmap (grey scale) into an osg::HeightField centered in (0,0,0). | |
osgText::Text * | createText (osgText::Font *pFont, float height, const osg::Vec3f &position, const osg::Vec4f &color) |
Convinience function that create an osgText::Text and then calls appropriate methods on it. | |
osg::Geode * | createCloud (const boost::filesystem::path &imagePath, unsigned int numSprites) |
Creates a random cloud made of sprites. | |
osg::Geode * | createCloud (const CloudParams &p) |
Creates a cloud made of sprites, from given parameters. |
std::pair<osg::Projection*, osg::MatrixTransform*> create2DProjection | ( | const osg::Matrix & | orthoProjectionMatrix | ) |
Creates a 2D projection, return that projection node and its first children (a MatrixTransform to which nodes can be added).
Definition at line 235 of file 3D/Commons.cpp.
Referenced by encapsulateIn2DProjection(), and Hud::Hud().
osg::Geode* createAxis | ( | float | axisSize | ) |
Convinience function that creates a node with 3 axis.
Definition at line 154 of file 3D/Commons.cpp.
References createAxisDrawable().
osg::Geometry* createAxisDrawable | ( | const osg::Vec3 & | corner, | |
const osg::Vec3 & | xdir, | |||
const osg::Vec3 & | ydir, | |||
const osg::Vec3 & | zdir | |||
) |
Creates a drawable that represent 3 axis.
Definition at line 94 of file 3D/Commons.cpp.
Referenced by createAxis().
osg::Geode* createCloud | ( | const CloudParams & | p | ) |
Creates a cloud made of sprites, from given parameters.
Definition at line 364 of file 3D/Commons.cpp.
References CloudParams::alphaOffsetMax, CloudParams::alphaOffsetMin, CloudParams::axis, CloudParams::colorScaleRand, createSquare(), CloudParams::density, CloudParams::hiColor, CloudParams::imagePath, CloudParams::lowColor, CloudParams::numSprites, rand(), CloudParams::ratio, osgDB::readImageFile(), CloudParams::skewHMax, CloudParams::skewHMin, CloudParams::skewVMax, CloudParams::skewVMin, CloudParams::spriteSizeMax, CloudParams::spriteSizeMin, and toVec3().
Referenced by createCloud().
osg::Geode* createCloud | ( | const boost::filesystem::path & | imagePath, | |
unsigned int | numSprites | |||
) |
Creates a random cloud made of sprites.
Definition at line 357 of file 3D/Commons.cpp.
References createCloud(), CloudParams::imagePath, and CloudParams::numSprites.
osg::Geode* createSegment | ( | const osg::Vec3 & | p1, | |
const osg::Vec3 & | p2, | |||
float | width, | |||
const osg::Vec4 & | color1, | |||
const osg::Vec4 & | color2 | |||
) |
Convinience function that creates a segment.
Definition at line 160 of file 3D/Commons.cpp.
References createSegmentDrawable().
osg::Geometry* createSegmentDrawable | ( | const osg::Vec3 & | p1, | |
const osg::Vec3 & | p2, | |||
float | width, | |||
const osg::Vec4 & | color1, | |||
const osg::Vec4 & | color2 | |||
) |
Creates a segment drawable.
Definition at line 120 of file 3D/Commons.cpp.
Referenced by createSegment().
osg::MatrixTransform* createShapeGeode | ( | osg::Shape * | shape, | |
float | tesselationDetailRatio | |||
) |
Creates a geode with a ShapeDrawable encapsulated in a MatrixTransform.
Definition at line 282 of file 3D/Commons.cpp.
Referenced by createShapeGeodeBox(), createShapeGeodeCapsule(), createShapeGeodeCylinder(), and createShapeGeodeSphere().
osg::MatrixTransform* createShapeGeodeBox | ( | const osg::Vec3 & | size | ) |
Creates a box (geode with a ShapeDrawable) encapsulated in a MatrixTransform.
Definition at line 296 of file 3D/Commons.cpp.
References createShapeGeode().
Referenced by createBox3DPhy(), createFixedBox3DPhy(), and C3DPhy::createPhysicsDebugView().
osg::MatrixTransform* createShapeGeodeCapsule | ( | const float | radius, | |
const float | length, | |||
float | tesselationDetailRatio | |||
) |
Creates a capsule (geode with a ShapeDrawable) encapsulated in a MatrixTransform.
Definition at line 298 of file 3D/Commons.cpp.
References createShapeGeode().
Referenced by createCapsule3DPhy(), createFixedCapsule3DPhy(), and C3DPhy::createPhysicsDebugView().
osg::MatrixTransform* createShapeGeodeCylinder | ( | const float | radius, | |
const float | length, | |||
float | tesselationDetailRatio | |||
) |
Creates a cylinder (geode with a ShapeDrawable) encapsulated in a MatrixTransform.
Definition at line 299 of file 3D/Commons.cpp.
References createShapeGeode().
Referenced by createCylinder3DPhy(), createFixedCylinder3DPhy(), and C3DPhy::createPhysicsDebugView().
osg::MatrixTransform* createShapeGeodeSphere | ( | const float | radius, | |
float | tesselationDetailRatio | |||
) |
Creates a sphere (geode with a ShapeDrawable) encapsulated in a MatrixTransform.
Definition at line 297 of file 3D/Commons.cpp.
References createShapeGeode().
Referenced by createFixedSphere3DPhy(), C3DPhy::createPhysicsDebugView(), createSphere3DPhy(), and Explosion::init().
osg::Transform* createSkySphere | ( | const boost::filesystem::path & | texturePath, | |
float | detailRatio = 0.5f | |||
) |
Creates a sky sphere at an "infinite distance" (actually use a MoveWithEyePointTransform to do as-if).
texturePath | Path of the texture used. | |
detailRatio | Same as osg::TessellationHints::setDetailRatio(float). |
Definition at line 59 of file 3D/Commons.cpp.
References osgDB::readImageFile().
osg::Geometry* createSquare | ( | const osg::Vec3 & | corner, | |
const osg::Vec3 & | width, | |||
const osg::Vec3 & | height, | |||
osg::Image * | image = NULL , |
|||
unsigned int | nbTextureCoords = 1 , |
|||
bool | invertYTexCoords = false | |||
) |
Creates a quad at a given position.
Similar to osg::createTexturedQuadGeometry().
Definition at line 166 of file 3D/Commons.cpp.
Referenced by createCloud(), and createSquareFor2D().
osgText::Text* createText | ( | osgText::Font * | pFont, | |
float | height, | |||
const osg::Vec3f & | position, | |||
const osg::Vec4f & | color | |||
) |
Convinience function that create an osgText::Text and then calls appropriate methods on it.
Definition at line 329 of file 3D/Commons.cpp.
osg::Projection* encapsulateIn2DProjection | ( | osg::Node * | pNode, | |
const osg::Matrix & | orthoProjectionMatrix | |||
) |
Sets the given node to be child of a 2D projection, and return that projection node.
Definition at line 248 of file 3D/Commons.cpp.
References create2DProjection().
osg::HeightField* readHeightMap | ( | const boost::filesystem::path & | path, | |
const float | vScale = 1.f , |
|||
const float | hScale = 3000.f | |||
) |
Loads a heightmap (grey scale) into an osg::HeightField centered in (0,0,0).
path | Path for the bitmap | |
vScale | Vertical (height) scale. | |
hScale | Horizontal scale. |
Definition at line 302 of file 3D/Commons.cpp.
References osgDB::readImageFile(), THROW_TRACED_EXCEPTION, and THROW_TRACED_FMT_EXCEPTION.
void setColor | ( | osg::Node * | pNode, | |
const osg::Vec4 & | color | |||
) |
Convinience function for setting diffuse and ambiant parameters. Creates a material and add it to the stateset of the node, or modifies the existing one.
Definition at line 275 of file 3D/Commons.cpp.
References ASSERT, and setColor().
void setColor | ( | osg::StateSet * | pStateSet, | |
const osg::Vec4 & | color | |||
) |
Convinience function for setting diffuse and ambiant parameters. Creates a material and add it to the given stateset, or modifies the existing one.
Definition at line 265 of file 3D/Commons.cpp.
References ASSERT.
Referenced by PhysicsDebugUpdateCB::operator()(), and setColor().
void setHudStatset | ( | osg::StateSet * | pStateset | ) |
void updateSquare | ( | osg::Geometry * | pGeometry, | |
const osg::Vec3 & | corner, | |||
const osg::Vec3 & | width, | |||
const osg::Vec3 & | height | |||
) |
Redifines a quad created by createSquare() with new dimensions and position, generally to use it as a progress bar.
setUseDisplayList(false)
after createSquare()
. Definition at line 224 of file 3D/Commons.cpp.
void updateSquare | ( | osg::Geometry * | pGeometry, | |
const osg::Vec3 & | width, | |||
const osg::Vec3 & | height | |||
) |
Updates a quad created by createSquare() with new dimensions, generally to use it as a progress bar.
setUseDisplayList(false)
after createSquare()
. Definition at line 218 of file 3D/Commons.cpp.
References updateSquare().
Referenced by updateSquare(), and updateSquareFor2D().