Lumiverse  2.5
A framework for creating lighting control applications
SimulationPatch.h
Go to the documentation of this file.
1 
4 #ifndef _SimulationPATCH_H_
5 #define _SimulationPATCH_H_
6 
7 #pragma once
8 
9 #include "LumiverseCoreConfig.h"
10 
11 #include <iostream>
12 #include <thread>
13 #include <algorithm>
14 #include <cstdio>
15 #include <atomic>
16 
17 #include "../Patch.h"
18 #include "../lib/libjson/libjson.h"
19 
20 namespace Lumiverse {
21 
27  : metadata(""), rerender_req(true) { }
28  virtual ~SimulationLightRecord() { }
29 
30  virtual void init() { rerender_req = true; }
31  virtual void clear() { }
32 
33  std::string metadata;
34  bool rerender_req;
35  };
36 
37 
46  class SimulationPatch : public Patch
47  {
48  public:
53  m_interrupt_flag.clear();
54  }
55 
61  SimulationPatch(const JSONNode data);
62 
66  virtual ~SimulationPatch();
67 
76  virtual void update(set<Device *> devices);
77 
81  virtual void init();
82 
86  virtual void close();
87 
93  virtual JSONNode toJSON();
94 
100  virtual string getType() { return "SimulationPatch"; }
101 
102  virtual void deleteDevice(string id);
103 
109  virtual int getWidth() = 0;
110 
116  virtual int getHeight() = 0;
117 
123  virtual float *getBufferPointer() { return NULL; }
124 
128  virtual void interruptRender();
129 
137  virtual void onDeviceChanged(Device *d);
138 
144  virtual void rerender();
145 
151  virtual bool isUpdateRequired(set<Device *> devices);
152 
156  virtual void clearUpdateFlags();
157 
163  //virtual float getPercentage() const { return m_interface->getPercentage(); }
164 
165  protected:
166 
172  virtual void updateLight(set<Device *> devices) = 0;
173 
179  virtual void loadLight(Device *d_ptr) = 0;
180 
185  virtual void loadJSON(const JSONNode data);
186 
191  virtual bool renderLoop() = 0;
192 
193  virtual void bindRenderLoop();
194 
198  map<string, SimulationLightRecord*> m_lights;
199 
200  std::atomic_flag m_interrupt_flag;
201 
205  std::thread *m_renderloop;
206  };
207 }
208 
209 
210 
211 #endif
virtual ~SimulationPatch()
Destroys the object.
Definition: SimulationPatch.cpp:48
map< string, SimulationLightRecord * > m_lights
A list contains infos about if a light is updated.
Definition: SimulationPatch.h:198
The Arnold Patch object is responsible for the communication between the Arnold renderer and the Lumi...
Definition: SimulationPatch.h:46
virtual string getType()
Gets the type of this object.
Definition: SimulationPatch.h:100
virtual void rerender()
Manually schedule a re-rendering.
Definition: SimulationPatch.cpp:170
virtual bool renderLoop()=0
Calls Arnold render function. This function runs in a separate thread.
virtual void loadLight(Device *d_ptr)=0
Loads a arnold light node. This function is also used to update a light node.
A Patch maps devices to output channels and handles the output of data to the network.
Definition: Patch.h:24
SimulationPatch()
Constructs a SimulationPatch object.
Definition: SimulationPatch.h:52
virtual int getHeight()=0
Gets the height of result.
virtual void update(set< Device * > devices)
Updates the rendering given the list of devices in the rig.
Definition: SimulationPatch.cpp:110
virtual int getWidth()=0
Gets the width of result.
Record that denotes if a arnold light node requires update.
Definition: SimulationPatch.h:25
virtual void init()
Initializes Arnold with ArnoldInterface.
Definition: SimulationPatch.cpp:128
virtual bool isUpdateRequired(set< Device * > devices)
Checks if any device connected with this patch has updated parameters or metadata.
Definition: SimulationPatch.cpp:56
virtual void updateLight(set< Device * > devices)=0
Gets the progress of current frame in percentage.
virtual void close()
Closes the Arnold session.
Definition: SimulationPatch.cpp:135
virtual void deleteDevice(string id)
Called when a device is deleted from the Rig.
Definition: SimulationPatch.cpp:162
virtual float * getBufferPointer()
Gets the pointer to the frame buffer.
Definition: SimulationPatch.h:123
virtual JSONNode toJSON()
Exports a JSONNode with the data in this patch.
Definition: SimulationPatch.cpp:143
Contains all core Lumiverse functions and variables.
Definition: Device.cpp:2
virtual void onDeviceChanged(Device *d)
Callback function for devices.
Definition: SimulationPatch.cpp:104
virtual void clearUpdateFlags()
Resets the update flags for lights.
Definition: SimulationPatch.cpp:91
virtual void interruptRender()
Stops the working rendering procedure if Arnold is running.
Definition: SimulationPatch.cpp:97
A Device in Lumiverse maintains information about a lighting device.
Definition: Device.h:55
virtual void loadJSON(const JSONNode data)
Loads data from a parsed JSON object.
Definition: SimulationPatch.cpp:15
std::thread * m_renderloop
The separate thread running the render loop.
Definition: SimulationPatch.h:205