AGX Dynamics  2.35.0.1
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/ScalarColorMap.h>
#include <agxSDK/GuiEventListener.h>
#include <agxRender/Color.h>
#include <agx/PushDisableWarnings.h>
#include <osg/observer_ptr>
#include <agx/PopDisableWarnings.h>

Go to the source code of this file.

Classes

class  agxOSG::ForceArrowRenderer
 Creates an arrow visualizing force, either contact force (for added bodies), or motor force for added Constraint1DOF (Hinge,Prismatic,..) More...
 

Namespaces

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

Typedefs

typedef agx::Vector< ExponentialMovingAverageStatisticVector > agxOSG::calculateTotalContactForceVectorVector
 
typedef agx::Vector< agx::Constraint1DOFObserver > agxOSG::Constraint1DOFObserverVector
 Helper vector's for ForceArrowListener. More...
 
typedef agx::Vector< std::pair< Constraint1DOFObserverVector, agx::Vec3 > > agxOSG::Constraint1DOFObserverVectorVec3PairVector
 
typedef agx::Vector< agxUtil::ExponentialMovingAverageStatistic > agxOSG::ExponentialMovingAverageStatisticVector
 
typedef agx::HashVector< agx::RigidBodyRef, agx::Vec3 > agxOSG::RigidBodyRefVec3PairTable
 

Enumerations

enum  agxOSG::ContactForceStatistics {
  agxOSG::NORMAL_X = 0 , agxOSG::NORMAL_Y , agxOSG::NORMAL_Z , agxOSG::FRICTION_X ,
  agxOSG::FRICTION_Y , agxOSG::FRICTION_Z , agxOSG::NUM_FORCES
}
 Contact force directions. More...
 
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::SPECULARMAP_TEXTURE = 5 , agxOSG::SPHEREMAP_TEXTURE = 6
}
 

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. More...
 
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. More...
 
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)
 Add text relative to an geometry. More...
 
AGXOSG_EXPORT osg::MatrixTransform * agxOSG::createAxes (agx::AffineMatrix4x4 relativeTransform, osg::Group *root, float scale=1.f, const agx::Vec4f &color=agx::Vec4f())
 
AGXOSG_EXPORT void agxOSG::createAxes (agx::Constraint *constraint, osg::Group *root, float scale=1.f, const agx::Vec4f &color=agx::Vec4f())
 Create axes at the constraint attachments. More...
 
AGXOSG_EXPORT osg::MatrixTransform * agxOSG::createAxes (agx::RigidBody *rb, agx::AffineMatrix4x4 relativeTransform, osg::Group *root, float scale=1.f, const agx::Vec4f &color=agx::Vec4f())
 
AGXOSG_EXPORT osg::MatrixTransform * agxOSG::createAxes (agx::RigidBody *rb, agx::Frame *relativeTransform, osg::Group *root, float scale=1.f, const agx::Vec4f &color=agx::Vec4f())
 Creates osg axes relative a rigid body given relative transform. More...
 
AGXOSG_EXPORT osg::MatrixTransform * agxOSG::createAxes (agxCollide::Geometry *geometry, agx::AffineMatrix4x4 relativeTransform, osg::Group *root, float scale=1, const agx::Vec4f &color=agx::Vec4f())
 
AGXOSG_EXPORT osg::MatrixTransform * agxOSG::createAxes (agxCollide::Geometry *geometry, agx::Frame *relativeTransform, osg::Group *root, float scale=1, const agx::Vec4f &color=agx::Vec4f())
 Creates osg axes relative a geometry given relative transform. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
AGXOSG_EXPORT osg::Texture2D * agxOSG::createTexture (const std::string &filename)
 Create a Texture2D object that can be assigned to nodes. More...
 
AGXOSG_EXPORT osg::TextureCubeMap * agxOSG::createTextureCubeMap (agx::Vector< osg::ref_ptr< osg::Image > > &images)
 Internal functions for creating texture cube maps. More...
 
AGXOSG_EXPORT osg::TextureCubeMap * agxOSG::createTextureCubeMap (const std::string &imagename, const std::string &filetype)
 
AGXOSG_EXPORT agxCollide::Trimesh * agxOSG::createTrimesh (osg::Node *node)
 Extracts mesh data from an osg::Node, creates an agxCollide::Trimesh from it and returns the result. More...
 
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) More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
AGXOSG_EXPORT agxOSG::GeometryNode * agxOSG::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. More...
 
AGXOSG_EXPORT agxSDK::EventListener * agxOSG::createVisualUpdater (agxSDK::EventListener *listener, osg::Group *node)
 Given some specific classes inheriting from EventListener, this function can handle custom visual representations and effects. More...
 
AGXOSG_EXPORT agxOSG::FrameTrajectoryDrawable * agxOSG::findFrameTrajectoryDrawable (osg::Group *root)
 
AGXOSG_EXPORT GeometryNode * agxOSG::findGeometryNode (const agxCollide::Geometry *geometry, osg::Group *rootNode)
 Finds the geometry node associated to a geometry. More...
 
AGXOSG_EXPORT agxOSG::ParticleSystemDrawable * agxOSG::findParticleSystemDrawable (osg::Group *root)
 
AGXOSG_EXPORT agxOSG::RigidBodySystemDrawable * agxOSG::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). More...
 
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. More...
 
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. More...
 
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. More...
 
AGXOSG_EXPORT bool agxOSG::removeText (const agxCollide::Geometry *geometry, osg::Group *root, size_t index=0)
 Remove text from a geometry. More...
 
AGXOSG_EXPORT void agxOSG::setAlpha (osg::Node *node, float alpha)
 Set the alpha part of the material for a node. More...
 
AGXOSG_EXPORT void agxOSG::setAmbientColor (osg::Node *node, const agx::Vec4f &color)
 Set the ambient part of a material for a node. More...
 
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. More...
 
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). More...
 
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. More...
 
AGXOSG_EXPORT void agxOSG::setDiffuseColor (osg::Node *node, const agx::Vec4f &color)
 Set the diffuse part of a material for a node. More...
 
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). More...
 
AGXOSG_EXPORT bool agxOSG::setOrbitCamera (osgViewer::Viewer *viewer, agxOSG::GeometryNode *node, const agx::Vec3 &eye, const agx::Vec3 &center, const agx::Vec3 &up, int trackerMode)
 
AGXOSG_EXPORT void agxOSG::setShininess (osg::Node *node, float shininess)
 Set the shininess exponent for the Phong specular model. More...
 
AGXOSG_EXPORT void agxOSG::setSpecularColor (osg::Node *node, const agx::Vec4f &color)
 Set the specular part of a material for a node. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
template<typename T >
void agxOSG::setUniform (osg::Node *node, const std::string &name, T value)
 
AGXOSG_EXPORT bool agxOSG::toggleWireFrameMode (osg::Node *node)