Ocular Engine
Ocular::Graphics::OBJImporter Class Reference

#include <OBJImporter.hpp>

Static Public Member Functions

static Core::SceneObjectImport (std::string const &path)
static bool FindMeshes (std::string const &path, std::vector< std::string > &names)

Detailed Description

!!! Need to rewrite this as it just repeats itself

OBJ files are handled differently from other mesh files such as PLY. This is because a single OBJ file may define multiple individual meshes within it, as well as specifying the materials (found in an accompanying .mat) that it uses.

Because of this, loading in an entire OBJ file does not create a single resource. Instead, it creates multiple SceneObjects which then contain the renderables for the described meshes and materials.

In addition to loading in an entire OBJ to a group of SceneObjects, one may query for the individual meshes defined within the file and use those separately.

For example, if we have an OBJ at

Resources/ Meshes/ SomeModel.obj

Which contains the following two meshes: pCube1 and pSphere1; we can retrieve the individual meshes using:

OcularResources->getResource("Meshes/SomeModel/pCube1"); OcularResources->getResource("Meshes/SomeModel/pSphere1");

The actual OBJ file can be used in two different ways. If requested by the Resources system, it will return a MultiResource which describes the contained meshes.


Alternatively, this OBJImporter class can be used to import the OBJ as SceneObjects.

SceneObject* parent = OBJImporter::Import("Meshes/SomeModel");

Which would create the following SceneObject hierarchy:

SceneObject: SomeModel Child SceneObject: pCube1 MeshRenderable Child SceneObject: pSphere1 MeshRenderable

Member Function Documentation

bool Ocular::Graphics::OBJImporter::FindMeshes ( std::string const &  path,
std::vector< std::string > &  names 

Discovers all of the names of the meshes described within the specified OBJ file.

[in]pathThe resource mapping path of the file (path relative to Resource folder, sans extension)
[in]namesContainer of all mesh names found within the OBJ file
May return FALSE if unable to parse the OBJ file.
Core::SceneObject * Ocular::Graphics::OBJImporter::Import ( std::string const &  path)

Creates a new SceneObject hierarchy from the specified OBJ file.

The SceneObject will be added to the active scene as a top-level object (no parent).

The returned object's name will match that of the filename and will have a child object for each mesh found within the OBJ.

[in]pathThe resource mapping path of the file (path relative to Resource folder, sans extension)
May return NULL if unable to parse the OBJ file.

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