4#ifndef GREM_RESOURCE_MODEL_HPP
5#define GREM_RESOURCE_MODEL_HPP
133 static_assert(__STDCPP_DEFAULT_NEW_ALIGNMENT__ >= 4);
859 const size_t jointCount = localJoints.
size();
873 pose(localJoints, localMorphTargetWeights, modelJointParentIndices);
1053 textureCoordinates, indices);
1276 bindPose.localMorphTargetWeights.clear();
1450 return *animationIndex;
1452 throw std::out_of_range{
"Animation \"" +
String{name} +
"\" not found."};
1465 if (
static_cast<size_t>(index) >=
animations.size()) {
1466 throw std::out_of_range{
"Invalid animation index."};
1537 throw std::out_of_range{
"Joint \"" +
String{name} +
"\" not found."};
1567 return *rootJointIndex;
1569 throw std::out_of_range{
"Skin \"" +
String{name} +
"\" not found."};
1598 return *textureIndex;
1600 throw std::out_of_range{
"Texture \"" +
String{name} +
"\" not found."};
1629 return *materialIndex;
1631 throw std::out_of_range{
"Material \"" +
String{name} +
"\" not found."};
1662 throw std::out_of_range{
"Light \"" +
String{name} +
"\" not found."};
1692 return *collisionLayerIndex;
1694 throw std::out_of_range{
"Collision layer \"" +
String{name} +
"\" not found."};
#define GREM_ASSERT(expression)
Definition assertions.hpp:77
Definition Allocation.hpp:25
Definition ArrayList.hpp:27
Definition BitArray.hpp:23
Convex polytope.
Definition ConvexPolytope.hpp:171
Base interface for a filesystem.
Definition Filesystem.hpp:25
Definition FunctionView.hpp:29
Definition HashMap.hpp:30
Optional value type that holds either a value or no value.
Definition Optional.hpp:58
Definition SharedPointer.hpp:65
constexpr detail::subspan_type_t< T, EXTENT, Offset, N > subspan() const
Definition Span.hpp:284
constexpr size_type size_bytes() const noexcept
Definition Span.hpp:253
constexpr size_type size() const noexcept
Definition Span.hpp:207
constexpr pointer data() const noexcept
Definition Span.hpp:203
Definition StridedSpan.hpp:427
Definition algorithms.hpp:132
Tagged union value type that holds a value of one of the given types.
Definition Variant.hpp:293
friend class Variant
Definition Variant.hpp:1402
Definition concepts.hpp:243
Definition aliases.hpp:18
ModelFileType
File type of a Model.
Definition Model.hpp:57
@ GLTF_BINARY
Binary glTF (.glb).
Definition Model.hpp:61
@ GLTF
glTF (.gltf).
Definition Model.hpp:60
@ OBJ
Wavefront OBJ (.obj).
Definition Model.hpp:59
@ UNKNOWN
Unknown file type.
Definition Image.hpp:31
qua< float > quat
Definition math.hpp:892
Clock::duration Duration
Definition Clock.hpp:25
StridedSpan(R &&range) -> StridedSpan< std::remove_reference_t< decltype(*std::data(range))>, DYNAMIC_EXTENT, sizeof(std::remove_reference_t< decltype(*std::data(range))>)>
vec< 4, float > vec4
Definition math.hpp:440
vec< 2, float > vec2
Definition math.hpp:438
vec< 3, float > vec3
Definition math.hpp:439
mat< 2, 2, float > mat2
Definition math.hpp:804
StringBase< char, std::char_traits< char >, std::allocator< char > > String
Definition String.hpp:17
auto as_strided_writable_bytes(StridedSpan< T, N, S > s) noexcept
Definition StridedSpan.hpp:734
mat< 4, 4, float > mat4
Definition math.hpp:806
constexpr Multiply MULTIPLY
Definition algorithms.hpp:92
StringViewBase< char, std::char_traits< char > > StringView
Definition StringView.hpp:16
CStringViewBase< char, std::char_traits< char > > CStringView
Definition CStringView.hpp:635
Generic axis-aligned box shape with minimum and maximum extents in N-dimensional space.
Definition geometry.hpp:149
The root object for a glTF asset.
Definition gltf.hpp:769
Collection of Node elements defined by an OBJ file.
Definition obj.hpp:83
Material library that stores the material properties for objects defined in an Asset.
Definition obj.hpp:153
Options for loading an image.
Definition Image.hpp:911
Configuration options for a Model.
Definition Model.hpp:67
vec3 rootScale
Scale to apply to the root joint of the model.
Definition Model.hpp:81
constexpr bool operator==(const ModelOptions &other) const =default
Compare these options to another set of options for equality.
bool excludePhysics
Exclude any physics information from the loaded model.
Definition Model.hpp:116
quat rootRotation
Rotation to apply to the root joint of the model.
Definition Model.hpp:76
bool excludeAnimations
Exclude any animations from the loaded model.
Definition Model.hpp:89
vec3 rootTranslation
Translation to apply to the root joint of the model.
Definition Model.hpp:71
bool excludeColliders
Exclude any colliders from the loaded model.
Definition Model.hpp:108
bool excludeLights
Exclude any lights from the loaded model.
Definition Model.hpp:97
Channel of a model animation.
Definition Model.hpp:557
AnimationPath targetPath
Target type.
Definition Model.hpp:565
MorphTargetWeightCount targetMorphTargetWeightCount
Number of affected morph target weights.
Definition Model.hpp:564
uint32_t targetOffset
Index into the joint array or morph target weight array.
Definition Model.hpp:563
KeyframeCount keyframeCount
Number of keyframes.
Definition Model.hpp:560
InterpolationMode interpolationMode
Interpolation type.
Definition Model.hpp:566
ValueOffset keyframeOutputValueOffset
Offset of the keyframe output values.
Definition Model.hpp:562
float maxTimePoint
End time of keyframes.
Definition Model.hpp:559
ValueOffset keyframeInputTimePointOffset
Offset of the keyframe input time points.
Definition Model.hpp:561
float minTimePoint
Start time of keyframes.
Definition Model.hpp:558
State of an animation affecting a pose.
Definition Model.hpp:634
Span< const float > jointBlendWeights
Normalized blend weights of each joint's influence on the pose.
Definition Model.hpp:661
bool looping
Whether the animation time should be wrapped or clamped when out of range of the animation.
Definition Model.hpp:676
Duration time
Current animation time from the start of the animation.
Definition Model.hpp:647
AnimationView animation
Animation to apply.
Definition Model.hpp:642
float blendWeight
Normalized overall blend weight of this animation's influence on the pose.
Definition Model.hpp:653
Span< const float > morphTargetWeightBlendWeights
Normalized blend weights of each morph target weight's influence on the pose.
Definition Model.hpp:670
Non-owning read-only view over a set of animation channels and their associated data.
Definition Model.hpp:608
float maxTimePoint
End time of all animation channels.
Definition Model.hpp:613
Span< const float > keyframeInputTimePoints
Non-owning read-only view over the keyframe input time points indexed by the animation channels.
Definition Model.hpp:622
Span< const AnimationChannel > channels
Non-owning read-only view over the animation channels.
Definition Model.hpp:616
float minTimePoint
Start time of all animation channels.
Definition Model.hpp:610
Span< const byte > keyframeOutputValueData
Non-owning read-only view over the keyframe output value data indexed by the animation channels.
Definition Model.hpp:628
Animation of a model.
Definition Model.hpp:570
float minTimePoint
Start time of all animation channels.
Definition Model.hpp:572
AnimationChannelIndex animationChannelOffset
Index of the first animation channel.
Definition Model.hpp:583
float maxTimePoint
End time of all animation channels.
Definition Model.hpp:575
Parameters describing a box shape.
Definition Model.hpp:423
vec3 size
Extents of the box in each axis in local space.
Definition Model.hpp:424
Parameters describing a capsule shape.
Definition Model.hpp:435
float halfLength
Half of the distance between the centers of the two capping spheres of capsule.
Definition Model.hpp:436
float bottomRadius
Radius of the sphere located at the bottom of the capsule (i.e. the sphere at the half-height along -...
Definition Model.hpp:437
float topRadius
Radius of the sphere located at the top of the capsule (i.e. the sphere at the half-height along +Y).
Definition Model.hpp:438
Collider in a model.
Definition Model.hpp:451
CollisionLayers responseLayers
Collision layers that the collider responds to collisions with.
Definition Model.hpp:456
CollisionLayers layers
Collision layers that the collider belongs to.
Definition Model.hpp:453
Shape shape
Shape of the collider.
Definition Model.hpp:452
CollisionLayers noDetectionLayers
Collision layers that the collider skips collision detection with.
Definition Model.hpp:455
CollisionLayers detectionLayers
Collision layers that the collider detects collisions with.
Definition Model.hpp:454
CollisionLayers noResponseLayers
Collision layers that the collider skips collision response with.
Definition Model.hpp:457
Parameters describing a cylinder shape.
Definition Model.hpp:428
float halfLength
Half of the height of the cylinder, centered along the Y axis.
Definition Model.hpp:429
float bottomRadius
Radius of the bottom of the cylinder (the disk located along -Y.).
Definition Model.hpp:430
float topRadius
Radius of the top of the cylinder (the disk located along +Y.).
Definition Model.hpp:431
Parameters describing a directional light.
Definition Model.hpp:384
float intensity
Illuminance of the light, in lux, if it were colored pure white.
Definition Model.hpp:386
vec3 color
Color of the light in linear RGB space.
Definition Model.hpp:385
Mesh instance in a model.
Definition Model.hpp:355
MeshIndex meshIndex
Index of the instance's mesh.
Definition Model.hpp:360
ValueOffset skinDataOffset
Index of the first 4-byte value in the skin data in the model.
Definition Model.hpp:371
MorphTargetWeightIndex morphTargetWeightOffset
Offset of the initial morph target weights of the instance, or 0 if not morphed.
Definition Model.hpp:374
InstanceFlags instanceFlags
Instance flags of the instance.
Definition Model.hpp:380
MaterialIndex materialIndex
Index of the instance's material, or an out-of-range index if the instance uses the default material.
Definition Model.hpp:357
JointIndex jointIndex
Index of the joint that the instance is attached to.
Definition Model.hpp:377
State of a local joint in a pose of a model.
Definition Model.hpp:534
vec3 translation
Local position of the joint.
Definition Model.hpp:535
bool visible
Whether the joint and its children are currently visible or not.
Definition Model.hpp:538
vec3 scale
Local scale of the joint.
Definition Model.hpp:537
quat rotation
Local orientation of the joint.
Definition Model.hpp:536
Light source in a model.
Definition Model.hpp:406
JointIndex jointIndex
Index of the model joint that controls the position and direction of the light.
Definition Model.hpp:407
Information about how a material uses a texture.
Definition Model.hpp:332
vec2 textureOffset
Texture coordinate offset to apply when sampling the texture.
Definition Model.hpp:334
mat2 textureBasis
Texture coordinate basis to apply when sampling the texture.
Definition Model.hpp:335
TextureIndex textureIndex
Index of the texture in the model's texture array, or an out-of-range index for the default texture.
Definition Model.hpp:333
Material of a mesh instance in a model.
Definition Model.hpp:330
MaterialType materialType
How to interpret the material parameters when shading.
Definition Model.hpp:338
TextureInfo occlusionRoughnessMetallicMap
Occlusion-roughness-metallic map of the material (linearly encoded), or an out-of-range index for a f...
Definition Model.hpp:348
float roughnessFactor
Roughness factor of the material.
Definition Model.hpp:341
float metallicFactor
Metallic factor of the material.
Definition Model.hpp:342
float indexOfRefraction
Index of refraction of the material.
Definition Model.hpp:346
float occlusionStrength
Occlusion strength of the material.
Definition Model.hpp:340
TextureInfo baseColorMap
Base color map of the material (sRGB-encoded), or an out-of-range index for a fully white texture.
Definition Model.hpp:347
vec3 emissiveFactor
Emissive factor of the material.
Definition Model.hpp:344
TextureInfo emissiveMap
Emissive map of the material (sRGB-encoded), or an out-of-range index for a fully white texture.
Definition Model.hpp:350
float normalScale
Normal scale of the material.
Definition Model.hpp:343
float alphaCutoff
Alpha cutoff value of the material.
Definition Model.hpp:345
vec4 baseColorFactor
Base color factor of the material.
Definition Model.hpp:339
FragmentFlags fragmentFlags
Fragment flags of the material.
Definition Model.hpp:351
TextureInfo normalMap
Normal map of the material (linearly encoded), or an out-of-range index for a flat normal texture.
Definition Model.hpp:349
Range of indexed vertices in a model.
Definition Model.hpp:223
IndexCount indexCount
Number of indices of the mesh, or 0 if not indexed.
Definition Model.hpp:228
Box< 3, float > boundingBox
Local axis-aligned bounding box of the mesh's vertex positions.
Definition Model.hpp:274
ValueOffset morphedVertexStride
Stride, in 4-byte values, of the vertices in the morph targets in this mesh, or 0 if not morphed.
Definition Model.hpp:237
VertexCount vertexCount
Number of vertices in the mesh.
Definition Model.hpp:231
MorphTargetCount morphTargetCount
Number of morph targets/weights, or 0 if not morphed.
Definition Model.hpp:234
ValueOffset morphTargetDataOffset
Index of the first 4-byte value in the morph target data in the model.
Definition Model.hpp:271
ValueOffset meshDataOffset
Index of the first 4-byte value in the mesh data in the model.
Definition Model.hpp:253
float boundingRadius
Maximum distance from the origin of the mesh's vertex positions.
Definition Model.hpp:277
PrimitiveType primitiveType
Type of primitives formed by the vertices of the mesh.
Definition Model.hpp:225
VertexFlags vertexFlags
Vertex flags of the mesh.
Definition Model.hpp:280
Physics joint between two physics objects in a model.
Definition Model.hpp:505
vec3 minDistances
The minimum of the allowed range of relative distance along each axis.
Definition Model.hpp:515
vec3 angularDriveDamping
The damping of the angular drive, scaling the torque based on the target angular velocity.
Definition Model.hpp:530
vec3 maxDistances
The maximum of the allowed range of relative distance along each axis.
Definition Model.hpp:516
bool driveIgnoresMassZ
Whether the value computed from the spring equation is the linear acceleration or the force to apply ...
Definition Model.hpp:510
vec3 targetAngularVelocity
Target angular velocity about each axis that this drive attempts to achieve.
Definition Model.hpp:528
vec3 minAngles
The minimum of the allowed range of relative angle about each axis.
Definition Model.hpp:517
vec3 linearStiffnesses
The spring constants used to calculate a restorative force along each axis when the joint is extended...
Definition Model.hpp:519
bool driveIgnoresMomentOfInertiaX
Whether the value computed from the spring equation is the angular acceleration or the torque to appl...
Definition Model.hpp:511
vec3 targetPosition
Target translation along each axis that the drive attempts to achieve.
Definition Model.hpp:525
vec3 linearDamping
Damping applied to the linear velocity along each axis when the joint is extended beyond the limit.
Definition Model.hpp:521
bool enableCollision
Allow the connected objects to collide.
Definition Model.hpp:514
vec3 linearDriveDamping
The damping of the linear drive, scaling the force based on the target linear velocity.
Definition Model.hpp:529
vec3 targetAngles
Target angle about each axis that the drive attempts to achieve.
Definition Model.hpp:526
Pair< PhysicsObjectIndex > objectIndices
Ordered pair of indices of the connected physics objects, or the maximum value if there is no object.
Definition Model.hpp:506
vec3 maxForce
Maximum force applied along each driven linear axis.
Definition Model.hpp:523
vec3 targetLinearVelocity
Target linear velocity along each axis that this drive attempts to achieve.
Definition Model.hpp:527
bool driveIgnoresMassY
Whether the value computed from the spring equation is the linear acceleration or the force to apply ...
Definition Model.hpp:509
vec3 angularDamping
Damping applied to the angular velocity about each axis when the joint is extended beyond the limit.
Definition Model.hpp:522
bool driveIgnoresMomentOfInertiaZ
Whether the value computed from the spring equation is the angular acceleration or the torque to appl...
Definition Model.hpp:513
vec3 maxAngles
The maximum of the allowed range of relative angle about each axis.
Definition Model.hpp:518
bool driveIgnoresMomentOfInertiaY
Whether the value computed from the spring equation is the angular acceleration or the torque to appl...
Definition Model.hpp:512
bool driveIgnoresMassX
Whether the value computed from the spring equation is the linear acceleration or the force to apply ...
Definition Model.hpp:508
Pair< JointIndex > jointIndices
Ordered pair of indices of the joints serving as the attachment frames.
Definition Model.hpp:507
vec3 maxTorque
Maximum torque applied along each driven angular axis.
Definition Model.hpp:524
vec3 angularStiffnesses
The spring constants used to calculate a restorative torque about each axis when the joint is extende...
Definition Model.hpp:520
Physics object contained in a model.
Definition Model.hpp:487
RestitutionCombine restitutionCombine
How to combine the restitution when this object collides with another.
Definition Model.hpp:501
float gravityFactor
Gravity factor of the object.
Definition Model.hpp:495
float restitution
Coefficient of restitution of the object.
Definition Model.hpp:499
float dynamicFriction
Dynamic friction of the object.
Definition Model.hpp:497
vec3 initialLinearVelocity
Initial linear velocity of the object in local space.
Definition Model.hpp:493
float staticFriction
Static friction of the object.
Definition Model.hpp:496
vec3 centerOfMass
Local center of mass of the object.
Definition Model.hpp:490
vec3 initialAngularVelocity
Initial angular velocity of the object in local space.
Definition Model.hpp:494
quat inertiaOrientation
Orientation of the local moment of inertia tensor of the object.
Definition Model.hpp:492
float mass
Mass of the object, or 0 to calculate.
Definition Model.hpp:489
JointIndex jointIndex
Index of the model joint that is affected by the object.
Definition Model.hpp:488
FrictionCombine frictionCombine
How to combine the friction when this object collides with another.
Definition Model.hpp:500
float rollingResistance
Rolling resistance of the object.
Definition Model.hpp:498
vec3 principalMomentsOfInertia
Diagonal of the local moment of inertia tensor of the object, or 0 to calculate.
Definition Model.hpp:491
Parameters describing a plane shape.
Definition Model.hpp:411
bool doubleSided
Whether the plane is double-sided or not.
Definition Model.hpp:414
float sizeZ
Size of the plane in the local Z axis.
Definition Model.hpp:413
float sizeX
Size of the plane in the local X axis.
Definition Model.hpp:412
Parameters describing a point light.
Definition Model.hpp:390
vec3 color
Color of the light in linear RGB space.
Definition Model.hpp:391
float intensity
Luminous intensity of the light, in candela, if it were colored pure white.
Definition Model.hpp:392
Reference to a local pose of a model.
Definition Model.hpp:698
PoseReference applyAnimation(const AnimationState &animationState) const
Add the influence of an animation state to the current pose.
Joint * localJoints
Non-owning pointer to the current local joints of the pose.
Definition Model.hpp:702
float * localMorphTargetWeights
Non-owning pointer to the current local morph target weights of the pose.
Definition Model.hpp:708
Read-only view over a local pose of a model.
Definition Model.hpp:682
const Joint * localJoints
Non-owning read-only pointer to the current local joints of the pose.
Definition Model.hpp:686
const float * localMorphTargetWeights
Non-owning read-only pointer to the current local morph target weights of the pose.
Definition Model.hpp:692
Local pose of a model.
Definition Model.hpp:733
ArrayList< Joint > localJoints
Current local joints of the pose.
Definition Model.hpp:734
ArrayList< float > localMorphTargetWeights
Current local morph target weights of the pose.
Definition Model.hpp:735
Pose & applyAnimation(const AnimationState &animationState)
Add the influence of an animation state to the current pose.
Definition Model.hpp:763
Parameters describing a sphere shape.
Definition Model.hpp:418
float radius
Radius of the sphere.
Definition Model.hpp:419
Parameters describing a spot light.
Definition Model.hpp:397
vec3 color
Color of the light in linear RGB space.
Definition Model.hpp:398
float outerConeAngle
Angle, in radians, where the light cone fades to zero.
Definition Model.hpp:402
float innerConeAngle
Angle, in radians, where the light cone reaches maximum brightness.
Definition Model.hpp:401
float intensity
Luminous intensity of the light, in candela, if it were colored pure white.
Definition Model.hpp:399
Texture of a material in a model.
Definition Model.hpp:312
WrappingMode horizontalWrappingMode
Horizontal wrapping mode of the texture sampler.
Definition Model.hpp:316
MinificationFilter minificationFilter
Minification filter of the texture sampler.
Definition Model.hpp:314
MagnificationFilter magnificationFilter
Magnification filter of the texture sampler.
Definition Model.hpp:315
Image image
Texture image data.
Definition Model.hpp:313
WrappingMode verticalWrappingMode
Vertical wrapping mode of the texture sampler.
Definition Model.hpp:317
AnimationIndex getAnimationIndex(StringView name) const
Get the index of an animation with a specific name.
Definition Model.hpp:1448
ArrayList< AnimationChannel > animationChannels
Animation channels of the model. Indexed by animations.
Definition Model.hpp:1111
HashMap< String, JointIndex, TransparentHash< StringView >, TransparentEqual< StringView > > JointMap
Map from name strings to joint indices.
Definition Model.hpp:587
MaterialType
Material type that specifies how the material parameters should be interpreted when shading a mesh in...
Definition Model.hpp:324
@ UNLIT
The shader should use only the base color at full brightness.
Definition Model.hpp:326
@ METALLIC_ROUGHNESS
The shader should interpret the material according to the standard metallic-roughness model.
Definition Model.hpp:325
LightMap lightMap
Map from light names to their index in the light array.
Definition Model.hpp:1127
PrimitiveType
Graphical primitive type formed by vertices in a model mesh.
Definition Model.hpp:213
@ TRIANGLE_STRIP
Each point, except the first two, forms a filled triangle with the previous two points.
Definition Model.hpp:219
@ POINTS
Individual points.
Definition Model.hpp:214
@ TRIANGLES
Each consecutive triple of points forms an individual filled triangle.
Definition Model.hpp:218
@ LINES
Each consecutive pair of points forms an individual line segment.
Definition Model.hpp:215
@ LINE_STRIP
Each point, except the first, forms a line segment to the previous point.
Definition Model.hpp:217
BitArray< MAX_COLLISION_LAYER_COUNT > CollisionLayers
Set of collision layers.
Definition Model.hpp:164
ArrayList< Material > materials
Materials of the model. Indexed by instances and materialMap.
Definition Model.hpp:1115
uint32_t PhysicsObjectIndex
Offset of a physics object in the model's physics object array.
Definition Model.hpp:158
Variant< resource::Image, resource::ImageView > Image
Image of a texture in a model.
Definition Model.hpp:284
uint16_t FragmentFlags
Set of FragmentFlag bits.
Definition Model.hpp:185
Model(const ConvexPolytope< 3, float > &polytope, const mat4 &transformation=mat4{1.0f})
Construct an untextured single-mesh model from a convex polytope.
AnimationView getAnimation(StringView name) const
Get the animation with a specific name.
Definition Model.hpp:1490
uint32_t MorphTargetWeightIndex
Offset of a morph target weight in the model's morph target weight array.
Definition Model.hpp:140
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 ...
uint32_t KeyframeCount
Number of keyframes in an animation channel of the model.
Definition Model.hpp:139
Buffer< byte > skinData
Skin data of the model. Indexed by instances.
Definition Model.hpp:1103
Buffer< byte > morphTargetData
Morph target data of the model. Indexed by meshes.
Definition Model.hpp:1102
AnimationMap animationMap
Map from animation names to their index in the animation array.
Definition Model.hpp:1124
CollisionLayerIndex getCollisionLayerIndex(StringView name) const
Get the index of a collision layer with a specific name.
Definition Model.hpp:1690
uint16_t VertexFlags
Set of VertexFlag bits.
Definition Model.hpp:168
uint32_t AnimationIndex
Offset of an animation in the model's animation array.
Definition Model.hpp:152
AnimationChannelIndex AnimationChannelCount
Number of animation channels in a range within the model's animation channel array.
Definition Model.hpp:151
ArrayList< float > keyframeInputTimePoints
Keyframe input time points of animation channels. Indexed by animationChannels.
Definition Model.hpp:1112
void reset() noexcept
Reset the model to an empty, invalid state that must not be rendered until the model is manually made...
Definition Model.hpp:1270
InstanceFlag
Single flag in a set of InstanceFlags, specifying information about a model mesh instance.
Definition Model.hpp:208
@ INSTANCE_REVERSE_WINDING_ORDER
Consider mesh faces with clockwise winding order as front-facing for this instance.
Definition Model.hpp:209
uint8_t InstanceFlags
Set of InstanceFlag bits.
Definition Model.hpp:205
uint32_t JointIndex
Offset of a joint in the model's joint array.
Definition Model.hpp:148
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.
Definition Model.hpp:980
Optional< LightIndex > findLightIndex(StringView name) const noexcept
Find the index of a light with a specific name.
Definition Model.hpp:1642
Buffer< byte > meshData
Mesh data of the model. Indexed by meshes.
Definition Model.hpp:1101
TextureMap textureMap
Map from texture names to their index in the texture array.
Definition Model.hpp:1125
MaterialIndex MaterialCount
Number of materials in a range within the model's material array.
Definition Model.hpp:145
uint32_t MaterialIndex
Offset of a material in the model's material array.
Definition Model.hpp:144
uint32_t InstanceIndex
Offset of an instance in the model's instance array.
Definition Model.hpp:154
HashMap< String, CollisionLayerIndex, TransparentHash< StringView >, TransparentEqual< StringView > > CollisionLayerMap
Map from name strings to collision layer indices.
Definition Model.hpp:602
Optional< MaterialIndex > findMaterialIndex(StringView name) const noexcept
Find the index of a material with a specific name.
Definition Model.hpp:1611
HashMap< String, MaterialIndex, TransparentHash< StringView >, TransparentEqual< StringView > > MaterialMap
Map from name strings to material indices.
Definition Model.hpp:596
JointIndex getSkinRootJointIndex(StringView name) const
Get the index of the root joint of a skin with a specific name.
Definition Model.hpp:1565
Model() noexcept=default
Construct an empty, invalid model that must not be rendered until manually made valid.
uint32_t MorphTargetCount
Number of morph targets in a mesh of the model.
Definition Model.hpp:138
JointMap skinMap
Map from skin names to the index of their root joint in the joint array.
Definition Model.hpp:1123
Variant< PlaneShape, SphereShape, BoxShape, CylinderShape, CapsuleShape, ConvexPolytopeShape, TriangleMeshShape > Shape
Collision shape in a model.
Definition Model.hpp:448
HashMap< String, LightIndex, TransparentHash< StringView >, TransparentEqual< StringView > > LightMap
Map from name strings to light indices.
Definition Model.hpp:599
PhysicsJointIndex PhysicsJointCount
Number of physics joints in a range within the model's physics joint array.
Definition Model.hpp:161
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.
AnimationIndex AnimationCount
Number of animations in a range within the model's animation array.
Definition Model.hpp:153
AnimationPath
Target type of a model animation channel.
Definition Model.hpp:542
@ JOINT_SCALE
The animation targets the scale of a local joint.
Definition Model.hpp:544
@ JOINT_ROTATION
The animation targets the rotation of a local joint.
Definition Model.hpp:543
@ JOINT_TRANSLATION
The animation targets the translation of a local joint.
Definition Model.hpp:545
@ MORPH_TARGET_WEIGHTS
The animation targets the morph target weights of the model.
Definition Model.hpp:546
uint32_t IndexCount
Number of indices in a mesh of the model.
Definition Model.hpp:136
uint32_t LightIndex
Offset of a light in the model's light array.
Definition Model.hpp:156
MeshIndex MeshCount
Number of meshes in a range within the model's mesh array.
Definition Model.hpp:147
SharedPointer< ConvexPolytope< 3, float > > ConvexPolytopeShape
Parameters describing a convex polytope shape.
Definition Model.hpp:442
ArrayList< PhysicsJoint > physicsJoints
Physics joints in the model.
Definition Model.hpp:1119
FragmentFlag
Single flag in a set of FragmentFlags, specifying fragment shader usage.
Definition Model.hpp:188
@ FRAGMENT_BASE_COLOR_MAPPED_ON_CHANNEL_0
The base color map is sampled using texture coordinate channel 0.
Definition Model.hpp:192
@ FRAGMENT_ALPHA_MASKED
Fragments with alpha less than the alpha cutoff are discarded.
Definition Model.hpp:189
@ FRAGMENT_METALLIC_ROUGHNESS_MAPPED_ON_CHANNEL_0
The metallic/roughness map is sampled using texture coordinate channel 0.
Definition Model.hpp:194
@ FRAGMENT_EMISSIVE_MAPPED_ON_CHANNEL_0
The emissive map is sampled using texture coordinate channel 0.
Definition Model.hpp:200
@ FRAGMENT_EMISSIVE_MAPPED_ON_CHANNEL_1
The emissive map is sampled using texture coordinate channel 1.
Definition Model.hpp:201
@ FRAGMENT_ALPHA_BLENDED
Fragments are alpha blended.
Definition Model.hpp:190
@ FRAGMENT_NORMAL_MAPPED_ON_CHANNEL_0
The normal map is sampled using texture coordinate channel 0.
Definition Model.hpp:198
@ FRAGMENT_METALLIC_ROUGHNESS_MAPPED_ON_CHANNEL_1
The metallic/roughness map is sampled using texture coordinate channel 1.
Definition Model.hpp:195
@ FRAGMENT_OCCLUSION_MAPPED_ON_CHANNEL_1
The occlusion map is sampled using texture coordinate channel 1.
Definition Model.hpp:197
@ FRAGMENT_NORMAL_MAPPED_ON_CHANNEL_1
The normal map is sampled using texture coordinate channel 1.
Definition Model.hpp:199
@ FRAGMENT_DOUBLE_SIDED
Fragments are double-sided.
Definition Model.hpp:191
@ FRAGMENT_OCCLUSION_MAPPED_ON_CHANNEL_0
The occlusion map is sampled using texture coordinate channel 0.
Definition Model.hpp:196
@ FRAGMENT_BASE_COLOR_MAPPED_ON_CHANNEL_1
The base color map is sampled using texture coordinate channel 1.
Definition Model.hpp:193
Optional< JointIndex > findSkinRootJointIndex(StringView name) const noexcept
Find the index of the root joint of a skin with a specific name.
Definition Model.hpp:1548
Optional< AnimationView > findAnimation(StringView name) const noexcept
Try to get the animation with a specific name.
Definition Model.hpp:1502
VertexFlag
Single flag in a set of VertexFlags, specifying vertex attribute usage.
Definition Model.hpp:171
@ VERTEX_COLORED
The vertex color component is used to tint the fragment color.
Definition Model.hpp:174
@ VERTEX_MORPHED_NORMAL
The vertex normal is morphed against the morph targets of the model using provided weights.
Definition Model.hpp:177
@ VERTEX_MORPHED_COLOR
The vertex color is morphed against the morph targets of the model using provided weights.
Definition Model.hpp:181
@ VERTEX_TEXTURED_ON_CHANNEL_1
Texture coordinate channel 1 is used to sample materials.
Definition Model.hpp:173
@ VERTEX_TEXTURED_ON_CHANNEL_0
Texture coordinate channel 0 is used to sample materials.
Definition Model.hpp:172
@ VERTEX_MORPHED_TEXTURE_COORDINATES_CHANNEL_1
Texture coordinate channel 1 is morphed against the morph targets of the model using provided weights...
Definition Model.hpp:180
@ VERTEX_MORPHED_TANGENT
The vertex tangent is morphed against the morph targets of the model using provided weights.
Definition Model.hpp:178
@ VERTEX_MORPHED_TEXTURE_COORDINATES_CHANNEL_0
Texture coordinate channel 0 is morphed against the morph targets of the model using provided weights...
Definition Model.hpp:179
@ VERTEX_MORPHED_POSITION
The vertex position is morphed against the morph targets of the model using provided weights.
Definition Model.hpp:176
@ VERTEX_SKINNED
The vertex joint components are used to skin the vertex over the model joints.
Definition Model.hpp:175
uint8_t CollisionLayerIndex
Index of a collision layer in a set of collision layers.
Definition Model.hpp:165
FrictionCombine
Friction combination algorithm.
Definition Model.hpp:466
@ MAXIMUM
The largest of the two values should be used.
Definition Model.hpp:469
@ AVERAGE
The two values should be averaged.
Definition Model.hpp:467
@ MINIMUM
The smallest of the two values should be used.
Definition Model.hpp:468
JointIndex getJointIndex(StringView name) const
Get the index of a joint with a specific name.
Definition Model.hpp:1533
Optional< TextureIndex > findTextureIndex(StringView name) const noexcept
Find the index of a texture with a specific name.
Definition Model.hpp:1580
InstanceIndex InstanceCount
Number of instances in a range within the model's instance array.
Definition Model.hpp:155
JointCount staticJointCount
Number of unskinned joints at the beginning of the joint array.
Definition Model.hpp:1109
uint32_t TextureIndex
Offset of a texture in the model's texture array.
Definition Model.hpp:142
ArrayList< Mesh > meshes
Layout of mesh data in the model. Indexed by instances.
Definition Model.hpp:1104
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.
MinificationFilter
Minification filter of a texture in a model.
Definition Model.hpp:287
@ UNSPECIFIED
Unspecified filter.
Definition Model.hpp:288
@ NEAREST_MIPMAP_NEAREST
Nearest-neighbor filtering from the nearest mip level.
Definition Model.hpp:291
@ LINEAR_MIPMAP_NEAREST
Linear filtering from the nearest mip level.
Definition Model.hpp:292
@ NEAREST_MIPMAP_LINEAR
Nearest-neighbor filtering linearly interpolated between mip levels.
Definition Model.hpp:293
@ LINEAR
Linear filtering without mipmapping.
Definition Model.hpp:290
@ NEAREST
Nearest-neighbor filtering without mipmapping.
Definition Model.hpp:289
@ LINEAR_MIPMAP_LINEAR
Linear filtering linearly interpoated between mip levels.
Definition Model.hpp:294
Optional< CollisionLayerIndex > findCollisionLayerIndex(StringView name) const noexcept
Find the index of a collision layer with a specific name.
Definition Model.hpp:1673
MorphTargetWeightIndex MorphTargetWeightCount
Number of morph target weights in a range within the model's morph target weight array.
Definition Model.hpp:141
JointMap jointMap
Map from joint names to their index in the joint array.
Definition Model.hpp:1122
Optional< JointIndex > findJointIndex(StringView name) const noexcept
Find the index of a joint with a specific name.
Definition Model.hpp:1517
WrappingMode
Wrapping mode of a texture in a model.
Definition Model.hpp:305
@ REPEAT
Wrap the texture coordinates.
Definition Model.hpp:306
@ CLAMP_TO_EDGE
Clamp the texture coordinates.
Definition Model.hpp:308
@ MIRRORED_REPEAT
Mirror the texture coordinates.
Definition Model.hpp:307
LightIndex getLightIndex(StringView name) const
Get the index of a light with a specific name.
Definition Model.hpp:1658
SharedPointer< TriangleMesh< 3, float > > TriangleMeshShape
Parameters describing a triangle mesh shape.
Definition Model.hpp:445
JointIndex JointCount
Number of joints in a range within the model's joint array.
Definition Model.hpp:149
uint32_t MeshIndex
Offset of a mesh in the model's mesh array.
Definition Model.hpp:146
TextureIndex getTextureIndex(StringView name) const
Get the index of a texture with a specific name.
Definition Model.hpp:1596
ArrayList< PhysicsObject > physicsObjects
Physics objects in the model. Indexed by physicsJoints and jointPhysicsObjectIndices.
Definition Model.hpp:1118
uint32_t AnimationChannelIndex
Offset of an animation channel in the model's animation channel array.
Definition Model.hpp:150
RestitutionCombine
Restitution combination algorithm.
Definition Model.hpp:479
Box< 3, float > bindPoseBoundingBox
Local axis-aligned bounding box of all meshes' vertex positions in the initial bind pose.
Definition Model.hpp:1120
ArrayList< PhysicsObjectIndex > jointPhysicsObjectIndices
Indices of the physics object that each joint in the model belongs to, or the maximum value if none.
Definition Model.hpp:1108
MaterialIndex getMaterialIndex(StringView name) const
Get the index of a material with a specific name.
Definition Model.hpp:1627
ArrayList< Optional< Collider > > jointColliders
Colliders of each joint in the model.
Definition Model.hpp:1107
PhysicsObjectIndex PhysicsObjectCount
Number of physics objects in a range within the model's physics object array.
Definition Model.hpp:159
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.
Definition Model.hpp:952
HashMap< String, TextureIndex, TransparentHash< StringView >, TransparentEqual< StringView > > TextureMap
Map from name strings to texture indices.
Definition Model.hpp:593
Optional< AnimationIndex > findAnimationIndex(StringView name) const noexcept
Find the index of an animation with a specific name.
Definition Model.hpp:1432
MagnificationFilter
Magnification filter of a texture in a model.
Definition Model.hpp:298
MaterialMap materialMap
Map from material names to their index in the material array.
Definition Model.hpp:1126
uint32_t VertexCount
Number of vertices in a mesh of the model.
Definition Model.hpp:137
InterpolationMode
Interpolation type of a model animation channel.
Definition Model.hpp:550
@ STEP
Discrete steps without interpolation.
Definition Model.hpp:552
@ CUBIC_SPLINE
Cubic spline interpolation.
Definition Model.hpp:553
Buffer< byte > keyframeOutputValueData
Keyframe output value data of animation channels. Indexed by animationChannels.
Definition Model.hpp:1113
Model(const Filesystem &filesystem, CStringView filepath, const ModelOptions &options={})
Load a model from a file.
float bindPoseBoundingRadius
Maximum distance from the origin of all meshes' vertex positions in the initial bind pose.
Definition Model.hpp:1121
ArrayList< Instance > instances
Mesh instances of the model.
Definition Model.hpp:1116
void assign(const ConvexPolytope< 3, float > &polytope, const mat4 &transformation=mat4{1.0f})
Assign an untextured single-mesh model from a convex polytope.
uint32_t ValueOffset
Index of a 4-byte value in a data array of the model.
Definition Model.hpp:135
static constexpr size_t MAX_COLLISION_LAYER_COUNT
Maximum number of collision layers in a model.
Definition Model.hpp:163
uint32_t PhysicsJointIndex
Offset of a physics joint in the model's physics joint array.
Definition Model.hpp:160
ArrayList< JointIndex > jointParentIndices
Indices of the parent joint of each joint of the model.
Definition Model.hpp:1106
AnimationView getAnimationAtIndex(AnimationIndex index) const
Get the animation at a specific index.
Definition Model.hpp:1464
ArrayList< Light > lights
Lights in the model. Indexed by lightMap.
Definition Model.hpp:1117
HashMap< String, AnimationIndex, TransparentHash< StringView >, TransparentEqual< StringView > > AnimationMap
Map from name strings to animation indices.
Definition Model.hpp:590
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.
Pose bindPose
Initial bind pose of the model. Indexed by instances, lights, physicsObjects, jointMap and skinMap.
Definition Model.hpp:1105
TextureIndex TextureCount
Number of textures in a range within the model's texture array.
Definition Model.hpp:143
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.
Definition Model.hpp:1085
ArrayList< Animation > animations
Animations of the model. Indexed by animationMap.
Definition Model.hpp:1110
ArrayList< Texture > textures
Textures of the model. Indexed by materials and textureMap.
Definition Model.hpp:1114
LightIndex LightCount
Number of lights in a range within the model's light array.
Definition Model.hpp:157
void load(const Filesystem &filesystem, CStringView filepath, const ModelOptions &options={})
Load and assign a model from a file.
CollisionLayerMap collisionLayerMap
Map from collision layer names to their index in a collision layer set.
Definition Model.hpp:1128