Lumiverse  2.5
A framework for creating lighting control applications
ArnoldPatch copy.h
1 
4 #ifndef _ArnoldPATCH_H_
5 #define _ArnoldPATCH_H_
6 
7 #pragma once
8 
9 #include "LumiverseCoreConfig.h"
10 
11 #include <algorithm>
12 #include <cstdio>
13 #include <ai.h>
14 #include "../Patch.h"
15 #include "../lib/libjson/libjson.h"
16 #include "ArnoldParameterVector.h"
17 
18 #include <iostream>
19 
20 namespace Lumiverse {
21 
22  struct ArnoldParam {
23  ArnoldParam()
24  : rerender_req(false), reblend_req(false), position(AI_V3_ZERO), color(AI_RGB_BLACK) { }
25  ArnoldParam(AtVector position, AtColor color)
26  : rerender_req(true), reblend_req(true), position(position), color(color) { }
27 
28  // TODO: re-render the scene if position changed.
29  bool rerender_req;
30  bool reblend_req;
31  AtVector position;
32 
33  AtColor color;
34 
35  size_t dimension;
36  std::string arnoldTypeName;
37  };
38 
39  template<typename T>
40  union AiNodeSet {
41  void (*AiNodeSet1D)(AtNode *, const char *, T);
42  void (*AiNodeSet2D)(AtNode *, const char *, T, T);
43  void (*AiNodeSet3D)(AtNode *, const char *, T, T, T);
44  void (*AiNodeSet4D)(AtNode *, const char *, T, T, T, T);
45  };
46 
47  template<typename T>
48  union AiArraySet {
49  bool (*AiArraySet1D) (AtArray*, AtUInt32, T, const char*, int);
50  void (*AiNodeSet1D)(AtNode *, const char *, T);
51  void (*AiNodeSet2D)(AtNode *, const char *, T, T);
52  void (*AiNodeSet3D)(AtNode *, const char *, T, T, T);
53  void (*AiNodeSet4D)(AtNode *, const char *, T, T, T, T);
54  };
55 
62  class ArnoldPatch : public Patch
63  {
64  public:
68  ArnoldPatch();
69 
75  ArnoldPatch(const JSONNode data);
76 
80  virtual ~ArnoldPatch();
81 
88  virtual void update(set<Device *> devices);
89 
96  virtual void init();
97 
101  virtual void close();
102 
108  virtual JSONNode toJSON();
109 
115  virtual string getType() { return "ArnoldPatch"; }
116 
117  private:
118 
119  void setArrayParameter(AtNode *light_ptr, const std::string &paramName, const std::string &value);
120 
121  void setParameter(AtNode *light_ptr, const std::string &paramName, const std::string &value);
122 
123  template<size_t D, typename T>
124  void setSingleParameter(AtNode *node, const std::string &paramName, const std::string &value,
125  union AiNodeSet<T> aiNodeSet) const;
126 
127  template<size_t D, typename T, class C>
128  void setArrayParameter(AtNode *node, const std::string &paramName, const std::string &value,
129  bool (*AiArraySet) (AtArray*, AtUInt32, C, const char*, int), const int AiType) const;
130 
131  bool updateLight(set<Device *> devices);
132 
133  void loadJSON(const JSONNode data);
134 
135  template<size_t D, typename T>
136  void parseArnoldParameter(const std::string &value, ArnoldParameterVector<D, T> &vector) const;
137 
138  void loadArnoldParam(const JSONNode data, ArnoldParam &param);
139 
140  void loadLight(Device *d_ptr);
141 
142  map<string, AtNode*> m_lights;
143 
144  map<string, ArnoldParam> m_arnold_params;
145 
146  std::string m_ass_file;
147 
148  };
149 }
150 
151 #endif
The Arnold Patch object is responsible for the communication between the Arnold renderer and the Lumi...
Definition: ArnoldPatch copy.h:62
Definition: ArnoldPatch copy.h:48
A Patch maps devices to output channels and handles the output of data to the network.
Definition: Patch.h:24
virtual void init()
Initializes connections and other network settings for the patch.
Definition: ArnoldPatch copy.cpp:381
virtual JSONNode toJSON()
Exports a JSONNode with the data in this patch.
Definition: ArnoldPatch copy.cpp:413
void loadJSON(const JSONNode data)
Loads data from a parsed JSON object.
Definition: ArnoldPatch copy.cpp:20
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
virtual string getType()
Gets the type of this object.
Definition: ArnoldPatch copy.h:115
ArnoldPatch()
Constructs a DMXPatch object.
Definition: ArnoldPatch copy.cpp:7
virtual ~ArnoldPatch()
Destroys the object.
Definition: ArnoldPatch copy.cpp:323
Stores a vector used by ArnoldPatch.
Defines a vector type for Arnold parameters, like color, vector etc.
Definition: ArnoldParameterVector.h:23
Contains all core Lumiverse functions and variables.
Definition: Device.cpp:2
Definition: ArnoldPatch copy.h:22
A Device in Lumiverse maintains information about a lighting device.
Definition: Device.h:55
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
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
Definition: ArnoldPatch copy.h:40