MAGE  v0.171.0
Matthias Advanced Game Engine
mage::rendering::loader::MDLReader< VertexT, IndexT > Class Template Reference

#include <mdl_reader.hpp>

Inheritance diagram for mage::rendering::loader::MDLReader< VertexT, IndexT >:
mage::LineReader

Public Member Functions

 MDLReader (ResourceManager &resource_manager, ModelOutput< VertexT, IndexT > &model_output)
 
 MDLReader (const MDLReader &reader)=delete
 
 MDLReader (MDLReader &&reader) noexcept
 
 ~MDLReader ()
 
MDLReaderoperator= (const MDLReader &reader)=delete
 
MDLReaderoperator= (MDLReader &&reader)=delete
 
void ReadFromFile (std::filesystem::path path, std::regex regex=s_default_regex, SelectionFunction selection_function=s_default_selection_function)
 
void ReadFromMemory (const std::string &input, std::regex regex=s_default_regex, SelectionFunction selection_function=s_default_selection_function)
 

Private Member Functions

virtual void Preprocess () override
 
virtual void ReadLine () override
 
virtual void Postprocess () override
 
void ReadMDLSubModel ()
 
void ReadMDLMaterialLibrary ()
 
- Private Member Functions inherited from mage::LineReader
LineReaderoperator= (const LineReader &reader)=delete
 
LineReaderoperator= (LineReader &&reader) noexcept
 
void ReadFromFile (std::filesystem::path path, std::regex regex=s_default_regex, SelectionFunction selection_function=s_default_selection_function)
 
void ReadFromMemory (const std::string &input, std::regex regex=s_default_regex, SelectionFunction selection_function=s_default_selection_function)
 
 LineReader ()
 
 LineReader (const LineReader &reader)=delete
 
 LineReader (LineReader &&reader) noexcept
 
 ~LineReader ()
 
const std::filesystem::path & GetPath () const noexcept
 
U32 GetCurrentLineNumber () const noexcept
 
template<typename T >
const T Read ()
 
template<typename T , std::size_t N, size_t A = alignof(T)>
const Array< T, N, A > Read ()
 
void ReadRemainingTokens ()
 
template<typename T >
bool Contains () const noexcept
 
bool ContainsTokens () const noexcept
 

Private Attributes

ResourceManagerm_resource_manager
 
ModelOutput< VertexT, IndexT > & m_model_output
 

Additional Inherited Members

- Private Types inherited from mage::LineReader
using SelectionFunction = std::function< const std::ssub_match(const std::smatch &) >
 
- Static Private Attributes inherited from mage::LineReader
static const std::regex s_default_regex = std::regex(R"((\"([^\"]*)\")|(\S+))")
 
static const SelectionFunction s_default_selection_function
 

Detailed Description

template<typename VertexT, typename IndexT>
class mage::rendering::loader::MDLReader< VertexT, IndexT >

A class of MDL file readers for reading models.

Template Parameters
VertexTThe vertex type.
IndexTThe index type.

Constructor & Destructor Documentation

◆ MDLReader() [1/3]

template<typename VertexT , typename IndexT >
mage::rendering::loader::MDLReader< VertexT, IndexT >::MDLReader ( ResourceManager resource_manager,
ModelOutput< VertexT, IndexT > &  model_output 
)
explicit

Constructs a MDL reader.

Parameters
[in,out]resource_managerA reference to the resource manager.
[in,out]model_outputA reference to the model output for storing the model data from file.

◆ MDLReader() [2/3]

template<typename VertexT , typename IndexT >
mage::rendering::loader::MDLReader< VertexT, IndexT >::MDLReader ( const MDLReader< VertexT, IndexT > &  reader)
delete

Constructs a MDL reader from the given MDL reader.

Parameters
[in]readerA reference to the MDL reader to copy.

◆ MDLReader() [3/3]

template<typename VertexT , typename IndexT >
mage::rendering::loader::MDLReader< VertexT, IndexT >::MDLReader ( MDLReader< VertexT, IndexT > &&  reader)
noexcept

Constructs a MDL reader by moving the given MDL reader.

Parameters
[in]readerA reference to the MDL reader to move.

◆ ~MDLReader()

template<typename VertexT , typename IndexT >
mage::rendering::loader::MDLReader< VertexT, IndexT >::~MDLReader ( )

Destructs this MDL reader.

Member Function Documentation

◆ operator=() [1/2]

template<typename VertexT , typename IndexT >
MDLReader& mage::rendering::loader::MDLReader< VertexT, IndexT >::operator= ( const MDLReader< VertexT, IndexT > &  reader)
delete

Copies the given MDL reader to this MDL reader.

Parameters
[in]readerA reference to a MDL reader to copy.
Returns
A reference to the copy of the given MDL reader (i.e. this MDL reader).

◆ operator=() [2/2]

template<typename VertexT , typename IndexT >
MDLReader& mage::rendering::loader::MDLReader< VertexT, IndexT >::operator= ( MDLReader< VertexT, IndexT > &&  reader)
delete

Moves the given MDL reader to this MDL reader.

Parameters
[in]readerA reference to a MDL reader to move.
Returns
A reference to the moved MDL reader (i.e. this MDL reader).

◆ Postprocess()

template<typename VertexT , typename IndexT >
virtual void mage::rendering::loader::MDLReader< VertexT, IndexT >::Postprocess ( )
overrideprivatevirtual

Post-processes after reading the current file of this MDL reader.

Exceptions
ExceptionFailed to finish post-processing successfully.

Reimplemented from mage::LineReader.

◆ Preprocess()

template<typename VertexT , typename IndexT >
virtual void mage::rendering::loader::MDLReader< VertexT, IndexT >::Preprocess ( )
overrideprivatevirtual

Pre-processes before reading the current file of this MDL reader.

Exceptions
ExceptionFailed to finish the pre-processing successfully.

Reimplemented from mage::LineReader.

◆ ReadFromFile()

template<typename VertexT , typename IndexT >
void mage::LineReader::ReadFromFile

Reads from the file associated with the given path.

Parameters
[in]pathThe path.
[in]regexThe (line) regex.
[in]selection_functionThe selection function.
Exceptions
ExceptionFailed to read from the file.

◆ ReadFromMemory()

template<typename VertexT , typename IndexT >
void mage::LineReader::ReadFromMemory

Reads from the given input string.

Parameters
[in]inputA reference to the input string.
[in]regexThe (line) regex.
[in]selection_functionThe selection function.
Exceptions
ExceptionFailed to read from the given input string.

◆ ReadLine()

template<typename VertexT , typename IndexT >
virtual void mage::rendering::loader::MDLReader< VertexT, IndexT >::ReadLine ( )
overrideprivatevirtual

Reads the current line of this MDL reader.

Exceptions
ExceptionFailed to the current line of this MDL reader.

Implements mage::LineReader.

◆ ReadMDLMaterialLibrary()

template<typename VertexT , typename IndexT >
void mage::rendering::loader::MDLReader< VertexT, IndexT >::ReadMDLMaterialLibrary ( )
private

Reads a Material Library definition and imports the materials corresponding to the model.

Exceptions
ExceptionFailed to read a Material Library definition.
ExceptionFailed to import the materials.

◆ ReadMDLSubModel()

template<typename VertexT , typename IndexT >
void mage::rendering::loader::MDLReader< VertexT, IndexT >::ReadMDLSubModel ( )
private

Reads a Submodel definition.

Exceptions
ExceptionFailed to read a Submodel definition.

Member Data Documentation

◆ m_model_output

template<typename VertexT , typename IndexT >
ModelOutput< VertexT, IndexT >& mage::rendering::loader::MDLReader< VertexT, IndexT >::m_model_output
private

A reference to the model output containing the model data of this MDL reader.

◆ m_resource_manager

template<typename VertexT , typename IndexT >
ResourceManager& mage::rendering::loader::MDLReader< VertexT, IndexT >::m_resource_manager
private

A reference to the resource manager of this MDL reader.