 |
AGX Dynamics
2.38.0.2
|
Go to the documentation of this file.
20 #pragma clang diagnostic push
21 #pragma clang diagnostic ignored "-Wconversion"
24 #include <agx/config/AGX_USE_OPENGL.h>
25 #include <agx/config/AGX_USE_FFMPEG.h>
26 #include <agx/config/AGX_USE_PYTHON.h>
28 #include <agx/config.h>
32 #include <osgViewer/Viewer>
33 #include <osg/Version>
34 #include <osg/ref_ptr>
35 #include <osg/MatrixTransform>
48 #if AGX_USE_WEBSOCKETS()
57 #include <agxCFG/ConfigScript.h>
76 # include <agx/config/AGX_PYTHON_VERSION.h>
80 #pragma clang diagnostic pop
85 class StandardManipulator;
86 class MatrixManipulator;
105 class CoSimulationServer;
109 class ExampleApplication;
110 class SceneDecorator;
111 class RenderProxyFactory;
113 #if AGX_USE_WEBSOCKETS()
114 class ExampleApplicationController;
129 SceneDescription(
const std::string& scriptFileName,
const std::string& scriptFunctionName,
bool isTest =
false,
float stop = -1,
bool isSlowUnittest =
false);
132 SceneDescription(
const std::string& sceneFile,
bool isTest =
false,
float stop = -1,
bool isSlowUnittest =
false);
147 #if defined(OSG_VERSION_GREATER_OR_EQUAL)
148 # if OSG_VERSION_GREATER_OR_EQUAL(2,9,11)
186 auto viewport = m_mainCamera->getViewport();
187 m_glCamera->
setViewPort(
static_cast<int>(viewport->width()),
static_cast<int>(m_mainCamera->getViewport()->height()));
189 using osg::Camera::DrawCallback::operator();
192 osg::Camera *m_mainCamera;
200 : m_glLights(mainLights),
201 m_decorator(decorator)
223 using osg::Camera::DrawCallback::operator();
235 #if defined(OSG_VERSION_GREATER_OR_EQUAL)
236 # if OSG_VERSION_GREATER_OR_EQUAL(2,9,11)
257 SINGLETON_CLASSNAME_METHOD();
258 virtual void shutdown()
override { s_instance =
nullptr; }
259 osgViewer::GraphicsWindow* getWindow( osgViewer::Viewer* viewer,
size_t num = 0 )
const;
275 CameraData(
const osgViewer::Viewer* viewer );
280 void applyTo( osg::Camera* camera )
const;
285 void applyTo( osgViewer::Viewer* viewer )
const;
300 void initialize(
const osg::Camera* camera );
333 MAIN_SCENE_MASK = 1 << 1,
334 DEBUG_RENDER_MASK = 1 << 2,
335 OSG_RENDER_MASK = 1 << 3,
337 DECORATOR_MASK = 1 << 5,
351 std::string getSolverName( SolverType t )
const;
352 SolverType getSolverType(
const std::string& name )
const;
365 void setEnableAutoPausing(
bool flag);
366 bool getEnableAutoPausing();
376 bool init(
int argc,
char** argv );
386 bool addScene(
const std::string& scriptFile,
const std::string& scriptFunction,
int key,
bool isPartofUnitTest=
true,
float stopAfter=-1,
bool isSlowUnittest=
false );
387 bool addScene(
const std::string& scriptFile,
const std::string& scriptFunction,
bool isPartofUnitTest=
true,
float stopAfter=-1,
bool isSlowUnittest=
false );
389 bool addScene(
BuildScenePtr sceneFunction,
int key,
bool isPartofUnitTest=
true,
float stopAfter=-1,
bool isSlowUnittest=
false );
390 bool addScene(
BuildScenePtr sceneFunction,
bool isPartofUnitTest=
true,
float stopAfter=-1,
bool isSlowUnittest=
false );
407 void setOsgNotifyLevel(osg::NotifySeverity severity)
const;
426 void stop(
int exitCode = 0) { m_shouldStop =
true; m_exitCode = exitCode; }
440 bool setWindowRectangle(
unsigned int x,
unsigned int y,
unsigned int width,
unsigned int height);
447 bool setWindowTitle(
const std::string& title);
450 bool breakRequested()
const;
452 virtual void setupViewer(
bool lightingEnabled =
true,
bool visibleWindow =
true );
454 void setupVideoCaptureRenderTotexture();
459 void setScene(osg::Group *scene ) { m_scene = scene; }
461 osg::Group* getSceneAgxOSGRoot();
464 #ifdef AGX_HAVE_DEPTHPEELING
465 void setEnableDepthPeeling(
bool flag );
466 bool getEnableDepthPeeling()
const;
467 agxOSG::DepthPeeling* getDepthPeeling();
477 bool setEnableDebugRenderer(
bool flag );
480 bool getEnableDebugRenderer()
const;
482 void setEnableTextDebugRendering(
bool flag );
483 bool getEnableTextDebugRendering()
const;
485 void setEnableCaptureSyncWithSimulation(
bool enableSync );
486 bool getEnableCaptureSyncWithSimulation( )
const;
488 void setEnableOSGRenderer(
bool flag );
489 bool getEnableOSGRenderer();
491 void setEnableVSync(
bool flag,
bool forceUpdate =
false );
492 bool getEnableVSync()
const;
517 #if defined(OSG_VERSION_GREATER_OR_EQUAL)
518 # if OSG_VERSION_GREATER_OR_EQUAL(2,9,11)
519 osgGA::CameraManipulator* getCameraManipulator();
520 const osgGA::CameraManipulator* getCameraManipulator()
const;
522 osgGA::MatrixManipulator* getCameraManipulator();
523 const osgGA::MatrixManipulator* getCameraManipulator()
const;
526 osgGA::MatrixManipulator* getCameraManipulator();
527 const osgGA::MatrixManipulator* getCameraManipulator()
const;
531 bool restoreFromFile(
const std::string& filename );
541 void setAutoStepping(
bool flag,
bool resetTimer =
true );
544 bool getAutoStepping( )
const;
555 void setRealTimeSync(
bool flag);
556 bool getRealTimeSync()
const;
559 const std::string& getJournalConfigurationPath()
const;
560 const std::string& getJournalPlaybackPath()
const;
562 void setJournalConfigurationPath(
const agx::String& path);
564 void setEnableJournalIncrementalStructure(
bool enable );
565 bool getEnableJournalIncrementalStructure()
const;
570 bool createSceneFromKey(
int key );
571 bool createSceneFromIndex(
int idx,
bool firstStartUp =
false );
575 void createNextScene();
576 void createPreviousScene();
578 size_t getNumScenes()
const;
586 osg::Group *
getRoot() {
return m_root.get(); }
588 void fitSceneIntoView();
589 void initSimulation(
agxSDK::Simulation *simulation =
nullptr,
bool initializeGraphics =
true);
590 void initViewer(
int width,
int height,
bool osgWindow =
true);
601 void stopAfter(
const agx::Real stopTime);
603 osgViewer::Viewer *
getViewer() {
return m_viewer.get(); }
604 osg::Camera *
getCamera() {
if (m_viewer.valid())
return m_viewer->getCamera();
else return nullptr; }
606 bool hasOffscreenWindow()
const;
618 intptr_t getHWND()
const;
627 void handleReactiveScriptErrors(
bool abortSimulation =
true );
633 void setEnableSimulationDump(
bool flag );
634 bool getEnableSimulationDump( )
const;
636 void updateCoSimulationServer();
637 bool updatePythonCoSimulationServer(
const agx::String& filename, std::stringstream& buffer);
640 void updateRemoteDebugger();
642 void stepSimulation();
659 static void registerRemovedGeometry(
GeometryNode *node);
661 void storeInitialJournalState();
662 void initRecordJournal();
663 void initAppendJournal();
665 void journalPlayback();
666 void listSessionNames(
const std::string& journalToList);
677 double heading,
double elevation,
double distance,
678 int trackerMode = 0);
690 int trackerMode = 0);
700 bool executeOneStepWithoutGraphics();
702 void updateServices();
716 void setQuitEventSetsDone(
bool flag);
717 bool getQuitEventSetsDone()
const;
722 bool getAllowWindowResizing()
const;
727 void setAllowWindowResizing(
bool flag);
733 void takeScreenShot(
const agx::String& filename=
"");
735 void synchronizedStep(
bool blocking =
false);
740 void initScene(osg::Group *
root);
747 void setJournalFormat(
agx::UInt journalFormat);
750 void setEnableJournal32bitMode(
bool enable);
753 void setEnableJournalRecord(
bool enable);
756 void setRequestedJournalFrequency(
agx::Real freq);
759 void setJournalRecordPath(
const agx::String& journalPath);
768 void setGridSize(
const agx::Vec2& gridSize);
774 void setGridResolution(
const agx::Vec2u gridResolution);
780 void setEnableGrid(
bool flag);
783 bool getEnableGrid()
const;
786 void setEnableCoordinateSystem(
bool flag);
789 bool getEnableCoordinateSystem()
const;
793 void throttleIdleCpuUsageBySleeping();
797 std::string getProfilingJournalPath()
const;
799 #if AGX_USE_WEBSOCKETS()
800 agxOSG::ExampleApplicationController *getController();
803 void pushParametersToControlChannel();
804 void setEnableControlChannelTickSignals(
bool flag);
805 void pushFrameToRemoteViewer();
808 void postExecution();
809 void setEnableThreadTimeline(
bool flag);
810 void setEnableTaskProfile(
bool flag);
814 agxPython::ScriptContextInterface* initPythonContext(agxPython::ScriptManager *scriptManager);
825 void setTargetFPS(
double fps);
830 double getTargetFPS();
837 void drawCoordinateSystem();
840 void addGranularCreateVisualCallbacks();
844 bool validateGranularLicenseLimits();
847 class SimulationListener;
852 bool timeToStop()
const;
856 void executeWithoutGraphics();
860 void executeWithGraphics();
863 void generateQuickProfiling();
866 void setArgumentsPostSceneCreation();
867 agxJson::Value extractSimulationStructureToJson();
868 void applyInitialParameters(
const std::string& filePath);
869 void initThreadTimeline();
871 void triggerPreFrameListeners();
872 void triggerPostFrameListeners();
874 bool attachScripts( osg::Group*
root );
875 osg::Group *executeMPyScript(
const agx::String& file,
bool& success);
927 #if AGX_USE_WEBSOCKETS()
928 friend class ExampleApplicationController;
930 friend class AutoPauseListener;
992 #ifdef AGX_HAVE_DEPTHPEELING
993 osg::ref_ptr<DepthPeeling> m_depthPeeling;
agx::AffineMatrix4x4 m_coordinateSystemTransform
agx::RealVector m_coSimulationInputData
AGXOSG_EXPORT osg::MatrixTransform * createAxes(float scale=1, float width=3)
Create a x, y and z arrow with the size 1.
AutoStepEvent autoStepEvent
agxSDK::SimulationRef m_simulation
agx::Vec2u m_gridResolution
osg::ref_ptr< osg::Switch > m_sceneSwitch
bool setLightPosition(agx::UInt index, const agx::Vec4 &position)
std::string m_sceneFilename
std::string m_journalSessionName
agxOSG::VideoFFMPEGPipeCapture * getVideoServerCapture()
Class for sending serialized agxSDK::Simulation over to a client.
agx::HashSet< agxCollide::GeometryPair > m_autoPausePairs
osg::ref_ptr< agxOSG::GuiEventAdapter > m_eventAdapter
void stop(int exitCode=0)
Stop (=exit) the application at next opportunity.
agxSDK::Simulation::GeometryEvent::CallbackType m_removeGeometryCallback
agx::ref_ptr< agx::Referenced > m_journal
agxGL::CameraRef m_GlCamera
std::string m_journalConfigurationPath
The rigid body class, combining a geometric model and a frame of reference.
Class that encapsulates rendering and simulation using OpenSceneGraph.
agx::ref_ptr< agx::Referenced > m_debugClient
Matrix class for rigid transformations (translation, rotation).
RenderTargetRefVector m_renderTargetSet
CameraMask
Specifies node masks for different parts of the rendering scene.
const agx::Matrix4x4 & getProjectionMatrix() const
Get the projection matrix.
agx::Vector< std::pair< std::string, int > > m_attachedScripts
std::string m_pythonFilePath
agx::ref_ptr< agx::Referenced > m_controller
virtual ~CameraSynchronization()
bool m_autoCycleThroughScenes
bool m_coordinateSystemEnabled
agx::HashTable< int, int > KeyBindings
std::string m_extractSimulationStructureToJsonPath
bool m_enableJournalIncrementalStructure
std::string scriptFunction
const agx::Matrix4x4 & getViewMatrix() const
Get the view matrix.
agx::Event m_sceneLoadEvent
agxIO::ArgumentParserRef m_arguments
agx::Vector< ExampleApplicationListenerRef > m_listeners
const std::string & getSaveSceneFilename() const
bool setLightDirection(agx::UInt index, const agx::Vec3 &direction)
GraphicsThrottler m_gfxThrottler
Callback2< Simulation *, agxCollide::Geometry * > CallbackType
void cancelStop()
Will cancel the stop if possible. Continue the ::run loop.
osg::ref_ptr< osg::Group > m_root
agx::Mutex m_serviceMutex
agxOSG::RenderToTexture * getVideoCaptureRendertoTexture()
bool m_enableJournalRecording
Generalized callback, using std::function.
Matrix class for affine transformations.
osg::Camera * getCamera()
agxOSG::LightSource getLightSource(Lights l)
Get a wrapper for a LightSource with only AGX types.
const agxOSG::ImageCapture * getImageCapture() const
agx::Callback m_stepCallback
bool getEnablePauseUpdate() const
agxSDK::ContactEventListenerRef m_autoPauseListener
osg::ref_ptr< osg::MatrixTransform > m_coordinateSystem
bool m_generateThreadTimeline
bool m_autoPausingEnabled
std::string m_journalPlaybackPath
Block synchronization primitive.
agx::Mutex & getFrameMutex()
osg::Group * getSceneRoot()
virtual void operator()(osg::RenderInfo &) const
StatisticsRendererRef m_statisticsRenderer
An assembly is a collection of basic simulation objects, such as rigid bodies, constraints,...
osg::Group *(* BuildScenePtr)(agxSDK::Simulation *simulation, ExampleApplication *application)
Decorates a scene with a specific AGX Rendering Style.
std::string m_journalEofMode
bool useCoSimulation() const
osg::ref_ptr< osg::Geode > m_grid
SolverType getSolverType() const
osg::ref_ptr< osg::Camera > m_textureCamera
std::string getScriptFile() const
osgGA::MatrixManipulator CameraManipulatorType
agx::Vec3 getGravity() const
osg::ref_ptr< osg::GraphicsContext > m_pBuffer
agxGL::LightsRef m_GlLights
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
void setScene(osg::Group *scene)
void setSolverType(SolverType t)
The HighAccurayTimer class can replace the regular Timer class in high level applications where the n...
const PickHandler * getPickHandler() const
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
KeyBindingsVector m_keybindingVector
agxOSG::RigidBodyRenderCacheRef m_cache
Base class for Singletons that should have its shutdown called explicitly before exit of the applicat...
RenderToTextureRef m_videoCaptureRenderToTexture
bool m_explicitJournalConfigurationPath
bool m_allowWindowResizing
PickHandler * getPickHandler()
agx::UInt m_journalFormat
Inheritance with partial specialization due to bug with ref_ptr containers.
osgViewer::Viewer * getViewer()
VideoFFMPEGPipeCaptureRef m_videoCapture
The geometry representation used by the collision detection engine.
osg::ref_ptr< osg::Group > m_scene
This namespace contains functionality for using AGX together with version 2 of the Functional Mockup ...
agx::Vec3 m_cameraHomeCenter
agx::ref_ptr< agx::Referenced > m_coSimulationServer
void setEnablePauseUpdate(bool flag)
agx::Journal::FrameJumpEvent::CallbackType m_foundIncrementalArchiveCallback
agxSDK::Simulation * getSimulation()
virtual ~LightsSynchronization()
AGXOSG_EXPORT agxOSG::GeometryNode * 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.
AGXCORE_EXPORT Component * root()
std::string m_coSimulationInputFile
void setViewPort(unsigned width, unsigned height)
Templated callback with one argument.
std::string m_profilingRoot
void clearAddedScenes()
Remove all added scenes.
osg::ref_ptr< osgViewer::Viewer > m_viewer
std::string m_coSimulationOutputFile
agx::Real m_profilingFrequency
void setViewMatrix(const agx::Matrix4x4 &matrix)
Set the view matrix.
Base class providing referencing counted objects.
#define AGX_DECLARE_POINTER_TYPES(type)
agxIO::ArgumentParser * getArguments()
The Timer class permits timing execution speed with the same refinement as the built in hardware cloc...
agx::RealModeEnum m_journalRealMode
agx::RealVector m_coSimulationOutputData
AGXOSG_EXPORT bool setOrbitCamera(osgViewer::Viewer *viewer, osg::Group *node, const agx::Vec3 &eye, const agx::Vec3 ¢er, const agx::Vec3 &up, int trackerMode)
agx::Real m_journalFrequency
agx::Vector< SceneDescription > KeyBindingsVector
agx::Event1< bool > AutoStepEvent
agxCFG::ConfigScriptRef m_settings
bool m_interactiveRemoteClient
std::string m_xmlPlotFile
osg::ref_ptr< osg::Camera > m_pBufferCamera
std::string m_cfgFileName
static CameraManipulatorFactory * s_instance
agx::Real m_journalRecordStartTime
agx::Callback getStepCallback() const
virtual void operator()(osg::RenderInfo &) const
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API.
agxOSG::RenderProxyFactory * m_renderProxyFactory
osg::ref_ptr< osg::Group > m_sceneRoot
A node that can be associated with a collision geometry so that the transformation of this node is up...
std::string m_journalRecordPath
PickHandlerRef m_pickHandler
CameraSynchronization(osg::Camera *mainCamera, agxGL::Camera *glCamera)
agxOSG::SceneDecorator * getSceneDecorator()
agxOSG::ImageCapture * getImageCapture()
Templated callback with two arguments.
osg::Group * getSceneSwitch()
virtual void shutdown() override
Implement this method to cleanup your Singleton class.
agx::Vector< agx::String > m_timelineFormats
bool isCameraHomeSet() const
Implementation of the abstract class from the agxRender namespace, this class is responsible for crea...
Container class for lights that is used for synchronizing light data with shaders,...
bool m_enableTerrainJournalRecording
LightsSynchronization(agxGL::Lights *mainLights, agxOSG::SceneDecorator *decorator)
osg::ref_ptr< agxOSG::SceneDecorator > m_decorator
agx::Real m_journalStartTime
KeyBindings m_keyBindings
agx::Real m_relativeStopTime
agx::Timer m_frameSleepTimer
agxOSG::ImageCaptureRef m_imageCapture
A pod-struct for holding information about scenes to load by the application.
An event with no arguments.
void setProjectionMatrix(const agx::Matrix4x4 &matrix)
Set the projection matrix.
RealModeEnum
The data type for basic floating point representation.
Only use as member allocated variable.
agx::Real m_journalStopTime
bool m_generateTaskProfile
osg::Camera * getTextureCamera()
Containins classes for sending/reading data over sockets as well as compression functionality.
agxOSG::RenderProxyFactory * getRenderProxyFactory()
A small argument parser class.
agxSDK::Simulation::RigidBodyEvent::CallbackType m_addBodyCallback
agx::Vec3 m_cameraHomeEye
std::string m_parameterFilePath
Render target is used for rendering camera content to a buffer, either a DEPTH or COLOR target.
void setStepCallback(agx::Callback callback)