GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::resource::Model Struct Reference

In-memory representation of a 3D model with all of its vertex data directly accessible. More...

#include <GREM/resource/Model.hpp>

Classes

struct  Mesh
 Range of indexed vertices in a model. More...
struct  Texture
 Texture of a material in a model. More...
struct  Material
 Material of a mesh instance in a model. More...
struct  Instance
 Mesh instance in a model. More...
struct  DirectionalLight
 Parameters describing a directional light. More...
struct  PointLight
 Parameters describing a point light. More...
struct  SpotLight
 Parameters describing a spot light. More...
struct  Light
 Light source in a model. More...
struct  PlaneShape
 Parameters describing a plane shape. More...
struct  SphereShape
 Parameters describing a sphere shape. More...
struct  BoxShape
 Parameters describing a box shape. More...
struct  CylinderShape
 Parameters describing a cylinder shape. More...
struct  CapsuleShape
 Parameters describing a capsule shape. More...
struct  Collider
 Collider in a model. More...
struct  PhysicsObject
 Physics object contained in a model. More...
struct  PhysicsJoint
 Physics joint between two physics objects in a model. More...
struct  Joint
 State of a local joint in a pose of a model. More...
struct  AnimationChannel
 Channel of a model animation. More...
struct  Animation
 Animation of a model. More...
struct  AnimationView
 Non-owning read-only view over a set of animation channels and their associated data. More...
struct  AnimationState
 State of an animation affecting a pose. More...
struct  PoseView
 Read-only view over a local pose of a model. More...
struct  PoseReference
 Reference to a local pose of a model. More...
struct  Pose
 Local pose of a model. More...
struct  TransformationView
 Read-only view over a world-space transformation of a model. More...
struct  TransformationReference
 Reference to a world-space transformation of a model. More...
struct  Transformation
 World-space transformation of a model. More...

Public Types

enum  VertexFlag : VertexFlags {
  VERTEX_TEXTURED_ON_CHANNEL_0 = 1 << 0 , VERTEX_TEXTURED_ON_CHANNEL_1 = 1 << 1 , VERTEX_COLORED = 1 << 2 , VERTEX_SKINNED = 1 << 3 ,
  VERTEX_MORPHED_POSITION = 1 << 4 , VERTEX_MORPHED_NORMAL = 1 << 5 , VERTEX_MORPHED_TANGENT = 1 << 6 , VERTEX_MORPHED_TEXTURE_COORDINATES_CHANNEL_0 = 1 << 7 ,
  VERTEX_MORPHED_TEXTURE_COORDINATES_CHANNEL_1 = 1 << 8 , VERTEX_MORPHED_COLOR = 1 << 9
}
 Single flag in a set of VertexFlags, specifying vertex attribute usage. More...
enum  FragmentFlag : FragmentFlags {
  FRAGMENT_ALPHA_MASKED = 1 << 0 , FRAGMENT_ALPHA_BLENDED = 1 << 1 , FRAGMENT_DOUBLE_SIDED = 1 << 2 , FRAGMENT_BASE_COLOR_MAPPED_ON_CHANNEL_0 = 1 << 3 ,
  FRAGMENT_BASE_COLOR_MAPPED_ON_CHANNEL_1 = 1 << 4 , FRAGMENT_METALLIC_ROUGHNESS_MAPPED_ON_CHANNEL_0 = 1 << 5 , FRAGMENT_METALLIC_ROUGHNESS_MAPPED_ON_CHANNEL_1 = 1 << 6 , FRAGMENT_OCCLUSION_MAPPED_ON_CHANNEL_0 = 1 << 7 ,
  FRAGMENT_OCCLUSION_MAPPED_ON_CHANNEL_1 = 1 << 8 , FRAGMENT_NORMAL_MAPPED_ON_CHANNEL_0 = 1 << 9 , FRAGMENT_NORMAL_MAPPED_ON_CHANNEL_1 = 1 << 10 , FRAGMENT_EMISSIVE_MAPPED_ON_CHANNEL_0 = 1 << 11 ,
  FRAGMENT_EMISSIVE_MAPPED_ON_CHANNEL_1 = 1 << 12
}
 Single flag in a set of FragmentFlags, specifying fragment shader usage. More...
enum  InstanceFlag : InstanceFlags { INSTANCE_REVERSE_WINDING_ORDER }
 Single flag in a set of InstanceFlags, specifying information about a model mesh instance. More...
enum class  PrimitiveType : uint8_t {
  POINTS , LINES , LINE_STRIP , TRIANGLES ,
  TRIANGLE_STRIP
}
 Graphical primitive type formed by vertices in a model mesh. More...
enum class  MinificationFilter : uint32_t {
  UNSPECIFIED = 0 , NEAREST = 9728 , LINEAR = 9729 , NEAREST_MIPMAP_NEAREST = 9984 ,
  LINEAR_MIPMAP_NEAREST = 9985 , NEAREST_MIPMAP_LINEAR = 9986 , LINEAR_MIPMAP_LINEAR = 9987
}
 Minification filter of a texture in a model. More...
enum class  MagnificationFilter : uint32_t { UNSPECIFIED = 0 , NEAREST = 9728 , LINEAR = 9729 }
 Magnification filter of a texture in a model. More...
enum class  WrappingMode : uint32_t { REPEAT = 10497 , MIRRORED_REPEAT = 33648 , CLAMP_TO_EDGE = 33071 }
 Wrapping mode of a texture in a model. More...
enum class  MaterialType : uint8_t { METALLIC_ROUGHNESS = 0 , UNLIT = 1 }
 Material type that specifies how the material parameters should be interpreted when shading a mesh instance of a model. More...
enum class  FrictionCombine : uint8_t { AVERAGE = 0 , MINIMUM = 1 , MAXIMUM = 2 , MULTIPLY = 3 }
 Friction combination algorithm. More...
enum class  RestitutionCombine : uint8_t { AVERAGE = 0 , MINIMUM = 1 , MAXIMUM = 2 , MULTIPLY = 3 }
 Restitution combination algorithm. More...
enum class  AnimationPath : uint8_t { JOINT_ROTATION , JOINT_SCALE , JOINT_TRANSLATION , MORPH_TARGET_WEIGHTS }
 Target type of a model animation channel. More...
enum class  InterpolationMode : uint8_t { LINEAR , STEP , CUBIC_SPLINE }
 Interpolation type of a model animation channel. More...
using ValueOffset = uint32_t
 Index of a 4-byte value in a data array of the model.
using IndexCount = uint32_t
 Number of indices in a mesh of the model.
using VertexCount = uint32_t
 Number of vertices in a mesh of the model.
using MorphTargetCount = uint32_t
 Number of morph targets in a mesh of the model.
using KeyframeCount = uint32_t
 Number of keyframes in an animation channel of the model.
using MorphTargetWeightIndex = uint32_t
 Offset of a morph target weight in the model's morph target weight array.
using MorphTargetWeightCount = MorphTargetWeightIndex
 Number of morph target weights in a range within the model's morph target weight array.
using TextureIndex = uint32_t
 Offset of a texture in the model's texture array.
using TextureCount = TextureIndex
 Number of textures in a range within the model's texture array.
using MaterialIndex = uint32_t
 Offset of a material in the model's material array.
using MaterialCount = MaterialIndex
 Number of materials in a range within the model's material array.
using MeshIndex = uint32_t
 Offset of a mesh in the model's mesh array.
using MeshCount = MeshIndex
 Number of meshes in a range within the model's mesh array.
using JointIndex = uint32_t
 Offset of a joint in the model's joint array.
using JointCount = JointIndex
 Number of joints in a range within the model's joint array.
using AnimationChannelIndex = uint32_t
 Offset of an animation channel in the model's animation channel array.
using AnimationChannelCount = AnimationChannelIndex
 Number of animation channels in a range within the model's animation channel array.
using AnimationIndex = uint32_t
 Offset of an animation in the model's animation array.
using AnimationCount = AnimationIndex
 Number of animations in a range within the model's animation array.
using InstanceIndex = uint32_t
 Offset of an instance in the model's instance array.
using InstanceCount = InstanceIndex
 Number of instances in a range within the model's instance array.
using LightIndex = uint32_t
 Offset of a light in the model's light array.
using LightCount = LightIndex
 Number of lights in a range within the model's light array.
using PhysicsObjectIndex = uint32_t
 Offset of a physics object in the model's physics object array.
using PhysicsObjectCount = PhysicsObjectIndex
 Number of physics objects in a range within the model's physics object array.
using PhysicsJointIndex = uint32_t
 Offset of a physics joint in the model's physics joint array.
using PhysicsJointCount = PhysicsJointIndex
 Number of physics joints in a range within the model's physics joint array.
using CollisionLayers = BitArray<MAX_COLLISION_LAYER_COUNT>
 Set of collision layers.
using CollisionLayerIndex = uint8_t
 Index of a collision layer in a set of collision layers.
using VertexFlags = uint16_t
 Set of VertexFlag bits.
using FragmentFlags = uint16_t
 Set of FragmentFlag bits.
using InstanceFlags = uint8_t
 Set of InstanceFlag bits.
using Image = Variant<resource::Image, resource::ImageView>
 Image of a texture in a model.
using ConvexPolytopeShape = SharedPointer<ConvexPolytope<3, float>>
 Parameters describing a convex polytope shape.
using TriangleMeshShape = SharedPointer<TriangleMesh<3, float>>
 Parameters describing a triangle mesh shape.
using Shape = Variant<PlaneShape, SphereShape, BoxShape, CylinderShape, CapsuleShape, ConvexPolytopeShape, TriangleMeshShape>
 Collision shape in a model.
using JointMap = HashMap<String, JointIndex, TransparentHash<StringView>, TransparentEqual<StringView>>
 Map from name strings to joint indices.
using AnimationMap = HashMap<String, AnimationIndex, TransparentHash<StringView>, TransparentEqual<StringView>>
 Map from name strings to animation indices.
using TextureMap = HashMap<String, TextureIndex, TransparentHash<StringView>, TransparentEqual<StringView>>
 Map from name strings to texture indices.
using MaterialMap = HashMap<String, MaterialIndex, TransparentHash<StringView>, TransparentEqual<StringView>>
 Map from name strings to material indices.
using LightMap = HashMap<String, LightIndex, TransparentHash<StringView>, TransparentEqual<StringView>>
 Map from name strings to light indices.
using CollisionLayerMap = HashMap<String, CollisionLayerIndex, TransparentHash<StringView>, TransparentEqual<StringView>>
 Map from name strings to collision layer indices.

Public Member Functions

 Model () noexcept=default
 Construct an empty, invalid model that must not be rendered until manually made valid.
 Model (StridedSpan< const vec3 > positions, StridedSpan< const uint32_t > indices, StridedSpan< const iA2B10G10R10vec4norm > normals={}, StridedSpan< const iA2B10G10R10vec4norm > tangents={}, StridedSpan< const vec2 > textureCoordinatesChannel0={}, StridedSpan< const vec2 > textureCoordinatesChannel1={}, StridedSpan< const u8vec4norm > colors={}, const Optional< Material > &material={})
 Construct a basic single-mesh model from raw mesh data.
 Model (const ConvexPolytope< 3, float > &polytope, const mat4 &transformation=mat4{1.0f})
 Construct an untextured single-mesh model from a convex polytope.
 Model (const Filesystem &filesystem, CStringView filepath, const ModelOptions &options={})
 Load a model from a file.
 Model (const gltf::Asset &asset, FunctionView< Image(CStringView relativeFilepath, const ImageOptions &options)> loadImage, FunctionView< Variant< Allocation< byte >, Span< const byte > >(CStringView relativeFilepath)> loadBufferData, const ModelOptions &options={})
 Construct a model from a loaded glTF asset.
 Model (const obj::Asset &asset, const obj::mtl::Library &materialLibrary, FunctionView< Image(CStringView relativeFilepath, const ImageOptions &options)> loadImage, const ModelOptions &options={})
 Construct a model from a loaded OBJ asset.
void reset () noexcept
 Reset the model to an empty, invalid state that must not be rendered until the model is manually made valid.
void assign (StridedSpan< const vec3 > positions, StridedSpan< const uint32_t > indices, StridedSpan< const iA2B10G10R10vec4norm > normals={}, StridedSpan< const iA2B10G10R10vec4norm > tangents={}, StridedSpan< const vec2 > textureCoordinatesChannel0={}, StridedSpan< const vec2 > textureCoordinatesChannel1={}, StridedSpan< const u8vec4norm > colors={}, const Optional< Material > &material={})
 Assign a basic single-mesh model from raw mesh data.
void assign (const ConvexPolytope< 3, float > &polytope, const mat4 &transformation=mat4{1.0f})
 Assign an untextured single-mesh model from a convex polytope.
void load (const Filesystem &filesystem, CStringView filepath, const ModelOptions &options={})
 Load and assign a model from a file.
void load (const gltf::Asset &asset, FunctionView< Image(CStringView relativeFilepath, const ImageOptions &options)> loadImage, FunctionView< Variant< Allocation< byte >, Span< const byte > >(CStringView relativeFilepath)> loadBufferData, const ModelOptions &options={})
 Assign a model from a loaded glTF asset.
void load (const obj::Asset &asset, const obj::mtl::Library &materialLibrary, FunctionView< Image(CStringView relativeFilepath, const ImageOptions &options)> loadImage, const ModelOptions &options={})
 Assign a model from a loaded OBJ asset.
Optional< AnimationIndex > findAnimationIndex (StringView name) const noexcept
 Find the index of an animation with a specific name.
AnimationIndex getAnimationIndex (StringView name) const
 Get the index of an animation with a specific name.
AnimationView getAnimationAtIndex (AnimationIndex index) const
 Get the animation at a specific index.
AnimationView getAnimation (StringView name) const
 Get the animation with a specific name.
Optional< AnimationView > findAnimation (StringView name) const noexcept
 Try to get the animation with a specific name.
Optional< JointIndex > findJointIndex (StringView name) const noexcept
 Find the index of a joint with a specific name.
JointIndex getJointIndex (StringView name) const
 Get the index of a joint with a specific name.
Optional< JointIndex > findSkinRootJointIndex (StringView name) const noexcept
 Find the index of the root joint of a skin with a specific name.
JointIndex getSkinRootJointIndex (StringView name) const
 Get the index of the root joint of a skin with a specific name.
Optional< TextureIndex > findTextureIndex (StringView name) const noexcept
 Find the index of a texture with a specific name.
TextureIndex getTextureIndex (StringView name) const
 Get the index of a texture with a specific name.
Optional< MaterialIndex > findMaterialIndex (StringView name) const noexcept
 Find the index of a material with a specific name.
MaterialIndex getMaterialIndex (StringView name) const
 Get the index of a material with a specific name.
Optional< LightIndex > findLightIndex (StringView name) const noexcept
 Find the index of a light with a specific name.
LightIndex getLightIndex (StringView name) const
 Get the index of a light with a specific name.
Optional< CollisionLayerIndex > findCollisionLayerIndex (StringView name) const noexcept
 Find the index of a collision layer with a specific name.
CollisionLayerIndex getCollisionLayerIndex (StringView name) const
 Get the index of a collision layer with a specific name.

Static Public Member Functions

static void generateTriangleNormals (StridedSpan< byte > normalData, StridedSpan< const vec3 > positions, StridedSpan< const uint32_t > indices)
 Generate normal vectors for each vertex in a set of triangles.
static void generateTriangleNormals (Span< byte > normalData, StridedSpan< const vec3 > positions, StridedSpan< const uint32_t > indices)
 Generate normal vectors for each vertex in a set of triangles.
static void generateTriangleNormals (StridedSpan< iA2B10G10R10vec4norm > normals, StridedSpan< const vec3 > positions, StridedSpan< const uint32_t > indices)
 Generate normal vectors for each vertex in a set of triangles.
static void generateTriangleTangents (StridedSpan< byte > tangentData, StridedSpan< const vec3 > positions, StridedSpan< const iA2B10G10R10vec4norm > normals, StridedSpan< const vec2 > textureCoordinates, StridedSpan< const uint32_t > indices)
 Generate tangent vectors for each vertex in a set of triangles.
static void generateTriangleTangents (Span< byte > tangentData, StridedSpan< const vec3 > positions, StridedSpan< const iA2B10G10R10vec4norm > normals, StridedSpan< const vec2 > textureCoordinates, StridedSpan< const uint32_t > indices)
 Generate tangent vectors for each vertex in a set of triangles.
static void generateTriangleTangents (StridedSpan< iA2B10G10R10vec4norm > tangents, StridedSpan< const vec3 > positions, StridedSpan< const iA2B10G10R10vec4norm > normals, StridedSpan< const vec2 > textureCoordinates, Span< const uint32_t > indices)
 Generate tangent vectors for each vertex in a set of triangles.
static ModelFileType determineFileType (Span< const byte > fileContents) noexcept
 Determine which model file type a file should be parsed as based on the contents at the beginning of the file.

Public Attributes

Buffer< byte > meshData {}
 Mesh data of the model. Indexed by meshes.
Buffer< byte > morphTargetData {}
 Morph target data of the model. Indexed by meshes.
Buffer< byte > skinData {}
 Skin data of the model. Indexed by instances.
ArrayList< Mesh > meshes {}
 Layout of mesh data in the model. Indexed by instances.
Pose bindPose {}
 Initial bind pose of the model. Indexed by instances, lights, physicsObjects, jointMap and skinMap.
ArrayList< JointIndex > jointParentIndices {}
 Indices of the parent joint of each joint of the model.
ArrayList< Optional< Collider > > jointColliders {}
 Colliders of each joint in the model.
ArrayList< PhysicsObjectIndex > jointPhysicsObjectIndices {}
 Indices of the physics object that each joint in the model belongs to, or the maximum value if none.
JointCount staticJointCount = 0
 Number of unskinned joints at the beginning of the joint array.
ArrayList< Animation > animations {}
 Animations of the model. Indexed by animationMap.
ArrayList< AnimationChannel > animationChannels {}
 Animation channels of the model. Indexed by animations.
ArrayList< float > keyframeInputTimePoints {}
 Keyframe input time points of animation channels. Indexed by animationChannels.
Buffer< byte > keyframeOutputValueData {}
 Keyframe output value data of animation channels. Indexed by animationChannels.
ArrayList< Texture > textures {}
 Textures of the model. Indexed by materials and textureMap.
ArrayList< Material > materials {}
 Materials of the model. Indexed by instances and materialMap.
ArrayList< Instance > instances {}
 Mesh instances of the model.
ArrayList< Light > lights {}
 Lights in the model. Indexed by lightMap.
ArrayList< PhysicsObject > physicsObjects {}
 Physics objects in the model. Indexed by physicsJoints and jointPhysicsObjectIndices.
ArrayList< PhysicsJoint > physicsJoints {}
 Physics joints in the model.
Box< 3, float > bindPoseBoundingBox {}
 Local axis-aligned bounding box of all meshes' vertex positions in the initial bind pose.
float bindPoseBoundingRadius = 0.0f
 Maximum distance from the origin of all meshes' vertex positions in the initial bind pose.
JointMap jointMap {}
 Map from joint names to their index in the joint array.
JointMap skinMap {}
 Map from skin names to the index of their root joint in the joint array.
AnimationMap animationMap {}
 Map from animation names to their index in the animation array.
TextureMap textureMap {}
 Map from texture names to their index in the texture array.
MaterialMap materialMap {}
 Map from material names to their index in the material array.
LightMap lightMap {}
 Map from light names to their index in the light array.
CollisionLayerMap collisionLayerMap {}
 Map from collision layer names to their index in a collision layer set.

Static Public Attributes

static constexpr size_t MAX_COLLISION_LAYER_COUNT = 32
 Maximum number of collision layers in a model.

Detailed Description

In-memory representation of a 3D model with all of its vertex data directly accessible.

Member Typedef Documentation

◆ ValueOffset

Index of a 4-byte value in a data array of the model.

◆ IndexCount

Number of indices in a mesh of the model.

◆ VertexCount

Number of vertices in a mesh of the model.

◆ MorphTargetCount

Number of morph targets in a mesh of the model.

◆ KeyframeCount

Number of keyframes in an animation channel of the model.

◆ MorphTargetWeightIndex

Offset of a morph target weight in the model's morph target weight array.

◆ MorphTargetWeightCount

Number of morph target weights in a range within the model's morph target weight array.

◆ TextureIndex

Offset of a texture in the model's texture array.

◆ TextureCount

Number of textures in a range within the model's texture array.

◆ MaterialIndex

Offset of a material in the model's material array.

◆ MaterialCount

Number of materials in a range within the model's material array.

◆ MeshIndex

Offset of a mesh in the model's mesh array.

◆ MeshCount

Number of meshes in a range within the model's mesh array.

◆ JointIndex

Offset of a joint in the model's joint array.

◆ JointCount

Number of joints in a range within the model's joint array.

◆ AnimationChannelIndex

Offset of an animation channel in the model's animation channel array.

◆ AnimationChannelCount

Number of animation channels in a range within the model's animation channel array.

◆ AnimationIndex

Offset of an animation in the model's animation array.

◆ AnimationCount

Number of animations in a range within the model's animation array.

◆ InstanceIndex

Offset of an instance in the model's instance array.

◆ InstanceCount

Number of instances in a range within the model's instance array.

◆ LightIndex

Offset of a light in the model's light array.

◆ LightCount

Number of lights in a range within the model's light array.

◆ PhysicsObjectIndex

Offset of a physics object in the model's physics object array.

◆ PhysicsObjectCount

Number of physics objects in a range within the model's physics object array.

◆ PhysicsJointIndex

Offset of a physics joint in the model's physics joint array.

◆ PhysicsJointCount

Number of physics joints in a range within the model's physics joint array.

◆ CollisionLayers

◆ CollisionLayerIndex

Index of a collision layer in a set of collision layers.

◆ VertexFlags

Set of VertexFlag bits.

◆ FragmentFlags

Set of FragmentFlag bits.

◆ InstanceFlags

Set of InstanceFlag bits.

◆ Image

◆ ConvexPolytopeShape

Parameters describing a convex polytope shape.

◆ TriangleMeshShape

Parameters describing a triangle mesh shape.

◆ Shape

◆ JointMap

◆ AnimationMap

◆ TextureMap

◆ MaterialMap

◆ LightMap

◆ CollisionLayerMap

Member Enumeration Documentation

◆ VertexFlag

Single flag in a set of VertexFlags, specifying vertex attribute usage.

Enumerator
VERTEX_TEXTURED_ON_CHANNEL_0 

Texture coordinate channel 0 is used to sample materials.

VERTEX_TEXTURED_ON_CHANNEL_1 

Texture coordinate channel 1 is used to sample materials.

VERTEX_COLORED 

The vertex color component is used to tint the fragment color.

VERTEX_SKINNED 

The vertex joint components are used to skin the vertex over the model joints.

VERTEX_MORPHED_POSITION 

The vertex position is morphed against the morph targets of the model using provided weights.

VERTEX_MORPHED_NORMAL 

The vertex normal is morphed against the morph targets of the model using provided weights.

VERTEX_MORPHED_TANGENT 

The vertex tangent is morphed against the morph targets of the model using provided weights.

VERTEX_MORPHED_TEXTURE_COORDINATES_CHANNEL_0 

Texture coordinate channel 0 is morphed against the morph targets of the model using provided weights.

VERTEX_MORPHED_TEXTURE_COORDINATES_CHANNEL_1 

Texture coordinate channel 1 is morphed against the morph targets of the model using provided weights.

VERTEX_MORPHED_COLOR 

The vertex color is morphed against the morph targets of the model using provided weights.

◆ FragmentFlag

Single flag in a set of FragmentFlags, specifying fragment shader usage.

Enumerator
FRAGMENT_ALPHA_MASKED 

Fragments with alpha less than the alpha cutoff are discarded.

FRAGMENT_ALPHA_BLENDED 

Fragments are alpha blended.

FRAGMENT_DOUBLE_SIDED 

Fragments are double-sided.

FRAGMENT_BASE_COLOR_MAPPED_ON_CHANNEL_0 

The base color map is sampled using texture coordinate channel 0.

FRAGMENT_BASE_COLOR_MAPPED_ON_CHANNEL_1 

The base color map is sampled using texture coordinate channel 1.

FRAGMENT_METALLIC_ROUGHNESS_MAPPED_ON_CHANNEL_0 

The metallic/roughness map is sampled using texture coordinate channel 0.

FRAGMENT_METALLIC_ROUGHNESS_MAPPED_ON_CHANNEL_1 

The metallic/roughness map is sampled using texture coordinate channel 1.

FRAGMENT_OCCLUSION_MAPPED_ON_CHANNEL_0 

The occlusion map is sampled using texture coordinate channel 0.

FRAGMENT_OCCLUSION_MAPPED_ON_CHANNEL_1 

The occlusion map is sampled using texture coordinate channel 1.

FRAGMENT_NORMAL_MAPPED_ON_CHANNEL_0 

The normal map is sampled using texture coordinate channel 0.

FRAGMENT_NORMAL_MAPPED_ON_CHANNEL_1 

The normal map is sampled using texture coordinate channel 1.

FRAGMENT_EMISSIVE_MAPPED_ON_CHANNEL_0 

The emissive map is sampled using texture coordinate channel 0.

FRAGMENT_EMISSIVE_MAPPED_ON_CHANNEL_1 

The emissive map is sampled using texture coordinate channel 1.

◆ InstanceFlag

Single flag in a set of InstanceFlags, specifying information about a model mesh instance.

Enumerator
INSTANCE_REVERSE_WINDING_ORDER 

Consider mesh faces with clockwise winding order as front-facing for this instance.

◆ PrimitiveType

enum class grem::resource::Model::PrimitiveType : uint8_t
strong

Graphical primitive type formed by vertices in a model mesh.

Enumerator
POINTS 

Individual points.

LINES 

Each consecutive pair of points forms an individual line segment.

LINE_STRIP 

Each point, except the first, forms a line segment to the previous point.

TRIANGLES 

Each consecutive triple of points forms an individual filled triangle.

TRIANGLE_STRIP 

Each point, except the first two, forms a filled triangle with the previous two points.

◆ MinificationFilter

enum class grem::resource::Model::MinificationFilter : uint32_t
strong

Minification filter of a texture in a model.

Enumerator
UNSPECIFIED 

Unspecified filter.

NEAREST 

Nearest-neighbor filtering without mipmapping.

LINEAR 

Linear filtering without mipmapping.

NEAREST_MIPMAP_NEAREST 

Nearest-neighbor filtering from the nearest mip level.

LINEAR_MIPMAP_NEAREST 

Linear filtering from the nearest mip level.

NEAREST_MIPMAP_LINEAR 

Nearest-neighbor filtering linearly interpolated between mip levels.

LINEAR_MIPMAP_LINEAR 

Linear filtering linearly interpoated between mip levels.

◆ MagnificationFilter

enum class grem::resource::Model::MagnificationFilter : uint32_t
strong

Magnification filter of a texture in a model.

Enumerator
UNSPECIFIED 

Unspecified filter.

NEAREST 

Nearest-neighbor filtering.

LINEAR 

Linear filtering.

◆ WrappingMode

enum class grem::resource::Model::WrappingMode : uint32_t
strong

Wrapping mode of a texture in a model.

Enumerator
REPEAT 

Wrap the texture coordinates.

MIRRORED_REPEAT 

Mirror the texture coordinates.

CLAMP_TO_EDGE 

Clamp the texture coordinates.

◆ MaterialType

enum class grem::resource::Model::MaterialType : uint8_t
strong

Material type that specifies how the material parameters should be interpreted when shading a mesh instance of a model.

Enumerator
METALLIC_ROUGHNESS 

The shader should interpret the material according to the standard metallic-roughness model.

UNLIT 

The shader should use only the base color at full brightness.

◆ FrictionCombine

enum class grem::resource::Model::FrictionCombine : uint8_t
strong

Friction combination algorithm.

When two objects collide, the friction combination algorithm with the lowest value of the two should be used.

Enumerator
AVERAGE 

The two values should be averaged.

MINIMUM 

The smallest of the two values should be used.

MAXIMUM 

The largest of the two values should be used.

MULTIPLY 

The two values should be multiplied with each other.

◆ RestitutionCombine

enum class grem::resource::Model::RestitutionCombine : uint8_t
strong

Restitution combination algorithm.

When two objects collide, the restitution combination algorithm with the lowest value of the two should be used.

Enumerator
AVERAGE 

The two values should be averaged.

MINIMUM 

The smallest of the two values should be used.

MAXIMUM 

The largest of the two values should be used.

MULTIPLY 

The two values should be multiplied with each other.

◆ AnimationPath

enum class grem::resource::Model::AnimationPath : uint8_t
strong

Target type of a model animation channel.

Enumerator
JOINT_ROTATION 

The animation targets the rotation of a local joint.

JOINT_SCALE 

The animation targets the scale of a local joint.

JOINT_TRANSLATION 

The animation targets the translation of a local joint.

MORPH_TARGET_WEIGHTS 

The animation targets the morph target weights of the model.

◆ InterpolationMode

enum class grem::resource::Model::InterpolationMode : uint8_t
strong

Interpolation type of a model animation channel.

Enumerator
LINEAR 

Linear interpolation.

STEP 

Discrete steps without interpolation.

CUBIC_SPLINE 

Cubic spline interpolation.

Constructor & Destructor Documentation

◆ Model() [1/6]

grem::resource::Model::Model ( )
defaultnoexcept

Construct an empty, invalid model that must not be rendered until manually made valid.

Warning
Only use this constructor if you intend to reassign the model or fill out all of its fields manually before use, such as if loading from a custom file format.

◆ Model() [2/6]

grem::resource::Model::Model ( StridedSpan< const vec3 > positions,
StridedSpan< const uint32_t > indices,
StridedSpan< const iA2B10G10R10vec4norm > normals = {},
StridedSpan< const iA2B10G10R10vec4norm > tangents = {},
StridedSpan< const vec2 > textureCoordinatesChannel0 = {},
StridedSpan< const vec2 > textureCoordinatesChannel1 = {},
StridedSpan< const u8vec4norm > colors = {},
const Optional< Material > & material = {} )

Construct a basic single-mesh model from raw mesh data.

Parameters
positionsvertex positions of the mesh.
indicestriangle vertex indices of the mesh. Must have a size that is divisible by 3. Each index must be less than positions.size().
normalsnormals of the vertices. Must either be empty or have the same size as positions. If empty, normals will be generated automatically.
tangentstangents of the vertices. Must either be empty or have the same size as positions. If empty, tangents will be generated automatically.
textureCoordinatesChannel0channel 0 texture coordinates of the vertices. Must either be empty or have the same size as positions.
textureCoordinatesChannel1channel 1 texture coordinates of the vertices. Must either be empty or have the same size as positions.
colorscolors of the vertices. Must either be empty or have the same size as positions.
materialmaterial of the mesh, or an empty optional to use the default material. If specified, its fragment flags must be valid for the given combination of texture coordinate channels.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ Model() [3/6]

grem::resource::Model::Model ( const ConvexPolytope< 3, float > & polytope,
const mat4 & transformation = mat4{1.0f} )

Construct an untextured single-mesh model from a convex polytope.

Parameters
polytopeconvex polytope to model.
transformationtransformation to apply to each of the polytope vertices in the new model.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ Model() [4/6]

grem::resource::Model::Model ( const Filesystem & filesystem,
CStringView filepath,
const ModelOptions & options = {} )

Load a model from a file.

The supported file formats are:

  • glTF 2.0 (.gltf)
  • Binary glTF 2.0 (.glb)
  • Wavefront OBJ (.obj)
Parameters
filesystemfilepath to load the files from.
filepathinput filepath of the model file to load.
optionsmodel options, see ModelOptions.
Exceptions
File::Erroron failure to open a file.
resource::Erroron failure to load a valid model.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
Note
The file format is determined entirely from the file contents; the filename extension is not taken into account.
Any material libraries, data files and texture image files required by the model are also loaded as needed. See the documentation of Image for a description of the supported image file formats.
Remarks
When authoring models, the glTF format should generally be preferred over OBJ, since glTF is more memory efficient, faster to load, properly standardized and supports features such as PBR materials and animation.

◆ Model() [5/6]

grem::resource::Model::Model ( const gltf::Asset & asset,
FunctionView< Image(CStringView relativeFilepath, const ImageOptions &options)> loadImage,
FunctionView< Variant< Allocation< byte >, Span< const byte > >(CStringView relativeFilepath)> loadBufferData,
const ModelOptions & options = {} )

Construct a model from a loaded glTF asset.

Parameters
assetglTF asset to construct the model from.
loadImagefunction to use to load the images required by the asset given their relative filepaths and image options.
loadBufferDatafunction to use to load the buffer contents required by the asset given their relative filepaths.
optionsmodel options, see ModelOptions.
Exceptions
resource::Erroron failure to load a valid model.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
anyexception thrown by the loadImage callback.
anyexception thrown by the loadBufferData callback.

◆ Model() [6/6]

grem::resource::Model::Model ( const obj::Asset & asset,
const obj::mtl::Library & materialLibrary,
FunctionView< Image(CStringView relativeFilepath, const ImageOptions &options)> loadImage,
const ModelOptions & options = {} )

Construct a model from a loaded OBJ asset.

Parameters
assetOBJ asset to construct the model from.
materialLibrarymaterial library to get materials from, which should contain the materials loaded from the files specified by obj::Asset::materialLibraryFilenames.
loadImagefunction to use to load the images required by the materials in the asset given their relative filepaths and image options.
optionsmodel options, see ModelOptions.
Exceptions
resource::Erroron failure to load a valid model.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
anyexception thrown by the loadImage callback.

Member Function Documentation

◆ generateTriangleNormals() [1/3]

void grem::resource::Model::generateTriangleNormals ( StridedSpan< byte > normalData,
StridedSpan< const vec3 > positions,
StridedSpan< const uint32_t > indices )
static

Generate normal vectors for each vertex in a set of triangles.

Parameters
normalDatastrided view of the byte offsets at which to write the generated normal vectors. Must have the same size as positions, and a stride that is greater than or equal to the size of a iA2B10G10R10vec4norm.
positionspositions of the vertices to generate normals for.
indicesoptional vertex indices.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
Note
If the number of indices is 0, each 3 consecutive vertices form a triangle. Otherwise, each 3 consecutive indices specify 3 vertices that form a triangle. The triangles are specified in counter-clockwise winding order.
Warning
If the number of indices is 0, the number of vertex positions must be divisible by 3. Otherwise, the number of indices must be divisible by 3.
Each given index must be in-range, i.e. have a value that is less than the number of vertex positions.

◆ generateTriangleNormals() [2/3]

void grem::resource::Model::generateTriangleNormals ( Span< byte > normalData,
StridedSpan< const vec3 > positions,
StridedSpan< const uint32_t > indices )
inlinestatic

Generate normal vectors for each vertex in a set of triangles.

Parameters
normalDataview over the memory to write the generated normal vectors to. Must have the same size as positions times the size of a iA2B10G10R10vec4norm.
positionspositions of the vertices to generate normals for.
indicesoptional vertex indices.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
Note
If the number of indices is 0, each 3 consecutive vertices form a triangle. Otherwise, each 3 consecutive indices specify 3 vertices that form a triangle. The triangles are specified in counter-clockwise winding order.
Warning
If the number of indices is 0, the number of vertex positions must be divisible by 3. Otherwise, the number of indices must be divisible by 3.
Each given index must be in-range, i.e. have a value that is less than the number of vertex positions.

◆ generateTriangleNormals() [3/3]

void grem::resource::Model::generateTriangleNormals ( StridedSpan< iA2B10G10R10vec4norm > normals,
StridedSpan< const vec3 > positions,
StridedSpan< const uint32_t > indices )
inlinestatic

Generate normal vectors for each vertex in a set of triangles.

Parameters
normalsnormal vectors to generate the values of. Must have the same size as positions.
positionspositions of the vertices to generate normals for.
indicesoptional vertex indices.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
Note
If the number of indices is 0, each 3 consecutive vertices form a triangle. Otherwise, each 3 consecutive indices specify 3 vertices that form a triangle. The triangles are specified in counter-clockwise winding order.
Warning
If the number of indices is 0, the number of vertex positions must be divisible by 3. Otherwise, the number of indices must be divisible by 3.
Each given index must be in-range, i.e. have a value that is less than the number of vertex positions.

◆ generateTriangleTangents() [1/3]

void grem::resource::Model::generateTriangleTangents ( StridedSpan< byte > tangentData,
StridedSpan< const vec3 > positions,
StridedSpan< const iA2B10G10R10vec4norm > normals,
StridedSpan< const vec2 > textureCoordinates,
StridedSpan< const uint32_t > indices )
static

Generate tangent vectors for each vertex in a set of triangles.

Parameters
tangentDatastrided view of the byte offsets at which to write the generated tangent vectors. Must have the same size as positions, and a stride that is greater than or equal to the size of a iA2B10G10R10vec4norm.
positionspositions of the vertices to generate tangents for.
normalsnormal vectors of the vertices to generate tangents for. Must have the same size as positions.
textureCoordinatesoptional texture coordinates of the vertices to generate tangents for, which help guide the generated tangent directions. Must either be empty or have the same size as positions.
indicesoptional vertex indices.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
Note
If the number of indices is 0, each 3 consecutive vertices form a triangle. Otherwise, each 3 consecutive indices specify 3 vertices that form a triangle. The triangles are specified in counter-clockwise winding order.
Warning
If the number of indices is 0, the number of vertex positions must be divisible by 3. Otherwise, the number of indices must be divisible by 3.
Each given index must be in-range, i.e. have a value that is less than the number of vertex positions.

◆ generateTriangleTangents() [2/3]

void grem::resource::Model::generateTriangleTangents ( Span< byte > tangentData,
StridedSpan< const vec3 > positions,
StridedSpan< const iA2B10G10R10vec4norm > normals,
StridedSpan< const vec2 > textureCoordinates,
StridedSpan< const uint32_t > indices )
inlinestatic

Generate tangent vectors for each vertex in a set of triangles.

Parameters
tangentDataview over the memory to write the generated tangent vectors to. Must have the same size as positions times the size of a iA2B10G10R10vec4norm.
positionspositions of the vertices to generate tangents for.
normalsnormal vectors of the vertices to generate tangents for. Must have the same size as positions.
textureCoordinatesoptional texture coordinates of the vertices to generate tangents for, which help guide the generated tangent directions. Must either be empty or have the same size as positions.
indicesoptional vertex indices.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
Note
If the number of indices is 0, each 3 consecutive vertices form a triangle. Otherwise, each 3 consecutive indices specify 3 vertices that form a triangle. The triangles are specified in counter-clockwise winding order.
Warning
If the number of indices is 0, the number of vertex positions must be divisible by 3. Otherwise, the number of indices must be divisible by 3.
Each given index must be in-range, i.e. have a value that is less than the number of vertex positions.

◆ generateTriangleTangents() [3/3]

void grem::resource::Model::generateTriangleTangents ( StridedSpan< iA2B10G10R10vec4norm > tangents,
StridedSpan< const vec3 > positions,
StridedSpan< const iA2B10G10R10vec4norm > normals,
StridedSpan< const vec2 > textureCoordinates,
Span< const uint32_t > indices )
inlinestatic

Generate tangent vectors for each vertex in a set of triangles.

Parameters
tangentstangent vectors to generate the values of. Must have the same size as positions.
positionspositions of the vertices to generate tangents for.
normalsnormal vectors of the vertices to generate tangents for. Must have the same size as positions.
textureCoordinatesoptional texture coordinates of the vertices to generate tangents for, which help guide the generated tangent directions. Must either be empty or have the same size as positions.
indicesoptional vertex indices.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
Note
If the number of indices is 0, each 3 consecutive vertices form a triangle. Otherwise, each 3 consecutive indices specify 3 vertices that form a triangle. The triangles are specified in counter-clockwise winding order.
Warning
If the number of indices is 0, the number of vertex positions must be divisible by 3. Otherwise, the number of indices must be divisible by 3.
Each given index must be in-range, i.e. have a value that is less than the number of vertex positions.

◆ determineFileType()

ModelFileType grem::resource::Model::determineFileType ( Span< const byte > fileContents)
staticnodiscardnoexcept

Determine which model file type a file should be parsed as based on the contents at the beginning of the file.

Parameters
fileContentsfile contents to be parsed.
Returns
the determined model file type, or ModelFileType::UNKNOWN if a type could not be determined.

◆ reset()

void grem::resource::Model::reset ( )
inlinenoexcept

Reset the model to an empty, invalid state that must not be rendered until the model is manually made valid.

Warning
Only use this function if you intend to reassign the model or fill out all of its fields manually before use, such as if loading from a custom file format.

◆ assign() [1/2]

void grem::resource::Model::assign ( StridedSpan< const vec3 > positions,
StridedSpan< const uint32_t > indices,
StridedSpan< const iA2B10G10R10vec4norm > normals = {},
StridedSpan< const iA2B10G10R10vec4norm > tangents = {},
StridedSpan< const vec2 > textureCoordinatesChannel0 = {},
StridedSpan< const vec2 > textureCoordinatesChannel1 = {},
StridedSpan< const u8vec4norm > colors = {},
const Optional< Material > & material = {} )

Assign a basic single-mesh model from raw mesh data.

Parameters
positionsvertex positions of the mesh.
indicestriangle vertex indices of the mesh. Must have a size that is divisible by 3. Each index must be less than positions.size().
normalsnormals of the vertices. Must either be empty or have the same size as positions. If empty, normals will be generated automatically.
tangentstangents of the vertices. Must either be empty or have the same size as positions. If empty, tangents will be generated automatically.
textureCoordinatesChannel0channel 0 texture coordinates of the vertices. Must either be empty or have the same size as positions.
textureCoordinatesChannel1channel 1 texture coordinates of the vertices. Must either be empty or have the same size as positions.
colorscolors of the vertices. Must either be empty or have the same size as positions.
materialmaterial of the mesh, or an empty optional to use the default material. If specified, its fragment flags must be valid for the given combination of texture coordinate channels.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ assign() [2/2]

void grem::resource::Model::assign ( const ConvexPolytope< 3, float > & polytope,
const mat4 & transformation = mat4{1.0f} )

Assign an untextured single-mesh model from a convex polytope.

Parameters
polytopeconvex polytope to model.
transformationtransformation to apply to each of the polytope vertices in the new model.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ load() [1/3]

void grem::resource::Model::load ( const Filesystem & filesystem,
CStringView filepath,
const ModelOptions & options = {} )

Load and assign a model from a file.

The supported file formats are:

  • glTF 2.0 (.gltf)
  • Binary glTF 2.0 (.glb)
  • Wavefront OBJ (.obj)
Parameters
filesystemfilepath to load the files from.
filepathinput filepath of the model file to load.
optionsmodel options, see ModelOptions.
Exceptions
File::Erroron failure to open a file.
resource::Erroron failure to load a valid model.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
Note
The file format is determined entirely from the file contents; the filename extension is not taken into account.
Any material libraries, data files and texture image files required by the model are also loaded as needed. See the documentation of Image for a description of the supported image file formats.
Remarks
When authoring models, the glTF format should generally be preferred over OBJ, since glTF is more memory efficient, faster to load, properly standardized and supports features such as PBR materials and animation.

◆ load() [2/3]

void grem::resource::Model::load ( const gltf::Asset & asset,
FunctionView< Image(CStringView relativeFilepath, const ImageOptions &options)> loadImage,
FunctionView< Variant< Allocation< byte >, Span< const byte > >(CStringView relativeFilepath)> loadBufferData,
const ModelOptions & options = {} )

Assign a model from a loaded glTF asset.

Parameters
assetglTF asset to assign the model from.
loadImagefunction to use to load the images required by the asset given their relative filepaths and image options.
loadBufferDatafunction to use to load the buffer contents required by the asset given their relative filepaths.
optionsmodel options, see ModelOptions.
Exceptions
resource::Erroron failure to load a valid model.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
anyexception thrown by the loadImage callback.
anyexception thrown by the loadBufferData callback.

◆ load() [3/3]

void grem::resource::Model::load ( const obj::Asset & asset,
const obj::mtl::Library & materialLibrary,
FunctionView< Image(CStringView relativeFilepath, const ImageOptions &options)> loadImage,
const ModelOptions & options = {} )

Assign a model from a loaded OBJ asset.

Parameters
assetOBJ asset to assign the model from.
materialLibrarymaterial library to get materials from, which should contain the materials loaded from the files specified by obj::Asset::materialLibraryFilenames.
loadImagefunction to use to load the images required by the materials in the asset given their relative filepaths and image options.
optionsmodel options, see ModelOptions.
Exceptions
resource::Erroron failure to load a valid model.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
anyexception thrown by the loadImage callback.

◆ findAnimationIndex()

Optional< AnimationIndex > grem::resource::Model::findAnimationIndex ( StringView name) const
inlinenodiscardnoexcept

Find the index of an animation with a specific name.

Parameters
namename of the animation to search for.
Returns
the index of the given animation in the model's animation array, or an empty optional if the animation wasn't found.

◆ getAnimationIndex()

AnimationIndex grem::resource::Model::getAnimationIndex ( StringView name) const
inlinenodiscard

Get the index of an animation with a specific name.

Parameters
namename of the animation to search for.
Returns
the index of the given animation in the model's animation array.
Exceptions
std::out_of_rangeif the given animation wasn't found.

◆ getAnimationAtIndex()

AnimationView grem::resource::Model::getAnimationAtIndex ( AnimationIndex index) const
inlinenodiscard

Get the animation at a specific index.

Parameters
indexindex of the animation to get.
Returns
a non-owning read-only view over the given animation.
Exceptions
std::out_of_rangeif the given index is out of range.

◆ getAnimation()

AnimationView grem::resource::Model::getAnimation ( StringView name) const
inlinenodiscard

Get the animation with a specific name.

Parameters
namename of the animation to search for.
Returns
a non-owning read-only view over the given animation.
Exceptions
std::out_of_rangeif the animation wasn't found.

◆ findAnimation()

Optional< AnimationView > grem::resource::Model::findAnimation ( StringView name) const
inlinenodiscardnoexcept

Try to get the animation with a specific name.

Parameters
namename of the animation to search for.
Returns
a non-owning read-only view over the given animation, or an empty optional if the animation wasn't found.

◆ findJointIndex()

Optional< JointIndex > grem::resource::Model::findJointIndex ( StringView name) const
inlinenodiscardnoexcept

Find the index of a joint with a specific name.

Parameters
namename of the joint to search for.
Returns
the index of the given joint in the model's joint array, or an empty optional if the joint wasn't found.

◆ getJointIndex()

JointIndex grem::resource::Model::getJointIndex ( StringView name) const
inlinenodiscard

Get the index of a joint with a specific name.

Parameters
namename of the joint to search for.
Returns
the index of the given joint in the model's joint array.
Exceptions
std::out_of_rangeif the given joint wasn't found.

◆ findSkinRootJointIndex()

Optional< JointIndex > grem::resource::Model::findSkinRootJointIndex ( StringView name) const
inlinenodiscardnoexcept

Find the index of the root joint of a skin with a specific name.

Parameters
namename of the skin whose root joint to search for.
Returns
the index of the root joint of the given skin in the model's joint array, or an empty optional if the skin wasn't found.

◆ getSkinRootJointIndex()

JointIndex grem::resource::Model::getSkinRootJointIndex ( StringView name) const
inlinenodiscard

Get the index of the root joint of a skin with a specific name.

Parameters
namename of the skin whose root joint to search for.
Returns
the index of the root joint of the given skin in the model's joint array.
Exceptions
std::out_of_rangeif the given skin wasn't found.

◆ findTextureIndex()

Optional< TextureIndex > grem::resource::Model::findTextureIndex ( StringView name) const
inlinenodiscardnoexcept

Find the index of a texture with a specific name.

Parameters
namename of the texture to search for.
Returns
the index of the given texture in the model's texture array, or an empty optional if the texture wasn't found.

◆ getTextureIndex()

TextureIndex grem::resource::Model::getTextureIndex ( StringView name) const
inlinenodiscard

Get the index of a texture with a specific name.

Parameters
namename of the texture to search for.
Returns
the index of the given texture in the model's texture array.
Exceptions
std::out_of_rangeif the given texture wasn't found.

◆ findMaterialIndex()

Optional< MaterialIndex > grem::resource::Model::findMaterialIndex ( StringView name) const
inlinenodiscardnoexcept

Find the index of a material with a specific name.

Parameters
namename of the material to search for.
Returns
the index of the given material in the model's material array, or an empty optional if the material wasn't found.

◆ getMaterialIndex()

MaterialIndex grem::resource::Model::getMaterialIndex ( StringView name) const
inlinenodiscard

Get the index of a material with a specific name.

Parameters
namename of the material to search for.
Returns
the index of the given material in the model's material array.
Exceptions
std::out_of_rangeif the given material wasn't found.

◆ findLightIndex()

Optional< LightIndex > grem::resource::Model::findLightIndex ( StringView name) const
inlinenodiscardnoexcept

Find the index of a light with a specific name.

Parameters
namename of the light to search for.
Returns
the index of the given light in the model's light array, or an empty optional if the light wasn't found.

◆ getLightIndex()

LightIndex grem::resource::Model::getLightIndex ( StringView name) const
inlinenodiscard

Get the index of a light with a specific name.

Parameters
namename of the light to search for.
Returns
the index of the given light in the model's light array.
Exceptions
std::out_of_rangeif the given light wasn't found.

◆ findCollisionLayerIndex()

Optional< CollisionLayerIndex > grem::resource::Model::findCollisionLayerIndex ( StringView name) const
inlinenodiscardnoexcept

Find the index of a collision layer with a specific name.

Parameters
namename of the collision layer to search for.
Returns
the index of the given collision layer, or an empty optional if the collision layer wasn't found.

◆ getCollisionLayerIndex()

CollisionLayerIndex grem::resource::Model::getCollisionLayerIndex ( StringView name) const
inlinenodiscard

Get the index of a collision layer with a specific name.

Parameters
namename of the collision layer to search for.
Returns
the index of the given collision layer in the model's collision layer array.
Exceptions
std::out_of_rangeif the given collision layer wasn't found.

Member Data Documentation

◆ MAX_COLLISION_LAYER_COUNT

size_t grem::resource::Model::MAX_COLLISION_LAYER_COUNT = 32
staticconstexpr

Maximum number of collision layers in a model.

◆ meshData

Buffer<byte> grem::resource::Model::meshData {}

Mesh data of the model. Indexed by meshes.

◆ morphTargetData

Buffer<byte> grem::resource::Model::morphTargetData {}

Morph target data of the model. Indexed by meshes.

◆ skinData

Buffer<byte> grem::resource::Model::skinData {}

Skin data of the model. Indexed by instances.

◆ meshes

ArrayList<Mesh> grem::resource::Model::meshes {}

Layout of mesh data in the model. Indexed by instances.

◆ bindPose

Pose grem::resource::Model::bindPose {}

Initial bind pose of the model. Indexed by instances, lights, physicsObjects, jointMap and skinMap.

◆ jointParentIndices

ArrayList<JointIndex> grem::resource::Model::jointParentIndices {}

Indices of the parent joint of each joint of the model.

◆ jointColliders

ArrayList<Optional<Collider> > grem::resource::Model::jointColliders {}

Colliders of each joint in the model.

◆ jointPhysicsObjectIndices

ArrayList<PhysicsObjectIndex> grem::resource::Model::jointPhysicsObjectIndices {}

Indices of the physics object that each joint in the model belongs to, or the maximum value if none.

◆ staticJointCount

JointCount grem::resource::Model::staticJointCount = 0

Number of unskinned joints at the beginning of the joint array.

◆ animations

ArrayList<Animation> grem::resource::Model::animations {}

Animations of the model. Indexed by animationMap.

◆ animationChannels

ArrayList<AnimationChannel> grem::resource::Model::animationChannels {}

Animation channels of the model. Indexed by animations.

◆ keyframeInputTimePoints

ArrayList<float> grem::resource::Model::keyframeInputTimePoints {}

Keyframe input time points of animation channels. Indexed by animationChannels.

◆ keyframeOutputValueData

Buffer<byte> grem::resource::Model::keyframeOutputValueData {}

Keyframe output value data of animation channels. Indexed by animationChannels.

◆ textures

ArrayList<Texture> grem::resource::Model::textures {}

Textures of the model. Indexed by materials and textureMap.

◆ materials

ArrayList<Material> grem::resource::Model::materials {}

Materials of the model. Indexed by instances and materialMap.

◆ instances

ArrayList<Instance> grem::resource::Model::instances {}

Mesh instances of the model.

◆ lights

ArrayList<Light> grem::resource::Model::lights {}

Lights in the model. Indexed by lightMap.

◆ physicsObjects

ArrayList<PhysicsObject> grem::resource::Model::physicsObjects {}

Physics objects in the model. Indexed by physicsJoints and jointPhysicsObjectIndices.

◆ physicsJoints

ArrayList<PhysicsJoint> grem::resource::Model::physicsJoints {}

Physics joints in the model.

◆ bindPoseBoundingBox

Box<3, float> grem::resource::Model::bindPoseBoundingBox {}

Local axis-aligned bounding box of all meshes' vertex positions in the initial bind pose.

◆ bindPoseBoundingRadius

float grem::resource::Model::bindPoseBoundingRadius = 0.0f

Maximum distance from the origin of all meshes' vertex positions in the initial bind pose.

◆ jointMap

JointMap grem::resource::Model::jointMap {}

Map from joint names to their index in the joint array.

◆ skinMap

JointMap grem::resource::Model::skinMap {}

Map from skin names to the index of their root joint in the joint array.

◆ animationMap

AnimationMap grem::resource::Model::animationMap {}

Map from animation names to their index in the animation array.

◆ textureMap

TextureMap grem::resource::Model::textureMap {}

Map from texture names to their index in the texture array.

◆ materialMap

MaterialMap grem::resource::Model::materialMap {}

Map from material names to their index in the material array.

◆ lightMap

LightMap grem::resource::Model::lightMap {}

Map from light names to their index in the light array.

◆ collisionLayerMap

CollisionLayerMap grem::resource::Model::collisionLayerMap {}

Map from collision layer names to their index in a collision layer set.


The documentation for this struct was generated from the following file: