11#include <glm/gtc/quaternion.hpp>
66 const std::vector<tinygltf::Buffer> & buffers,
67 const std::vector<tinygltf::BufferView> & bufferViews,
105 const std::vector<tinygltf::Buffer> & buffers,
106 const std::vector<tinygltf::BufferView> & bufferViews,
107 const std::vector<tinygltf::Accessor> & accessors,
108 const tinygltf::Primitive & primitive
125 std::optional<GltfBufferDataView>
201 tinygltf::Image
image = tinygltf::Image();
245 const tinygltf::Value & vs_extension,
246 const tinygltf::Model * model =
nullptr
315 const tinygltf::Value & extension,
316 const tinygltf::Model * model =
nullptr
509 const tinygltf::Model & model,
510 const tinygltf::Material & material,
699 void parsePbrData(
const tinygltf::Model & model,
const tinygltf::Material & material );
749 tinygltf::Model model,
831 const tinygltf::Model & model,
832 const tinygltf::Mesh &
mesh,
833 const tinygltf::Node & node,
930 void load(
const std::filesystem::path & path, std::vector<GltfMeshData> & meshes )
const;
942 std::optional<tinygltf::Model>
loadModel(
const std::filesystem::path & path )
const;
953 tinygltf::Model
loadAsync(
const std::filesystem::path & path )
const;
Animation clip loaded from glTF animation data.
std::vector< Vertex > getPrimitiveVertices(const tinygltf::Primitive &primitive)
Legacy primitive vertex extraction entry point.
NamedThreadPool * threadPool
std::optional< tinygltf::Model > loadModel(const std::filesystem::path &path) const
Loads a full ASCII glTF model through tinygltf.
static Assets::Skin loadSkinData(const tinygltf::Model &model, int skinIndex)
Load skin (skeleton) data from a glTF model.
GltfLoader(NamedThreadPool *threadPool=nullptr)
Creates a loader that can use an optional thread pool for deferred work.
tinygltf::Model loadMetadataOnly(const std::filesystem::path &path) const
Loads only the GLTF metadata (nodes, names, transforms) without loading buffer data.
void load(const std::filesystem::path &path, std::vector< GltfMeshData > &meshes) const
Loads a vector of meshes from a gltf file.
Ecs::PrimitiveData loadPrimitiveData(GltfVertexData vertexData)
Converts resolved glTF vertex and index views into engine primitive data.
static Animation loadAnimationData(const tinygltf::Model &model, int animIndex, const Assets::Skin &skin)
Load animation data from a glTF model.
tinygltf::Model loadAsync(const std::filesystem::path &path) const
Loads a glTF model while skipping image payload loading.
~GltfLoader()
Waits for queued work on the supplied thread pool before destruction.
Runtime-owned Vulkan texture resource.
Skeleton definition loaded from glTF skin data.
Wrapper for texture data.
Tracy-named thread pool using BS_tracy::tracy_thread_pool.
Engine::Core::MaterialData MaterialData
Manages IBL (Image-Based Lighting) resources for specular reflections.
PipelineNames
Named graphics pipelines used by material selection and shader lookup.
const tinygltf::Buffer & buffer
Buffer referenced by bufferView.buffer.
GltfBufferDataView(const std::vector< tinygltf::Buffer > &buffers, const std::vector< tinygltf::BufferView > &bufferViews, const tinygltf::Accessor &accessor)
Resolves an accessor to its buffer view, buffer, and raw data pointer.
const tinygltf::Accessor & accessor
Accessor that describes the element count, type, and component type.
const tinygltf::BufferView & bufferView
Buffer view referenced by accessor.bufferView.
const float * data
Raw pointer to the first accessor byte, interpreted as float data by callers.
Stores the material data which is relevant for our current set of shaders.
float getMetallicFactor() const
Gets the glTF metallic factor.
glm::vec3 getEmissiveFactor() const
Gets the emissive factor.
bool hasVulkanSchneeExtension() const
Checks whether the material has a Vulkan Schnee material extension.
void parsePbrData(const tinygltf::Model &model, const tinygltf::Material &material)
const Materials::MaterialData & getMaterialData() const
Gets immutable engine material data generated from glTF and extension data.
GltfMaterialData()=default
uint32_t getNormalTextureIndex() const
Gets the engine normal texture index.
bool hasTexture() const
Checks whether the material references a base color texture.
GltfMaterialData(const tinygltf::Model &model, const tinygltf::Material &material, const StaticMeshExtensions &meshSettings)
int32_t getGltfMetallicRoughnessTextureIndex() const
Gets the original glTF metallic-roughness texture index.
bool hasEmissiveTexture() const
Checks whether the glTF material references an emissive texture.
bool hasNormalTexture() const
Checks whether the glTF material references a normal texture.
int32_t gltfNormalTextureIndex
uint32_t roughnessMetallicTextureIndex
uint32_t getTextureIndex() const
Gets the engine texture index for the base color texture.
const VulkanSchneeMaterialExtension & getVulkanSchneeExtension() const
Gets the parsed Vulkan Schnee material extension.
const std::filesystem::path & getLightmapPath() const
Gets the lightmap texture path from the engine extension.
int32_t getGltfNormalTextureIndex() const
Gets the original glTF normal texture index.
int32_t getGltfEmissiveTextureIndex() const
Gets the original glTF emissive texture index.
float getRoughnessFactor() const
Gets the glTF roughness factor.
int32_t gltfMetallicRoughnessTextureIndex
uint32_t getEmissiveTextureIndex() const
Gets the engine emissive texture index.
Materials::MaterialData materialData
std::optional< MaterialExtensions > materialExtensions
float getNormalScale() const
Gets the normal map scale.
uint32_t getRoughnessMetallicTextureIndex() const
Gets the engine metallic-roughness texture index.
bool hasMetallicRoughnessTexture() const
Checks whether the glTF material references a metallic-roughness texture.
Materials::MaterialData & getMaterialDataRef()
Gets mutable engine material data generated from glTF and extension data.
std::filesystem::path lightmapPath
uint32_t normalTextureIndex
int32_t gltfEmissiveTextureIndex
glm::vec4 baseColorFactor
uint32_t emissiveTextureIndex
bool hasLightmapTexture() const
Checks whether this material uses a lightmap texture path.
std::string getShaderName() const
Gets the shader name selected for this material.
std::vector< GltfMeshPrimitiveData > getPrimitives() const
Gets a copy of parsed primitives.
std::string getName() const
Gets the mesh node name.
int skinIndex
glTF skin index (-1 = no skin)
GltfMeshData(const tinygltf::Model &model, const tinygltf::Mesh &mesh, const tinygltf::Node &node, const glm::mat4 &transform)
Parses one mesh node into engine primitive data.
std::vector< GltfMeshPrimitiveData > & getPrimitivesRef()
Gets mutable parsed primitives.
std::vector< GltfMeshPrimitiveData > primitives
glm::mat4 getTransform() const
Gets the model matrix for the object from the file it was imported from.
int getSkinIndex() const
Gets the glTF skin index referenced by the mesh node.
GltfMaterialData getMaterialData() const
Gets material data parsed for this primitive.
const std::vector< BoneVertexData > & getBoneVertexData() const
Gets per-vertex bone weights and joint indices.
GltfMeshPrimitiveData()=default
Creates empty primitive data.
RuntimeTexture * colorTexturePtr
bool hasSkinData() const
Checks whether this primitive has skinning data.
uint32_t getColorTextureIndex() const
Gets the glTF color texture index referenced by this primitive.
std::vector< Vertex > vertices
std::vector< Vertex > getVertices() const
Gets the vertices parsed for this primitive.
RuntimeTexture * getColorTexturePtr() const
Gets the pointer to the primitive of the color texture.
GltfMeshPrimitiveData(tinygltf::Model model, tinygltf::Primitive primitive, StaticMeshExtensions meshSettings)
Extracts primitive geometry and material data from tinygltf objects.
std::vector< uint32_t > indices
tinygltf::Primitive primitive
std::vector< BoneVertexData > boneVertexData
Empty for static meshes.
std::vector< uint32_t > getIndices() const
Gets the raw unprocessed list of all indices.
GltfMaterialData materialData
GltfTextureData()=default
Creates an empty texture payload.
bool hasTextureData() const
Checks whether an image payload is stored.
GltfTextureData(const tinygltf::Image &image)
Stores an image payload from tinygltf.
tinygltf::Image getImage() const
Gets the stored tinygltf image.
Resolved vertex attribute and index views for a glTF primitive.
std::optional< GltfBufferDataView > uvDataView
TEXCOORD_0 attribute view when present.
std::optional< GltfBufferDataView > positionDataView
POSITION attribute view when present.
std::optional< GltfBufferDataView > normalDataView
NORMAL attribute view when present.
std::optional< GltfBufferDataView > indexDataView
Primitive index accessor view.
GltfVertexData(const std::vector< tinygltf::Buffer > &buffers, const std::vector< tinygltf::BufferView > &bufferViews, const std::vector< tinygltf::Accessor > &accessors, const tinygltf::Primitive &primitive)
Extracts known attribute views from a primitive.
std::optional< GltfBufferDataView > jointsDataView
JOINTS_0 attribute view when present.
std::optional< GltfBufferDataView > tangentDataView
TANGENT attribute view when present. The xyz values store tangent direction and w stores handedness.
std::optional< GltfBufferDataView > lightmapDataView
TEXCOORD_1 attribute view when present.
std::optional< GltfBufferDataView > weightsDataView
WEIGHTS_0 attribute view when present.
MaterialExtensions()=default
std::optional< VulkanSchneeMaterialExtension > vulkanSchneeMaterialExtension
Parsed Vulkan Schnee material extension when present.
MaterialExtensions(const tinygltf::ExtensionMap &material)
Parses material-level glTF extensions recognized by the engine.
Parses all extensions and extracts recognized extensions.
StaticMeshExtensions(const tinygltf::Model &model, const tinygltf::ExtensionMap &extensions)
Parses mesh or node extensions with access to model-dependent data.
StaticMeshExtensions(const tinygltf::ExtensionMap &extensions)
Parses mesh or node extensions without model-dependent data.
StaticMeshExtensions()=default
std::optional< VulkanSchneeExtension > vulkanSchneeExtension
Parsed Vulkan Schnee engine extension when present.
StaticMeshSettings(const tinygltf::Value &extras)
Parses lightmap settings from a tinygltf extras object.
StaticMeshSettings()=default
Creates settings with lightmaps disabled.
std::filesystem::path lightMapPath
Path to the baked lightmap texture.
bool bUsesLightMaps
True when the mesh uses baked lightmaps.
int lightMapUvIndex
UV channel index used for lightmap sampling.
std::vector< uint32_t > edgeIndices
std::vector< glm::vec3 > vertices
std::vector< uint32_t > indices
CollisionProperties()=default
std::vector< uint32_t > indices
bool hasCollision() const
static ShapeType parseShapeType(const std::string &typeStr)
CollisionProperties(const tinygltf::Value &extension, const tinygltf::Model *model=nullptr)
std::vector< CompoundChild > compoundChildren
std::vector< glm::vec3 > vertices
float angularDiameterDegrees
DirectionalLightProperties(const tinygltf::Value &extension)
bool isLightmapPathValid() const
std::filesystem::path lightmapPath
LightmapProperties(const tinygltf::Value &extension)
std::filesystem::path lightmapKtxPath
const std::filesystem::path & getRuntimeLightmapPath() const
std::optional< LightmapProperties > lightmapProperties
bool getReceiveShadows() const
bool getCastShadows() const
bool getHasLightmaps() const
LightProperties(const tinygltf::Value &extension)
MeshProperties(const tinygltf::Value &extension)
PointLightProperties(const tinygltf::Value &extension)
VulkanSchneeExtension(const tinygltf::Value &vs_extension, const tinygltf::Model *model=nullptr)
VulkanSchneeExtension()=default
std::optional< LightProperties > lightProperties
bool hasPointLightProperties() const
std::optional< DirectionalLightProperties > directionalLightProperties
bool hasCollisionProperties() const
static std::string extractVersion(const tinygltf::Value &vs_extension)
Extracts the version from the material extension.
std::optional< PointLightProperties > pointLightProperties
bool hasLightProperties() const
bool hasMeshProperties() const
bool hasLightmapProperties() const
std::optional< MeshProperties > meshProperties
std::optional< LightProperties::LightmapProperties > lightmapProperties
std::optional< CollisionProperties > collisionProperties
bool hasDirectionalLightProperties() const
ShaderParameter(const tinygltf::Value ¶m)
Extracts all material data from the gltf file. All data during runtime will be read from an object of...
std::map< std::string, tinygltf::Value > customProperties
VulkanSchneeMaterialExtension()=default
VulkanSchneeMaterialExtension(const tinygltf::Value &vs_extension)
std::map< std::string, ShaderParameter > shaderParameters
Rendering::PipelineNames materialName
std::map< std::string, double > nodeProperties