44 #include <luxcore/cfg.h>
45 #include <luxrays/utils/exportdefs.h>
65 #define LC_LOG(a) { if (luxcore::LuxCore_LogHandler) { std::stringstream _LUXCORE_LOG_LOCAL_SS; _LUXCORE_LOG_LOCAL_SS << a; luxcore::LuxCore_LogHandler(_LUXCORE_LOG_LOCAL_SS.str().c_str()); } }
74 CPP_EXPORT CPP_API
void Init(
void (*LogHandler)(
const char *) = NULL);
83 CPP_EXPORT CPP_API
void SetLogHandler(
void (*LogHandler)(
const char *) = NULL);
150 CPP_EXPORT
class CPP_API
Film {
194 CHANNEL_RADIANCE_PER_PIXEL_NORMALIZED = 1 << 0,
195 CHANNEL_RADIANCE_PER_SCREEN_NORMALIZED = 1 << 1,
196 CHANNEL_ALPHA = 1 << 2,
197 CHANNEL_IMAGEPIPELINE = 1 << 3,
198 CHANNEL_DEPTH = 1 << 4,
199 CHANNEL_POSITION = 1 << 5,
200 CHANNEL_GEOMETRY_NORMAL = 1 << 6,
201 CHANNEL_SHADING_NORMAL = 1 << 7,
202 CHANNEL_MATERIAL_ID = 1 << 8,
203 CHANNEL_DIRECT_DIFFUSE = 1 << 9,
204 CHANNEL_DIRECT_GLOSSY = 1 << 10,
205 CHANNEL_EMISSION = 1 << 11,
206 CHANNEL_INDIRECT_DIFFUSE = 1 << 12,
207 CHANNEL_INDIRECT_GLOSSY = 1 << 13,
208 CHANNEL_INDIRECT_SPECULAR = 1 << 14,
209 CHANNEL_MATERIAL_ID_MASK = 1 << 15,
210 CHANNEL_DIRECT_SHADOW_MASK = 1 << 16,
211 CHANNEL_INDIRECT_SHADOW_MASK = 1 << 17,
212 CHANNEL_UV = 1 << 18,
213 CHANNEL_RAYCOUNT = 1 << 19,
214 CHANNEL_BY_MATERIAL_ID = 1 << 20,
215 CHANNEL_IRRADIANCE = 1 << 21,
216 CHANNEL_OBJECT_ID = 1 << 22,
217 CHANNEL_OBJECT_ID_MASK = 1 << 23,
218 CHANNEL_BY_OBJECT_ID = 1 << 24,
219 CHANNEL_FRAMEBUFFER_MASK = 1 << 25,
220 CHANNEL_SAMPLECOUNT = 1 << 26,
221 CHANNEL_CONVERGENCE = 1 << 27
232 static Film *Create(
const std::string &fileName);
245 const bool hasPixelNormalizedChannel,
246 const bool hasScreenNormalizedChannel);
253 virtual unsigned int GetWidth()
const = 0;
259 virtual unsigned int GetHeight()
const = 0;
275 virtual float GetFilmY(
const unsigned int imagePipelineIndex = 0)
const = 0;
279 virtual void Clear() = 0;
286 virtual void AddFilm(
const Film &film) = 0;
299 virtual void AddFilm(
const Film &film,
300 const unsigned int srcOffsetX,
const unsigned int srcOffsetY,
301 const unsigned int srcWidth,
const unsigned int srcHeight,
302 const unsigned int dstOffsetX,
const unsigned int dstOffsetY) = 0;
307 virtual void SaveOutputs()
const = 0;
323 virtual void SaveOutput(
const std::string &fileName,
const FilmOutputType type,
const luxrays::Properties &props)
const = 0;
330 virtual void SaveFilm(
const std::string &fileName)
const = 0;
337 virtual double GetTotalSampleCount()
const = 0;
345 virtual size_t GetOutputSize(
const FilmOutputType type)
const = 0;
353 virtual bool HasOutput(
const FilmOutputType type)
const = 0;
361 virtual unsigned int GetOutputCount(
const FilmOutputType type)
const = 0;
367 virtual unsigned int GetRadianceGroupCount()
const = 0;
379 throw std::runtime_error(
"Called Film::GetOutput() with wrong type");
388 virtual bool HasChannel(
const FilmChannelType type)
const = 0;
396 virtual unsigned int GetChannelCount(
const FilmChannelType type)
const = 0;
410 throw std::runtime_error(
"Called Film::GetChannel() with wrong type");
426 virtual void DeleteAllImagePipelines() = 0;
429 virtual void GetOutputFloat(
const FilmOutputType type,
float *buffer,
const unsigned int index) = 0;
430 virtual void GetOutputUInt(
const FilmOutputType type,
unsigned int *buffer,
const unsigned int index) = 0;
432 virtual const float *GetChannelFloat(
const FilmChannelType type,
const unsigned int index) = 0;
433 virtual const unsigned int *GetChannelUInt(
const FilmChannelType type,
const unsigned int index) = 0;
436 template<> CPP_API
void Film::GetOutput<float>(
const FilmOutputType type,
float *buffer,
const unsigned int index);
437 template<> CPP_API
void Film::GetOutput<unsigned int>(
const FilmOutputType type,
unsigned int *buffer,
const unsigned int index);
438 template<> CPP_API
const float *Film::GetChannel<float>(
const FilmChannelType type,
const unsigned int index);
439 template<> CPP_API
const unsigned int *Film::GetChannel<unsigned int>(
const FilmChannelType type,
const unsigned int index);
466 virtual const CameraType GetType()
const = 0;
473 virtual void Translate(
const float x,
const float y,
const float z)
const = 0;
480 virtual void TranslateLeft(
const float t)
const = 0;
487 virtual void TranslateRight(
const float t)
const = 0;
494 virtual void TranslateForward(
const float t)
const = 0;
501 virtual void TranslateBackward(
const float t)
const = 0;
510 virtual void Rotate(
const float angle,
const float x,
const float y,
const float z)
const = 0;
517 virtual void RotateLeft(
const float angle)
const = 0;
524 virtual void RotateRight(
const float angle)
const = 0;
531 virtual void RotateUp(
const float angle)
const = 0;
538 virtual void RotateDown(
const float angle)
const = 0;
559 } ChannelSelectionType;
578 TESSEL_SOLID_ADAPTIVE
579 } StrandsTessellationType;
586 static Scene *Create(
const float imageScale = 1.f);
604 static Scene *Create(
const std::string &fileName,
const float imageScale = 1.f);
613 virtual void GetBBox(
float min[3],
float max[3])
const = 0;
620 virtual const Camera &GetCamera()
const = 0;
635 T *pixels,
const float gamma,
const unsigned int channels,
636 const unsigned int width,
const unsigned int height,
639 throw std::runtime_error(
"Called Scene::DefineImageMap() with wrong type");
648 virtual bool IsImageMapDefined(
const std::string &imgMapName)
const = 0;
655 virtual void SetDeleteMeshData(
const bool v) = 0;
676 virtual void DefineMesh(
const std::string &meshName,
677 const long plyNbVerts,
const long plyNbTris,
678 float *p,
unsigned int *vi,
float *n,
float *uv,
679 float *cols,
float *alphas) = 0;
688 virtual void SaveMesh(
const std::string &meshName,
const std::string &fileName) = 0;
704 virtual void DefineStrands(
const std::string &shapeName,
const luxrays::cyHairFile &strandsFile,
705 const StrandsTessellationType tesselType,
706 const unsigned int adaptiveMaxDepth,
const float adaptiveError,
707 const unsigned int solidSideCount,
const bool solidCapBottom,
const bool solidCapTop,
708 const bool useCameraPosition) = 0;
716 virtual bool IsMeshDefined(
const std::string &meshName)
const = 0;
724 virtual bool IsTextureDefined(
const std::string &texName)
const = 0;
732 virtual bool IsMaterialDefined(
const std::string &matName)
const = 0;
738 virtual const unsigned int GetLightCount()
const = 0;
744 virtual const unsigned int GetObjectCount()
const = 0;
764 virtual void DuplicateObject(
const std::string &srcObjName,
const std::string &dstObjName,
765 const float *transMat) = 0;
777 virtual void DuplicateObject(
const std::string &srcObjName,
const std::string &dstObjNamePrefix,
778 const unsigned int count,
const float *transMat) = 0;
788 virtual void DuplicateObject(
const std::string &srcObjName,
const std::string &dstObjName,
789 const unsigned int steps,
const float *times,
const float *transMat) = 0;
804 virtual void DuplicateObject(
const std::string &srcObjName,
const std::string &dstObjNamePrefix,
805 const unsigned int count,
const unsigned int steps,
const float *times,
const float *transMat) = 0;
812 virtual void UpdateObjectTransformation(
const std::string &objName,
const float *transMat) = 0;
819 virtual void UpdateObjectMaterial(
const std::string &objName,
const std::string &matName) = 0;
826 virtual void DeleteObject(
const std::string &objName) = 0;
834 virtual void DeleteLight(
const std::string &lightName) = 0;
839 virtual void RemoveUnusedImageMaps() = 0;
843 virtual void RemoveUnusedTextures() = 0;
847 virtual void RemoveUnusedMaterials() = 0;
851 virtual void RemoveUnusedMeshes() = 0;
864 virtual void Save(
const std::string &fileName)
const = 0;
869 static float *AllocVerticesBuffer(
const unsigned int meshVertCount);
873 static unsigned int *AllocTrianglesBuffer(
const unsigned int meshTriCount);
876 virtual void DefineImageMapUChar(
const std::string &imgMapName,
877 unsigned char *pixels,
const float gamma,
const unsigned int channels,
878 const unsigned int width,
const unsigned int height,
879 ChannelSelectionType selectionType, WrapType wrapType) = 0;
880 virtual void DefineImageMapHalf(
const std::string &imgMapName,
881 unsigned short *pixels,
const float gamma,
const unsigned int channels,
882 const unsigned int width,
const unsigned int height,
883 ChannelSelectionType selectionType, WrapType wrapType) = 0;
884 virtual void DefineImageMapFloat(
const std::string &imgMapName,
885 float *pixels,
const float gamma,
const unsigned int channels,
886 const unsigned int width,
const unsigned int height,
887 ChannelSelectionType selectionType, WrapType wrapType) = 0;
890 template<>
void CPP_API Scene::DefineImageMap<unsigned char>(
const std::string &imgMapName,
891 unsigned char *pixels,
const float gamma,
const unsigned int channels,
892 const unsigned int width,
const unsigned int height,
894 template<>
void CPP_API Scene::DefineImageMap<unsigned short>(
const std::string &imgMapName,
895 unsigned short *pixels,
const float gamma,
const unsigned int channels,
896 const unsigned int width,
const unsigned int height,
898 template<>
void CPP_API Scene::DefineImageMap<float>(
const std::string &imgMapName,
899 float *pixels,
const float gamma,
const unsigned int channels,
900 const unsigned int width,
const unsigned int height,
926 static RenderConfig *Create(
const std::string &fileName);
966 virtual Scene &GetScene()
const = 0;
982 virtual void Delete(
const std::string &prefix) = 0;
998 virtual bool GetFilmSize(
unsigned int *filmFullWidth,
unsigned int *filmFullHeight,
999 unsigned int *filmSubRegion)
const = 0;
1005 virtual void DeleteSceneOnExit() = 0;
1011 virtual void Save(
const std::string &fileName) = 0;
1017 virtual void Export(
const std::string &dirName) = 0;
1037 static RenderState *Create(
const std::string &fileName);
1045 virtual void Save(
const std::string &fileName)
const = 0;
1073 static RenderSession *Create(
const RenderConfig *config,
const std::string &startStateFileName,
const std::string &startFilmFileName);
1083 virtual const RenderConfig &GetRenderConfig()
const = 0;
1096 virtual void Start() = 0;
1100 virtual void Stop() = 0;
1105 virtual bool IsStarted()
const = 0;
1110 virtual void BeginSceneEdit() = 0;
1114 virtual void EndSceneEdit() = 0;
1119 virtual bool IsInSceneEdit()
const = 0;
1124 virtual void Pause() = 0;
1129 virtual void Resume() = 0;
1134 virtual bool IsInPause()
const = 0;
1139 virtual bool HasDone()
const = 0;
1144 virtual void WaitForDone()
const = 0;
1150 virtual void WaitNewFrame() = 0;
1157 virtual Film &GetFilm() = 0;
1164 virtual void UpdateStats() = 0;
1189 virtual void SaveResumeFile(
const std::string &fileName) = 0;
CPP_EXPORT CPP_API void(* LuxCore_LogHandler)(const char *msg)
Scene stores textures, materials and objects definitions.
A generic container for values.
RenderConfig stores all the configuration settings used to render a scene.
void DefineImageMap(const std::string &imgMapName, T *pixels, const float gamma, const unsigned int channels, const unsigned int width, const unsigned int height, ChannelSelectionType selectionType=DEFAULT, WrapType wrapType=REPEAT)
Defines an image map (to be later used in textures, infinite lights, etc.). The memory allocated for ...
void GetOutput(const FilmOutputType type, T *buffer, const unsigned int index=0)
Fills the buffer with a Film output channel.
RenderSession executes a rendering based on the RenderConfig provided.
Camera stores camera definitions.
CPP_EXPORT CPP_API luxrays::Properties GetPlatformDesc()
Return a list of properties describing the features available. The properties currently supported are...
CPP_EXPORT CPP_API void ParseLXS(const std::string &fileName, luxrays::Properties &renderConfig, luxrays::Properties &scene)
Parses a scene described using LuxRender SDL (Scene Description Language).
CPP_EXPORT CPP_API luxrays::Properties GetOpenCLDeviceDescs()
Return the list of OpenCL devices available. For instance:
A container for multiple Property.
ChannelSelectionType
Types of image map channel selection.
FilmChannelType
Types of Film channel available.
Film stores all the outputs of a rendering. It can be obtained from a RenderSession or as stand alone...
CPP_EXPORT CPP_API void Init(void(*LogHandler)(const char *)=NULL)
Initializes LuxCore API. This function has to be called before anything else. This function is thread...
CPP_EXPORT CPP_API void SetLogHandler(void(*LogHandler)(const char *)=NULL)
Initializes LuxCore API. This function can be called if you want to update the log handler...
FilmOutputType
Types of Film channel available.
CPP_EXPORT CPP_API void KernelCacheFill(const luxrays::Properties &config, void(*ProgressHandler)(const size_t, const size_t)=NULL)
File the OpenCL kernel cache with entries.
WrapType
Types of image map wrap mode.
const T * GetChannel(const FilmChannelType type, const unsigned int index=0)
Returns a pointer to the type of channel requested. The channel is not normalized (if it has a weight...
RenderState is used to resume a rendering from a previous saved point.