4 #ifndef _ArnoldINTERFACE_H_
5 #define _ArnoldINTERFACE_H_
9 #include "LumiverseCoreConfig.h"
15 #include "../lib/arnold/include/ai.h"
19 #include "../lib/libjson/libjson.h"
31 : dimension(1), arnoldTypeName(
"unknown") { }
34 std::string arnoldTypeName;
40 void (*AiNodeSetter1D)(AtNode *,
const char *, T);
41 void (*AiNodeSetter2D)(AtNode *,
const char *, T, T);
42 void (*AiNodeSetter3D)(AtNode *,
const char *, T, T, T);
43 void (*AiNodeSetter4D)(AtNode *,
const char *, T, T, T, T);
55 bucket_xo(-1), bucket_yo(-1), bucket_size_x(-1), bucket_size_y(-1) { }
83 m_bucket_pos(NULL), m_bucket_num(0),
m_open(false) { }
91 delete[] m_bucket_pos;
109 virtual void init(
const JSONNode jsonPatch) { this->
init(); }
114 virtual void close();
140 virtual bool setDims(
int w,
int h);
153 void setParameter(
string lightName,
string param,
int val);
158 void setParameter(
string lightName,
string param,
float val);
163 void setParameter(
string lightName,
string param, Eigen::Matrix3f rot, Eigen::Vector3f trans);
168 void setParameter(
string lightName,
string param,
float x,
float y,
float z);
180 void setParameter(AtNode *light_ptr,
const std::string ¶mName,
const std::string &value);
191 void setArrayParameter(AtNode *light_ptr,
const std::string ¶mName,
const std::string &value);
196 virtual void setOptionParameter(
const std::string ¶mName,
int val);
197 virtual void setOptionParameter(
const std::string ¶mName,
float val);
202 int getOptionParameter(
const std::string ¶mName);
209 void loadArnoldParam(
const JSONNode data);
300 virtual int render(
const std::set<Device*>& ) {
return this->
render(); }
311 virtual JSONNode
toJSON();
318 if (m_progress.bucket_sum < 0)
320 return (0.f + m_progress.bucket_cur) / m_progress.bucket_sum * 100.f;
341 void updateSurfaceColor(Eigen::Vector3d white);
366 void addGobo(AtNode *light_ptr, std::string file,
float deg,
float rot);
371 void setLogFileName(
string filename,
int flags = AI_LOG_ALL);
376 map<string, AtNode*> getLights();
381 void setDriverFileName(
string base,
string filename);
418 template<
size_t D,
typename T>
419 void setSingleParameter(AtNode *node,
const std::string ¶mName,
const std::string &value,
420 union AiNodeSetter<T> aiNodeSetter)
const;
433 template<
size_t D,
typename T,
class C>
434 void setArrayParameter(AtNode *node,
const std::string ¶mName,
const std::string &value,
435 bool (*
AiArraySet) (AtArray*, AtUInt32, C,
const char*,
int),
const int AiType)
const;
442 void appendToOutputs(
const std::string buffer_output);
454 std::transform(str.begin(), str.end(), str.begin(), ::tolower);
455 if ((!str.empty() && str[0] ==
'.') ||
456 ((str.find(
".ies") != std::string::npos || str.find(
".ass") != std::string::npos
457 || str.find(
".jpg") != std::string::npos) &&
458 (str.find(
"/") == std::string::npos && str.find(
"\\") == std::string::npos)))
475 map<string, ArnoldParam> m_arnold_params;
533 std::string m_default_path;
536 string m_bufDriverName;
553 template<
size_t D,
typename T>
556 std::string value_spaceless = value;
561 for (
char c : value) {
563 if (!std::isspace(c, loc)) {
564 value_spaceless[count++] = c;
567 value_spaceless = value_spaceless.substr(0, count);
572 for (i = 0; i < D; i++) {
573 std::istringstream iss(value_spaceless.substr(offset));
577 offset = value_spaceless.find(
",", offset);
579 if (offset == std::string::npos) {
589 Logger::log(
WARN,
"Input dimension disagrees with vector dimension. Extra elements are left with existing values.");
std::string getAssFile()
Gets the path to ass file.
Definition: ArnoldInterface.h:224
virtual JSONNode toJSON()
Parses the arnold parameter map to a JSON node.
Definition: ArnoldInterface.cpp:569
void setAssFile(std::string fileName)
Sets the path to ass file.
Definition: ArnoldInterface.h:217
bool getPredictive()
Gets the predictive flag.
Definition: ArnoldInterface.h:266
bool m_open
If the interface is currently open.
Definition: ArnoldInterface.h:521
virtual void interrupt()
Interrupts current rendering.
Definition: ArnoldInterface.cpp:560
Definition: ArnoldPatch copy.h:48
void setPredictive(bool predictive)
Sets the predictive flag.
Definition: ArnoldInterface.h:259
void setPluginDirectory(std::string dir)
Sets the directory containing the plugin (buffer_driver).
Definition: ArnoldInterface.h:231
int m_height
The height of the result.
Definition: ArnoldInterface.h:501
bool m_predictive
If turn on (so-called) predictive rendering.
Definition: ArnoldInterface.h:516
Wrapper for progress information computed based on number of buckets.
Definition: ArnoldInterface.h:59
int m_samples
Arnold AA samples.
Definition: ArnoldInterface.h:511
float getGamma()
Gets the gamma.
Definition: ArnoldInterface.h:252
std::string m_plugin_dir
The directory containing the plugin (buffer_driver).
Definition: ArnoldInterface.h:486
virtual int render()
Starts rendering with Arnold. Returns the error code of AiRender, so the caller can know if the rende...
Definition: ArnoldInterface.cpp:536
int getHeight()
Gets the height of result.
Definition: ArnoldInterface.h:135
ArnoldInterface()
Constructs a ArnoldInterface object.
Definition: ArnoldInterface.h:82
std::string toRelativePath(std::string file)
Converts to relative path with respect to json path. Currently it only checks if the file contains "...
Definition: ArnoldInterface.cpp:352
virtual int render(const std::set< Device * > &)
Fire off a render request using the given set of devices.
Definition: ArnoldInterface.h:300
virtual bool isDistributedOpen()
Indicates if the distributed interface is currently open In the base class, this is the same as the l...
Definition: ArnoldInterface.cpp:430
float m_gamma
The gamma for gamma correction.
Definition: ArnoldInterface.h:506
virtual void close()
Closes the Arnold session.
Definition: ArnoldInterface.cpp:507
virtual string getInterfaceType()
Gets the type of this object.
Definition: ArnoldInterface.h:121
static bool isRelativeFileName(std::string str)
Checks to see if this arnold STRING parameter is a file. Currently it only checks if the file contain...
Definition: ArnoldInterface.h:450
bool isUsingCaching()
Check whether this patch has caching enabled.
Definition: ArnoldInterface.h:393
virtual float getPercentage()
Gets the progress of current frame as a percentage.
Definition: ArnoldInterface.h:317
void setDefaultPath(std::string def_path)
Sets the default path.
Definition: ArnoldInterface.h:349
virtual void loadIfUsingCaching(const set< Device * > &)
If the interface is caching it should use this function to perform any preload operations it may be d...
Definition: ArnoldInterface.h:404
virtual void init()
Initializes the Arnold renderer.
Definition: ArnoldInterface.cpp:435
bool isOpen()
Checks if this interface is currently open.
Definition: ArnoldInterface.h:363
BucketPositionInfo * getBucketPositionInfo() const
Gets the current bucket for each worker thread.
Definition: ArnoldInterface.h:327
Stores a vector used by ArnoldPatch.
Defines a vector type for Arnold parameters, like color, vector etc.
Definition: ArnoldParameterVector.h:23
void log(LOG_LEVEL level, string message)
Logs a meesage to the output file.
Definition: Logger.cpp:46
bool m_using_caching
Is this interface using caching – currently only used for notifying the distributed renderer that it...
Definition: ArnoldInterface.h:543
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
std::string getDefaultPath()
Gets the default path.
Definition: ArnoldInterface.h:356
Wrapper for unit (bucket) being rendered.
Definition: ArnoldInterface.h:48
float * m_buffer
The pointer to the frame buffer.
Definition: ArnoldInterface.h:491
void setUsingCaching(bool usingCaching)
Set whether this interface is using caching.
Definition: ArnoldInterface.h:398
static bool parseArnoldParameter(const std::string &value, ArnoldParameterVector< D, T > &vector)
Parses a formatted string into a ArnoldParameterVector instance.
Definition: ArnoldInterface.h:554
virtual float * getBufferPointer()
Gets the pointer to the frame buffer.
Definition: ArnoldInterface.h:147
std::string getPluginDirectory()
Gets the directory containing the plugin (buffer_driver).
Definition: ArnoldInterface.h:238
virtual bool setDims(int w, int h)
Sets the dimensions of the image.
Definition: ArnoldInterface.cpp:140
virtual void setSamples(int samples)
Sets the camera sampling rate used for current rendering.
Definition: ArnoldInterface.cpp:527
Interface between ArnoldPatch and arnold. Almost all arnold APIs are called from this class...
Definition: ArnoldInterface.h:73
virtual ~ArnoldInterface()
Destroys the object.
Definition: ArnoldInterface.h:88
int getWidth()
Gets the width of result.
Definition: ArnoldInterface.h:128
int m_width
The width of the result.
Definition: ArnoldInterface.h:496
std::string m_ass_file
The path to ass file.
Definition: ArnoldInterface.h:481
void setGamma(float gamma)
Sets the gamma.
Definition: ArnoldInterface.h:245
virtual void init(const JSONNode jsonPatch)
Initialize the ArnoldRenderer with a reference to a JSON serialized parent patch. ...
Definition: ArnoldInterface.h:109