Lumiverse  2.5
A framework for creating lighting control applications
ArnoldPatch.h
Go to the documentation of this file.
1 
4 #ifndef _ArnoldPATCH_H_
5 #define _ArnoldPATCH_H_
6 
7 #pragma once
8 
9 #include "LumiverseCoreConfig.h"
10 
11 #include <iostream>
12 #include <thread>
13 #include <algorithm>
14 #include <cstdio>
15 
16 #include "SimulationPatch.h"
17 #include "../lib/libjson/libjson.h"
18 #include "ArnoldParameterVector.h"
19 #include "ArnoldInterface.h"
20 #include "DistributedArnoldInterface.h"
21 #include "CachingArnoldInterface.h"
23 
24 namespace Lumiverse {
25 
26 #ifdef USE_ARNOLD
27  struct ArnoldParam;
28 
32  struct ArnoldLightRecord : public SimulationLightRecord {
33  ArnoldLightRecord()
34  : light(NULL), SimulationLightRecord() {}
35  ArnoldLightRecord(AtNode *node)
36  : light(node) {
37  metadata = AiNodeGetName(node);
38  rerender_req = true;
39  }
40 
41  virtual void init() {
42  rerender_req = true;
43  light = NULL;
44  }
45 
46  virtual void clear() {
47  light = NULL;
48  }
49 
50  AtNode *light;
51  };
52 #endif
53 
62  class ArnoldPatch : public SimulationPatch
63  {
64  public:
69  SimulationPatch() { }
70 
76  ArnoldPatch(const JSONNode data);
77 
81  virtual ~ArnoldPatch();
82 
91  virtual void update(set<Device *> devices);
92 
96  virtual void init() override;
97 
101  virtual void close() override;
102 
108  virtual JSONNode toJSON() override;
109 
115  virtual string getType() override { return "ArnoldPatch"; }
116 
122  virtual int getWidth() {
123  if (!m_interface->isOpen())
124  m_interface->init();
125  return m_interface->getWidth();
126  }
127 
133  virtual int getHeight() {
134  if (!m_interface->isOpen())
135  m_interface->init();
136  return m_interface->getHeight();
137  }
138 
144  virtual float *getBufferPointer() {
145  if (!m_interface->isOpen())
146  m_interface->init();
147  return m_interface->getBufferPointer();
148  }
149 
153  bool setDims(int w, int h) {
154  if (w > 0 && h > 0) {
155  m_interface->setDims(w, h);
156  return true;
157  }
158  return false;
159  }
160 
161  size_t getBufferSize() {
162  return getWidth() * getHeight() * 4;
163  }
164 
170  int getSamples() { return m_interface->getSamples(); }
171 
177  void setSamples(int samples);
178 
182  virtual void interruptRender() override;
183 
188 
194  virtual float getPercentage() const { return m_interface->getPercentage(); }
195 
201 
207  virtual size_t getBucketNumber() const { return m_interface->getBucketNumber(); }
208 
214  void setArnoldInterface(ArnoldInterface *arnold_interface) { m_interface = arnold_interface; };
215 
220  virtual bool renderLoop(const std::set<Device *> &devices);
221 
226  virtual bool renderLoop();
227 
233  void setAssFile(std::string assFile) { m_interface->setAssFile(assFile); }
234 
238  virtual void setOptionParameter(std::string paramName, int val);
239  virtual void setOptionParameter(std::string paramName, float val);
240 
246  void updateLight(set<Device *> devices);
247 
248  protected:
249 
255  virtual void loadLight(Device *d_ptr) override;
256 
262  void updateLightPredictive(set<Device *> devices);
263 
268  virtual void loadJSON(const JSONNode data) override;
269 
275 
276  private:
277 #ifdef USE_ARNOLD
278  void setOrientation(AtNode *light_ptr, Device *d_ptr, LumiverseOrientation *pan, LumiverseOrientation *tilt);
279  void setOrientation(AtNode *light_ptr, Device *d_ptr, std::string pan_str, std::string tilt_str);
280 #endif
281 
287  void modifyLightColor(Device *d, Eigen::Vector3d white);
288 
294  bool useDistributedRendering(JSONNode patch);
295 
299  bool m_using_distributed = false;
300 
306  bool cacheRendering(const JSONNode data);
307 
312 
316  bool _caching;
317  };
318 }
319 
320 #endif
virtual float getPercentage() const
Gets the progress of current frame in percentage.
Definition: ArnoldPatch.h:194
An interface for serving distributed cached Arnold render responses.
virtual int getWidth()
Gets the width of result.
Definition: ArnoldPatch.h:122
void setAssFile(std::string fileName)
Sets the path to ass file.
Definition: ArnoldInterface.h:217
void setSamples(int samples)
Sets the sample rate (n * n per pixel).
Definition: ArnoldPatch.cpp:515
The Arnold Patch object is responsible for the communication between the Arnold renderer and the Lumi...
Definition: SimulationPatch.h:46
virtual void setOptionParameter(std::string paramName, int val)
Set global arnold options on the interface.
Definition: ArnoldPatch.cpp:183
ArnoldInterface * m_interface
Arnold Interface If we're distributing our rendering this is a DistributedArnoldInterface.
Definition: ArnoldPatch.h:274
void forceInterrupt()
Forcefully stops the current arnold render function.
Definition: ArnoldPatch.h:187
virtual void interrupt()
Interrupts current rendering.
Definition: ArnoldInterface.cpp:560
void init(const char *jsonPatchStr, const char *filename)
Initializes data structures.
Definition: Dumiverse.cpp:29
int getSamples()
Gets the sample rate (n * n per pixel).
Definition: ArnoldPatch.h:170
bool useDistributedRendering(JSONNode patch)
Check if an Arnold patch should use distributed rendering.
Definition: ArnoldPatch.cpp:206
virtual void init()
Initializes connections and other network settings for the patch.
Definition: ArnoldPatch copy.cpp:381
virtual size_t getBucketNumber() const
Gets number of buckets rendered simultanously. This is usually the number of threads supported by har...
Definition: ArnoldPatch.h:207
int getHeight()
Gets the height of result.
Definition: ArnoldInterface.h:135
void setAssFile(std::string assFile)
Set the path to this patch's ass.
Definition: ArnoldPatch.h:233
void modifyLightColor(Device *d, Eigen::Vector3d white)
Modifies light color according to Picture Perfect RGB Rendering Using Spectral Prefiltering and Sharp...
Definition: ArnoldPatch.cpp:368
virtual float * getBufferPointer()
Gets the pointer to the frame buffer.
Definition: ArnoldPatch.h:144
void updateLightPredictive(set< Device * > devices)
Resets the arnold light node and surface with updated parameters of deices. Experiment with methods f...
Definition: ArnoldPatch.cpp:408
Defines an orientation in Lumiverse.
Definition: LumiverseOrientation.h:61
bool setDims(int w, int h)
Sets the width and height of the resulting image.
Definition: ArnoldPatch.h:153
virtual JSONNode toJSON()
Exports a JSONNode with the data in this patch.
Definition: ArnoldPatch copy.cpp:413
An interface for serving cached Arnold render responses.
virtual bool renderLoop()
Calls Arnold render function. This function runs in a separate thread.
Definition: ArnoldPatch.cpp:485
bool m_rendering
Internal flag used to ensure thread safety.
Definition: ArnoldPatch.h:311
void loadJSON(const JSONNode data)
Loads data from a parsed JSON object.
Definition: ArnoldPatch copy.cpp:20
virtual BucketPositionInfo * getBucketPositionInfo() const
Gets the current bucket for each worker thread.
Definition: ArnoldPatch.h:200
virtual float getPercentage()
Gets the progress of current frame as a percentage.
Definition: ArnoldInterface.h:317
bool cacheRendering(const JSONNode data)
Check if an Arnold patch should used cached rendering.
Definition: ArnoldPatch.cpp:195
bool _caching
Internal flag used to see if cached rendering is being used.
Definition: ArnoldPatch.h:316
Implementation of a patch for Arnold.
virtual void init()
Initializes the Arnold renderer.
Definition: ArnoldInterface.cpp:435
bool isOpen()
Checks if this interface is currently open.
Definition: ArnoldInterface.h:363
void setArnoldInterface(ArnoldInterface *arnold_interface)
Set the interface we're using Set the ArnoldInterface reference we're using to perform rendering...
Definition: ArnoldPatch.h:214
bool updateLight(set< Device * > devices)
Gets the progress of current frame in percentage.
Definition: ArnoldPatch copy.cpp:327
virtual void close()
Closes connections to the interfaces.
Definition: ArnoldPatch copy.cpp:404
ArnoldPatch()
Constructs a ArnoldPatch object.
Definition: ArnoldPatch.h:68
virtual ~ArnoldPatch()
Destroys the object.
Definition: ArnoldPatch copy.cpp:323
BucketPositionInfo * getBucketPositionInfo() const
Gets the current bucket for each worker thread.
Definition: ArnoldInterface.h:327
Stores a vector used by ArnoldPatch.
Contains all core Lumiverse functions and variables.
Definition: Device.cpp:2
int getSamples()
Gets the sampling rate.
Definition: ArnoldInterface.h:282
size_t getBucketNumber() const
Gets number of buckets rendered simultanously. This is usually the number of threads supported by har...
Definition: ArnoldInterface.h:334
virtual string getType() override
Gets the type of this object.
Definition: ArnoldPatch.h:115
bool m_using_distributed
Are we using a distributed renderer with this patch.
Definition: ArnoldPatch.h:299
Implementation of a interface between ArnoldPatch and arnold.
Wrapper for unit (bucket) being rendered.
Definition: ArnoldInterface.h:48
virtual int getHeight()
Gets the height of result.
Definition: ArnoldPatch.h:133
A Device in Lumiverse maintains information about a lighting device.
Definition: Device.h:55
virtual float * getBufferPointer()
Gets the pointer to the frame buffer.
Definition: ArnoldInterface.h:147
virtual void update(set< Device * > devices)
Updates the values sent to the DMX network given the list of devices in the rig.
Definition: ArnoldPatch copy.cpp:352
virtual bool setDims(int w, int h)
Sets the dimensions of the image.
Definition: ArnoldInterface.cpp:140
Interface between ArnoldPatch and arnold. Almost all arnold APIs are called from this class...
Definition: ArnoldInterface.h:73
virtual void interruptRender() override
Stops the working rendering procedure if Arnold is running.
Definition: ArnoldPatch.cpp:501
void loadLight(Device *d_ptr)
Loads a arnold light node. This function is also used to update a light node.
Definition: ArnoldPatch copy.cpp:297
int getWidth()
Gets the width of result.
Definition: ArnoldInterface.h:128