AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
EmbeddedGLWindow.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGXOSG_EMBEDDEDGLWINDOW_H
18#define AGXOSG_EMBEDDEDGLWINDOW_H
19
20
21#include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
22
23#include <agxGL/Camera.h>
24#include <agxGL/Lights.h>
25#include <osgViewer/Viewer>
26#include <osg/Version>
27#include <osgGA/TrackballManipulator>
28#include <osgGA/StateSetManipulator>
29#include <osgViewer/GraphicsWindow>
30#include <agxOSG/PickHandler.h>
32
33#include <agx/PopDisableWarnings.h> // End of disabled warnings.
34
35#include <agxOSG/export.h>
36#include <agx/Integer.h>
37#include <agxSDK/Simulation.h>
38#include <agxOSG/RenderProxy.h>
39
40namespace agxOSG
41{
46 {
47 public:
54 {
55 MAIN_SCENE_MASK = 1 << 1,
56 DEBUG_RENDER_MASK = 1 << 2,
57 OSG_RENDER_MASK = 1 << 3,
58 HUD_MASK = 1 << 4,
59 DECORATOR_MASK = 1 << 5,
60 };
61
62 public:
63
66
73 bool init(int x, int y, int width, int height);
74
80 void resize(int x, int y, int width, int height);
81 osgGA::EventQueue* getEventQueue() const;
82
87 void mouseMoveEvent(int x, int y);
88
94 void mousePressEvent(int x, int y, int button);
95
101 void mouseReleaseEvent(int x, int y, int button);
102
108 void keyPressEvent(int key, int mod_mask);
109
115 void keyReleaseEvent(int key, int mod_mask);
116
121 void wheelEvent(int motion);
122
126 void frame();
127
131 osg::Camera *getCamera();
132
136 const osg::Camera *getCamera() const;
137
143
148
153
157 osg::Group* getRoot();
158
162 const osg::Group* getRoot() const;
163
168
173
176
180 int getWidth();
181
186
191 void clear();
192
194
195 void setPolygonMode( int mode );
196
197 int getPolygonMode() const;
198
199 agx::Real getSceneRadius(osg::Group* scene) const;
200
202 void initGL();
203
204 private:
205
206 osg::ref_ptr<osgViewer::Viewer> m_viewer;
207 agxSDK::SimulationRef m_simulation;
208 osg::ref_ptr<osg::Group> m_root;
209 osg::ref_ptr<agxOSG::SceneDecorator> m_decorator;
210 osg::ref_ptr<osgGA::StandardManipulator> m_manipulator;
211 osg::ref_ptr<osgGA::StateSetManipulator> m_ssm;
212 agxGL::CameraRef m_GlCamera;
213 agxGL::LightsRef m_GlLights;
214 osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> m_embeddedWindow;
215 agx::ref_ptr<agxOSG::RenderProxyFactory> m_renderProxyFactory;
217 osg::ref_ptr<agxOSG::GuiEventAdapter> m_adapter;
218
219 bool m_agxgl_initialized;
220 };
221}
222
223#endif
#define AGXOSG_EXPORT
This class is for embedding an OSG based window inside another OpenGL contex, for example in QT.
void fitSceneIntoView()
Will move the camera so that the whole scene is visible.
agxSDK::Simulation * getSimulation() const
void setOrbitCamera(agxOSG::GeometryNode *node, const agx::Vec3 &pos)
void mouseMoveEvent(int x, int y)
Called upon mouse event.
void setPolygonMode(int mode)
void frame()
Should be called to update the rendering frame.
void mousePressEvent(int x, int y, int button)
Called upon pressing a mouse button.
osgGA::EventQueue * getEventQueue() const
const osg::Group * getRoot() const
void resize(int x, int y, int width, int height)
Called at resize of the window.
bool init(int x, int y, int width, int height)
Will initialize the scenegraph, camera, viewer A valid OpenGL context should be initialized and activ...
EmbeddedGLWindow()
Constructor.
void keyPressEvent(int key, int mod_mask)
Called upon a keypress event.
const osg::Camera * getCamera() const
void mouseReleaseEvent(int x, int y, int button)
Called upon releasing a mouse button.
void clear()
Will remove simulation, deallocate all scene graph elements After call to this method,...
agx::Real getSceneRadius(osg::Group *scene) const
CameraMask
Specifies node masks for different parts of the rendering scene.
void setSimulation(agxSDK::Simulation *simulation)
Associate a Simulation to this window.
agxOSG::SceneDecorator * getSceneDecorator()
void removeSimulation()
Deassociates any registered simulation.
void wheelEvent(int motion)
Called when the mouse wheel is used.
void keyReleaseEvent(int key, int mod_mask)
Called upon a keyrelease event.
osg::Group * getRoot()
osg::Camera * getCamera()
~EmbeddedGLWindow()
Destructor.
A node that can be associated with a collision geometry so that the transformation of this node is up...
Definition: GeometryNode.h:42
Decorates a scene with a specific AGX Rendering Style.
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:131
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
double Real
Definition: Real.h:41