AGX Dynamics  2.35.0.1
LuaScriptOperation.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. 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 having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 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 #ifndef AGXLUA_LUASCRIPTOPERATION_H
18  #define AGXLUA_LUASCRIPTOPERATION_H
19 
20 #include <agx/config/AGX_USE_LUA.h>
21 #include <fstream>
22 #include <agxLua/export.h>
23 #include <agxControl/SensorEvent.h>
24 #include <agxControl/EventSensor.h>
25 
26 #if AGX_USE_LUA()
27 
28 /*
29 This file defines some example sensor operations
30 */
31 namespace agxLua
32 {
37  AGX_DECLARE_POINTER_TYPES(LuaScriptOperation);
38  class AGXLUA_EXPORT LuaScriptOperation : public agxControl::SensorOperation
39  {
40  public:
41 
42  LuaScriptOperation(const agx::Name& name = agx::Name());
43  LuaScriptOperation(const agx::Name& name, const agx::String& script, const agx::String& functionIdentifier="");
44 
45  virtual void triggerParticleEvent(const agx::TimeStamp& t,
46  agxSDK::Simulation* simulation,
47  agx::Physics::ParticleGeometryContactInstance contact,
48  agx::Physics::ParticleData& particleData,
49  agx::Physics::GeometryData& geometryData,
50  agxControl::EventSensor* sensor) override;
51 
52  virtual void triggerEvent(const agx::TimeStamp& t,
53  agxSDK::Simulation * simulation,
55  agxControl::EventSensor* sensor) override;
56 
57  virtual void postContactHandling(agxSDK::Simulation * simulation, agxControl::EventSensor *sensor) override;
58 
59  void doInit(agxSDK::Simulation * simulation);
60 
61  AGXSTREAM_DECLARE_SERIALIZABLE(agxLua::LuaScriptOperation);
62 
63  protected:
64  virtual ~LuaScriptOperation();
65 
66  void doErrorHandling(const agx::String& function, const agx::String& lastError);
67 
68  protected:
69  agx::String m_script;
70  agx::String m_functionIdentifier;
71  bool m_initiated;
72  };
73 }
74 
75 #endif
76 
77 #endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
#define AGXLUA_EXPORT
Definition: agxLua/export.h:42
A contact between two geometries.
Definition: Contacts.h:270
This is a sensor class that can be attached to an geometry in the simulation.
Definition: EventSensor.h:48
A specific type of sensor event that triggers a change in the simulation when activated by a contact.
Definition: SensorEvent.h:118
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:127
Representation of a name string.
Definition: Name.h:33
agx::Real TimeStamp
Definition: TimeStamp.h:26