17 #ifndef AGXOSG_EXAMPLEAPPLICATIONCONTROLLER_H
18 #define AGXOSG_EXAMPLEAPPLICATIONCONTROLLER_H
35 #include <osg/Geometry>
36 #include <osg/PositionAttitudeTransform>
37 #include <osg/LineWidth>
38 #include <osgViewer/Viewer>
39 #include <osg/ShapeDrawable>
47 #include <agxCallable/CallableAccessor.h>
49 #if AGX_USE_WEBSOCKETS()
54 class ExampleApplication;
65 void signalAutoStepping(
bool flag);
66 void pushParameters();
68 void setEnableTickSignals(
bool flag);
71 void updateMouseSpringRenderer();
77 bool needSceneLoading();
78 void performSceneLoading();
88 void initPlotCallbacks();
92 void initRemoteConnection();
122 #if AGX_USE_WEBSOCKETS()
127 void simulationTickCallback(
agx::Clock *clock);
149 void buildStateMessage(agxJson::Value& eRoot);
151 #if AGX_USE_WEBSOCKETS()
183 void getConstraintData(
agx::Constraint *constraint, agxJson::Value& eConstraint);
184 void getRigidBodyData(
agx::RigidBody *body, agxJson::Value& eBody);
186 agxJson::Value& createArrayElement( agxJson::Value& eParent,
const char* groupName );
197 virtual ~StructureSynchronization();
209 agxNet::WebSocketRefVector m_sockets;
223 void frameCallback(agxData::Frame *frame);
224 virtual void writeFrame(
const agxData::Frame *frame)
override;
225 virtual void endOfStream()
override;
232 virtual ~MouseSpringRenderer();
240 osg::PositionAttitudeTransform *m_mouseAttachTransform;
241 osg::PositionAttitudeTransform *m_mousePositionTransform;
242 osg::Geometry *m_mouseSpringLine;
243 osg::ref_ptr< osg::Switch > m_mouseSpringSwitch;
254 OrbitCamera() : enabled(
false), mode(0) {}
264 OrbitCamera m_orbitCamera;
270 bool m_enableTickCallback;
276 bool m_remoteSimulationReceived;
278 agx::Real m_interactiveClientHeartbeatTimeOut;
286 bool m_needSceneLoading;
290 class ControlChannelTCP :
public Referenced
303 void registerMessageHandler(
const agx::String& uri, MessageHandler callback);
306 virtual ~ControlChannelTCP();
314 agxNet::TCPSocketRefVector m_clientSockets;
317 MessageHandlerTable m_messageHandlerTable;
321 bool m_setupComplete;
323 #if AGX_USE_WEBSOCKETS()
328 agxNet::WebSocket::ControlChannel::SocketEvent::CallbackType m_controlChannelSocketConnectedCallback;
329 agxNet::WebSocket::ControlChannel::SocketEvent::CallbackType m_controlChannelSocketDisconnectedCallback;
331 #if AGX_USE_WEBPLOT()
349 typedef std::queue<agxNet::StructuredMessageRef> FrameMessageQueue;
350 FrameMessageQueue m_frameMessageQueue;
357 VideoStreamRef m_videoStream;
360 agx::RigidBodyRefVector m_monitoredBodies;
361 agx::ConstraintRefVector m_monitoredConstraints;
362 bool m_djangoProxyResponse;
363 agxCallable::CallableAccessorRefVector m_dataStreamCallables;
389 virtual void run()
override;
394 void updatePickHandlers();
Class that encapsulates rendering and simulation using OpenSceneGraph.
Basic wrapper class aroud std::thread.
void AGXPHYSICS_EXPORT init()
Initialize agx.
void pushFrame(const RenderFrame &frame)
AGXOSG_EXPORT bool setOrbitCamera(osgViewer::Viewer *viewer, agxOSG::GeometryNode *node, const agx::Vec3 &eye, const agx::Vec3 ¢er, const agx::Vec3 &up, int trackerMode)
A component is an object containing other objects, enabling hierarchical structuring.
Generalized callback, using std::function.
A socket that connects to a client.
The base class for a constraint.
#define AGX_DECLARE_POINTER_TYPES(type)
The Timer class permits timing execution speed with the same refinement as the built in hardware cloc...
Base class providing referencing counted objects.
The geometry representation used by the collision detection engine.
The FrameWriter writes frames to an external target.
Templated callback with one argument.
Templated callback with three arguments.
virtual ~RemoteViewerThread()
GLenum GLuint GLenum GLsizei const GLchar * message
Callback1< Clock * > CallbackType
agx::ref_ptr< const Frame > FrameConstRef
std::condition_variable Condition
The rigid body class, combining a geometric model and a frame of reference.
ControlChannel(agx::UInt16 port, const agx::String &token="")
osg::ref_ptr< osg::Image > image
Templated callback with two arguments.
RemoteViewerThread(ExampleApplication *application)
Handles testing of ports in a range.
Clock class keeps representation of virtual/simulated time.
AGXCORE_EXPORT Component * root()
Inheritance with partial specialization due to bug with ref_ptr containers.
agx::Object is a refcounted object with a name.