#include <geometryfromfile.h>
Public Member Functions | |
GeometryFromFile (Core &core) | |
virtual bool | init (utility::ErrorState &errorState) override |
virtual MeshInstance & | getMeshInstance () override |
virtual const MeshInstance & | getMeshInstance () const override |
![]() | |
Resource () | |
![]() | |
Object () | |
virtual | ~Object () |
virtual void | onDestroy () |
Object (Object &)=delete | |
Object & | operator= (const Object &)=delete |
Object (Object &&)=delete | |
Object & | operator= (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... | |
![]() | |
std::string | mID |
Property: 'mID' unique name of the object. Used as an identifier by the system. More... | |
Additional Inherited Members | |
![]() | |
static bool | isIDProperty (rtti::Instance &object, const rtti::Property &property) |
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.
GeometryFromFile | ( | Core & | core | ) |
|
overridevirtual |
Implements IMesh.
|
overridevirtual |
Implements IMesh.
|
overridevirtual |
Loads the 3D geometry from file and creates the mesh instance. Every mesh becomes a single shape, vertex attributes are shared.
errorState | contains the error if initialization fails |
Reimplemented from Object.
bool mCalculateTangents = true |
Property: 'CalculateTangents' If tangents and bi-tangents are calculated, does nothing if no normals are present or calculated.
ECullMode mCullMode = ECullMode::Back |
Property: 'CullMode' controls which triangles are culled, back facing, front facing etc.
bool mGenerateNormals = false |
Property: 'GenerateNormals' If normals are generated when not present.
std::string mPath |
Property: 'Path' path to the geometry (.fbx, .obj, etc.) file on disk.
EPolygonMode mPolygonMode = EPolygonMode::Fill |
Property: 'PolygonMode' Mesh polygon mode (fill, wires, points)
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.
EMemoryUsage mUsage = EMemoryUsage::Static |
Property: 'Usage' If the mesh is uploaded once or frequently updated.