1 /***************************************************************************
2 * Copyright (C) 1998-2009 by authors (see AUTHORS.txt ) *
4 * This file is part of LuxRender. *
6 * Lux Renderer is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 3 of the License, or *
9 * (at your option) any later version. *
11 * Lux Renderer is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19 * This project is based on PBRT ; see http://www.pbrt.org *
20 * Lux Renderer website : http://www.luxrender.net *
21 ***************************************************************************/
23 #ifndef LUX_CPP_API_H // LUX_API_H already used by Lux core/api.h
28 #include <boost/thread.hpp>
30 // LuxRender core includes
32 #include "queryable.h"
36 #include "lux_instance.h"
37 #include "lux_paramset.h"
39 class lux_wrapped_context : public lux_instance {
41 lux_wrapped_context(const char* _name);
42 ~lux_wrapped_context();
45 const char* version();
46 const char* getName();
48 // file parsing methods
49 bool parse(const char* filename, bool async);
50 bool parsePartial(const char* filename, bool async);
51 bool parseSuccessful();
56 void setHaltSamplesPerPixel(int haltspp, bool haveEnoughSamplesPerPixel, bool suspendThreadsWhenDone);
57 unsigned int addThread();
64 // scene description methods
65 void accelerator(const char *aName, const lux_paramset* params);
66 void areaLightSource(const char *aName, const lux_paramset* params);
67 void attributeBegin();
69 void camera(const char *cName, const lux_paramset* params);
70 void concatTransform(float tx[16]);
71 void coordinateSystem(const char *cnName);
72 void coordSysTransform(const char *cnName);
73 void exterior(const char *eName);
74 void film(const char *fName, const lux_paramset* params);
76 void interior(const char *iName);
77 void lightGroup(const char *lName, const lux_paramset* params);
78 void lightSource(const char *lName, const lux_paramset* params);
79 void lookAt(float ex, float ey, float ez, float lx, float ly, float lz, float ux, float uy, float uz);
80 void makeNamedMaterial(const char *mName, const lux_paramset* params);
81 void makeNamedVolume(const char *vName, const char *vType, const lux_paramset* params);
82 void material(const char *mName, const lux_paramset* params);
83 void motionInstance(const char *mName, float startTime, float endTime, const char *toTransform);
84 void namedMaterial(const char *mName);
85 void objectBegin(const char *oName);
87 void objectInstance(const char *oName);
88 void pixelFilter(const char *pName, const lux_paramset* params);
89 void portalInstance(const char *pName);
90 void portalShape(const char *pName, const lux_paramset* params);
91 void renderer(const char *rName, const lux_paramset* params);
92 void reverseOrientation();
93 void rotate(float angle, float ax, float ay, float az);
94 void sampler(const char *sName, const lux_paramset* params);
95 void scale(float sx, float sy, float sz);
96 void shape(const char *sName, const lux_paramset* params);
97 void surfaceIntegrator(const char *sName, const lux_paramset* params);
98 void texture(const char *tName, const char *tVariant, const char *tType, const lux_paramset* params);
99 void transform(float tx[16]);
100 void transformBegin();
102 void translate(float dx, float dy, float dz);
103 void volume(const char *vName, const lux_paramset* params);
104 void volumeIntegrator(const char *vName, const lux_paramset* params);
109 void loadFLM(const char* fName);
110 void saveFLM(const char* fName);
111 void saveEXR(const char *filename, bool useHalfFloat, bool includeZBuffer, bool tonemapped);
112 void overrideResumeFLM(const char *fName);
113 void updateFramebuffer();
114 const unsigned char* framebuffer();
115 const float* floatFramebuffer();
116 const float* alphaBuffer();
117 const float* zBuffer();
118 const unsigned char* getHistogramImage(unsigned int width, unsigned int height, int options);
120 // Old-style parameter update interface
121 // To implement these requires exporting further luxComponent* symbols; In most cases the
122 // new Queryable system should be preferred anyhow.
123 // void setParameterValue(luxComponent comp, luxComponentParameters param, double value, unsigned int index);
124 // double getParameterValue(luxComponent comp, luxComponentParameters param, unsigned int index);
125 // double getDefaultParameterValue(luxComponent comp, luxComponentParameters param, unsigned int index);
126 // void setStringParameterValue(luxComponent comp, luxComponentParameters param, const char* value, unsigned int index);
127 // unsigned int getStringParameterValue(luxComponent comp, luxComponentParameters param, char* dst, unsigned int dstlen, unsigned int index);
128 // unsigned int getDefaultStringParameterValue(luxComponent comp, luxComponentParameters param, char* dst, unsigned int dstlen, unsigned int index);
130 // Queryable interface
131 const char* getAttributes();
132 // TODO; this requires a get*Attribute()/set*Attribute() method for each data type.
133 // void* getAttribute(const char *objectName, const char *attributeName);
134 // void setAttribute(const char *objectName, const char *attributeName, void* value);
136 // Networking interface
137 void addServer(const char *sName);
138 void removeServer(const char *sName);
139 unsigned int getServerCount();
140 void updateFilmFromNetwork();
141 void setNetworkServerUpdateInterval(int updateInterval);
142 int getNetworkServerUpdateInterval();
143 // How to return data from this one? Export another data type?
144 // boost::python::tuple getRenderingServersStatus();
147 double statistics(const char* statName);
148 const char* printableStatistics(const bool addTotal); // Deprecated
149 void updateStatisticsWindow();
151 // Debugging interface
152 void enableDebugMode();
153 void disableRandomMode();
154 void setEpsilon(const float minValue, const float maxValue);
159 std::vector<boost::thread*> render_threads;
163 ctx = new lux::Context(name);
165 lux::Context::SetActive(ctx);
167 void world_end_thread()
173 class lux_wrapped_paramset : public lux_paramset {
175 lux_wrapped_paramset();
176 ~lux_wrapped_paramset();
178 lux::ParamSet* GetParamSet() { return ps; };
180 void AddFloat(const char*, const float *, u_int nItems = 1);
181 void AddInt(const char*, const int *, u_int nItems = 1);
182 void AddBool(const char*, const bool *, u_int nItems = 1);
183 void AddPoint(const char*, const float *, u_int nItems = 1);
184 void AddVector(const char*, const float *, u_int nItems = 1);
185 void AddNormal(const char*, const float *, u_int nItems = 1);
186 void AddRGBColor(const char*, const float *, u_int nItems = 1);
187 void AddString(const char*, const char*, u_int nItems = 1);
188 void AddTexture(const char*, const char*);
194 // exported factory and cleanup functions
195 CPP_EXPORT CPP_API lux_instance* CreateLuxInstance(const char* _name);
196 CPP_EXPORT CPP_API void DestroyLuxInstance(lux_instance* inst);
198 CPP_EXPORT CPP_API lux_paramset* CreateLuxParamSet();
199 CPP_EXPORT CPP_API void DestroyLuxParamSet(lux_paramset* ps);
201 #endif // LUX_CPP_API_H