MobileRT  1.0
A multi platform C++ CPU progressive Ray Tracer.
Components::OBJLoader Class Referencefinal

#include <OBJLoader.hpp>

Inheritance diagram for Components::OBJLoader:
Inheritance graph
Collaboration diagram for Components::OBJLoader:
Collaboration graph

Public Member Functions

 OBJLoader ()=delete
 
 OBJLoader (::std::istream &isObj, ::std::istream &isMtl)
 
 OBJLoader (const OBJLoader &objLoader)=delete
 
 OBJLoader (OBJLoader &&objLoader) noexcept=delete
 
 ~OBJLoader () final
 
OBJLoaderoperator= (const OBJLoader &objLoader)=delete
 
OBJLoaderoperator= (OBJLoader &&objLoader) noexcept=delete
 
bool fillScene (::MobileRT::Scene *scene, ::std::function<::std::unique_ptr<::MobileRT::Sampler >()> lambda, ::std::string filePath, ::std::unordered_map<::std::string, ::MobileRT::Texture > texturesCache) final
 
- Public Member Functions inherited from MobileRT::ObjectLoader
 ObjectLoader ()=default
 
 ObjectLoader (const ObjectLoader &objectLoader)=delete
 
 ObjectLoader (ObjectLoader &&objectLoader) noexcept=delete
 
virtual ~ObjectLoader ()
 
ObjectLoaderoperator= (const ObjectLoader &objectLoader)=delete
 
ObjectLoaderoperator= (ObjectLoader &&objectLoader) noexcept=delete
 
bool isProcessed () const
 
virtual bool fillScene (Scene *scene, ::std::function<::std::unique_ptr< Sampler >()> lambda, ::std::string filePath, ::std::unordered_map<::std::string, ::MobileRT::Texture > texturesCache)=0
 

Static Public Member Functions

static const ::MobileRT::TexturegetTextureFromCache (::std::unordered_map<::std::string, ::MobileRT::Texture > *const texturesCache, ::std::string &&textureBinary, long size, const ::std::string &texPath)
 

Private Types

template<typename T1 , typename T2 , typename T3 >
using triple = ::std::tuple< T1, T2, T3 >
 

Private Member Functions

triple<::glm::vec3, ::glm::vec3, ::glm::vec3 > loadNormal (const ::tinyobj::shape_t &index, ::std::int32_t indexOffset, const triple<::glm::vec3, ::glm::vec3, ::glm::vec3 > &vertex) const
 
triple<::glm::vec3, ::glm::vec3, ::glm::vec3 > loadVertices (const ::tinyobj::shape_t &shape, ::std::int32_t indexOffset) const
 
const ::MobileRT::TexturegetTextureFromCache (::std::unordered_map<::std::string, ::MobileRT::Texture > *const texturesCache, const ::std::string &filePath, const ::std::string &texPath)
 
void fillSceneThreadWork (::std::uint32_t threadId, ::std::uint32_t numberOfThreads, ::MobileRT::Scene *const scene, const ::std::function<::std::unique_ptr<::MobileRT::Sampler >()> &lambda, const ::std::string &filePath, ::std::unordered_map<::std::string, ::MobileRT::Texture > *const texturesCache, ::std::mutex *const mutex)
 

Static Private Member Functions

static triple<::glm::vec2, ::glm::vec2, ::glm::vec2 > normalizeTexCoord (const MobileRT::Texture &texture, const ::std::tuple<::glm::vec2, ::glm::vec2, ::glm::vec2 > &texCoord)
 

Private Attributes

::tinyobj::attrib_t attrib_ {}
 
::std::vector<::tinyobj::shape_t > shapes_ {}
 
::std::vector<::tinyobj::material_t > materials_ {}
 

Additional Inherited Members

- Protected Attributes inherited from MobileRT::ObjectLoader
bool isProcessed_ {false}
 
::std::int32_t numberTriangles_ {-1}
 

Detailed Description

A class which loads a scene from an OBJ file and fills the scene with the loaded geometry.

Member Typedef Documentation

◆ triple

template<typename T1 , typename T2 , typename T3 >
using Components::OBJLoader::triple = ::std::tuple<T1, T2, T3>
private

Constructor & Destructor Documentation

◆ OBJLoader() [1/4]

Components::OBJLoader::OBJLoader ( )
explicitdelete

◆ OBJLoader() [2/4]

OBJLoader::OBJLoader ( ::std::istream &  isObj,
::std::istream &  isMtl 
)
explicit
Here is the call graph for this function:

◆ OBJLoader() [3/4]

Components::OBJLoader::OBJLoader ( const OBJLoader objLoader)
delete

◆ OBJLoader() [4/4]

Components::OBJLoader::OBJLoader ( OBJLoader &&  objLoader)
deletenoexcept

◆ ~OBJLoader()

OBJLoader::~OBJLoader ( )
final

The destructor.

Member Function Documentation

◆ fillScene()

bool OBJLoader::fillScene ( ::MobileRT::Scene scene,
::std::function<::std::unique_ptr<::MobileRT::Sampler >()>  lambda,
::std::string  filePath,
::std::unordered_map<::std::string, ::MobileRT::Texture texturesCache 
)
final
Here is the call graph for this function:

◆ fillSceneThreadWork()

void OBJLoader::fillSceneThreadWork ( ::std::uint32_t  threadId,
::std::uint32_t  numberOfThreads,
::MobileRT::Scene *const  scene,
const ::std::function<::std::unique_ptr<::MobileRT::Sampler >()> &  lambda,
const ::std::string &  filePath,
::std::unordered_map<::std::string, ::MobileRT::Texture > *const  texturesCache,
::std::mutex *const  mutex 
)
private

Fill the scene with the loaded triangles.

This method is called by the fillScene method with multiple threads.

Fill the scene with the loaded triangles.

Here is the call graph for this function:

◆ getTextureFromCache() [1/2]

const ::MobileRT::Texture& Components::OBJLoader::getTextureFromCache ( ::std::unordered_map<::std::string, ::MobileRT::Texture > *const  texturesCache,
const ::std::string &  filePath,
const ::std::string &  texPath 
)
private
Here is the caller graph for this function:

◆ getTextureFromCache() [2/2]

static const ::MobileRT::Texture& Components::OBJLoader::getTextureFromCache ( ::std::unordered_map<::std::string, ::MobileRT::Texture > *const  texturesCache,
::std::string &&  textureBinary,
long  size,
const ::std::string &  texPath 
)
static

◆ loadNormal()

OBJLoader::triple<::glm::vec3,::glm::vec3,::glm::vec3 > OBJLoader::loadNormal ( const ::tinyobj::shape_t &  shape,
::std::int32_t  indexOffset,
const triple<::glm::vec3, ::glm::vec3, ::glm::vec3 > &  vertex 
) const
private

Helper method that loads a normal from the tinyobjloader library structure.

Parameters
shapeThe shape structure from the tinyobj library.
indexOffsetThe indices of the normals in the tinyobjloader structure.
vertexThe vertices' values of the triangle.
Returns
The loaded normal.
Here is the call graph for this function:

◆ loadVertices()

OBJLoader::triple<::glm::vec3,::glm::vec3,::glm::vec3 > OBJLoader::loadVertices ( const ::tinyobj::shape_t &  shape,
::std::int32_t  indexOffset 
) const
private

Helper method that loads the vertices' values.

Parameters
shapeThe shape structure from the tinyobj library.
indexOffsetThe indices of the normals in the tinyobjloader structure.
Returns
The loaded vertices.

◆ normalizeTexCoord()

OBJLoader::triple<::glm::vec2,::glm::vec2,::glm::vec2 > OBJLoader::normalizeTexCoord ( const MobileRT::Texture texture,
const ::std::tuple<::glm::vec2, ::glm::vec2, ::glm::vec2 > &  texCoord 
)
staticprivate

Helper method that normalizes the texture coordinates.

Parameters
textureThe texture of the texture coordinates.
texCoordThe texture coordinates to normalize.
Returns
The normalized texture coordinates.
Here is the call graph for this function:

◆ operator=() [1/2]

OBJLoader& Components::OBJLoader::operator= ( const OBJLoader objLoader)
delete

◆ operator=() [2/2]

OBJLoader& Components::OBJLoader::operator= ( OBJLoader &&  objLoader)
deletenoexcept

Member Data Documentation

◆ attrib_

::tinyobj::attrib_t Components::OBJLoader::attrib_ {}
private

◆ materials_

::std::vector<::tinyobj::material_t> Components::OBJLoader::materials_ {}
private

◆ shapes_

::std::vector<::tinyobj::shape_t> Components::OBJLoader::shapes_ {}
private

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