LightsprintSDK 2021.08.08
|
#include <RRScene.h>
Public Types | |
typedef RRScene * | Loader(const RRString &filename, RRFileLocator *textureLocator, bool *aborting) |
typedef bool | Saver(const RRScene *scene, const RRString &filename) |
Public Member Functions | |
RRScene () | |
RRScene (const RRString &filename, RRFileLocator *textureLocator=nullptr, bool *aborting=nullptr) | |
bool | save (const RRString &filename) const |
virtual | ~RRScene () |
void | transform (const RRMatrix3x4 &transformation) |
void | normalizeUnits (float currentUnitLengthInMeters) |
void | normalizeUpAxis (unsigned currentUpAxis) |
void | getAllBuffers (RRVector< RRBuffer * > &buffers, const RRVector< unsigned > *layers) const |
RRScene * | preprocessScene (bool splitMultimaterials, unsigned copyLayerToMaterialLightmaps) |
Public Member Functions inherited from rr::RRUniformlyAllocated | |
void * | operator new (std::size_t n) |
void * | operator new[] (std::size_t n) |
void | operator delete (void *p, std::size_t n) |
void | operator delete[] (void *p, std::size_t n) |
Static Public Member Functions | |
static void | registerLoader (const char *extensions, Loader *loader) |
static void | registerSaver (const char *extensions, Saver *saver) |
static const char * | getSupportedLoaderExtensions () |
static const char * | getSupportedSaverExtensions () |
Public Attributes | |
RRObjects | objects |
RRLights | lights |
RRBuffer * | environment |
RRCameras | cameras |
Protected Attributes | |
RRObjects * | protectedObjects |
RRLights * | protectedLights |
Additional Inherited Members | |
Protected Member Functions inherited from rr::RRUniformlyAllocatedNonCopyable | |
RRUniformlyAllocatedNonCopyable () | |
~RRUniformlyAllocatedNonCopyable () | |
3d scene.
typedef RRScene * rr::RRScene::Loader(const RRString &filename, RRFileLocator *textureLocator, bool *aborting) |
Template of custom scene loader.
Template of custom scene saver.
rr::RRScene::RRScene | ( | ) |
Creates empty scene.
rr::RRScene::RRScene | ( | const RRString & | filename, |
RRFileLocator * | textureLocator = nullptr , |
||
bool * | aborting = nullptr |
||
) |
Loads 3d scene from file.
Scene load is attempted using loaders registered via registerLoader(). Loaders for ~35 formats (Supported formats) are implemented in LightsprintIO library, rr_io::registerIO() will register all of them for you.
Our loaders try to load all textures from proper paths specified by scene file, but if it fails, additional attempts are made as specified by textureLocator. textureLocator tells also what to do when texture is not found at all (create stub texture or create material without texture?)
If file contains information on units or up direction, our importers convert units to meters and up to Y.
filename | Filename of scene. If it is empty, scene will be empty. |
textureLocator | Optional custom file locator, for finding texture files in unusual location. nullptr = default locator will be used. |
aborting | Import may be asynchronously aborted by setting *aborting to true. |
|
virtual |
Deletes scene including all objects and lights.
bool rr::RRScene::save | ( | const RRString & | filename | ) | const |
Saves 3d scene to file.
Scene save is attempted using savers registered via registerSaver(). One saver is implemented in LightsprintIO library, rr_io::registerSavers() will register it for you. See rr_io::registerSavers() for details on formats/features supported.
filename | Name of file to be created. |
void rr::RRScene::transform | ( | const RRMatrix3x4 & | transformation | ) |
Transforms scene by given matrix (i.e. transforms all object matrices and lights).
This function reads contents of scene from objects and lights, not protectedObjects and protectedLights, so if you call it from your RRScene constructor, fill objects and lights first.
void rr::RRScene::normalizeUnits | ( | float | currentUnitLengthInMeters | ) |
Changes units to meters.
Using meters is not strictly necessary, global illumination works on all scales. However, it is recommended to import scenes in meters. This function reads contents of scene from objects and lights, not protectedObjects and protectedLights, so if you call it from your RRScene constructor, fill objects and lights first.
void rr::RRScene::normalizeUpAxis | ( | unsigned | currentUpAxis | ) |
Changes up axist to Y.
Using up Y is not strictly necessary, global illumination works in all directions. However, it is recommended to import scenes so that Y is up. This function reads contents of scene from objects and lights, not protectedObjects and protectedLights, so if you call it from your RRScene constructor, fill objects and lights first.
currentUpAxis | 0=X, 1=Y, 2=Z |
void rr::RRScene::getAllBuffers | ( | RRVector< RRBuffer * > & | buffers, |
const RRVector< unsigned > * | layers | ||
) | const |
Inserts all buffers found in scene's materials, lights, environment and illumination layers into collection.
Can be used to gather all texture filenames, to pause all videos etc.
buffers | In-out collection of buffers. Unique input buffers are preserved, new buffers from scene are added to collection. Ordering of input buffers may change and duplicates and nullptr buffers are removed. |
layers | Illumination from given layers will be gathered too. |
RRScene * rr::RRScene::preprocessScene | ( | bool | splitMultimaterials, |
unsigned | copyLayerToMaterialLightmaps | ||
) |
Preprocess scene before saving.
Various fileformats have various limitations, and preprocessing scene before save() can work around them. Created scene is intended only for saving, delete it after save().
splitMultimaterials | Split objects with multiple facegroups(materials) into multiple object with one facegroup(material). This is recommended for .scn (SmallLuxGPU) and Assimp based exporters. |
copyLayerToMaterialLightmaps | Copy lighting from this layer into RRMaterial::lightmap. This is recommended for Assimp based exporters, if you wish to export lightmaps or ambient maps. |
|
static |
Registers scene loader so it can be used by RRScene constructor.
Extensions are case insensitive, in "*.dae;*.3ds;*.md5mesh" format.
Several loaders are implemented in LightsprintIO library, rr_io::registerIO() will register all of them for you (by calling this function several times).
Multiple loaders may be registered, even for the same extension. If first loader fails to load scene, second one is tried etc.
|
static |
Similar to registerLoader().
|
static |
Returns list of supported loader extensions in "*.dae;*.3ds;*.md5mesh" format.
All extensions of registered loaders are returned in one static string, don't free() it. nullptr is returned if no loaders were registered.
|
static |
Returns list of supported saver extensions in "*.dae;*.3ds;*.md5mesh" format.
All extensions of registered savers are returned in one static string, don't free() it. nullptr is returned if no savers were registered.
RRObjects rr::RRScene::objects |
Collection of objects in scene. May be freely modified, does not delete objects in destructor.
RRLights rr::RRScene::lights |
Collection of lights in scene. May be freely modified, does not delete lights in destructor.
RRBuffer* rr::RRScene::environment |
Scene environment, skybox. May be modified, but carefully, scene owns environment and deletes it in destructor, so delete old environment before setting new one.
RRCameras rr::RRScene::cameras |
Collection of cameras in scene. May be freely modified.
|
protected |
Protected collection of objects in scene, owns objects, deletes them in destructor.
|
protected |
Protected collection of lights in scene, owns lights, deletes them in destructor.