 |
AGXDynamics
2.35.0.3
|
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>
46 #if AGX_USE_WEBSOCKETS()
55 #include <agxCFG/ConfigScript.h>
73 # include <agx/config/AGX_PYTHON_VERSION.h>
77 #pragma clang diagnostic pop
82 class StandardManipulator;
83 class MatrixManipulator;
102 class CoSimulationServer;
106 class ExampleApplication;
107 class SceneDecorator;
108 class RenderProxyFactory;
110 #if AGX_USE_WEBSOCKETS()
111 class ExampleApplicationController;
126 SceneDescription(
const std::string& scriptFileName,
const std::string& scriptFunctionName,
bool isTest =
false,
float stop =
float(),
bool isSlowUnittest =
false);
129 SceneDescription(
const std::string& sceneFile,
bool isTest =
false,
float stop =
float(),
bool isSlowUnittest =
false);
144 #if defined(OSG_VERSION_GREATER_OR_EQUAL)
145 # if OSG_VERSION_GREATER_OR_EQUAL(2,9,11)
183 auto viewport = m_mainCamera->getViewport();
184 m_glCamera->
setViewPort(
static_cast<int>(viewport->width()),
static_cast<int>(m_mainCamera->getViewport()->height()));
186 using osg::Camera::DrawCallback::operator();
189 osg::Camera *m_mainCamera;
197 : m_glLights(mainLights),
198 m_decorator(decorator)
220 using osg::Camera::DrawCallback::operator();
232 #if defined(OSG_VERSION_GREATER_OR_EQUAL)
233 # if OSG_VERSION_GREATER_OR_EQUAL(2,9,11)
254 SINGLETON_CLASSNAME_METHOD();
255 virtual void shutdown()
override { s_instance =
nullptr; }
256 osgViewer::GraphicsWindow* getWindow( osgViewer::Viewer* viewer,
size_t num = 0 )
const;
272 CameraData(
const osgViewer::Viewer* viewer );
277 void applyTo( osg::Camera* camera )
const;
282 void applyTo( osgViewer::Viewer* viewer )
const;
297 void initialize(
const osg::Camera* camera );
330 MAIN_SCENE_MASK = 1 << 1,
331 DEBUG_RENDER_MASK = 1 << 2,
332 OSG_RENDER_MASK = 1 << 3,
334 DECORATOR_MASK = 1 << 5,
348 std::string getSolverName( SolverType t )
const;
349 SolverType getSolverType(
const std::string& name )
const;
362 void setEnableAutoPausing(
bool flag);
363 bool getEnableAutoPausing();
373 bool init(
int argc,
char** argv );
383 bool addScene(
const std::string& scriptFile,
const std::string& scriptFunction,
int key,
bool isPartofUnitTest=
true,
float stopAfter=
float(),
bool isSlowUnittest=
false );
384 bool addScene(
const std::string& scriptFile,
const std::string& scriptFunction,
bool isPartofUnitTest=
true,
float stopAfter=
float(),
bool isSlowUnittest=
false );
386 bool addScene(
BuildScenePtr sceneFunction,
int key,
bool isPartofUnitTest=
true,
float stopAfter=
float(),
bool isSlowUnittest=
false );
387 bool addScene(
BuildScenePtr sceneFunction,
bool isPartofUnitTest=
true,
float stopAfter=
float(),
bool isSlowUnittest=
false );
404 void setOsgNotifyLevel(osg::NotifySeverity severity)
const;
410 void stop(
int exitCode = 0) { m_shouldStop =
true; m_exitCode = exitCode; }
425 bool setWindowRectangle(
unsigned int x,
unsigned int y,
unsigned int width,
unsigned int height);
432 bool setWindowTitle(
const std::string& title);
435 bool breakRequested()
const;
437 virtual void setupViewer(
bool lightingEnabled =
true,
bool visibleWindow =
true );
439 void setupVideoCaptureRenderTotexture();
444 void setScene(osg::Group *scene ) { m_scene = scene; }
446 osg::Group* getSceneAgxOSGRoot();
449 #ifdef AGX_HAVE_DEPTHPEELING
450 void setEnableDepthPeeling(
bool flag );
451 bool getEnableDepthPeeling()
const;
452 agxOSG::DepthPeeling* getDepthPeeling();
462 bool setEnableDebugRenderer(
bool flag );
465 bool getEnableDebugRenderer()
const;
467 void setEnableTextDebugRendering(
bool flag );
468 bool getEnableTextDebugRendering()
const;
470 void setEnableCaptureSyncWithSimulation(
bool enableSync );
471 bool getEnableCaptureSyncWithSimulation( )
const;
473 void setEnableOSGRenderer(
bool flag );
474 bool getEnableOSGRenderer();
476 void setEnableVSync(
bool flag,
bool forceUpdate =
false );
477 bool getEnableVSync()
const;
502 #if defined(OSG_VERSION_GREATER_OR_EQUAL)
503 # if OSG_VERSION_GREATER_OR_EQUAL(2,9,11)
504 osgGA::CameraManipulator* getCameraManipulator();
505 const osgGA::CameraManipulator* getCameraManipulator()
const;
507 osgGA::MatrixManipulator* getCameraManipulator();
508 const osgGA::MatrixManipulator* getCameraManipulator()
const;
511 osgGA::MatrixManipulator* getCameraManipulator();
512 const osgGA::MatrixManipulator* getCameraManipulator()
const;
516 bool restoreFromFile(
const std::string& filename );
521 void setAutoStepping(
bool flag );
524 bool getAutoStepping( )
const;
535 void setRealTimeSync(
bool flag);
536 bool getRealTimeSync()
const;
539 const std::string& getJournalConfigurationPath()
const;
540 const std::string& getJournalPlaybackPath()
const;
542 void setJournalConfigurationPath(
const agx::String& path);
544 void setEnableJournalIncrementalStructure(
bool enable );
545 bool getEnableJournalIncrementalStructure()
const;
550 bool createSceneFromKey(
int key );
551 bool createSceneFromIndex(
int idx,
bool firstStartUp =
false );
555 void createNextScene();
556 void createPreviousScene();
558 size_t getNumScenes()
const;
566 osg::Group *
getRoot() {
return m_root.get(); }
568 void fitSceneIntoView();
569 void initSimulation(
agxSDK::Simulation *simulation =
nullptr,
bool initializeGraphics =
true);
570 void initViewer(
int width,
int height,
bool osgWindow =
true);
581 void stopAfter(
const agx::Real stopTime);
583 osgViewer::Viewer *
getViewer() {
return m_viewer.get(); }
584 osg::Camera *
getCamera() {
if (m_viewer.valid())
return m_viewer->getCamera();
else return nullptr; }
586 bool hasOffscreenWindow()
const;
598 intptr_t getHWND()
const;
610 return m_luaFilePath;
613 void handleReactiveScriptErrors(
bool abortSimulation =
true );
619 void setEnableSimulationDump(
bool flag );
620 bool getEnableSimulationDump( )
const;
622 void updateCoSimulationServer();
623 bool updatePythonCoSimulationServer(
const agx::String& filename, std::stringstream& buffer);
626 void updateRemoteDebugger();
628 void stepSimulation();
645 static void registerRemovedGeometry(
GeometryNode *node);
647 void storeInitialJournalState();
648 void initRecordJournal();
650 void journalPlayback();
651 void listSessionNames(
const std::string& journalToList);
662 double heading,
double elevation,
double distance,
663 int trackerMode = 0);
675 int trackerMode = 0);
677 bool executeOneStepWithGraphics();
678 bool executeOneStepWithoutGraphics();
680 void updateServices();
694 void setQuitEventSetsDone(
bool flag);
695 bool getQuitEventSetsDone()
const;
700 bool getAllowWindowResizing()
const;
705 void setAllowWindowResizing(
bool flag);
711 void takeScreenShot(
const agx::String& filename=
"");
713 void synchronizedStep(
bool blocking =
false);
718 void initScene(osg::Group *
root);
725 void setJournalFormat(
agx::UInt journalFormat);
728 void setEnableJournal32bitMode(
bool enable);
731 void setEnableJournalRecord(
bool enable);
734 void setRequestedJournalFrequency(
agx::Real freq);
737 void setJournalRecordPath(
const agx::String& journalPath);
746 void setGridSize(
const agx::Vec2& gridSize);
752 void setGridResolution(
const agx::Vec2u gridResolution);
758 void setEnableGrid(
bool flag);
761 bool getEnableGrid()
const;
764 void setEnableCoordinateSystem(
bool flag);
767 bool getEnableCoordinateSystem()
const;
771 void throttleIdleCpuUsageBySleeping();
775 std::string getProfilingJournalPath()
const;
777 #if AGX_USE_WEBSOCKETS()
778 agxOSG::ExampleApplicationController *getController();
781 void pushParametersToControlChannel();
782 void setEnableControlChannelTickSignals(
bool flag);
783 void pushFrameToRemoteViewer();
786 void postExecution();
787 void setEnableThreadTimeline(
bool flag);
788 void setEnableTaskProfile(
bool flag);
792 agxPython::ScriptContextInterface* initPythonContext(agxPython::ScriptManager *scriptManager);
804 void drawCoordinateSystem();
807 void addGranularCreateVisualCallbacks();
810 class SimulationListener;
813 void executeWithoutGraphics();
817 void executeWithGraphics();
820 void generateQuickProfiling();
823 void setArgumentsPostSceneCreation();
824 agxJson::Value extractSimulationStructureToJson();
825 void applyInitialParameters(
const std::string& filePath);
826 void initThreadTimeline();
827 bool initBrickInterop();
829 void triggerPreFrameListeners();
830 void triggerPostFrameListeners();
832 bool attachScripts( osg::Group*
root );
836 osg::Group *executeMPyScript(
const agx::String& file,
bool& success);
885 #if AGX_USE_WEBSOCKETS()
886 friend class ExampleApplicationController;
888 friend class AutoPauseListener;
949 #ifdef AGX_HAVE_DEPTHPEELING
950 osg::ref_ptr<DepthPeeling> m_depthPeeling;
agx::AffineMatrix4x4 m_coordinateSystemTransform
agx::RealVector m_coSimulationInputData
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
RenderTargetRefVector m_renderTargetSet
AGXOSG_EXPORT bool setOrbitCamera(osgViewer::Viewer *viewer, agxOSG::GeometryNode *node, const agx::Vec3 &eye, const agx::Vec3 ¢er, const agx::Vec3 &up, int trackerMode)
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)
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
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)
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_luaFilePath
std::string m_coSimulationInputFile
void setViewPort(unsigned width, unsigned height)
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...
std::string getLuaFilePath() const
Get file path to most recent lua file.
agx::RealModeEnum m_journalRealMode
agx::RealVector m_coSimulationOutputData
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.
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,...
LightsSynchronization(agxGL::Lights *mainLights, agxOSG::SceneDecorator *decorator)
osg::ref_ptr< agxOSG::SceneDecorator > m_decorator
agx::Real m_journalStartTime
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.
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)