Lumiverse  2.5
A framework for creating lighting control applications
PhotoPatch.h
Go to the documentation of this file.
1 
4 #ifndef _PhotoPatch_H_
5 #define _PhotoPatch_H_
6 
7 #pragma once
8 
9 #include "LumiverseCoreConfig.h"
10 #ifdef USE_ARNOLD
11 
12 #include <iostream>
13 #include <thread>
14 #include <algorithm>
15 #include <cstdio>
16 #include <atomic>
17 
18 #include "../Patch.h"
19 #include "SimulationPatch.h"
20 #include "../lib/libjson/libjson.h"
21 
22 namespace Lumiverse {
23 
24  struct PhotoLightRecord : SimulationLightRecord {
25  PhotoLightRecord()
26  : intensity(0), color(1.f, 1.f, 1.f), photo(NULL), SimulationLightRecord() {}
27  virtual ~PhotoLightRecord() {
28  delete[] photo;
29  }
30  virtual void init() override {
31  SimulationLightRecord::init();
32  intensity = 0;
33  color.setOnes();
34  }
35 
36  virtual void clear() override {
37  delete[] photo;
38  photo = NULL;
39  }
40 
41  float intensity;
42  Eigen::Vector3f color;
43  float *photo;
44  };
45 
54  class PhotoPatch : public SimulationPatch
55  {
56  public:
60  PhotoPatch() : m_blend(NULL), m_blend_buffer(NULL),
61  SimulationPatch() { }
62 
68  PhotoPatch(const JSONNode data);
69 
73  virtual ~PhotoPatch();
74 
78  virtual void init() override;
79 
85  virtual JSONNode toJSON() override;
86 
92  virtual string getType() override { return "PhotoPatch"; }
93 
99  virtual int getWidth() { return m_width; }
100 
106  virtual int getHeight() { return m_height; }
107 
113  virtual float *getBufferPointer() override { return m_blend; }
114 
120  //virtual float getPercentage() const { return m_interface.getPercentage(); }
121 
122  protected:
128  virtual void updateLight(set<Device *> devices);
129 
135  virtual void loadLight(Device *d_ptr);
136 
141  virtual void loadJSON(const JSONNode data) override;
142 
147  virtual bool renderLoop();
148 
149  virtual void bindRenderLoop() override;
150 
151  float *m_blend;
152 
153  int m_height;
154  int m_width;
155 
156  private:
157 
158  bool blendUint8(float* blended, unsigned char* light, float intensity, Eigen::Vector3f color);
159 
160  bool blendFloat(float* blended, float* light, float intensity, Eigen::Vector3f color);
161 
162  float *m_blend_buffer;
163 
164  };
165 }
166 
167 
168 #endif
169 #endif
void init(const char *jsonPatchStr, const char *filename)
Initializes data structures.
Definition: Dumiverse.cpp:29
int getWidth()
Get the width of the loaded image.
Definition: Dumiverse.cpp:17
int getHeight()
Get the height of the loaded image.
Definition: Dumiverse.cpp:21
Implementation of a patch for Arnold.
Contains all core Lumiverse functions and variables.
Definition: Device.cpp:2