Commit 90c87333 authored by Jonathan Kunstwald's avatar Jonathan Kunstwald

Make assimp importer partly thread safe, add MeshData

parent 830597fe
This diff is collapsed.
#pragma once
#include <glm/glm.hpp>
#include <glow/common/non_copyable.hh>
#include <glow/common/property.hh>
#include <glow/fwd.hh>
#include <assimp/postprocess.h>
#include <string>
#include <vector>
namespace glow
{
namespace assimp
{
constexpr uint32_t importDefaultFlags =
aiProcess_SortByPType |
aiProcess_Triangulate |
aiProcess_CalcTangentSpace |
aiProcess_GenSmoothNormals |
aiProcess_GenUVCoords |
aiProcess_PreTransformVertices;
constexpr uint32_t importFlipUVFlags = importDefaultFlags | aiProcess_FlipUVs;
/**
* @brief Importer for geometry
*
......@@ -50,72 +66,102 @@ private: // settings
/// vec2 aTexCoord is available (hopefully)
bool mGenerateUVCoords = true;
bool mFlipUVCoords = false;
public:
GLOW_PROPERTY(CalculateTangents);
GLOW_PROPERTY(Triangulate);
GLOW_PROPERTY(GenerateSmoothNormal);
GLOW_PROPERTY(PreTransformVertices);
GLOW_PROPERTY(GenerateUVCoords);
GLOW_PROPERTY(FlipUVCoords);
public:
struct MeshData
{
std::vector<glm::vec3> positions;
std::vector<glm::vec3> normals;
std::vector<glm::vec3> tangents;
std::vector<std::vector<glm::vec2>> texCoords;
std::vector<std::vector<glm::vec4>> colors;
std::vector<uint32_t> indices;
std::string filename;
};
Importer();
/// Loads a VA from a given filename
/// Supported file formats at time of writing this are:
///
/// COMMON INTERCHANGE FORMATS
/// Autodesk ( .fbx )
/// Collada ( .dae )
/// glTF ( .gltf, .glb )
/// Blender 3D ( .blend )
/// 3ds Max 3DS ( .3ds )
/// 3ds Max ASE ( .ase )
/// Wavefront Object ( .obj )
/// Industry Foundation Classes (IFC/Step) ( .ifc )
/// XGL ( .xgl,.zgl )
/// Stanford Polygon Library ( .ply )
/// *AutoCAD DXF ( .dxf )
/// LightWave ( .lwo )
/// LightWave Scene ( .lws )
/// Modo ( .lxo )
/// Stereolithography ( .stl )
/// DirectX X ( .x )
/// AC3D ( .ac )
/// Milkshape 3D ( .ms3d )
/// * TrueSpace ( .cob,.scn )
///
/// MOTION CAPTURE FORMATS
/// Biovision BVH ( .bvh )
/// * CharacterStudio Motion ( .csm )
/// GRAPHICS ENGINE FORMATS
/// Ogre XML ( .xml )
/// Irrlicht Mesh ( .irrmesh )
/// * Irrlicht Scene ( .irr )
/// GAME FILE FORMATS
/// Quake I ( .mdl )
/// Quake II ( .md2 )
/// Quake III Mesh ( .md3 )
/// Quake III Map/BSP ( .pk3 )
/// * Return to Castle Wolfenstein ( .mdc )
/// Doom 3 ( .md5* )
/// *Valve Model ( .smd,.vta )
/// *Open Game Engine Exchange ( .ogex )
/// *Unreal ( .3d )
///
/// OTHER FILE FORMATS
/// BlitzBasic 3D ( .b3d )
/// Quick3D ( .q3d,.q3s )
/// Neutral File Format ( .nff )
/// Sense8 WorldToolKit ( .nff )
/// Object File Format ( .off )
/// PovRAY Raw ( .raw )
/// Terragen Terrain ( .ter )
/// 3D GameStudio (3DGS) ( .mdl )
/// 3D GameStudio (3DGS) Terrain ( .hmp )
/// Izware Nendo ( .ndo )
///
/// Each attribute gets their own buffer.
/// Importer instance version of LoadAndCreateMesh
SharedVertexArray load(std::string const& filename);
/// Importer instance version of LoadData
MeshData loadDataCustom(std::string const& filename);
public:
/// Loads and creates a VA from a given filename
/// Supported file formats at time of writing this are:
///
/// COMMON INTERCHANGE FORMATS
/// Autodesk ( .fbx )
/// Collada ( .dae )
/// glTF ( .gltf, .glb )
/// Blender 3D ( .blend )
/// 3ds Max 3DS ( .3ds )
/// 3ds Max ASE ( .ase )
/// Wavefront Object ( .obj )
/// Industry Foundation Classes (IFC/Step) ( .ifc )
/// XGL ( .xgl,.zgl )
/// Stanford Polygon Library ( .ply )
/// *AutoCAD DXF ( .dxf )
/// LightWave ( .lwo )
/// LightWave Scene ( .lws )
/// Modo ( .lxo )
/// Stereolithography ( .stl )
/// DirectX X ( .x )
/// AC3D ( .ac )
/// Milkshape 3D ( .ms3d )
/// * TrueSpace ( .cob,.scn )
///
/// MOTION CAPTURE FORMATS
/// Biovision BVH ( .bvh )
/// * CharacterStudio Motion ( .csm )
/// GRAPHICS ENGINE FORMATS
/// Ogre XML ( .xml )
/// Irrlicht Mesh ( .irrmesh )
/// * Irrlicht Scene ( .irr )
/// GAME FILE FORMATS
/// Quake I ( .mdl )
/// Quake II ( .md2 )
/// Quake III Mesh ( .md3 )
/// Quake III Map/BSP ( .pk3 )
/// * Return to Castle Wolfenstein ( .mdc )
/// Doom 3 ( .md5* )
/// *Valve Model ( .smd,.vta )
/// *Open Game Engine Exchange ( .ogex )
/// *Unreal ( .3d )
///
/// OTHER FILE FORMATS
/// BlitzBasic 3D ( .b3d )
/// Quick3D ( .q3d,.q3s )
/// Neutral File Format ( .nff )
/// Sense8 WorldToolKit ( .nff )
/// Object File Format ( .off )
/// PovRAY Raw ( .raw )
/// Terragen Terrain ( .ter )
/// 3D GameStudio (3DGS) ( .mdl )
/// 3D GameStudio (3DGS) Terrain ( .hmp )
/// Izware Nendo ( .ndo )
///
/// Each attribute gets their own buffer.
static SharedVertexArray LoadAndCreateMesh(std::string const& filename, uint32_t flags = importDefaultFlags);
/// Creates a VA from MeshData, requires OGL context and initialized GLOW on the same thread
static SharedVertexArray CreateMeshFromData(const MeshData& data);
/// Loads MeshData from a given filename with the given importer flags
/// Can be run on any thread
static MeshData LoadData(std::string const& filename, uint32_t flags = importDefaultFlags);
};
}
}
};
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment