20 #pragma clang diagnostic push
21 #pragma clang diagnostic ignored "-Wconversion"
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>
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;
123 SceneDescription(
BuildScenePtr sc,
bool isTest =
false,
float stop =
float(),
bool isSlowUnittest =
false);
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 );
316 MAIN_SCENE_MASK = 1 << 1,
317 DEBUG_RENDER_MASK = 1 << 2,
318 OSG_RENDER_MASK = 1 << 3,
320 DECORATOR_MASK = 1 << 5,
334 std::string getSolverName( SolverType t )
const;
335 SolverType getSolverType(
const std::string& name )
const;
348 void setEnableAutoPausing(
bool flag);
349 bool getEnableAutoPausing();
357 bool init(
int argc,
char** argv );
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 );
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 );
388 void setOsgNotifyLevel(osg::NotifySeverity
severity)
const;
391 void stop(
int exitCode = 0) { m_shouldStop =
true; m_exitCode = exitCode; }
403 bool setWindowRectangle(
unsigned int x,
unsigned int y,
unsigned int width,
unsigned int height);
407 bool breakRequested()
const;
409 virtual void setupViewer(
bool lightingEnabled =
true,
bool visibleWindow =
true );
411 void setupVideoCaptureRenderTotexture();
416 void setScene(osg::Group *scene ) { m_scene = scene; }
418 osg::Group* getSceneAgxOSGRoot();
421 #ifdef AGX_HAVE_DEPTHPEELING
422 void setEnableDepthPeeling(
bool flag );
423 bool getEnableDepthPeeling()
const;
424 agxOSG::DepthPeeling* getDepthPeeling();
434 bool setEnableDebugRenderer(
bool flag );
437 bool getEnableDebugRenderer()
const;
439 void setEnableTextDebugRendering(
bool flag );
440 bool getEnableTextDebugRendering()
const;
442 void setEnableCaptureSyncWithSimulation(
bool enableSync );
443 bool getEnableCaptureSyncWithSimulation( )
const;
445 void setEnableOSGRenderer(
bool flag );
446 bool getEnableOSGRenderer();
448 void setEnableVSync(
bool flag,
bool forceUpdate =
false );
449 bool getEnableVSync()
const;
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;
479 osgGA::MatrixManipulator* getCameraManipulator();
480 const osgGA::MatrixManipulator* getCameraManipulator()
const;
483 osgGA::MatrixManipulator* getCameraManipulator();
484 const osgGA::MatrixManipulator* getCameraManipulator()
const;
488 bool restoreFromFile(
const std::string& filename );
493 void setAutoStepping(
bool flag );
496 bool getAutoStepping( )
const;
507 void setRealTimeSync(
bool flag);
508 bool getRealTimeSync()
const;
511 const std::string& getJournalConfigurationPath()
const;
512 const std::string& getJournalPlaybackPath()
const;
514 void setJournalConfigurationPath(
const agx::String& path);
516 void setEnableJournalIncrementalStructure(
bool enable );
517 bool getEnableJournalIncrementalStructure()
const;
522 bool createSceneFromKey(
int key );
523 bool createSceneFromIndex(
int idx,
bool firstStartUp =
false );
527 void createNextScene();
528 void createPreviousScene();
530 size_t getNumScenes()
const;
538 osg::Group *
getRoot() {
return m_root.get(); }
540 void fitSceneIntoView();
541 void initSimulation(
agxSDK::Simulation *simulation =
nullptr,
bool initializeGraphics =
true);
542 void initViewer(
int width,
int height,
bool osgWindow =
true);
553 void stopAfter(
const agx::Real stopTime);
555 osgViewer::Viewer *
getViewer() {
return m_viewer.get(); }
556 osg::Camera *
getCamera() {
if (m_viewer.valid())
return m_viewer->getCamera();
else return nullptr; }
558 bool hasOffscreenWindow()
const;
570 intptr_t getHWND()
const;
582 return m_luaFilePath;
585 void handleReactiveScriptErrors(
bool abortSimulation =
true );
591 void setEnableSimulationDump(
bool flag );
592 bool getEnableSimulationDump( )
const;
594 void updateCoSimulationServer();
595 bool updatePythonCoSimulationServer(
const agx::String& filename, std::stringstream& buffer);
598 void updateRemoteDebugger();
600 void stepSimulation();
617 static void registerRemovedGeometry(
GeometryNode *node);
619 void storeInitialJournalState();
620 void initRecordJournal();
622 void journalPlayback();
623 void listSessionNames(
const std::string& journalToList);
634 double heading,
double elevation,
double distance,
635 int trackerMode = 0);
647 int trackerMode = 0);
649 bool executeOneStepWithGraphics();
650 void updateServices();
664 void setQuitEventSetsDone(
bool flag);
665 bool getQuitEventSetsDone()
const;
670 bool getAllowWindowResizing()
const;
675 void setAllowWindowResizing(
bool flag);
681 void takeScreenShot(
const agx::String& filename=
"");
683 void synchronizedStep(
bool blocking =
false);
687 void initScene(osg::Group *
root);
694 void setJournalFormat(
agx::UInt journalFormat);
697 void setEnableJournal32bitMode(
bool enable);
700 void setEnableJournalRecord(
bool enable);
703 void setRequestedJournalFrequency(
agx::Real freq);
706 void setJournalRecordPath(
const agx::String& journalPath);
715 void setGridSize(
const agx::Vec2& gridSize);
721 void setGridResolution(
const agx::Vec2u gridResolution);
727 void setEnableGrid(
bool flag);
730 bool getEnableGrid()
const;
733 void setEnableCoordinateSystem(
bool flag);
736 bool getEnableCoordinateSystem()
const;
740 #if AGX_USE_WEBSOCKETS()
744 void pushParametersToControlChannel();
745 void setEnableControlChannelTickSignals(
bool flag);
746 void pushFrameToRemoteViewer();
749 void postExecution();
750 void setEnableThreadTimeline(
bool flag);
751 void setEnableTaskProfile(
bool flag);
767 void drawCoordinateSystem();
770 class SimulationListener;
773 void executeWithGraphics();
775 void executeWithoutGraphics();
776 void generateQuickProfiling();
779 void setArgumentsPostSceneCreation();
780 agxJson::Value extractSimulationStructureToJson();
781 void applyInitialParameters(
const std::string& filePath);
782 void initThreadTimeline();
783 bool initBrickInterop();
785 bool attachScripts( osg::Group*
root );
789 osg::Group *executeMPyScript(
const agx::String& file,
bool& success);
838 #if AGX_USE_WEBSOCKETS()
841 friend class AutoPauseListener;
899 #ifdef AGX_HAVE_DEPTHPEELING
900 osg::ref_ptr<DepthPeeling> m_depthPeeling;
void setScene(osg::Group *scene)
Class that encapsulates rendering and simulation using OpenSceneGraph.
agx::UInt m_journalFormat
osgViewer::Viewer * getViewer()
VideoFFMPEGPipeCaptureRef m_videoCapture
osg::ref_ptr< osg::Group > m_scene
void AGXPHYSICS_EXPORT init()
Initialize agx.
KeyBindingsVector m_keybindingVector
agx::Vec3 m_cameraHomeCenter
RenderToTextureRef m_videoCaptureRenderToTexture
bool m_explicitJournalConfigurationPath
bool m_allowWindowResizing
void setEnablePauseUpdate(bool flag)
std::string m_luaFilePath
PickHandler * getPickHandler()
std::string m_coSimulationInputFile
bool getEnablePauseUpdate() const
void clearAddedScenes()
Remove all added scenes.
Class that manages the embedded Python interpreter and a script context.
std::string m_coSimulationOutputFile
agx::Real m_profilingFrequency
osg::Group *(* BuildScenePtr)(agxSDK::Simulation *simulation, ExampleApplication *application)
AGXOSG_EXPORT bool setOrbitCamera(osgViewer::Viewer *viewer, agxOSG::GeometryNode *node, const agx::Vec3 &eye, const agx::Vec3 ¢er, const agx::Vec3 &up, int trackerMode)
agxIO::ArgumentParser * getArguments()
agxOSG::LightSource getLightSource(Lights l)
Get a wrapper for a LightSource with only AGX types.
agx::ref_ptr< agx::Referenced > m_coSimulationServer
AGXOSG_EXPORT bool executePythonScript(const std::string &filename, const std::string &function, agxSDK::Simulation *simulation, agxOSG::ExampleApplication *application, osg::Group *root)
Execute a named function in a python script file.
agx::RealModeEnum m_journalRealMode
virtual void operator()(osg::RenderInfo &) const
agxSDK::Simulation * getSimulation()
agx::Event1< bool > AutoStepEvent
agxCFG::ConfigScriptRef m_settings
Generalized callback, using std::function.
The HighAccurayTimer class can replace the regular Timer class in high level applications where the n...
virtual void operator()(osg::RenderInfo &) const
osg::ref_ptr< osgViewer::Viewer > m_viewer
Matrix class for affine transformations.
agx::Real m_journalRecordStartTime
GLenum GLuint GLenum severity
agx::RealVector m_coSimulationOutputData
agx::Real m_journalFrequency
agx::Vector< SceneDescription > KeyBindingsVector
bool m_interactiveRemoteClient
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
std::string m_cfgFileName
std::string m_xmlPlotFile
static CameraManipulatorFactory * s_instance
std::string m_journalRecordPath
PickHandlerRef m_pickHandler
The Timer class permits timing execution speed with the same refinement as the built in hardware cloc...
agxOSG::SceneDecorator * getSceneDecorator()
agxOSG::ImageCapture * getImageCapture()
virtual void shutdown() override
Implement this method to cleanup your Singleton class.
bool setLightDirection(agx::UInt index, const agx::Vec3 &direction)
Internal class which interfaces to a ScriptContext in an abstract and safe manner.
CameraSynchronization(osg::Camera *mainCamera, agxGL::Camera *glCamera)
agxOSG::RenderProxyFactory * m_renderProxyFactory
agx::Real m_relativeStopTime
Render target is used for rendering camera content to a buffer, either a DEPTH or COLOR target...
agxOSG::ImageCaptureRef m_imageCapture
Block synchronization primitive.
bool setLightPosition(agx::UInt index, const agx::Vec4 &position)
A small argument parser class.
Decorates a scene with a specific AGX Rendering Style.
Base class providing referencing counted objects.
bool m_generateTaskProfile
bool useCoSimulation() const
agx::Real m_journalStopTime
bool m_enableSyncBrickSimulation
The geometry representation used by the collision detection engine.
osg::Camera * getTextureCamera()
Only use as member allocated variable.
osg::Group * getSceneSwitch()
agxOSG::RenderProxyFactory * getRenderProxyFactory()
void setProjectionMatrix(const agx::Matrix4x4 &matrix)
Set the projection matrix.
agx::Vector< agx::String > m_timelineFormats
void setStepCallback(agx::Callback callback)
agx::AffineMatrix4x4 m_coordinateSystemTransform
osg::ref_ptr< agxOSG::SceneDecorator > m_decorator
agx::Real m_journalStartTime
KeyBindings m_keyBindings
agx::RealVector m_coSimulationInputData
osg::ref_ptr< osg::Switch > m_sceneSwitch
std::string m_sceneFilename
std::string m_journalSessionName
LightsSynchronization(agxGL::Lights *mainLights, agxOSG::SceneDecorator *decorator)
std::string m_parameterFilePath
agx::Vec3 m_cameraHomeEye
std::string getScriptFile() const
A node that can be associated with a collision geometry so that the transformation of this node is up...
void setViewMatrix(const agx::Matrix4x4 &matrix)
Set the view matrix.
const agxOSG::ImageCapture * getImageCapture() const
Class for sending serialized agxSDK::Simulation over to a client.
void stop(int exitCode=0)
Stop (=exit) the application at next opportunity.
const PickHandler * getPickHandler() const
agxSDK::Simulation::GeometryEvent::CallbackType m_removeGeometryCallback
AutoStepEvent autoStepEvent
agxGL::CameraRef m_GlCamera
agxSDK::SimulationRef m_simulation
agx::Vec2u m_gridResolution
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
SolverType getSolverType() const
agxOSG::VideoFFMPEGPipeCapture * getVideoServerCapture()
std::string scriptFunction
agx::HashSet< agxCollide::GeometryPair > m_autoPausePairs
osg::ref_ptr< agxOSG::GuiEventAdapter > m_eventAdapter
CameraMask
Specifies node masks for different parts of the rendering scene.
agx::Callback getStepCallback() const
The rigid body class, combining a geometric model and a frame of reference.
agx::ref_ptr< agx::Referenced > m_journal
agx::Vec3 getGravity() const
std::string m_pythonFilePath
std::string m_journalConfigurationPath
bool m_autoCycleThroughScenes
bool m_coordinateSystemEnabled
agx::HashTable< int, int > KeyBindings
bool isCameraHomeSet() const
Templated callback with two arguments.
std::string m_extractSimulationStructureToJsonPath
RealModeEnum
The data type for basic floating point representation.
agxIO::ArgumentParserRef m_arguments
virtual ~CameraSynchronization()
agx::Event m_sceneLoadEvent
const agx::Matrix4x4 & getViewMatrix() const
Get the view matrix.
agx::ref_ptr< agx::Referenced > m_debugClient
void setViewPort(unsigned width, unsigned height)
RenderTargetRefVector m_renderTargetSet
agx::Mutex m_serviceMutex
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...
agxOSG::RenderToTexture * getVideoCaptureRendertoTexture()
A pod-struct for holding information about scenes to load by the application.
agx::ref_ptr< agx::Referenced > m_controller
osg::Camera * getCamera()
bool m_enableJournalIncrementalStructure
agxSDK::ContactEventListenerRef m_autoPauseListener
osg::ref_ptr< osg::MatrixTransform > m_coordinateSystem
bool m_autoPausingEnabled
virtual ~LightsSynchronization()
std::string getLuaFilePath() const
Get file path to most recent lua file.
const std::string & getSaveSceneFilename() const
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.
bool m_enableJournalRecording
osg::ref_ptr< osg::GraphicsContext > m_pBuffer
agx::ref_ptr< ExampleApplication > ExampleApplicationRef
void setSolverType(SolverType t)
agx::Callback m_stepCallback
An event with no arguments.
bool m_generateThreadTimeline
std::string m_journalPlaybackPath
Container class for lights that is used for synchronizing light data with shaders, such as particle sprite shaders.
StatisticsRendererRef m_statisticsRenderer
osg::Group * getSceneRoot()
std::string m_journalEofMode
An assembly is a collection of basic simulation objects, such as rigid bodies, constraints, geometries.
const agx::Matrix4x4 & getProjectionMatrix() const
Get the projection matrix.
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...
agxGL::LightsRef m_GlLights