NAP
Public Member Functions | Public Attributes | List of all members
GeometryFromFile Class Reference

#include <geometryfromfile.h>

Public Member Functions

 GeometryFromFile (Core &core)
 
virtual bool init (utility::ErrorState &errorState) override
 
virtual MeshInstancegetMeshInstance () override
 
virtual const MeshInstancegetMeshInstance () const override
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Public Attributes

std::string mPath
 Property: 'Path' path to the geometry (.fbx, .obj, etc.) file on disk. More...
 
EMemoryUsage mUsage = EMemoryUsage::Static
 Property: 'Usage' If the mesh is uploaded once or frequently updated. More...
 
EPolygonMode mPolygonMode = EPolygonMode::Fill
 Property: 'PolygonMode' Mesh polygon mode (fill, wires, points) More...
 
ECullMode mCullMode = ECullMode::Back
 Property: 'CullMode' controls which triangles are culled, back facing, front facing etc. More...
 
bool mGenerateNormals = false
 Property: 'GenerateNormals' If normals are generated when not present. More...
 
float mSmoothingAngle = 60.0f
 Property: 'NormalSmoothingAngle' The maximum angle between two normals at the same vertex position to be considered the same. Only used when normals are generated. More...
 
bool mCalculateTangents = true
 Property: 'CalculateTangents' If tangents and bi-tangents are calculated, does nothing if no normals are present or calculated. More...
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 

Description

Imports 3D Geometry from file and converts the individual meshes into a single nap::MeshInstance. Every extracted mesh becomes a single shape, vertex attributes are shared. Many 3D geometry file formats are supported, including '.obj', '.fbx' etc. For a full list of supported file formats visit http://assimp.sourceforge.net/

The resource checks, on initialization, which attributes it needs to create, based on the extracted mesh data. If the file contains multiple meshes with varying types of data, and a particular mesh doesn't have a specific set of data, the attribute data of that mesh is initialized to zero and a warning is issued.

For example: Say the file contains 2 meshes, mesh 1 has color data but mesh 2 does not. This means that the color data of mesh 2 will be initialized to 0. If both meshes carry no color data at all no color attribute is created.

The operator attempts to extract Vertex, Normal, Color, UV and Tangent information. Up to 8 Color and UV channels are supported. You can choose to generate normals, tangents and bi-tangents. These are only generated when not already present on the mesh and 'GenerateNormals' / 'CalculateTangents' is set to true.

Only models that contain closed faces (quads / triangles etc.) are currently supported The mesh is triangulated on load.

Note that it is faster and often better to load geometry from a '.mesh' file using the nap::MeshFromFile resource. '.mesh' files are created by the 'fbxconverter' tool and are stored in a more optimal (binary) format, optimized for faster reads. Another advantage of using the 'fbxconverter' tool is that every mesh contained in that file is converted into an individual '.mesh' file, subsequently giving you more control over material assignment.

Inheritance diagram for GeometryFromFile:
[legend]
Collaboration diagram for GeometryFromFile:
[legend]

Constructor & Destructor Documentation

◆ GeometryFromFile()

GeometryFromFile ( Core core)

Member Function Documentation

◆ getMeshInstance() [1/2]

virtual const MeshInstance& getMeshInstance ( ) const
overridevirtual
Returns
the mesh instance, created during init after a successful load.

Implements IMesh.

◆ getMeshInstance() [2/2]

virtual MeshInstance& getMeshInstance ( )
overridevirtual
Returns
the mesh instance, created during init after a successful load.

Implements IMesh.

◆ init()

virtual bool init ( utility::ErrorState errorState)
overridevirtual

Loads the 3D geometry from file and creates the mesh instance. Every mesh becomes a single shape, vertex attributes are shared.

Parameters
errorStatecontains the error if initialization fails
Returns
if initialization succeeded.

Reimplemented from Object.

Member Data Documentation

◆ mCalculateTangents

bool mCalculateTangents = true

Property: 'CalculateTangents' If tangents and bi-tangents are calculated, does nothing if no normals are present or calculated.

◆ mCullMode

Property: 'CullMode' controls which triangles are culled, back facing, front facing etc.

◆ mGenerateNormals

bool mGenerateNormals = false

Property: 'GenerateNormals' If normals are generated when not present.

◆ mPath

std::string mPath

Property: 'Path' path to the geometry (.fbx, .obj, etc.) file on disk.

◆ mPolygonMode

Property: 'PolygonMode' Mesh polygon mode (fill, wires, points)

◆ mSmoothingAngle

float mSmoothingAngle = 60.0f

Property: 'NormalSmoothingAngle' The maximum angle between two normals at the same vertex position to be considered the same. Only used when normals are generated.

◆ mUsage

Property: 'Usage' If the mesh is uploaded once or frequently updated.