AGX Dynamics  2.37.3.2
ExampleApplication.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or
9 having been advised so by Algoryx Simulation AB for a time limited evaluation,
10 or having purchased a valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 #ifdef __clang__
20 #pragma clang diagnostic push
21 #pragma clang diagnostic ignored "-Wconversion"
22 #endif
23 
24 #include <agx/config/AGX_USE_OPENGL.h>
25 #include <agx/config/AGX_USE_FFMPEG.h>
26 #include <agx/config/AGX_USE_PYTHON.h>
27 
28 #include <agx/config.h>
29 
30 #include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
31 #include <osg/Switch>
32 #include <osgViewer/Viewer>
33 #include <osg/Version>
34 #include <osg/ref_ptr>
35 #include <osg/MatrixTransform>
36 #include <agx/PopDisableWarnings.h> // End of disabled warnings.
37 
38 #include <agxOSG/DepthPeeling.h>
39 #include <agxOSG/export.h>
40 #include <agxOSG/GuiEventAdapter.h>
41 #include <agxOSG/PickHandler.h>
42 #include <agxOSG/RenderTarget.h>
43 #include <agxOSG/RenderToTexture.h>
47 
48 #if AGX_USE_WEBSOCKETS()
50 #endif
51 
52 #include <agxSDK/Simulation.h>
56 #include <agxOSG/ImageCapture.h>
57 #include <agxCFG/ConfigScript.h>
58 
59 #include <agx/Timer.h>
60 #include <agx/Journal.h>
62 
63 #include <agxIO/ArgumentParser.h>
64 #include <agx/HighAccuracyTimer.h>
65 
66 #include <cstddef>
67 
68 #if AGX_USE_OPENGL()
69 #include <agxGL/Camera.h>
70 #include <agxGL/Lights.h>
71 #endif
72 
73 #if AGX_USE_PYTHON()
74 # include <agxPython/ScriptManager.h>
75 # include <agxPython/ScriptContext.h>
76 # include <agx/config/AGX_PYTHON_VERSION.h>
77 #endif
78 
79 #ifdef __clang__
80 #pragma clang diagnostic pop
81 #endif
82 
83 namespace osgGA
84 {
85  class StandardManipulator;
86  class MatrixManipulator;
87 }
88 
89 namespace agxFMI2
90 {
91  namespace Export
92  {
93  class Module;
94  }
95 }
96 
97 
98 namespace agxSDK
99 {
100  class Assembly;
101 }
102 
103 namespace agxNet
104 {
105  class CoSimulationServer;
106 }
107 
108 namespace agxOSG {
109  class ExampleApplication;
110  class SceneDecorator;
111  class RenderProxyFactory;
112  class GeometryNode;
113 #if AGX_USE_WEBSOCKETS()
114  class ExampleApplicationController;
115 #endif
116 
117  typedef osg::Group * (*BuildScenePtr)(agxSDK::Simulation *simulation, ExampleApplication *application);
118 
121 
124 
126  SceneDescription(BuildScenePtr sc, bool isTest = false, float stop = -1, bool isSlowUnittest = false);
127 
129  SceneDescription(const std::string& scriptFileName, const std::string& scriptFunctionName, bool isTest = false, float stop = -1, bool isSlowUnittest = false);
130 
132  SceneDescription(const std::string& sceneFile, bool isTest = false, float stop = -1, bool isSlowUnittest = false);
133 
134  bool isValid() const { return valid; }
135 
136 
138  bool unittest;
139  float stopAfter;
141  bool valid;
142  std::string scriptFunction;
143  std::string fileName;
144  };
145 
146 
147 #if defined(OSG_VERSION_GREATER_OR_EQUAL)
148 # if OSG_VERSION_GREATER_OR_EQUAL(2,9,11)
149  typedef osgGA::StandardManipulator CameraManipulatorType;
150 # else
151  typedef osgGA::MatrixManipulator CameraManipulatorType;
152 # endif
153 #else
154  typedef osgGA::MatrixManipulator CameraManipulatorType;
155 #endif
156 
157 
158 
159 #if AGX_USE_OPENGL()
160  class CameraSynchronization : public osg::Camera::DrawCallback
161  {
162  public:
163  CameraSynchronization(osg::Camera *mainCamera, agxGL::Camera *glCamera) : m_mainCamera(mainCamera), m_glCamera(glCamera)
164  {
165  }
166 
168  {
169  }
170 
171  virtual void operator () (osg::RenderInfo& /* renderInfo */) const
172  {
173  // Explicit support for Real=float agx with Real=double osg
174  agxData::Val<agx::Matrix4x4d> projection(agx::Matrix4x4d(m_mainCamera->getProjectionMatrix().ptr()));
175  agx::Matrix4x4 m = projection.transform<agx::Matrix4x4 > ();
176 
177  if (m != m_glCamera->getProjectionMatrix())
178  m_glCamera->setProjectionMatrix(m);
179 
180  agxData::Val<agx::Matrix4x4d> view(agx::Matrix4x4d(m_mainCamera->getViewMatrix().ptr()));
181  agx::Matrix4x4 m2 = view.transform<agx::Matrix4x4 > ();
182 
183  if (m2 != m_glCamera->getViewMatrix())
184  m_glCamera->setViewMatrix(m2);
185 
186  auto viewport = m_mainCamera->getViewport();
187  m_glCamera->setViewPort(static_cast<int>(viewport->width()), static_cast<int>(m_mainCamera->getViewport()->height()));
188  }
189  using osg::Camera::DrawCallback::operator();
190 
191  private:
192  osg::Camera *m_mainCamera;
193  agxGL::Camera *m_glCamera;
194  };
195 
196  class LightsSynchronization : public osg::Camera::DrawCallback
197  {
198  public:
200  : m_glLights(mainLights),
201  m_decorator(decorator)
202  {
203  }
204 
206  {
207  }
208 
209  virtual void operator () (osg::RenderInfo& /* renderInfo */) const
210  {
211 
212  auto updateLight = [this](size_t index, agxOSG::LightSource l)
213  {
214  m_glLights->setLightPosition(index, l.getPosition());
215  m_glLights->setLightDirection(index, l.getDirection());
216  };
217 
218  updateLight(0, m_decorator->getLightSource(agxOSG::SceneDecorator::LIGHT0));
219  updateLight(1, m_decorator->getLightSource(agxOSG::SceneDecorator::LIGHT1));
220  updateLight(2, m_decorator->getLightSource(agxOSG::SceneDecorator::LIGHT2));
221  }
222 
223  using osg::Camera::DrawCallback::operator();
224 
225  private:
226  agxGL::Lights *m_glLights;
227  SceneDecorator *m_decorator;
228  };
229 #endif
230 
232  {
233  public:
234  enum Types { TRACKBALL,
235 #if defined(OSG_VERSION_GREATER_OR_EQUAL)
236 # if OSG_VERSION_GREATER_OR_EQUAL(2,9,11)
237  FPS,
238 # endif
239 #endif
240  NUM_TYPES };
241 
243 
244  static CameraManipulatorFactory* instance();
245 
246  CameraManipulatorType* next( osgViewer::Viewer* viewer = nullptr );
247  CameraManipulatorType* next( osgViewer::GraphicsWindow* window = nullptr );
248  CameraManipulatorType* create( osgViewer::Viewer* viewer = nullptr );
249  CameraManipulatorType* create( Types type, osgViewer::Viewer* viewer = nullptr );
250  CameraManipulatorType* create( Types type, osgViewer::GraphicsWindow* window = nullptr );
251  CameraManipulatorType* create( osgViewer::GraphicsWindow* window = nullptr );
252 
253  void setType( Types type ) { m_currentType = type; }
254  Types getType() const { return m_currentType; }
255 
256  protected:
257  SINGLETON_CLASSNAME_METHOD();
258  virtual void shutdown() override { s_instance = nullptr; }
259  osgViewer::GraphicsWindow* getWindow( osgViewer::Viewer* viewer, size_t num = 0 ) const;
260 
263  };
264 
266  {
270  CameraData( const osg::Camera* camera );
271 
275  CameraData( const osgViewer::Viewer* viewer );
276 
280  void applyTo( osg::Camera* camera ) const;
281 
285  void applyTo( osgViewer::Viewer* viewer ) const;
286 
289  double fieldOfView;
290  double aspectRatio;
291  bool valid;
292  double nearFarRatio;
293 
297 
298  private:
299  CameraData();
300  void initialize( const osg::Camera* camera );
301  };
302 
305 
306  public:
307  virtual void preFrame(ExampleApplication* app);
308  virtual void postFrame(ExampleApplication* app);
309 
310  protected:
311  virtual ~ExampleApplicationListener() override;
312  };
313 
314 
316 
321  {
322  public:
324  AutoStepEvent autoStepEvent;
325 
332  {
333  MAIN_SCENE_MASK = 1 << 1,
334  DEBUG_RENDER_MASK = 1 << 2,
335  OSG_RENDER_MASK = 1 << 3,
336  HUD_MASK = 1 << 4,
337  DECORATOR_MASK = 1 << 5,
338  };
339 
341  {
342  MULTI, // New.
343  ITERATIVE, // New forced to iterative.
344  NUM_SOLVERS
345  };
346 
347 
348  void setSolverType( SolverType t ) { m_solverType = t; }
349  SolverType getSolverType() const { return m_solverType; }
350 
351  std::string getSolverName( SolverType t ) const;
352  SolverType getSolverType( const std::string& name ) const;
353 
357  void addAutoPausePair(const agx::RigidBody *body1, const agx::RigidBody *body2);
358  void addAutoPausePair(const agxCollide::Geometry *geometry1, const agxCollide::Geometry *geometry2);
359  void removeAutoPausePair(const agx::RigidBody *body1, const agx::RigidBody *body2);
360  void removeAutoPausePair(const agxCollide::Geometry *geometry1, const agxCollide::Geometry *geometry2);
361 
365  void setEnableAutoPausing(bool flag);
366  bool getEnableAutoPausing();
367 
369  ExampleApplication( agxSDK::Simulation *simulation=nullptr );
370 
371  bool init( agxIO::ArgumentParser* arguments, bool agxOnly = false );
372 
373  void addListener(ExampleApplicationListener *listener);
374 
375 #ifndef SWIG
376  bool init( int argc, char** argv );
377 #endif
378 
379  agxIO::ArgumentParser* getArguments() { return m_arguments.get(); }
380 
381  agxOSG::RenderProxyFactory *getRenderProxyFactory() { return m_renderProxyFactory; }
382 
383  void setTimeStep( agx::Real dt );
384  agx::Real getTimeStep() const;
385 
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 );
388 
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 );
391 
392  bool addScene( SceneDescription sceneDescription, int key);
393  bool addScene( SceneDescription sceneDescription);
394 
396  void clearAddedScenes() { m_keybindingVector.clear(); }
397 
398  agx::Callback getStepCallback() const { return m_stepCallback; }
399  void setStepCallback(agx::Callback callback) { m_stepCallback = callback; }
400 
401  bool initialized() const { return m_initialized; }
402 
403  agxOSG::SceneDecorator *getSceneDecorator() { return m_decorator; }
404 
405  virtual int run();
406 
407  void setOsgNotifyLevel(osg::NotifySeverity severity) const;
408 
420  osg::Group* executePythonScript(const agx::String& file, const agx::String& function, bool& success);
421 
426  void stop(int exitCode = 0) { m_shouldStop = true; m_exitCode = exitCode; }
427 
429  void cancelStop() { m_shouldStop = false; }
430 
432  bool shouldStop() const { return m_shouldStop; }
433 
440  bool setWindowRectangle(unsigned int x, unsigned int y, unsigned int width, unsigned int height);
441 
447  bool setWindowTitle(const std::string& title);
448 
450  bool breakRequested() const;
451 
452  virtual void setupViewer( bool lightingEnabled = true, bool visibleWindow = true );
453 
454  void setupVideoCaptureRenderTotexture();
455 
456  //void initScene();
457 
458  osg::Group *getScene() { return m_scene.get(); }
459  void setScene(osg::Group *scene ) { m_scene = scene; }
460  osg::Group *getSceneRoot() { return m_sceneRoot.get(); }
461  osg::Group* getSceneAgxOSGRoot();
462  osg::Group *getSceneSwitch() { return m_sceneSwitch.get(); }
463 
464 #ifdef AGX_HAVE_DEPTHPEELING
465  void setEnableDepthPeeling( bool flag );
466  bool getEnableDepthPeeling() const;
467  agxOSG::DepthPeeling* getDepthPeeling();
468 #endif
469 
477  bool setEnableDebugRenderer( bool flag );
478 
480  bool getEnableDebugRenderer() const;
481 
482  void setEnableTextDebugRendering( bool flag );
483  bool getEnableTextDebugRendering() const;
484 
485  void setEnableCaptureSyncWithSimulation( bool enableSync );
486  bool getEnableCaptureSyncWithSimulation( ) const;
487 
488  void setEnableOSGRenderer( bool flag );
489  bool getEnableOSGRenderer();
490 
491  void setEnableVSync( bool flag, bool forceUpdate = false );
492  bool getEnableVSync() const;
493 
494  void getCameraHome( agx::Vec3& eye, agx::Vec3& center, agx::Vec3& up);
495  void setCameraHome( const agx::Vec3& eye, const agx::Vec3& center, const agx::Vec3& up=agx::Vec3(0,0,1) );
496 
502  void addRenderTarget(agxOSG::RenderTarget* rtt, osg::Node *targetSceneNode=nullptr);
503 
508  bool removeRenderTarget(agxOSG::RenderTarget* rtt);
509 
515  void setDebugRenderInverseMatrix( const agx::AffineMatrix4x4 &m );
516 
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;
521 #else
522  osgGA::MatrixManipulator* getCameraManipulator();
523  const osgGA::MatrixManipulator* getCameraManipulator() const;
524 #endif
525 #else
526  osgGA::MatrixManipulator* getCameraManipulator();
527  const osgGA::MatrixManipulator* getCameraManipulator() const;
528 #endif
529  agxSDK::Simulation *getSimulation() { return m_simulation.get(); }
530 
531  bool restoreFromFile( const std::string& filename );
532  void journalRenderLoader(agxSDK::Assembly *assembly, bool keyFrame);
533 
534 
541  void setAutoStepping( bool flag, bool resetTimer = true );
542 
544  bool getAutoStepping( ) const;
545 
546 
547  void setEnablePauseUpdate( bool flag ) { m_pauseUpdate = flag; }
548  bool getEnablePauseUpdate( ) const { return m_pauseUpdate; }
549 
555  void setRealTimeSync(bool flag);
556  bool getRealTimeSync() const;
557 
558  agx::Journal *getJournal();
559  const std::string& getJournalConfigurationPath() const;
560  const std::string& getJournalPlaybackPath() const;
561 
562  void setJournalConfigurationPath(const agx::String& path);
563 
564  void setEnableJournalIncrementalStructure( bool enable );
565  bool getEnableJournalIncrementalStructure() const;
566 
567  SceneDescription getCallbackIdx( size_t idx );
568 
569  SceneDescription getCallback( int key );
570  bool createSceneFromKey( int key );
571  bool createSceneFromIndex( int idx, bool firstStartUp = false );
572 
573 
574  void reloadScene();
575  void createNextScene();
576  void createPreviousScene();
577 
578  size_t getNumScenes() const;
579 
580  void step();
581 
582  void changeSolver();
583 
584  const std::string& getSaveSceneFilename() const { return m_sceneFilename; }
585 
586  osg::Group *getRoot() { return m_root.get(); }
587 
588  void fitSceneIntoView();
589  void initSimulation(agxSDK::Simulation *simulation = nullptr, bool initializeGraphics = true);
590  void initViewer(int width, int height, bool osgWindow = true);
591 
592  void initGraphics();
593  void initRpc();
594  bool readCFGFile();
595 
601  void stopAfter(const agx::Real stopTime);
602 
603  osgViewer::Viewer *getViewer() { return m_viewer.get(); }
604  osg::Camera *getCamera() { if (m_viewer.valid()) return m_viewer->getCamera(); else return nullptr; }
605 
606  bool hasOffscreenWindow() const;
607 
611  agxOSG::CameraData getCameraData() const;
612 
616  void applyCameraData( const agxOSG::CameraData& cameraData );
617 
618  intptr_t getHWND() const;
619 
620  agx::Vec3 getViewDirection();
621 
622  PickHandler* getPickHandler() { return m_pickHandler; }
623  const PickHandler* getPickHandler() const { return m_pickHandler; }
624 
625  std::string getScriptFile() const { return m_scriptFile; }
626 
627  void handleReactiveScriptErrors( bool abortSimulation = true );
628 
629  agx::Real getTimeStamp() const;
630 
631  void clearScene();
632 
633  void setEnableSimulationDump( bool flag );
634  bool getEnableSimulationDump( ) const;
635 
636  void updateCoSimulationServer();
637  bool updatePythonCoSimulationServer(const agx::String& filename, std::stringstream& buffer);
638  bool coSimulationCallPython(agxNet::CoSimulationServer* server);
639 
640  void updateRemoteDebugger();
641  void centerScene();
642  void stepSimulation();
643 
644  bool useCoSimulation() const {return m_useCoSimulation;}
645 
646  agx::Vec3 getGravity() const { return m_gravity; }
647 
648 
649  agxOSG::ImageCapture *getImageCapture() { return m_imageCapture; }
650  const agxOSG::ImageCapture *getImageCapture() const { return m_imageCapture; }
651 
653 
654  osg::Camera *getTextureCamera() { return m_textureCamera; }
655 
656 
657  bool isCameraHomeSet() const { return m_cameraHomeSet; }
658 
659  static void registerRemovedGeometry(GeometryNode *node);
660 
661  void storeInitialJournalState();
662  void initRecordJournal();
663  void initAppendJournal();
664 
665  void journalPlayback();
666  void listSessionNames(const std::string& journalToList);
667 
677  double heading, double elevation, double distance,
678  int trackerMode = 0);
679 
689  const agx::Vec3& eye, const agx::Vec3& center, const agx::Vec3& up = agx::Vec3::Z_AXIS(),
690  int trackerMode = 0);
691 
698  bool executeOneStepWithGraphics(agx::HighAccuracyTimer& timer);
699 
700  bool executeOneStepWithoutGraphics();
701 
702  void updateServices();
703 
704 
709  bool done() const;
710 
711 
716  void setQuitEventSetsDone(bool flag);
717  bool getQuitEventSetsDone() const;
718 
722  bool getAllowWindowResizing() const;
723 
727  void setAllowWindowResizing(bool flag);
728 
733  void takeScreenShot(const agx::String& filename="");
734 
735  void synchronizedStep(bool blocking = false);
736 
737  void stepWrapper();
738 
739  void initScene();
740  void initScene(osg::Group *root);
741 
742 
744  agx::UInt getJournalFormat() const;
745 
747  void setJournalFormat(agx::UInt journalFormat);
748 
750  void setEnableJournal32bitMode(bool enable);
751 
753  void setEnableJournalRecord(bool enable);
754 
756  void setRequestedJournalFrequency(agx::Real freq);
757 
759  void setJournalRecordPath(const agx::String& journalPath);
760 
762  void setCoordinateSystemTransform( const agx::AffineMatrix4x4& coordinateSystemTransform);
763 
765  agx::AffineMatrix4x4 getCoordinateSystemTransform() const;
766 
768  void setGridSize(const agx::Vec2& gridSize);
769 
771  agx::Vec2 getGridSize() const;
772 
774  void setGridResolution(const agx::Vec2u gridResolution);
775 
777  agx::Vec2u getGridResolution() const;
778 
780  void setEnableGrid(bool flag);
781 
783  bool getEnableGrid() const;
784 
786  void setEnableCoordinateSystem(bool flag);
787 
789  bool getEnableCoordinateSystem() const;
790 
791  // Throttle calls to avoid excessive CPU usage
792  // Is automatically called from `executeWithoutGraphics`
793  void throttleIdleCpuUsageBySleeping();
794 
795  agxOSG::RenderToTexture * getVideoCaptureRendertoTexture() { return m_videoCaptureRenderToTexture; }
796 
797  std::string getProfilingJournalPath() const;
798 
799 #if AGX_USE_WEBSOCKETS()
800  agxOSG::ExampleApplicationController *getController();
801 
802  agx::UInt16 getControlChannelPort();
803  void pushParametersToControlChannel();
804  void setEnableControlChannelTickSignals(bool flag);
805  void pushFrameToRemoteViewer();
806 #endif
807 
808  void postExecution();
809  void setEnableThreadTimeline(bool flag);
810  void setEnableTaskProfile(bool flag);
811  int getExitCode() { return m_exitCode; }
812 
813 #if AGX_USE_PYTHON()
814  agxPython::ScriptContextInterface* initPythonContext(agxPython::ScriptManager *scriptManager);
815 #endif
816 
817  void createVisual(agxSDK::Simulation *simulation, float detailRatio = 1.0f, bool createAxes = false);
818  void createVisual(agxSDK::Assembly *assembly, float detailRatio = 1.0f, bool createAxes = false);
819  agx::Mutex& getFrameMutex() { return m_frameMutex; }
820 
825  void setTargetFPS(double fps);
826 
830  double getTargetFPS();
831 
832  protected:
833 
834  virtual ~ExampleApplication();
835 
836  void drawGrid();
837  void drawCoordinateSystem();
838 
839  void granularCreated( agxSDK::Simulation* sim, agx::RigidBody* body );
840  void addGranularCreateVisualCallbacks();
841  void foundIncrementalArchive( agx::Journal* journal );
842 
843  // Return true if we are ok with the number of particles with respect to the granular license limits.
844  bool validateGranularLicenseLimits();
845 
846  protected:
847  class SimulationListener;
848 
852  bool timeToStop() const;
853 
854 
855  void execute();
856  void executeWithoutGraphics();
857  bool executeOneStepWithoutGraphics(bool& saveAfterEnabled, agx::Real saveAfterTime, agx::HighAccuracyTimer& timer);
858 
859 
860  void executeWithGraphics();
861  bool executeOneStepWithGraphics(bool& saveAfterEnabled, agx::Real saveAfterTime, agx::HighAccuracyTimer& timer);
862 
863  void generateQuickProfiling();
864  void journalSceneLoader(const agx::String& path);
865  void removeGeometryNode(agxSDK::Simulation*, agxCollide::Geometry*);
866  void setArgumentsPostSceneCreation(); // This function will override a number of settings with their command line argument specifications
867  agxJson::Value extractSimulationStructureToJson();
868  void applyInitialParameters(const std::string& filePath);
869  void initThreadTimeline();
870  bool initBrickInterop();
871 
872  void triggerPreFrameListeners();
873  void triggerPostFrameListeners();
874 
875  bool attachScripts( osg::Group* root );
876  osg::Group *loadBrickModel( const agx::String& file, const agx::String& model, bool& success );
877  osg::Group *executeMPyScript(const agx::String& file, bool& success);
878 
879  osg::Group *createScene( const SceneDescription& desc, bool &success );
880 
881  agx::Real calculateStopTime(const SceneDescription& desc);
882 
883  osg::ref_ptr<agxOSG::SceneDecorator> m_decorator;
885  osg::ref_ptr<agxOSG::GuiEventAdapter> m_eventAdapter;
886  osg::ref_ptr<osgViewer::Viewer> m_viewer;
887 
889 
890  osg::ref_ptr<osg::Group> m_root;
891  osg::ref_ptr<osg::Group> m_sceneRoot;
892  osg::ref_ptr<osg::Group> m_scene;
893  osg::ref_ptr<osg::Switch> m_sceneSwitch;
894 
896 
898 
900 
902 
903  KeyBindings m_keyBindings;
904  KeyBindingsVector m_keybindingVector;
905 
908 
909  std::string m_sceneFilename;
910  std::string m_parameterFilePath;
911 
913  std::string m_cfgFileName;
914 
916 
925  bool m_agxOnly;
927  // std::string m_exportMayaAnimationPath;
928 
929 #if AGX_USE_WEBSOCKETS()
930  friend class ExampleApplicationController;
931 #endif
932  friend class AutoPauseListener;
936 
938 
939  agxCFG::ConfigScriptRef m_settings;
940 
941  std::string m_xmlPlotFile;
943 
944  std::string m_scriptFile;
949 
951 #if AGX_USE_OPENGL()
954 #endif
961  std::string m_profilingRoot;
969  bool m_vSync;
970  std::string m_pythonFilePath;
977  std::string m_journalEofMode;
978  std::string m_journalRecordPath;
979  std::string m_journalSessionName;
982  // agx::UInt m_journalStride;
986 
989 
991 
993 
994 #ifdef AGX_HAVE_DEPTHPEELING
995  osg::ref_ptr<DepthPeeling> m_depthPeeling;
996 #endif
1001  osg::ref_ptr<osg::Camera> m_textureCamera;
1013  osg::ref_ptr<osg::GraphicsContext> m_pBuffer;
1014  osg::ref_ptr<osg::Camera> m_pBufferCamera;
1016 
1017  public:
1020  bool m_isFMU;
1022  std::string m_hostName;
1023 
1024  protected:
1030  osg::ref_ptr<osg::Geode> m_grid;
1031  osg::ref_ptr<osg::MatrixTransform> m_coordinateSystem;
1039 
1040  std::string m_videoName;
1044 
1048  };
1049 
1050 }
void setScene(osg::Group *scene)
Class that encapsulates rendering and simulation using OpenSceneGraph.
osgViewer::Viewer * getViewer()
Containins classes for sending/reading data over sockets as well as compression functionality.
Definition: MacUtil.h:22
VideoFFMPEGPipeCaptureRef m_videoCapture
const PickHandler * getPickHandler() const
osg::ref_ptr< osg::Group > m_scene
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API...
KeyBindingsVector m_keybindingVector
T transform() const
Definition: Value.h:339
agxOSG::RigidBodyRenderCacheRef m_cache
RenderToTextureRef m_videoCaptureRenderToTexture
osg::Group *(* BuildScenePtr)(agxSDK::Simulation *simulation, ExampleApplication *application)
agx::Journal::FrameJumpEvent::CallbackType m_foundIncrementalArchiveCallback
void setEnablePauseUpdate(bool flag)
#define AGXOSG_EXPORT
void clearAddedScenes()
Remove all added scenes.
AGXOSG_EXPORT bool setOrbitCamera(osgViewer::Viewer *viewer, agxOSG::GeometryNode *node, const agx::Vec3 &eye, const agx::Vec3 &center, const agx::Vec3 &up, int trackerMode)
agxIO::ArgumentParser * getArguments()
agx::ref_ptr< agx::Referenced > m_coSimulationServer
agx::RealModeEnum m_journalRealMode
agxSDK::Simulation * getSimulation()
agx::Event1< bool > AutoStepEvent
agxCFG::ConfigScriptRef m_settings
Generalized callback, using std::function.
Definition: Callback.h:53
The HighAccurayTimer class can replace the regular Timer class in high level applications where the n...
osg::ref_ptr< osgViewer::Viewer > m_viewer
Matrix class for affine transformations.
Definition: EulerAngles.h:34
agx::RealVector m_coSimulationOutputData
agx::Vector< SceneDescription > KeyBindingsVector
osg::ref_ptr< osg::Group > m_sceneRoot
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
Implementation of the abstract class from the agxRender namespace, this class is responsible for crea...
osg::ref_ptr< osg::Camera > m_pBufferCamera
static CameraManipulatorFactory * s_instance
The Timer class permits timing execution speed with the same refinement as the built in hardware cloc...
Definition: Timer.h:74
agxOSG::SceneDecorator * getSceneDecorator()
agxOSG::ImageCapture * getImageCapture()
virtual void shutdown() override
Implement this method to cleanup your Singleton class.
agx::Callback getStepCallback() const
CameraSynchronization(osg::Camera *mainCamera, agxGL::Camera *glCamera)
agxOSG::RenderProxyFactory * m_renderProxyFactory
Render target is used for rendering camera content to a buffer, either a DEPTH or COLOR target...
Definition: RenderTarget.h:40
agxOSG::ImageCaptureRef m_imageCapture
Block synchronization primitive.
A small argument parser class.
Decorates a scene with a specific AGX Rendering Style.
Base class providing referencing counted objects.
Definition: Referenced.h:119
static Vec3T Z_AXIS()
Definition: Vec3Template.h:783
The geometry representation used by the collision detection engine.
Definition: Geometry.h:92
Only use as member allocated variable.
Definition: Value.h:284
agxOSG::RenderProxyFactory * getRenderProxyFactory()
agx::Vector< agx::String > m_timelineFormats
void setStepCallback(agx::Callback callback)
agx::AffineMatrix4x4 m_coordinateSystemTransform
osg::ref_ptr< agxOSG::SceneDecorator > m_decorator
uint32_t UInt
Definition: Integer.h:34
agx::RealVector m_coSimulationInputData
osg::ref_ptr< osg::Switch > m_sceneSwitch
agxSDK::Simulation::RigidBodyEvent::CallbackType m_addBodyCallback
LightsSynchronization(agxGL::Lights *mainLights, agxOSG::SceneDecorator *decorator)
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
A node that can be associated with a collision geometry so that the transformation of this node is up...
Definition: GeometryNode.h:41
Class for sending serialized agxSDK::Simulation over to a client.
void stop(int exitCode=0)
Stop (=exit) the application at next opportunity.
agxSDK::Simulation::GeometryEvent::CallbackType m_removeGeometryCallback
agxSDK::SimulationRef m_simulation
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.
osgGA::MatrixManipulator CameraManipulatorType
agxOSG::VideoFFMPEGPipeCapture * getVideoServerCapture()
Callback2< T1, T2 > CallbackType
Definition: Event.h:37
agx::HashSet< agxCollide::GeometryPair > m_autoPausePairs
osg::ref_ptr< agxOSG::GuiEventAdapter > m_eventAdapter
CameraMask
Specifies node masks for different parts of the rendering scene.
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:54
agx::ref_ptr< agx::Referenced > m_journal
agx::HashTable< int, int > KeyBindings
Templated callback with two arguments.
Definition: Callback.h:139
std::string m_extractSimulationStructureToJsonPath
RealModeEnum
The data type for basic floating point representation.
Definition: Real.h:35
agxIO::ArgumentParserRef m_arguments
agx::Vector< ExampleApplicationListenerRef > m_listeners
const std::string & getSaveSceneFilename() const
agx::ref_ptr< agx::Referenced > m_debugClient
RenderTargetRefVector m_renderTargetSet
std::mutex Mutex
Definition: Referenced.h:99
agx::Vector< std::pair< std::string, int > > m_attachedScripts
This namespace contains functionality for using AGX together with version 2 of the Functional Mockup ...
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
agxOSG::RenderToTexture * getVideoCaptureRendertoTexture()
A pod-struct for holding information about scenes to load by the application.
agx::ref_ptr< agx::Referenced > m_controller
agxSDK::ContactEventListenerRef m_autoPauseListener
osg::ref_ptr< osg::MatrixTransform > m_coordinateSystem
uint16_t UInt16
Definition: Integer.h:39
double Real
Definition: Real.h:42
void cancelStop()
Will cancel the stop if possible. Continue the ::run loop.
AGXCORE_EXPORT Component * root()
osg::ref_ptr< osg::Group > m_root
AGXOSG_EXPORT osg::MatrixTransform * 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.
Inheritance with partial specialization due to bug with ref_ptr containers.
osg::ref_ptr< osg::GraphicsContext > m_pBuffer
void setSolverType(SolverType t)
const agxOSG::ImageCapture * getImageCapture() const
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
An event with no arguments.
Definition: Event.h:89
Container class for lights that is used for synchronizing light data with shaders, such as particle sprite shaders.
Definition: Lights.h:30
StatisticsRendererRef m_statisticsRenderer
An assembly is a collection of basic simulation objects, such as rigid bodies, constraints, geometries.
Definition: Assembly.h:66
SolverType getSolverType() const
osg::ref_ptr< osg::Geode > m_grid
osg::ref_ptr< osg::Camera > m_textureCamera
Base class for Singletons that should have its shutdown called explicitly before exit of the applicat...
Definition: Singleton.h:30
std::string getScriptFile() const