 |
AGXDynamics
2.35.0.2
|
Go to the documentation of this file.
17 #ifndef AGXOSG_UTILS_H
18 #define AGXOSG_UTILS_H
33 #include <osg/observer_ptr>
41 class RigidBodyEmitter;
56 class ExponentialMovingAverageStatistic;
61 class FractureGenerator;
87 class FrameTrajectoryDrawable;
155 const agx::RigidBody* rigidBody, osg::Group* rootNode,
const std::string& imagePath,
170 float scaleU = 1.0f,
float scaleV = 1.0f);
192 float scaleU = 1.0f,
float scaleV = 1.0f);
219 template <
typename T>
220 void setUniform( osg::Node *node,
const std::string& name, T value)
222 if ( node ==
nullptr )
225 node->getOrCreateStateSet()->addUniform(
new osg::Uniform(name.c_str(), value));
241 const std::string& text,
300 bool wireFrameMode =
false);
598 void setSmoothFactor(
const agx::Real& smoothFactor);
605 void setConeLength(
const agx::Real& length);
611 void setArrowRadius(
const agx::Real& radius);
625 virtual void update(
float x,
float y);
AGXOSG_EXPORT void setAmbientColor(osg::Node *node, const agx::Vec4f &color)
Set the ambient part of a material for a node.
AGXOSG_EXPORT void 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...
AGXOSG_EXPORT osg::Geode * createParticleTrajectoriesVisual(agx::ParticleSystem *particleSystem, osg::Group *root, agx::Real sampling, agx::UInt numPositions)
Creates a visual of the particle position trajectories.
agx::Vector< std::pair< Constraint1DOFObserverVector, agx::Vec3 > > Constraint1DOFObserverVectorVec3PairVector
agx::Vector< agxUtil::ExponentialMovingAverageStatistic > ExponentialMovingAverageStatisticVector
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
AGXOSG_EXPORT osg::Geode * 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.
Derive from this class to implement a listener for simulation GuiEvents.
Specialization for constraints that have only one degree of freedom such as Hinge and Prismatic.
RigidBodyRefVec3PairTable m_bodies
The rigid body class, combining a geometric model and a frame of reference.
#define DOXYGEN_END_INTERNAL_BLOCK()
An EventListener can be associated to a Simulation and triggered upon various events.
AGXOSG_EXPORT osg::Geode * 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 bool setOrbitCamera(osgViewer::Viewer *viewer, agxOSG::GeometryNode *node, const agx::Vec3 &eye, const agx::Vec3 ¢er, const agx::Vec3 &up, int trackerMode)
#define DEFAULT_PARTICLE_RENDERING_MODE
#define DOXYGEN_START_INTERNAL_BLOCK()
A class holding 4 dimensional vectors and providing basic arithmetic.
AGXOSG_EXPORT osg::Texture2D * createTexture(const std::string &filename)
Create a Texture2D object that can be assigned to nodes.
AGXOSG_EXPORT osg::TextureCubeMap * createTextureCubeMap(agx::Vector< osg::ref_ptr< osg::Image > > &images)
Internal functions for creating texture cube maps.
AGXOSG_EXPORT bool getEnableOutline(osg::Node *node)
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
AGXOSG_EXPORT bool 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.
AGXOSG_EXPORT void setSpecularColor(osg::Node *node, const agx::Vec4f &color)
Set the specular part of a material for a node.
AGXOSG_EXPORT void setEnableLight(bool enable, int lightNum, osg::Node *node)
agx::Vector< agx::Constraint1DOFObserver > Constraint1DOFObserverVector
Helper vector's for ForceArrowListener.
AGXOSG_EXPORT void setDiffuseColor(agxCollide::Geometry *geometry, const agx::Vec4f &color, osg::Group *root)
Set the diffuse part of a material for a geometry.
An assembly is a collection of basic simulation objects, such as rigid bodies, constraints,...
Utility color class with "common colors".
AGXOSG_EXPORT agxCollide::Trimesh * createTrimesh(osg::Node *node)
Extracts mesh data from an osg::Node, creates an agxCollide::Trimesh from it and returns the result.
With this class you can attach an ObserverFrame object relative to a RigidBody.
A basic particle system that contains all the storages and buffers required for basic operation and a...
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
agx::Vector< ExponentialMovingAverageStatisticVector > calculateTotalContactForceVectorVector
ExponentialMovingAverageStatisticVector m_constraintStatistics
AGXOSG_EXPORT bool toggleWireFrameMode(osg::Node *node)
AGXOSG_EXPORT bool setEnableWireFrameMode(osg::Node *node, bool flag)
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
agx::HashVector< agx::RigidBodyRef, agx::Vec3 > RigidBodyRefVec3PairTable
void setUniform(osg::Node *node, const std::string &name, T value)
AGXOSG_EXPORT osg::Geode * 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 void setAlpha(osg::Node *node, float alpha)
Set the alpha part of the material for a node.
virtual void update(float x, float y)
Called once per simulation frame.
ContactForceStatistics
Contact force directions.
The geometry representation used by the collision detection engine.
AGXOSG_EXPORT void setEnvMapReflectionCoefficient(osg::Node *node, float coeff)
Specifies the amount of reflection that should be used (if CubeMap or SphereMap is assigned to the no...
AGXOSG_EXPORT GeometryNode * findGeometryNode(const agxCollide::Geometry *geometry, osg::Group *rootNode)
Finds the geometry node associated to a geometry.
This class contains all Geometries and performs Broad Phase and Narrow Phase collision detection to c...
AGXOSG_EXPORT bool setCubeMapTexture(osg::Node *node, const std::string &imagePath, const std::string &imageType=".dds")
Assigns a Cubemap texture to the specified node.
AGXOSG_EXPORT bool setEnableOutline(osg::Node *node, bool enabled, const agxRender::Color &color=agxRender::Color(1, 1, 0, 1), float width=2.0)
AGXCORE_EXPORT Component * root()
Spawns new Rigid Bodies inside a volume given to the Emitter.
AGXOSG_EXPORT osg::Group * 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...
AGXOSG_EXPORT void setShininess(osg::Node *node, float shininess)
Set the shininess exponent for the Phong specular model.
This namespace consists of a set of classes for handling geometric intersection tests including boole...
Creates an arrow visualizing force, either contact force (for added bodies), or motor force for added...
AGXOSG_EXPORT agxOSG::FrameTrajectoryDrawable * findFrameTrajectoryDrawable(osg::Group *root)
The base class for a constraint.
AGXOSG_EXPORT void 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 removeText(const agxCollide::Geometry *geometry, osg::Group *root, size_t index=0)
Remove text from a geometry.
AGXOSG_EXPORT osgText::Text * 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 void createAxes(agx::Constraint *constraint, osg::Group *root, float scale=1.f, const agx::Vec4f &color=agx::Vec4f())
Create axes at the constraint attachments.
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
AGXOSG_EXPORT bool 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.
Triangle mesh for geometric intersection tests.
A node that can be associated with a collision geometry so that the transformation of this node is up...
Constraint1DOFObserverVectorVec3PairVector m_constraint1DOFVectors
AGXOSG_EXPORT agxCollide::LocalGeometryContact 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.
calculateTotalContactForceVectorVector m_bodyStatistics
AGXOSG_EXPORT void addRenderCallbackToFracture(agxModel::FractureGenerator *listener, osg::Group *root)
Adds default createVisual callback to a FractureGenerator when new fragments are created that copies ...
static agxRender::Color Yellow()
The object defining a frame of reference and providing transformations operations.
AGXOSG_EXPORT bool 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.
Spawns new bodys inside a given volume.
The agxUtil namespace contain classes and methods for utility functionality.
AGXOSG_EXPORT agxSDK::EventListener * createVisualUpdater(agxSDK::EventListener *listener, osg::Group *node)
Given some specific classes inheriting from EventListener, this function can handle custom visual rep...
AGXOSG_EXPORT agxOSG::ParticleSystemDrawable * findParticleSystemDrawable(osg::Group *root)
AGXOSG_EXPORT agxOSG::RigidBodySystemDrawable * findRigidBodySystemDrawable(osg::Group *root)
AGXOSG_EXPORT bool forceWireFrameModeOn(osg::Node *node)
AGXOSG_EXPORT osg::Geode * 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 * 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.