AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
utils.h File Reference
#include <agxOSG/export.h>
#include <agx/Vec4.h>
#include <agxUtil/agxUtil.h>
#include <agxUtil/Statistic.h>
#include <agxOSG/Node.h>
#include <agxOSG/ParticleSystemDrawable.h>
#include <agxOSG/RigidBodySystemDrawable.h>
#include <agxOSG/RigidBodyRenderCache.h>
#include <agxOSG/ScalarColorMap.h>
#include <agxOSG/DeformableRenderer.h>
#include <agxSDK/GuiEventListener.h>
#include <agxRender/Color.h>
#include <agx/PushDisableWarnings.h>
#include <osg/observer_ptr>
#include <osgGA/NodeTrackerManipulator>
#include <agx/PopDisableWarnings.h>
#include <agx/config/AGX_USE_AGXTERRAIN.h>

Go to the source code of this file.

Namespaces

namespace  agx
 The agx namespace contains the dynamics/math part of the AGX Dynamics API.
 
namespace  agxCollide
 This namespace consists of a set of classes for handling geometric intersection tests including boolean tests, penetration and contact sets.
 
namespace  agxModel
 Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
 
namespace  agxOSG
 The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
 
namespace  agxSDK
 The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simulation system including Material, event listeners etc.
 
namespace  agxUtil
 The agxUtil namespace contain classes and methods for utility functionality.
 

Enumerations

enum  agxOSG::TextureMode {
  agxOSG::DIFFUSE_TEXTURE =0 , agxOSG::SHADOW_TEXTURE =1 , agxOSG::SHADOW_JITTER_TEXTURE =2 , agxOSG::NORMALMAP_TEXTURE =3 ,
  agxOSG::HEIGHTMAP_TEXTURE =4 , agxOSG::ROUGHNESS_TEXTURE = 5 , agxOSG::CUBEMAP_TEXTURE = 6 , agxOSG::METALLIC_TEXTURE = 7
}
 

Functions

AGXOSG_EXPORT void agxOSG::addRenderCallbackToFracture (agxModel::FractureGenerator *listener, osg::Group *root)
 Adds default createVisual callback to a FractureGenerator when new fragments are created that copies RenderData from the fractured geometry shape if it exists.
 
AGXOSG_EXPORT void agxOSG::addRenderColorCallbackToFracture (agxModel::FractureGenerator *listener, osg::Group *root, const agx::Vec4f &color)
 Adds createVisual callback to a FractureGenerator when new fragments are created that sets a specific color.
 
AGXOSG_EXPORT bool agxOSG::addText (const agxCollide::Geometry *geometry, osg::Group *root, const std::string &text, const agx::Vec3 &relPosition=agx::Vec3(0, 0, 0), const agx::Vec4f &color=agxRender::Color::Yellow(), agx::Real size=0.2, int alignment=6)
 Add text relative to an geometry.
 
AGXOSG_EXPORT osg::Geode * agxOSG::create3DGrid (unsigned int resU, unsigned int resV, unsigned int resW, const agx::Vec3 &origin, const agx::Vec3 &endPointX, const agx::Vec3 &endPointY, const agx::Vec3 &endPointZ, float width)
 Create a uniform grid and adds it to a root.
 
AGXOSG_EXPORT osg::Geometry * agxOSG::create3DGrid (unsigned int resU, unsigned int resV, unsigned int resW, const osg::Vec3 &origin, const osg::Vec3 &endPointX, const osg::Vec3 &endPointY, const osg::Vec3 &endPointZ, float width)
 Create a uniform grid and adds it to a root.
 
AGXOSG_EXPORT osg::MatrixTransform * agxOSG::createAxes (agx::AffineMatrix4x4 absoluteTransform, osg::Group *root, float scale=1, float width=3)
 Creates osg axes relative the world given the absoluteTransform.
 
AGXOSG_EXPORT bool agxOSG::createAxes (agx::Constraint *constraint, osg::Group *root, float scale=1, float width=3)
 Create two axes at the constraint attachments.
 
AGXOSG_EXPORT osg::MatrixTransform * agxOSG::createAxes (agx::RigidBody *rb, agx::AffineMatrix4x4 relativeTransform, osg::Group *root, float scale=1, float width=3)
 Creates osg axes relative a rigid body given relative transform.
 
AGXOSG_EXPORT osg::MatrixTransform * agxOSG::createAxes (agx::RigidBody *rb, agx::Frame *relativeTransform, osg::Group *root, float scale=1, float width=3)
 Creates osg axes relative a rigid body given relative transform.
 
AGXOSG_EXPORT osg::MatrixTransform * agxOSG::createAxes (agxCollide::Geometry *geometry, agx::AffineMatrix4x4 relativeTransform, osg::Group *root, float scale=1, float width=3)
 Creates osg axes relative a geometry given relative transform.
 
AGXOSG_EXPORT osg::MatrixTransform * agxOSG::createAxes (agxCollide::Geometry *geometry, agx::Frame *relativeTransform, osg::Group *root, float scale=1, float width=3)
 Creates osg axes relative a geometry given relative transform.
 
AGXOSG_EXPORT osg::MatrixTransform * agxOSG::createAxes (float scale=1, float width=3)
 Create a x, y and z arrow with the size 1.
 
AGXOSG_EXPORT osg::Geode * agxOSG::createCubeLines (const agx::Vec3 &position, const agx::Vec3 &boxHalfVec3, const agxRender::Color &color=agxRender::Color::BlueViolet(), const agx::Real lineWidth=2.0f)
 This function generates a cube using line segments and returns an osg::Geode node, which can be added to an OSG scenegraph.
 
AGXOSG_EXPORT osg::MatrixTransform * agxOSG::createCylinder (const agx::AffineMatrix4x4 &transform, const agx::Vec4 &color, float radius, float height)
 Create and return a new Cylinder to render.
 
AGXOSG_EXPORT osg::Geode * agxOSG::createFrameTrajectoryDrawable (agxSDK::Simulation *simulation, osg::Group *root, agx::UInt numPositions, const agx::Vec4f &defaultColor=agx::Vec4f(0.5, 0.5, 0.5, 1.0))
 
AGXOSG_EXPORT osg::Geode * agxOSG::createGrid (unsigned int resU, unsigned int resV, const agx::Vec3 &origin, const agx::Vec3 &endPointX, const agx::Vec3 &endPointY, osg::Group *root)
 Create a uniform grid and adds it to a root.
 
AGXOSG_EXPORT osg::Geometry * agxOSG::createGrid (unsigned int resU, unsigned int resV, const osg::Vec3 &origin, const osg::Vec3 &endPointX, const osg::Vec3 &endPointY, bool wireFrameMode=false)
 Create a uniform grid.
 
AGXOSG_EXPORT osg::Geode * agxOSG::createLine (const agx::Vec3 &p1, const agx::Vec3 &p2, const agx::Vec4 &color, float width)
 Create and return a new Line to render.
 
AGXOSG_EXPORT osg::Geode * agxOSG::createParticleContactGraph (agx::ParticleSystem *particleSystem, osg::Group *root, agx::Real minForce, agx::Real maxForce)
 Creates a visual of the particle contact network, which colors contacts depending on contact force.
 
AGXOSG_EXPORT osg::Geode * agxOSG::createParticleTrajectoriesVisual (agx::ParticleSystem *particleSystem, osg::Group *root, agx::Real sampling, agx::UInt numPositions)
 Creates a visual of the particle position trajectories.
 
AGXOSG_EXPORT osg::Geode * agxOSG::createPolyline (const agx::Vec3Vector &points, const agx::Vec4 &color, float width)
 Create and return a new Polyine to render.
 
AGXOSG_EXPORT osg::Geode * agxOSG::createRigidBodyTrajectoriesVisual (agxSDK::Simulation *simulation, osg::Group *root, agx::Real sampling, agx::UInt numPositions, ScalarColorMap *scalarColorMap=nullptr)
 Creates a visual of the rigid body position trajectories.
 
AGXOSG_EXPORT osg::Geode * agxOSG::createSphere (const agx::Vec3 &center, const agx::Vec4 &color, float radius)
 Create and return a new Sphere to render.
 
AGXOSG_EXPORT osg::Geode * agxOSG::createText (const std::string &text, const agx::Vec3 &relPosition=agx::Vec3(0, 0, 0), const agx::Vec4f &color=agxRender::Color::Yellow(), agx::Real size=0.2)
 Create a text object.
 
AGXOSG_EXPORT osg::Texture2D * agxOSG::createTexture (const agxCollide::TextureDataRef data, bool linear)
 
AGXOSG_EXPORT osg::Texture2D * agxOSG::createTexture (const std::string &filename)
 Create a Texture2D object that can be assigned to nodes.
 
AGXOSG_EXPORT osg::TextureCubeMap * agxOSG::createTextureCubeMap (agx::Vector< osg::ref_ptr< osg::Image > > &images)
 Create a TextureCubeMap from 6 images with a 90x90 fov.
 
AGXOSG_EXPORT osg::TextureCubeMap * agxOSG::createTextureCubeMap (const std::string &imagename, const std::string &filetype)
 Creates an returns a CubeMap based on the images.
 
AGXOSG_EXPORT agxCollide::TrimeshagxOSG::createTrimesh (osg::Node *node)
 Extracts mesh data from an osg::Node, creates an agxCollide::Trimesh from it and returns the result.
 
AGXOSG_EXPORT osg::Group * agxOSG::createVisual (agx::Emitter *emitter, osg::Group *root)
 
AGXOSG_EXPORT osg::MatrixTransform * agxOSG::createVisual (agx::ObserverFrame *frame, osg::Group *root, float scale=1)
 Create a visual representation of an ObserverFrame (axis)
 
AGXOSG_EXPORT osg::Geode * agxOSG::createVisual (agx::ParticleSystem *particleSystem, osg::Group *root, agxOSG::ParticleSystemDrawable::ParticleRenderingMode mode=DEFAULT_PARTICLE_RENDERING_MODE, agxOSG::ParticleSystemDrawable::ParticleShaderMode particleShaderMode=agxOSG::ParticleSystemDrawable::ROTATION_SPRITES)
 Given a particle system, create a visual representation.
 
AGXOSG_EXPORT osg::Group * agxOSG::createVisual (agx::RigidBody *rb, osg::Group *root, float detailRatio=1.0f, bool createAxes=false)
 Given a rigid body, this function creates visual representation of all the geometries.
 
AGXOSG_EXPORT osg::Group * agxOSG::createVisual (agx::RigidBodyEmitter *emitter, osg::Group *root)
 
AGXOSG_EXPORT osg::Group * agxOSG::createVisual (agxSDK::Assembly *parent, osg::Group *root, float detailRatio=1.0f, bool createAxes=false)
 Given an Assembly, this function creates visual representation of all the geometries.
 
AGXOSG_EXPORT osg::Group * agxOSG::createVisual (agxSDK::Simulation *simulation, osg::Group *root, float detailRatio=1.0f, bool createAxes=false)
 Given a simulation, this function creates visual representation of all the contents in the simulation, such as geometries and particle systems.
 
AGXOSG_EXPORT agxOSG::TerrainVoxelRendereragxOSG::createVisual (agxSDK::TerrainInstance *terrainInstance, osg::Group *root)
 A terrain requires a TerrainVoxelRenderer for rendering and this function will create a TerrainVoxelRenderer and return a pointer to it for modification.
 
AGXOSG_EXPORT agxOSG::GeometryNodeagxOSG::createVisual (const agxCollide::Geometry *geometry, osg::Group *root, float detailRatio=1.0f, bool createAxes=false, bool evenIfSensor=true)
 Given a geometry, this function create visual representation of the shape.
 
AGXOSG_EXPORT agxOSG::DeformableRendereragxOSG::createVisual (const agxModel::DeformableObject *deformable, osg::Group *root, const agxRender::Color &color=agxRender::Color::DarkOliveGreen(), bool colorSurfaceStress=false, const agxRender::Color &maxStressColor=agxRender::Color::Red(), agx::Real maxStressLimit=6.0E4)
 Create deformable renderer given deformable object, root node and color.
 
AGXOSG_EXPORT osg::Group * agxOSG::createVisualTemplateCaching (agxSDK::Assembly *parent, osg::Group *root, agxOSG::RigidBodyRenderCache *cache=nullptr, float detailRatio=1.0f, bool createAxes=false)
 Given an Assembly, this function creates visual representation of all the geometries.
 
AGXOSG_EXPORT agxSDK::EventListeneragxOSG::createVisualUpdater (agxSDK::EventListener *listener, osg::Group *root)
 Given some specific classes inheriting from EventListener, this function can handle custom visual representations and effects.
 
AGXOSG_EXPORT std::tuple< osg::Group *, std::vector< size_t > > agxOSG::createVisualWithGeometryConnection (agx::RigidBody *rb, osg::Group *root, float detailRatio=1.0f, bool createAxes=false)
 Given a rigid body, this function creates visual representation of all the geometries.
 
AGXOSG_EXPORT agxOSG::DeformableRendereragxOSG::findDeformableRenderer (const agxModel::DeformableObject *deformable, osg::Group *root)
 Searches for renderer of deformable in root.
 
AGXOSG_EXPORT agxOSG::FrameTrajectoryDrawableagxOSG::findFrameTrajectoryDrawable (osg::Group *root)
 
AGXOSG_EXPORT GeometryNode * agxOSG::findGeometryNode (const agxCollide::Geometry *geometry, osg::Group *rootNode)
 Finds the geometry node associated to a geometry.
 
AGXOSG_EXPORT agx::Vector< GeometryNode * > agxOSG::findGeometryNodes (const agxCollide::Geometry *geometry, osg::Group *rootNode)
 Finds the geometry nodes associated to a geometry, if multiple are present in the specified root graph.
 
AGXOSG_EXPORT agxOSG::ParticleSystemDrawableagxOSG::findParticleSystemDrawable (osg::Group *root)
 
AGXOSG_EXPORT agxOSG::RigidBodySystemDrawableagxOSG::findRigidBodySystemDrawable (osg::Group *root)
 
AGXOSG_EXPORT osgText::Text * agxOSG::findText (const agxCollide::Geometry *geometry, osg::Group *root, size_t index=0)
 Finds a text object already added to the geometry (so the text can be changed).
 
AGXOSG_EXPORT bool agxOSG::forceWireFrameModeOn (osg::Node *node)
 
AGXOSG_EXPORT bool agxOSG::getEnableOutline (osg::Node *node)
 
AGXOSG_EXPORT agxCollide::LocalGeometryContact agxOSG::getHoveredGeometryContact (const osg::Camera *camera, agxCollide::Space *space, float x, float y)
 Get a geometry contact given the current camera and a position in the camera window.
 
AGXOSG_EXPORT void agxOSG::getNearFarPoints (const osg::Camera *camera, float x, float y, agx::Vec3 &near, agx::Vec3 &far)
 Get the near and far points of the current window, given a camera and x and y position.
 
AGXOSG_EXPORT bool agxOSG::loadCubeMapImages (const std::string &imagename, const std::string &filetype, agx::Vector< osg::ref_ptr< osg::Image > > &images)
 Internal function to load images into an array.
 
AGXOSG_EXPORT bool agxOSG::removeText (const agxCollide::Geometry *geometry, osg::Group *root, size_t index=0)
 Remove text from a geometry.
 
AGXOSG_EXPORT void agxOSG::setAlpha (osg::Node *node, float alpha, bool override=false)
 Set the alpha part of the material for a node.
 
AGXOSG_EXPORT void agxOSG::setAmbientColor (osg::Node *node, const agx::Vec4f &color, bool override=false)
 Set the ambient part of a material for a node.
 
AGXOSG_EXPORT bool agxOSG::setCubeMapTexture (osg::Node *node, const std::string &imagePath, const std::string &imageType=".dds")
 Assigns a Cubemap texture to the specified node.
 
AGXOSG_EXPORT void agxOSG::setDiffuseColor (agx::RigidBody *rb, const agx::Vec4f &color, osg::Group *root)
 Set the diffuse part of a material for a rigid body (all geometries).
 
AGXOSG_EXPORT void agxOSG::setDiffuseColor (agxCollide::Geometry *geometry, const agx::Vec4f &color, osg::Group *root)
 Set the diffuse part of a material for a geometry.
 
AGXOSG_EXPORT void agxOSG::setDiffuseColor (osg::Node *node, const agx::Vec4f &color, bool override=false)
 Set the diffuse part of a material for a node.
 
AGXOSG_EXPORT void agxOSG::setEnableLight (bool enable, int lightNum, osg::Node *node)
 
AGXOSG_EXPORT bool agxOSG::setEnableOutline (osg::Node *node, bool enabled, const agxRender::Color &color=agxRender::Color(1, 1, 0, 1), float width=2.0)
 
AGXOSG_EXPORT bool agxOSG::setEnableWireFrameMode (osg::Node *node, bool flag)
 
AGXOSG_EXPORT void agxOSG::setEnvMapReflectionCoefficient (osg::Node *node, float coeff)
 Specifies the amount of reflection that should be used (if CubeMap or SphereMap is assigned to the node).
 
AGXOSG_EXPORT void agxOSG::setGamma (osg::Node *node, float gamma, bool override=false)
 Set the gamma that will be used to transform Physical color to monitor color.
 
AGXOSG_EXPORT void agxOSG::setMetallic (osg::Node *node, float metallic, bool override=false)
 Set the metallic:ness of the material.
 
AGXOSG_EXPORT bool agxOSG::setOrbitCamera (osgViewer::Viewer *viewer, osg::Group *node, const agx::Vec3 &eye, const agx::Vec3 &center, const agx::Vec3 &up, int trackerMode=osgGA::NodeTrackerManipulator::NODE_CENTER)
 
AGXOSG_EXPORT void agxOSG::setRoughness (osg::Node *node, float roughness, bool override=false)
 Set the roughness of the material.
 
AGXOSG_EXPORT void agxOSG::setShininess (osg::Node *node, float shininess, bool override=false)
 Set the shininess exponent for the Phong specular model.
 
AGXOSG_EXPORT void agxOSG::setSpecularColor (osg::Node *node, const agx::Vec4f &color, bool override=false)
 Set the specular part of a material for a node.
 
AGXOSG_EXPORT bool agxOSG::setTexture (agxOSG::GeometryNode *node, agxOSG::Texture2D *texture, bool repeat=false, TextureMode mode=DIFFUSE_TEXTURE, float scaleU=1.0f, float scaleV=1.0f)
 Apply a 2D Texture to the specified node in OVERRIDE|PROTECTED mode.
 
AGXOSG_EXPORT bool agxOSG::setTexture (const agx::RigidBody *rigidBody, osg::Group *rootNode, const std::string &imagePath, bool repeat=false, TextureMode mode=DIFFUSE_TEXTURE)
 For all geometries in the rigid body, this function will set a 2D texture in OVERRIDE|PROTECTED mode.
 
AGXOSG_EXPORT bool agxOSG::setTexture (const agxCollide::Geometry *geometry, osg::Group *rootNode, const std::string &imagePath, bool repeat=false, TextureMode mode=DIFFUSE_TEXTURE)
 Read an image from disk and apply to the specified geometry as a 2D Texture in OVERRIDE|PROTECTED mode.
 
AGXOSG_EXPORT bool agxOSG::setTexture (osg::Node *node, agxOSG::Texture2D *texture, bool repeat=false, TextureMode mode=DIFFUSE_TEXTURE, float scaleU=1.0f, float scaleV=1.0f)
 Apply a 2D Texture to the specified node in OVERRIDE|PROTECTED mode.
 
AGXOSG_EXPORT bool agxOSG::setTexture (osg::Node *node, const agxCollide::TextureDataRef data, bool repeat=false, TextureMode mode=DIFFUSE_TEXTURE, float scaleU=1.0f, float scaleV=1.0f)
 
AGXOSG_EXPORT bool agxOSG::setTexture (osg::Node *node, const std::string &imagePath, bool repeat=false, TextureMode mode=DIFFUSE_TEXTURE, float scaleU=1.0f, float scaleV=1.0f)
 Read an image from disk and apply to the specified node as a 2D Texture in OVERRIDE|PROTECTED mode.
 
AGXOSG_EXPORT bool agxOSG::setTexture (osg::Node *node, osg::Texture2D *texture, bool repeat=false, TextureMode mode=DIFFUSE_TEXTURE, float scaleU=1.0f, float scaleV=1.0f)
 Apply a 2D Texture to the specified node in OVERRIDE|PROTECTED mode.
 
template<typename T >
void agxOSG::setUniform (osg::Node *node, const std::string &name, T value)
 
AGXOSG_EXPORT size_t agxOSG::smoothNormals (osg::Node *node, float creaseAngle=1.48353f)
 Smoothes the normals of all meshes in osg::Geometries using agxUtil::SmoothingVisitor found under the specified node and child nodes.
 
AGXOSG_EXPORT bool agxOSG::toggleWireFrameMode (osg::Node *node)