Ocular Engine
Ocular::Graphics::ResourceLoader_OBJ Class Reference

#include <ResourceLoader_OBJ.hpp>

Inheritance diagram for Ocular::Graphics::ResourceLoader_OBJ:

Public Member Functions

virtual bool loadResource (Core::Resource *&resource, Core::File const &file, std::string const &mappingName) override
virtual bool loadSubResource (Core::Resource *&resource, Core::File const &file, std::string const &mappingName) override
virtual bool exploreResource (Core::File const &file) override
- Public Member Functions inherited from Ocular::Core::AResourceLoader
 AResourceLoader (std::string const &extension, ResourceType type)
virtual std::string getSupportedFileType () const
ResourceType getResourceType () const

Protected Member Functions

void createMeshes (Core::MultiResource *multiResource)
void createMesh (Mesh *mesh, OBJGroup const *group)
void addFace (OBJFace const *face, std::vector< Vertex > *vertices, std::vector< uint32_t > *indices, Math::Vector3f &min, Math::Vector3f &max)
void faceToVertex (std::vector< Vertex > *vertices, OBJVertexGroup const &group, Math::Vector3f &min, Math::Vector3f &max)
void createMaterials (Core::MultiResource *multiResource)
void createMaterial (Material *material, OBJMaterial const *objMaterial, std::string const &relPath)
bool isFileValid (Core::File const &file) const
void splitParentSubNames (std::string const &mappingName, std::string &parent, std::string &sub) const
- Protected Member Functions inherited from Ocular::Core::AResourceLoader
bool isFileValid (Core::File const &file) const

Additional Inherited Members

- Protected Attributes inherited from Ocular::Core::AResourceLoader
std::string m_SupportedExtension
ResourceType m_Type

Detailed Description

ResourceLoader implementation for the Wavefront OBJ geometric data file format.

The OBJ file format can describe multiple individual meshes, and so this ResourceLoader creates and returns a MultiResource instance. In addition to the MultiResource, it also loads in each individual mesh as a Mesh resource.

See the OBJImporter class for information on how to use an OBJ file in the Ocular Engne.

Member Function Documentation

bool Ocular::Graphics::ResourceLoader_OBJ::exploreResource ( Core::File const &  file)

Catalogs a list of all groups in the specified OBJ file and records them as individual Mesh mappings.

Ignores any group named 'default'.

[in]fileThe OBJ file to explore.

Explores the OBJ file. For each 'group' tag found that is not 'default' it will add a new Resource mapping path to the global ResourceManager.

Also checks for materials via the 'usemtl' tag.

Reimplemented from Ocular::Core::AResourceLoader.

bool Ocular::Graphics::ResourceLoader_OBJ::loadResource ( Core::Resource *&  resource,
Core::File const &  file,
std::string const &  mappingName 

Loads the entire OBJ file into memory and returns a pointer to the resulting MultiResource instance.

[out]resourceThe MultiResource containing all subresource Meshes and Materials contained within the file.
[in]fileThe OBJ file that is to be represented by the MultiResource.

Reimplemented from Ocular::Core::AResourceLoader.

bool Ocular::Graphics::ResourceLoader_OBJ::loadSubResource ( Core::Resource *&  resource,
Core::File const &  file,
std::string const &  mappingName 

Loads a specific OBJ group as an individual Mesh resource.

It should be noted that loading an individual group requires the full parsing of the OBJ file. Because of this, the entire MutliResource is loaded at once to prevent multiple calls to parse the same file.

[out]resourceThe subresource loaded as an instance of Mesh.
[in]fileThe OBJ file that the subresource is contained within.
[in]mappingNameIndividual mapping name of the subresource. From this, the OBJ group name for the mesh is extracted.

Reimplemented from Ocular::Core::AResourceLoader.

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