LuxCore  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
luxcore::Scene Class Referenceabstract

Scene stores textures, materials and objects definitions. More...

#include <luxcore.h>

Public Types

enum  ChannelSelectionType {
  DEFAULT, RED, GREEN, BLUE,
  ALPHA, MEAN, WEIGHTED_MEAN, RGB
}
 Types of image map channel selection. More...
 
enum  WrapType { REPEAT, BLACK, WHITE, CLAMP }
 Types of image map wrap mode. More...
 
enum  StrandsTessellationType { TESSEL_RIBBON, TESSEL_RIBBON_ADAPTIVE, TESSEL_SOLID, TESSEL_SOLID_ADAPTIVE }
 Types of strands tessellation. More...
 

Public Member Functions

virtual ~Scene ()
 
virtual void GetBBox (float min[3], float max[3]) const =0
 Returns the bounding box of the complete scene (as minimum and maximum point). It is available only during the rendering (i.e. after a RenderSession::Start()). More...
 
virtual const CameraGetCamera () const =0
 Returns the Camera of the scene. More...
 
template<class T >
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 pixels array is NOT freed by the Scene class nor is used after the execution of this method. The types supported are "unsigned char", "unsigned short" (as a place holder for half type) and "float". More...
 
virtual bool IsImageMapDefined (const std::string &imgMapName) const =0
 Check if an image map with the given name has been defined. More...
 
virtual void SetDeleteMeshData (const bool v)=0
 Sets if the Scene class destructor will delete the arrays pointed to by the defined meshes. More...
 
virtual void DefineMesh (const std::string &meshName, const long plyNbVerts, const long plyNbTris, float *p, unsigned int *vi, float *n, float *uv, float *cols, float *alphas)=0
 Defines a mesh (to be later used in one or more scene objects). The memory allocated for the ExtTriangleMesh is always freed by the Scene class, however freeing of memory for the vertices, triangle indices, etc. depends on the setting of SetDeleteMeshData(). NOTE: vertices and triangles buffers MUST be allocated with Scene::AllocVerticesBuffer() and Scene::AllocTrianglesBuffer(). More...
 
virtual void SaveMesh (const std::string &meshName, const std::string &fileName)=0
 Save a previously defined mesh to file system in PLY or BPY format. More...
 
virtual void DefineStrands (const std::string &shapeName, const luxrays::cyHairFile &strandsFile, const StrandsTessellationType tesselType, const unsigned int adaptiveMaxDepth, const float adaptiveError, const unsigned int solidSideCount, const bool solidCapBottom, const bool solidCapTop, const bool useCameraPosition)=0
 Defines a mesh (to be later used in one or more scene objects) starting from the strands/hairs definition included in strandsFile. More...
 
virtual bool IsMeshDefined (const std::string &meshName) const =0
 Check if a mesh with the given name has been defined. More...
 
virtual bool IsTextureDefined (const std::string &texName) const =0
 Check if a texture with the given name has been defined. More...
 
virtual bool IsMaterialDefined (const std::string &matName) const =0
 Check if a material with the given name has been defined. More...
 
virtual const unsigned int GetLightCount () const =0
 Returns the number of light sources in the Scene. More...
 
virtual const unsigned int GetObjectCount () const =0
 Returns the number of objects in the Scene. More...
 
virtual void Parse (const luxrays::Properties &props)=0
 Edits or creates camera, textures, materials and/or objects based on the Properties defined. If the scene is in use by a RenderSession, it must be called between a RenderSession::BeginSceneEdit() and RenderSession::EndSceneEdit(). More...
 
virtual void DuplicateObject (const std::string &srcObjName, const std::string &dstObjName, const float *transMat)=0
 Duplicate an object in an instance using the passed transformation. More...
 
virtual void DuplicateObject (const std::string &srcObjName, const std::string &dstObjNamePrefix, const unsigned int count, const float *transMat)=0
 Duplicate an object multiple times in instances using the passed transformations. Mostly useful for fast creating many copies of the same object (for instance for particles). More...
 
virtual void DuplicateObject (const std::string &srcObjName, const std::string &dstObjName, const unsigned int steps, const float *times, const float *transMat)=0
 Duplicate an object in a motion blur instance using the passed transformation. More...
 
virtual void DuplicateObject (const std::string &srcObjName, const std::string &dstObjNamePrefix, const unsigned int count, const unsigned int steps, const float *times, const float *transMat)=0
 Duplicate an object multiple times in a motion blur instance using the passed transformations. Mostly useful for fast creating many copies of the same object (for instance for particles). More...
 
virtual void UpdateObjectTransformation (const std::string &objName, const float *transMat)=0
 Apply a transformation to an object. More...
 
virtual void UpdateObjectMaterial (const std::string &objName, const std::string &matName)=0
 Apply a new material to an object. More...
 
virtual void DeleteObject (const std::string &objName)=0
 Deletes an object from the scene. More...
 
virtual void DeleteLight (const std::string &lightName)=0
 Deletes a light from the scene. More...
 
virtual void RemoveUnusedImageMaps ()=0
 Removes all unused image maps. More...
 
virtual void RemoveUnusedTextures ()=0
 Removes all unused textures. More...
 
virtual void RemoveUnusedMaterials ()=0
 Removes all unused materials. More...
 
virtual void RemoveUnusedMeshes ()=0
 Removes all unused meshes. More...
 
virtual const luxrays::PropertiesToProperties () const =0
 Returns all the Properties required to define this Scene. More...
 
virtual void Save (const std::string &fileName) const =0
 Serializes a Scene in a file. More...
 
template<>
void CPP_API DefineImageMap (const std::string &imgMapName, unsigned char *pixels, const float gamma, const unsigned int channels, const unsigned int width, const unsigned int height, Scene::ChannelSelectionType selectionType, Scene::WrapType wrapType)
 
template<>
void CPP_API DefineImageMap (const std::string &imgMapName, unsigned short *pixels, const float gamma, const unsigned int channels, const unsigned int width, const unsigned int height, Scene::ChannelSelectionType selectionType, Scene::WrapType wrapType)
 
template<>
void CPP_API DefineImageMap (const std::string &imgMapName, float *pixels, const float gamma, const unsigned int channels, const unsigned int width, const unsigned int height, Scene::ChannelSelectionType selectionType, Scene::WrapType wrapType)
 

Static Public Member Functions

static SceneCreate (const float imageScale=1.f)
 Create a new empty Scene. More...
 
static SceneCreate (const luxrays::Properties &props, const float imageScale=1.f)
 Creates a new Scene as defined by props. More...
 
static SceneCreate (const std::string &fileName, const float imageScale=1.f)
 Creates a new Scene as defined in fileName file. More...
 
static float * AllocVerticesBuffer (const unsigned int meshVertCount)
 This must be used to allocate Mesh vertices buffer. More...
 
static unsigned int * AllocTrianglesBuffer (const unsigned int meshTriCount)
 This must be used to allocate Mesh triangles buffer. More...
 

Protected Member Functions

virtual void DefineImageMapUChar (const std::string &imgMapName, unsigned char *pixels, const float gamma, const unsigned int channels, const unsigned int width, const unsigned int height, ChannelSelectionType selectionType, WrapType wrapType)=0
 
virtual void DefineImageMapHalf (const std::string &imgMapName, unsigned short *pixels, const float gamma, const unsigned int channels, const unsigned int width, const unsigned int height, ChannelSelectionType selectionType, WrapType wrapType)=0
 
virtual void DefineImageMapFloat (const std::string &imgMapName, float *pixels, const float gamma, const unsigned int channels, const unsigned int width, const unsigned int height, ChannelSelectionType selectionType, WrapType wrapType)=0
 

Detailed Description

Scene stores textures, materials and objects definitions.

Definition at line 544 of file luxcore.h.

Member Enumeration Documentation

Types of image map channel selection.

Enumerator
DEFAULT 
RED 
GREEN 
BLUE 
ALPHA 
MEAN 
WEIGHTED_MEAN 
RGB 

Definition at line 549 of file luxcore.h.

Types of strands tessellation.

Enumerator
TESSEL_RIBBON 
TESSEL_RIBBON_ADAPTIVE 
TESSEL_SOLID 
TESSEL_SOLID_ADAPTIVE 

Definition at line 573 of file luxcore.h.

Types of image map wrap mode.

Enumerator
REPEAT 
BLACK 
WHITE 
CLAMP 

Definition at line 563 of file luxcore.h.

Constructor & Destructor Documentation

virtual luxcore::Scene::~Scene ( )
virtual

Member Function Documentation

static unsigned int* luxcore::Scene::AllocTrianglesBuffer ( const unsigned int  meshTriCount)
static

This must be used to allocate Mesh triangles buffer.

static float* luxcore::Scene::AllocVerticesBuffer ( const unsigned int  meshVertCount)
static

This must be used to allocate Mesh vertices buffer.

static Scene* luxcore::Scene::Create ( const float  imageScale = 1.f)
static

Create a new empty Scene.

Parameters
imageScaledefines the scale used for storing any kind of image in memory.
static Scene* luxcore::Scene::Create ( const luxrays::Properties props,
const float  imageScale = 1.f 
)
static

Creates a new Scene as defined by props.

Parameters
propsare the Properties used to build the new Scene.
imageScaledefines the scale used for storing any kind of image in memory.
static Scene* luxcore::Scene::Create ( const std::string &  fileName,
const float  imageScale = 1.f 
)
static

Creates a new Scene as defined in fileName file.

Parameters
fileNameis the name of the file with the scene description to read. It can be a text SDL file or a serialized binary file. The extension for the binary format must be ".bsc".
imageScaledefines the scale used for storing any kind of image in memory. This parameter has no effect when loading binary serialized binary file.
template<class T >
void luxcore::Scene::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 
)
inline

Defines an image map (to be later used in textures, infinite lights, etc.). The memory allocated for pixels array is NOT freed by the Scene class nor is used after the execution of this method. The types supported are "unsigned char", "unsigned short" (as a place holder for half type) and "float".

Parameters
imgMapNameis the name of the defined image map.
pixelsis a pointer to an array of image map pixels.
gammais the gamma correction value of the image.
channelsis the number of data used for each pixel (1 or 3).
widthis the width of the image map.
heightis the height of the image map.

Definition at line 634 of file luxcore.h.

template<>
void CPP_API luxcore::Scene::DefineImageMap ( const std::string &  imgMapName,
unsigned char *  pixels,
const float  gamma,
const unsigned int  channels,
const unsigned int  width,
const unsigned int  height,
Scene::ChannelSelectionType  selectionType,
Scene::WrapType  wrapType 
)
template<>
void CPP_API luxcore::Scene::DefineImageMap ( const std::string &  imgMapName,
unsigned short *  pixels,
const float  gamma,
const unsigned int  channels,
const unsigned int  width,
const unsigned int  height,
Scene::ChannelSelectionType  selectionType,
Scene::WrapType  wrapType 
)
template<>
void CPP_API luxcore::Scene::DefineImageMap ( const std::string &  imgMapName,
float *  pixels,
const float  gamma,
const unsigned int  channels,
const unsigned int  width,
const unsigned int  height,
Scene::ChannelSelectionType  selectionType,
Scene::WrapType  wrapType 
)
virtual void luxcore::Scene::DefineImageMapFloat ( const std::string &  imgMapName,
float *  pixels,
const float  gamma,
const unsigned int  channels,
const unsigned int  width,
const unsigned int  height,
ChannelSelectionType  selectionType,
WrapType  wrapType 
)
protectedpure virtual
virtual void luxcore::Scene::DefineImageMapHalf ( const std::string &  imgMapName,
unsigned short *  pixels,
const float  gamma,
const unsigned int  channels,
const unsigned int  width,
const unsigned int  height,
ChannelSelectionType  selectionType,
WrapType  wrapType 
)
protectedpure virtual
virtual void luxcore::Scene::DefineImageMapUChar ( const std::string &  imgMapName,
unsigned char *  pixels,
const float  gamma,
const unsigned int  channels,
const unsigned int  width,
const unsigned int  height,
ChannelSelectionType  selectionType,
WrapType  wrapType 
)
protectedpure virtual
virtual void luxcore::Scene::DefineMesh ( const std::string &  meshName,
const long  plyNbVerts,
const long  plyNbTris,
float *  p,
unsigned int *  vi,
float *  n,
float *  uv,
float *  cols,
float *  alphas 
)
pure virtual

Defines a mesh (to be later used in one or more scene objects). The memory allocated for the ExtTriangleMesh is always freed by the Scene class, however freeing of memory for the vertices, triangle indices, etc. depends on the setting of SetDeleteMeshData(). NOTE: vertices and triangles buffers MUST be allocated with Scene::AllocVerticesBuffer() and Scene::AllocTrianglesBuffer().

Parameters
meshNameis the name of the defined mesh.
plyNbVertsis the number of mesh vertices.
plyNbTrisis the number of mesh triangles.
pis a pointer to an array of vertices. Embree accelerator has a very special requirement. The 4 bytes after the z-coordinate of the last vertex have to be readable memory, thus padding is required.
viis a pointer to an array of triangles.
nis a pointer to an array of normals. It can be NULL.
uvis a pointer to an array of UV coordinates. It can be NULL.
colsis a pointer to an array of vertices colors. It can be NULL.
alphasis a pointer to an array of vertices alphas. It can be NULL.
virtual void luxcore::Scene::DefineStrands ( const std::string &  shapeName,
const luxrays::cyHairFile strandsFile,
const StrandsTessellationType  tesselType,
const unsigned int  adaptiveMaxDepth,
const float  adaptiveError,
const unsigned int  solidSideCount,
const bool  solidCapBottom,
const bool  solidCapTop,
const bool  useCameraPosition 
)
pure virtual

Defines a mesh (to be later used in one or more scene objects) starting from the strands/hairs definition included in strandsFile.

Parameters
shapeNameis the name of the defined shape.
strandsFileincludes all information about the strands .
tesselTypeis the tessellation used to transform the strands in a triangle mesh.
adaptiveMaxDepthis maximum number of subdivisions for adaptive tessellation.
adaptiveErroris the error threshold for adaptive tessellation.
solidSideCountis the number of sides for solid tessellation.
solidCapBottomis a flag to set if strands has to have a bottom cap.
solidCapTopis a flag to set if strands has to have a top cap.
useCameraPositionis a flag to set if ribbon tessellation has to be faced toward the camera.
virtual void luxcore::Scene::DeleteLight ( const std::string &  lightName)
pure virtual

Deletes a light from the scene.

Parameters
lightNameis the name of the object to delete. Note: to delete area lights, use DeleteObject().
virtual void luxcore::Scene::DeleteObject ( const std::string &  objName)
pure virtual

Deletes an object from the scene.

Parameters
objNameis the name of the object to delete.
virtual void luxcore::Scene::DuplicateObject ( const std::string &  srcObjName,
const std::string &  dstObjName,
const float *  transMat 
)
pure virtual

Duplicate an object in an instance using the passed transformation.

Parameters
srcObjNameis the name of the object to duplicate.
dstObjNameis the name of the object to create.
transMatis the transformation 4x4 matrix to use.
virtual void luxcore::Scene::DuplicateObject ( const std::string &  srcObjName,
const std::string &  dstObjNamePrefix,
const unsigned int  count,
const float *  transMat 
)
pure virtual

Duplicate an object multiple times in instances using the passed transformations. Mostly useful for fast creating many copies of the same object (for instance for particles).

Parameters
srcObjNameis the name of the object to duplicate.
dstObjNamePrefixis the prefix of the names of the object to create. The number of the copy will be appended.
countis the number of the object to create.
transMatis an array of transformation 4x4 matrices to use.
virtual void luxcore::Scene::DuplicateObject ( const std::string &  srcObjName,
const std::string &  dstObjName,
const unsigned int  steps,
const float *  times,
const float *  transMat 
)
pure virtual

Duplicate an object in a motion blur instance using the passed transformation.

Parameters
srcObjNameis the name of the object to duplicate.
dstObjNameis the name of the object to create.
stepsis the number of motion blur steps.
timesis an array of times to use
transMatis an array of the transformation 4x4 matrix to use.
virtual void luxcore::Scene::DuplicateObject ( const std::string &  srcObjName,
const std::string &  dstObjNamePrefix,
const unsigned int  count,
const unsigned int  steps,
const float *  times,
const float *  transMat 
)
pure virtual

Duplicate an object multiple times in a motion blur instance using the passed transformations. Mostly useful for fast creating many copies of the same object (for instance for particles).

Parameters
srcObjNameis the name of the object to duplicate.
dstObjNamePrefixis the name of the object to create.
dstObjNamePrefixis the prefix of the names of the object to create. The number of the copy will be appended.
countis the number of the object to create.
stepsis the number of motion blur steps.
timesis an array of times to use
transMatis an array of the transformation 4x4 matrix to use.
virtual void luxcore::Scene::GetBBox ( float  min[3],
float  max[3] 
) const
pure virtual

Returns the bounding box of the complete scene (as minimum and maximum point). It is available only during the rendering (i.e. after a RenderSession::Start()).

virtual const Camera& luxcore::Scene::GetCamera ( ) const
pure virtual

Returns the Camera of the scene.

Returns
a reference to the Camera of this Scene. It is available only during the rendering (i.e. after a RenderSession::Start()).
virtual const unsigned int luxcore::Scene::GetLightCount ( ) const
pure virtual

Returns the number of light sources in the Scene.

Returns
the number of light sources in the Scene.
virtual const unsigned int luxcore::Scene::GetObjectCount ( ) const
pure virtual

Returns the number of objects in the Scene.

Returns
the number of objects in the Scene.
virtual bool luxcore::Scene::IsImageMapDefined ( const std::string &  imgMapName) const
pure virtual

Check if an image map with the given name has been defined.

Parameters
imgMapNameis the name to check.
Returns
true if the image map has been defined, false otherwise.
virtual bool luxcore::Scene::IsMaterialDefined ( const std::string &  matName) const
pure virtual

Check if a material with the given name has been defined.

Parameters
matNameis the name to check.
Returns
true if the material has been defined, false otherwise.
virtual bool luxcore::Scene::IsMeshDefined ( const std::string &  meshName) const
pure virtual

Check if a mesh with the given name has been defined.

Parameters
meshNameis the name to check.
Returns
true if the mesh has been defined, false otherwise.
virtual bool luxcore::Scene::IsTextureDefined ( const std::string &  texName) const
pure virtual

Check if a texture with the given name has been defined.

Parameters
texNameis the name to check.
Returns
true if the texture has been defined, false otherwise.
virtual void luxcore::Scene::Parse ( const luxrays::Properties props)
pure virtual

Edits or creates camera, textures, materials and/or objects based on the Properties defined. If the scene is in use by a RenderSession, it must be called between a RenderSession::BeginSceneEdit() and RenderSession::EndSceneEdit().

Parameters
propsare the Properties with the definition of camera, textures, materials and/or objects.
virtual void luxcore::Scene::RemoveUnusedImageMaps ( )
pure virtual

Removes all unused image maps.

virtual void luxcore::Scene::RemoveUnusedMaterials ( )
pure virtual

Removes all unused materials.

virtual void luxcore::Scene::RemoveUnusedMeshes ( )
pure virtual

Removes all unused meshes.

virtual void luxcore::Scene::RemoveUnusedTextures ( )
pure virtual

Removes all unused textures.

virtual void luxcore::Scene::Save ( const std::string &  fileName) const
pure virtual

Serializes a Scene in a file.

Parameters
fileNameis the name of the file where to serialize the scene.
virtual void luxcore::Scene::SaveMesh ( const std::string &  meshName,
const std::string &  fileName 
)
pure virtual

Save a previously defined mesh to file system in PLY or BPY format.

Parameters
meshNameis the name of the defined mesh to be saved.
fileNameis the name of the file where to save the mesh. If it has the extension ".ply", the text PLY format will be used. If it has the extension ".bpy", the text PLY format will be used.
virtual void luxcore::Scene::SetDeleteMeshData ( const bool  v)
pure virtual

Sets if the Scene class destructor will delete the arrays pointed to by the defined meshes.

Parameters
vdefines if the Scene class destructor will delete the mesh data.
virtual const luxrays::Properties& luxcore::Scene::ToProperties ( ) const
pure virtual

Returns all the Properties required to define this Scene.

Returns
a reference to the Properties of this Scene.
virtual void luxcore::Scene::UpdateObjectMaterial ( const std::string &  objName,
const std::string &  matName 
)
pure virtual

Apply a new material to an object.

Parameters
objNameis the name of the object to apply the material to.
matNameis the new material name.
virtual void luxcore::Scene::UpdateObjectTransformation ( const std::string &  objName,
const float *  transMat 
)
pure virtual

Apply a transformation to an object.

Parameters
objNameis the name of the object to transform.
transMatis the transformation 4x4 matrix to apply.

The documentation for this class was generated from the following file: