AGXDynamics  2.31.1.0
ExampleApplication.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2021. 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>
45 
46 #if AGX_USE_WEBSOCKETS()
48 #endif
49 
50 #include <agxSDK/Simulation.h>
54 #include <agxOSG/ImageCapture.h>
55 #include <agxCFG/ConfigScript.h>
56 
57 #include <agx/Timer.h>
59 
60 #include <agxIO/ArgumentParser.h>
61 #include <agx/HighAccuracyTimer.h>
62 
63 #include <cstddef>
64 
65 #if AGX_USE_OPENGL()
66 #include <agxGL/Camera.h>
67 #include <agxGL/Lights.h>
68 #endif
69 
70 #if AGX_USE_PYTHON()
71 # include <agxPython/ScriptManager.h>
72 # include <agxPython/ScriptContext.h>
73 # include <agx/config/AGX_PYTHON_VERSION.h>
74 #endif
75 
76 #ifdef __clang__
77 #pragma clang diagnostic pop
78 #endif
79 
80 namespace osgGA
81 {
82  class StandardManipulator;
83  class MatrixManipulator;
84 }
85 
86 namespace agxFMI
87 {
88  namespace Export
89  {
90  class Module;
91  }
92 }
93 
94 
95 namespace agxSDK
96 {
97  class Assembly;
98 }
99 
100 namespace agxNet
101 {
102  class CoSimulationServer;
103 }
104 
105 namespace agxOSG {
106  class ExampleApplication;
107  class SceneDecorator;
108  class RenderProxyFactory;
109  class GeometryNode;
110 #if AGX_USE_WEBSOCKETS()
111  class ExampleApplicationController;
112 #endif
113 
114  typedef osg::Group * (*BuildScenePtr)(agxSDK::Simulation *simulation, ExampleApplication *application);
115 
118 
121 
123  SceneDescription(BuildScenePtr sc, bool isTest = false, float stop = float(), bool isSlowUnittest = false);
124 
126  SceneDescription(const std::string& scriptFileName, const std::string& scriptFunctionName, bool isTest = false, float stop = float(), bool isSlowUnittest = false);
127 
129  SceneDescription(const std::string& sceneFile, bool isTest = false, float stop = float(), bool isSlowUnittest = false);
130 
131  bool isValid() const { return valid; }
132 
133 
135  bool unittest;
136  float stopAfter;
138  bool valid;
139  std::string scriptFunction;
140  std::string fileName;
141  };
142 
143 
144 #if defined(OSG_VERSION_GREATER_OR_EQUAL)
145 # if OSG_VERSION_GREATER_OR_EQUAL(2,9,11)
146  typedef osgGA::StandardManipulator CameraManipulatorType;
147 # else
148  typedef osgGA::MatrixManipulator CameraManipulatorType;
149 # endif
150 #else
151  typedef osgGA::MatrixManipulator CameraManipulatorType;
152 #endif
153 
154 
155 
156 #if AGX_USE_OPENGL()
157  class CameraSynchronization : public osg::Camera::DrawCallback
158  {
159  public:
160  CameraSynchronization(osg::Camera *mainCamera, agxGL::Camera *glCamera) : m_mainCamera(mainCamera), m_glCamera(glCamera)
161  {
162  }
163 
165  {
166  }
167 
168  virtual void operator () (osg::RenderInfo& /* renderInfo */) const
169  {
170  // Explicit support for Real=float agx with Real=double osg
171  agxData::Val<agx::Matrix4x4d> projection(agx::Matrix4x4d(m_mainCamera->getProjectionMatrix().ptr()));
172  agx::Matrix4x4 m = projection.transform<agx::Matrix4x4 > ();
173 
174  if (m != m_glCamera->getProjectionMatrix())
175  m_glCamera->setProjectionMatrix(m);
176 
177  agxData::Val<agx::Matrix4x4d> view(agx::Matrix4x4d(m_mainCamera->getViewMatrix().ptr()));
178  agx::Matrix4x4 m2 = view.transform<agx::Matrix4x4 > ();
179 
180  if (m2 != m_glCamera->getViewMatrix())
181  m_glCamera->setViewMatrix(m2);
182 
183  auto viewport = m_mainCamera->getViewport();
184  m_glCamera->setViewPort(static_cast<int>(viewport->width()), static_cast<int>(m_mainCamera->getViewport()->height()));
185  }
186  using osg::Camera::DrawCallback::operator();
187 
188  private:
189  osg::Camera *m_mainCamera;
190  agxGL::Camera *m_glCamera;
191  };
192 
193  class LightsSynchronization : public osg::Camera::DrawCallback
194  {
195  public:
197  : m_glLights(mainLights),
198  m_decorator(decorator)
199  {
200  }
201 
203  {
204  }
205 
206  virtual void operator () (osg::RenderInfo& /* renderInfo */) const
207  {
208 
209  auto updateLight = [this](size_t index, agxOSG::LightSource l)
210  {
211  m_glLights->setLightPosition(index, l.getPosition());
212  m_glLights->setLightDirection(index, l.getDirection());
213  };
214 
215  updateLight(0, m_decorator->getLightSource(agxOSG::SceneDecorator::LIGHT0));
216  updateLight(1, m_decorator->getLightSource(agxOSG::SceneDecorator::LIGHT1));
217  updateLight(2, m_decorator->getLightSource(agxOSG::SceneDecorator::LIGHT2));
218  }
219 
220  using osg::Camera::DrawCallback::operator();
221 
222  private:
223  agxGL::Lights *m_glLights;
224  SceneDecorator *m_decorator;
225  };
226 #endif
227 
229  {
230  public:
231  enum Types { TRACKBALL,
232 #if defined(OSG_VERSION_GREATER_OR_EQUAL)
233 # if OSG_VERSION_GREATER_OR_EQUAL(2,9,11)
234  FPS,
235 # endif
236 #endif
237  NUM_TYPES };
238 
240 
241  static CameraManipulatorFactory* instance();
242 
243  CameraManipulatorType* next( osgViewer::Viewer* viewer = nullptr );
244  CameraManipulatorType* next( osgViewer::GraphicsWindow* window = nullptr );
245  CameraManipulatorType* create( osgViewer::Viewer* viewer = nullptr );
246  CameraManipulatorType* create( Types type, osgViewer::Viewer* viewer = nullptr );
247  CameraManipulatorType* create( Types type, osgViewer::GraphicsWindow* window = nullptr );
248  CameraManipulatorType* create( osgViewer::GraphicsWindow* window = nullptr );
249 
250  void setType( Types type ) { m_currentType = type; }
251  Types getType() const { return m_currentType; }
252 
253  protected:
254  SINGLETON_CLASSNAME_METHOD();
255  virtual void shutdown() override { s_instance = nullptr; }
256  osgViewer::GraphicsWindow* getWindow( osgViewer::Viewer* viewer, size_t num = 0 ) const;
257 
260  };
261 
263  {
267  CameraData( const osg::Camera* camera );
268 
272  CameraData( const osgViewer::Viewer* viewer );
273 
277  void applyTo( osg::Camera* camera ) const;
278 
282  void applyTo( osgViewer::Viewer* viewer ) const;
283 
286  double fieldOfView;
287  double aspectRatio;
288  bool valid;
289  double nearFarRatio;
290 
294 
295  private:
296  CameraData();
297  void initialize( const osg::Camera* camera );
298  };
299 
304  {
305  public:
307  AutoStepEvent autoStepEvent;
308 
315  {
316  MAIN_SCENE_MASK = 1 << 1,
317  DEBUG_RENDER_MASK = 1 << 2,
318  OSG_RENDER_MASK = 1 << 3,
319  HUD_MASK = 1 << 4,
320  DECORATOR_MASK = 1 << 5,
321  };
322 
324  {
325  MULTI, // New.
326  ITERATIVE, // New forced to iterative.
327  NUM_SOLVERS
328  };
329 
330 
331  void setSolverType( SolverType t ) { m_solverType = t; }
332  SolverType getSolverType() const { return m_solverType; }
333 
334  std::string getSolverName( SolverType t ) const;
335  SolverType getSolverType( const std::string& name ) const;
336 
340  void addAutoPausePair(const agx::RigidBody *body1, const agx::RigidBody *body2);
341  void addAutoPausePair(const agxCollide::Geometry *geometry1, const agxCollide::Geometry *geometry2);
342  void removeAutoPausePair(const agx::RigidBody *body1, const agx::RigidBody *body2);
343  void removeAutoPausePair(const agxCollide::Geometry *geometry1, const agxCollide::Geometry *geometry2);
344 
348  void setEnableAutoPausing(bool flag);
349  bool getEnableAutoPausing();
350 
352  ExampleApplication( agxSDK::Simulation *simulation=nullptr );
353 
354  bool init( agxIO::ArgumentParser* arguments, bool agxOnly = false );
355 
356 #ifndef SWIG
357  bool init( int argc, char** argv );
358 #endif
359 
360  agxIO::ArgumentParser* getArguments() { return m_arguments.get(); }
361 
362  agxOSG::RenderProxyFactory *getRenderProxyFactory() { return m_renderProxyFactory; }
363 
364  void setTimeStep( agx::Real dt );
365  agx::Real getTimeStep() const;
366 
367  bool addScene( const std::string& scriptFile, const std::string& scriptFunction, int key, bool isPartofUnitTest=true, float stopAfter=float(), bool isSlowUnittest=false );
368  bool addScene( const std::string& scriptFile, const std::string& scriptFunction, bool isPartofUnitTest=true, float stopAfter=float(), bool isSlowUnittest=false );
369 
370  bool addScene( BuildScenePtr sceneFunction, int key, bool isPartofUnitTest=true, float stopAfter=float(), bool isSlowUnittest=false );
371  bool addScene( BuildScenePtr sceneFunction, bool isPartofUnitTest=true, float stopAfter=float(), bool isSlowUnittest=false );
372 
373  bool addScene( SceneDescription sceneDescription, int key);
374  bool addScene( SceneDescription sceneDescription);
375 
377  void clearAddedScenes() { m_keybindingVector.clear(); }
378 
379  agx::Callback getStepCallback() const { return m_stepCallback; }
380  void setStepCallback(agx::Callback callback) { m_stepCallback = callback; }
381 
382  bool initialized() const { return m_initialized; }
383 
384  agxOSG::SceneDecorator *getSceneDecorator() { return m_decorator; }
385 
386  virtual int run();
387 
388  void setOsgNotifyLevel(osg::NotifySeverity severity) const;
389 
391  void stop(int exitCode = 0) { m_shouldStop = true; m_exitCode = exitCode; }
392 
394  bool shouldStop() const { return m_shouldStop; }
395 
396 
403  bool setWindowRectangle(unsigned int x, unsigned int y, unsigned int width, unsigned int height);
404 
405 
407  bool breakRequested() const;
408 
409  virtual void setupViewer( bool lightingEnabled = true, bool visibleWindow = true );
410 
411  void setupVideoCaptureRenderTotexture();
412 
413  //void initScene();
414 
415  osg::Group *getScene() { return m_scene.get(); }
416  void setScene(osg::Group *scene ) { m_scene = scene; }
417  osg::Group *getSceneRoot() { return m_sceneRoot.get(); }
418  osg::Group* getSceneAgxOSGRoot();
419  osg::Group *getSceneSwitch() { return m_sceneSwitch.get(); }
420 
421 #ifdef AGX_HAVE_DEPTHPEELING
422  void setEnableDepthPeeling( bool flag );
423  bool getEnableDepthPeeling() const;
424  agxOSG::DepthPeeling* getDepthPeeling();
425 #endif
426 
434  bool setEnableDebugRenderer( bool flag );
435 
437  bool getEnableDebugRenderer() const;
438 
439  void setEnableTextDebugRendering( bool flag );
440  bool getEnableTextDebugRendering() const;
441 
442  void setEnableCaptureSyncWithSimulation( bool enableSync );
443  bool getEnableCaptureSyncWithSimulation( ) const;
444 
445  void setEnableOSGRenderer( bool flag );
446  bool getEnableOSGRenderer();
447 
448  void setEnableVSync( bool flag, bool forceUpdate = false );
449  bool getEnableVSync() const;
450 
451  void getCameraHome( agx::Vec3& eye, agx::Vec3& center, agx::Vec3& up);
452  void setCameraHome( const agx::Vec3& eye, const agx::Vec3& center, const agx::Vec3& up=agx::Vec3(0,0,1) );
453 
459  void addRenderTarget(agxOSG::RenderTarget* rtt, osg::Node *targetSceneNode=nullptr);
460 
465  bool removeRenderTarget(agxOSG::RenderTarget* rtt);
466 
472  void setDebugRenderInverseMatrix( const agx::AffineMatrix4x4 &m );
473 
474 #if defined(OSG_VERSION_GREATER_OR_EQUAL)
475 # if OSG_VERSION_GREATER_OR_EQUAL(2,9,11)
476  osgGA::CameraManipulator* getCameraManipulator();
477  const osgGA::CameraManipulator* getCameraManipulator() const;
478 #else
479  osgGA::MatrixManipulator* getCameraManipulator();
480  const osgGA::MatrixManipulator* getCameraManipulator() const;
481 #endif
482 #else
483  osgGA::MatrixManipulator* getCameraManipulator();
484  const osgGA::MatrixManipulator* getCameraManipulator() const;
485 #endif
486  agxSDK::Simulation *getSimulation() { return m_simulation.get(); }
487 
488  bool restoreFromFile( const std::string& filename );
489  void journalRenderLoader(agxSDK::Assembly *assembly, bool keyFrame);
490 
491 
493  void setAutoStepping( bool flag );
494 
496  bool getAutoStepping( ) const;
497 
498 
499  void setEnablePauseUpdate( bool flag ) { m_pauseUpdate = flag; }
500  bool getEnablePauseUpdate( ) const { return m_pauseUpdate; }
501 
507  void setRealTimeSync(bool flag);
508  bool getRealTimeSync() const;
509 
510  agx::Journal *getJournal();
511  const std::string& getJournalConfigurationPath() const;
512  const std::string& getJournalPlaybackPath() const;
513 
514  void setJournalConfigurationPath(const agx::String& path);
515 
516  void setEnableJournalIncrementalStructure( bool enable );
517  bool getEnableJournalIncrementalStructure() const;
518 
519  SceneDescription getCallbackIdx( size_t idx );
520 
521  SceneDescription getCallback( int key );
522  bool createSceneFromKey( int key );
523  bool createSceneFromIndex( int idx, bool firstStartUp = false );
524 
525 
526  void reloadScene();
527  void createNextScene();
528  void createPreviousScene();
529 
530  size_t getNumScenes() const;
531 
532  void step();
533 
534  void changeSolver();
535 
536  const std::string& getSaveSceneFilename() const { return m_sceneFilename; }
537 
538  osg::Group *getRoot() { return m_root.get(); }
539 
540  void fitSceneIntoView();
541  void initSimulation(agxSDK::Simulation *simulation = nullptr, bool initializeGraphics = true);
542  void initViewer(int width, int height, bool osgWindow = true);
543 
544  void initGraphics();
545  void initRpc();
546  bool readCFGFile();
547 
553  void stopAfter(const agx::Real stopTime);
554 
555  osgViewer::Viewer *getViewer() { return m_viewer.get(); }
556  osg::Camera *getCamera() { if (m_viewer.valid()) return m_viewer->getCamera(); else return nullptr; }
557 
558  bool hasOffscreenWindow() const;
559 
563  agxOSG::CameraData getCameraData() const;
564 
568  void applyCameraData( const agxOSG::CameraData& cameraData );
569 
570  intptr_t getHWND() const;
571 
572  agx::Vec3 getViewDirection();
573 
574  PickHandler* getPickHandler() { return m_pickHandler; }
575  const PickHandler* getPickHandler() const { return m_pickHandler; }
576 
577  std::string getScriptFile() const { return m_scriptFile; }
578 
580  std::string getLuaFilePath() const
581  {
582  return m_luaFilePath;
583  }
584 
585  void handleReactiveScriptErrors( bool abortSimulation = true );
586 
587  agx::Real getTimeStamp() const;
588 
589  void clearScene();
590 
591  void setEnableSimulationDump( bool flag );
592  bool getEnableSimulationDump( ) const;
593 
594  void updateCoSimulationServer();
595  bool updatePythonCoSimulationServer(const agx::String& filename, std::stringstream& buffer);
596  bool coSimulationCallPython(agxNet::CoSimulationServer* server);
597 
598  void updateRemoteDebugger();
599  void centerScene();
600  void stepSimulation();
601 
602  bool useCoSimulation() const {return m_useCoSimulation;}
603 
604  agx::Vec3 getGravity() const { return m_gravity; }
605 
606 
607  agxOSG::ImageCapture *getImageCapture() { return m_imageCapture; }
608  const agxOSG::ImageCapture *getImageCapture() const { return m_imageCapture; }
609 
611 
612  osg::Camera *getTextureCamera() { return m_textureCamera; }
613 
614 
615  bool isCameraHomeSet() const { return m_cameraHomeSet; }
616 
617  static void registerRemovedGeometry(GeometryNode *node);
618 
619  void storeInitialJournalState();
620  void initRecordJournal();
621 
622  void journalPlayback();
623  void listSessionNames(const std::string& journalToList);
624 
634  double heading, double elevation, double distance,
635  int trackerMode = 0);
636 
646  const agx::Vec3& eye, const agx::Vec3& center, const agx::Vec3& up = agx::Vec3::Z_AXIS(),
647  int trackerMode = 0);
648 
649  bool executeOneStepWithGraphics();
650  void updateServices();
651 
652 
657  bool done() const;
658 
659 
664  void setQuitEventSetsDone(bool flag);
665  bool getQuitEventSetsDone() const;
666 
670  bool getAllowWindowResizing() const;
671 
675  void setAllowWindowResizing(bool flag);
676 
681  void takeScreenShot(const agx::String& filename="");
682 
683  void synchronizedStep(bool blocking = false);
684  void stepWrapper();
685 
686  void initScene();
687  void initScene(osg::Group *root);
688 
689 
691  agx::UInt getJournalFormat() const;
692 
694  void setJournalFormat(agx::UInt journalFormat);
695 
697  void setEnableJournal32bitMode(bool enable);
698 
700  void setEnableJournalRecord(bool enable);
701 
703  void setRequestedJournalFrequency(agx::Real freq);
704 
706  void setJournalRecordPath(const agx::String& journalPath);
707 
709  void setCoordinateSystemTransform( const agx::AffineMatrix4x4& coordinateSystemTransform);
710 
712  agx::AffineMatrix4x4 getCoordinateSystemTransform() const;
713 
715  void setGridSize(const agx::Vec2& gridSize);
716 
718  agx::Vec2 getGridSize() const;
719 
721  void setGridResolution(const agx::Vec2u gridResolution);
722 
724  agx::Vec2u getGridResolution() const;
725 
727  void setEnableGrid(bool flag);
728 
730  bool getEnableGrid() const;
731 
733  void setEnableCoordinateSystem(bool flag);
734 
736  bool getEnableCoordinateSystem() const;
737 
738  agxOSG::RenderToTexture * getVideoCaptureRendertoTexture() { return m_videoCaptureRenderToTexture; }
739 
740 #if AGX_USE_WEBSOCKETS()
741  agxOSG::ExampleApplicationController *getController();
742 
743  agx::UInt16 getControlChannelPort();
744  void pushParametersToControlChannel();
745  void setEnableControlChannelTickSignals(bool flag);
746  void pushFrameToRemoteViewer();
747 #endif
748 
749  void postExecution();
750  void setEnableThreadTimeline(bool flag);
751  void setEnableTaskProfile(bool flag);
752  int getExitCode() { return m_exitCode; }
753 
754 #if AGX_USE_PYTHON()
755  agxPython::ScriptContextInterface* initPythonContext(agxPython::ScriptManager *scriptManager);
756 #endif
757 
758  void createVisual(agxSDK::Simulation *simulation, float detailRatio = 1.0f, bool createAxes = false);
759  void createVisual(agxSDK::Assembly *assembly, float detailRatio = 1.0f, bool createAxes = false);
760 
761 
762  protected:
763 
764  virtual ~ExampleApplication();
765 
766  void drawGrid();
767  void drawCoordinateSystem();
768 
769  protected:
770  class SimulationListener;
771 
772  void execute();
773  void executeWithGraphics();
774  bool executeOneStepWithGraphics(bool& saveAfterEnabled, agx::Real saveAfterTime, agx::HighAccuracyTimer& timer);
775  void executeWithoutGraphics();
776  void generateQuickProfiling();
777  void journalSceneLoader(const agx::String& path);
778  void removeGeometryNode(agxSDK::Simulation*, agxCollide::Geometry*);
779  void setArgumentsPostSceneCreation(); // This function will override a number of settings with their command line argument specifications
780  agxJson::Value extractSimulationStructureToJson();
781  void applyInitialParameters(const std::string& filePath);
782  void initThreadTimeline();
783  bool initBrickInterop();
784 
785  bool attachScripts( osg::Group* root );
786  osg::Group *executeLuaScript( const agx::String& file, const agx::String& function, bool& success );
787  osg::Group *executePythonScript( const agx::String& file, const agx::String& function, bool& success );
788  osg::Group *loadBrickModel( const agx::String& file, const agx::String& model, bool& success );
789  osg::Group *executeMPyScript(const agx::String& file, bool& success);
790 
791  osg::Group *createScene( const SceneDescription& desc, bool &success );
792 
793  osg::ref_ptr<agxOSG::SceneDecorator> m_decorator;
795  osg::ref_ptr<agxOSG::GuiEventAdapter> m_eventAdapter;
796  osg::ref_ptr<osgViewer::Viewer> m_viewer;
797 
799 
800  osg::ref_ptr<osg::Group> m_root;
801  osg::ref_ptr<osg::Group> m_sceneRoot;
802  osg::ref_ptr<osg::Group> m_scene;
803  osg::ref_ptr<osg::Switch> m_sceneSwitch;
804 
806 
808 
810 
812 
813  KeyBindings m_keyBindings;
814  KeyBindingsVector m_keybindingVector;
815 
818 
819  std::string m_sceneFilename;
820  std::string m_parameterFilePath;
821 
823  std::string m_cfgFileName;
824 
826 
834  bool m_agxOnly;
836  // std::string m_exportMayaAnimationPath;
837 
838 #if AGX_USE_WEBSOCKETS()
839  friend class ExampleApplicationController;
840 #endif
841  friend class AutoPauseListener;
845 
847 
848  agxCFG::ConfigScriptRef m_settings;
849 
850  std::string m_xmlPlotFile;
852 
853  std::string m_scriptFile;
858 
860 #if AGX_USE_OPENGL()
863 #endif
877  bool m_vSync;
878  std::string m_luaFilePath;
879  std::string m_pythonFilePath;
886  std::string m_journalEofMode;
887  std::string m_journalRecordPath;
888  std::string m_journalSessionName;
891  // agx::UInt m_journalStride;
895 
898 
899 #ifdef AGX_HAVE_DEPTHPEELING
900  osg::ref_ptr<DepthPeeling> m_depthPeeling;
901 #endif
906  osg::ref_ptr<osg::Camera> m_textureCamera;
915  RenderTargetRefVector m_renderTargetSet;
916  osg::ref_ptr<osg::GraphicsContext> m_pBuffer;
917  osg::ref_ptr<osg::Camera> m_pBufferCamera;
920 
921  public:
924  bool m_isFMU;
926  std::string m_hostName;
927 
928  protected:
934  osg::ref_ptr<osg::Geode> m_grid;
935  osg::ref_ptr<osg::MatrixTransform> m_coordinateSystem;
942 
943  std::string m_videoName;
946 
947  };
948 
950 }
void setScene(osg::Group *scene)
Class that encapsulates rendering and simulation using OpenSceneGraph.
osgViewer::Viewer * getViewer()
Name space containing classes for sending/reading data over sockets.
Definition: MacUtil.h:22
VideoFFMPEGPipeCaptureRef m_videoCapture
const PickHandler * getPickHandler() const
osg::ref_ptr< osg::Group > m_scene
void AGXPHYSICS_EXPORT init()
Initialize agx.
KeyBindingsVector m_keybindingVector
T transform() const
Definition: Value.h:333
RenderToTextureRef m_videoCaptureRenderToTexture
osg::Group *(* BuildScenePtr)(agxSDK::Simulation *simulation, ExampleApplication *application)
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:36
GLenum GLuint GLenum severity
Definition: gl.h:5539
agx::RealVector m_coSimulationOutputData
std::string getLuaFilePath() const
Get file path to most recent lua file.
agx::Vector< SceneDescription > KeyBindingsVector
osg::ref_ptr< osg::Group > m_sceneRoot
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:73
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:113
static Vec3T Z_AXIS()
Definition: Vec3Template.h:789
The geometry representation used by the collision detection engine.
Definition: Geometry.h:88
Only use as member allocated variable.
Definition: Value.h:278
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
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:52
agx::ref_ptr< agx::Referenced > m_journal
agx::HashTable< int, int > KeyBindings
std::string m_extractSimulationStructureToJsonPath
RealModeEnum
The data type for basic floating point representation.
Definition: Real.h:35
agxIO::ArgumentParserRef m_arguments
const std::string & getSaveSceneFilename() const
agx::ref_ptr< agx::Referenced > m_debugClient
RenderTargetRefVector m_renderTargetSet
std::mutex Mutex
Definition: Referenced.h:93
agx::Vector< std::pair< std::string, int > > m_attachedScripts
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:121
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
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
agx::ref_ptr< ExampleApplication > ExampleApplicationRef
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:31
StatisticsRendererRef m_statisticsRenderer
An assembly is a collection of basic simulation objects, such as rigid bodies, constraints, geometries.
Definition: Assembly.h:73
GLenum type
Definition: gl.h:5539
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