|
GREM 3.12.0
Game/Rendering Engine Modules for C++
|
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. | |
In-memory representation of a 3D model with all of its vertex data directly accessible.
| using grem::resource::Model::ValueOffset = uint32_t |
Index of a 4-byte value in a data array of the model.
| using grem::resource::Model::IndexCount = uint32_t |
Number of indices in a mesh of the model.
| using grem::resource::Model::VertexCount = uint32_t |
Number of vertices in a mesh of the model.
| using grem::resource::Model::MorphTargetCount = uint32_t |
Number of morph targets in a mesh of the model.
| using grem::resource::Model::KeyframeCount = uint32_t |
Number of keyframes in an animation channel of the model.
| using grem::resource::Model::MorphTargetWeightIndex = uint32_t |
Offset of a morph target weight in the model's morph target weight array.
Number of morph target weights in a range within the model's morph target weight array.
| using grem::resource::Model::TextureIndex = uint32_t |
Offset of a texture in the model's texture array.
Number of textures in a range within the model's texture array.
| using grem::resource::Model::MaterialIndex = uint32_t |
Offset of a material in the model's material array.
Number of materials in a range within the model's material array.
| using grem::resource::Model::MeshIndex = uint32_t |
Offset of a mesh in the model's mesh array.
Number of meshes in a range within the model's mesh array.
| using grem::resource::Model::JointIndex = uint32_t |
Offset of a joint in the model's joint array.
Number of joints in a range within the model's joint array.
| using grem::resource::Model::AnimationChannelIndex = uint32_t |
Offset of an animation channel in the model's animation channel array.
Number of animation channels in a range within the model's animation channel array.
| using grem::resource::Model::AnimationIndex = uint32_t |
Offset of an animation in the model's animation array.
Number of animations in a range within the model's animation array.
| using grem::resource::Model::InstanceIndex = uint32_t |
Offset of an instance in the model's instance array.
Number of instances in a range within the model's instance array.
| using grem::resource::Model::LightIndex = uint32_t |
Offset of a light in the model's light array.
Number of lights in a range within the model's light array.
| using grem::resource::Model::PhysicsObjectIndex = uint32_t |
Offset of a physics object in the model's physics object array.
Number of physics objects in a range within the model's physics object array.
| using grem::resource::Model::PhysicsJointIndex = uint32_t |
Offset of a physics joint in the model's physics joint array.
Number of physics joints in a range within the model's physics joint array.
Set of collision layers.
| using grem::resource::Model::CollisionLayerIndex = uint8_t |
Index of a collision layer in a set of collision layers.
| using grem::resource::Model::VertexFlags = uint16_t |
Set of VertexFlag bits.
| using grem::resource::Model::FragmentFlags = uint16_t |
Set of FragmentFlag bits.
| using grem::resource::Model::InstanceFlags = uint8_t |
Set of InstanceFlag bits.
Image of a texture in a model.
| using grem::resource::Model::ConvexPolytopeShape = SharedPointer<ConvexPolytope<3, float>> |
Parameters describing a convex polytope shape.
| using grem::resource::Model::TriangleMeshShape = SharedPointer<TriangleMesh<3, float>> |
Parameters describing a triangle mesh shape.
| using grem::resource::Model::Shape = Variant<PlaneShape, SphereShape, BoxShape, CylinderShape, CapsuleShape, ConvexPolytopeShape, TriangleMeshShape> |
Collision shape in a model.
| using grem::resource::Model::JointMap = HashMap<String, JointIndex, TransparentHash<StringView>, TransparentEqual<StringView>> |
Map from name strings to joint indices.
| using grem::resource::Model::AnimationMap = HashMap<String, AnimationIndex, TransparentHash<StringView>, TransparentEqual<StringView>> |
Map from name strings to animation indices.
| using grem::resource::Model::TextureMap = HashMap<String, TextureIndex, TransparentHash<StringView>, TransparentEqual<StringView>> |
Map from name strings to texture indices.
| using grem::resource::Model::MaterialMap = HashMap<String, MaterialIndex, TransparentHash<StringView>, TransparentEqual<StringView>> |
Map from name strings to material indices.
| using grem::resource::Model::LightMap = HashMap<String, LightIndex, TransparentHash<StringView>, TransparentEqual<StringView>> |
Map from name strings to light indices.
| using grem::resource::Model::CollisionLayerMap = HashMap<String, CollisionLayerIndex, TransparentHash<StringView>, TransparentEqual<StringView>> |
Map from name strings to collision layer indices.
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. |
Single flag in a set of FragmentFlags, specifying fragment shader usage.
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. |
|
strong |
Graphical primitive type formed by vertices in a model mesh.
|
strong |
Minification filter of a texture in a model.
|
strong |
|
strong |
|
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. |
|
strong |
Friction combination algorithm.
When two objects collide, the friction combination algorithm with the lowest value of the two should be used.
|
strong |
Restitution combination algorithm.
When two objects collide, the restitution combination algorithm with the lowest value of the two should be used.
|
strong |
Target type of a model animation channel.
|
strong |
|
defaultnoexcept |
Construct an empty, invalid model that must not be rendered until manually made valid.
| 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.
| positions | vertex positions of the mesh. |
| indices | triangle vertex indices of the mesh. Must have a size that is divisible by 3. Each index must be less than positions.size(). |
| normals | normals of the vertices. Must either be empty or have the same size as positions. If empty, normals will be generated automatically. |
| tangents | tangents of the vertices. Must either be empty or have the same size as positions. If empty, tangents will be generated automatically. |
| textureCoordinatesChannel0 | channel 0 texture coordinates of the vertices. Must either be empty or have the same size as positions. |
| textureCoordinatesChannel1 | channel 1 texture coordinates of the vertices. Must either be empty or have the same size as positions. |
| colors | colors of the vertices. Must either be empty or have the same size as positions. |
| material | material 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. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
| 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.
| polytope | convex polytope to model. |
| transformation | transformation to apply to each of the polytope vertices in the new model. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
| grem::resource::Model::Model | ( | const Filesystem & | filesystem, |
| CStringView | filepath, | ||
| const ModelOptions & | options = {} ) |
Load a model from a file.
The supported file formats are:
| filesystem | filepath to load the files from. |
| filepath | input filepath of the model file to load. |
| options | model options, see ModelOptions. |
| File::Error | on failure to open a file. |
| resource::Error | on failure to load a valid model. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
| 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.
| asset | glTF asset to construct the model from. |
| loadImage | function to use to load the images required by the asset given their relative filepaths and image options. |
| loadBufferData | function to use to load the buffer contents required by the asset given their relative filepaths. |
| options | model options, see ModelOptions. |
| resource::Error | on failure to load a valid model. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
| any | exception thrown by the loadImage callback. |
| any | exception thrown by the loadBufferData callback. |
| 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.
| asset | OBJ asset to construct the model from. |
| materialLibrary | material library to get materials from, which should contain the materials loaded from the files specified by obj::Asset::materialLibraryFilenames. |
| loadImage | function to use to load the images required by the materials in the asset given their relative filepaths and image options. |
| options | model options, see ModelOptions. |
| resource::Error | on failure to load a valid model. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
| any | exception thrown by the loadImage callback. |
|
static |
Generate normal vectors for each vertex in a set of triangles.
| normalData | strided 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. |
| positions | positions of the vertices to generate normals for. |
| indices | optional vertex indices. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
|
inlinestatic |
Generate normal vectors for each vertex in a set of triangles.
| normalData | view over the memory to write the generated normal vectors to. Must have the same size as positions times the size of a iA2B10G10R10vec4norm. |
| positions | positions of the vertices to generate normals for. |
| indices | optional vertex indices. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
|
inlinestatic |
Generate normal vectors for each vertex in a set of triangles.
| normals | normal vectors to generate the values of. Must have the same size as positions. |
| positions | positions of the vertices to generate normals for. |
| indices | optional vertex indices. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
|
static |
Generate tangent vectors for each vertex in a set of triangles.
| tangentData | strided 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. |
| positions | positions of the vertices to generate tangents for. |
| normals | normal vectors of the vertices to generate tangents for. Must have the same size as positions. |
| textureCoordinates | optional 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. |
| indices | optional vertex indices. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
|
inlinestatic |
Generate tangent vectors for each vertex in a set of triangles.
| tangentData | view over the memory to write the generated tangent vectors to. Must have the same size as positions times the size of a iA2B10G10R10vec4norm. |
| positions | positions of the vertices to generate tangents for. |
| normals | normal vectors of the vertices to generate tangents for. Must have the same size as positions. |
| textureCoordinates | optional 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. |
| indices | optional vertex indices. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
|
inlinestatic |
Generate tangent vectors for each vertex in a set of triangles.
| tangents | tangent vectors to generate the values of. Must have the same size as positions. |
| positions | positions of the vertices to generate tangents for. |
| normals | normal vectors of the vertices to generate tangents for. Must have the same size as positions. |
| textureCoordinates | optional 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. |
| indices | optional vertex indices. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
|
staticnodiscardnoexcept |
Determine which model file type a file should be parsed as based on the contents at the beginning of the file.
| fileContents | file contents to be parsed. |
|
inlinenoexcept |
Reset the model to an empty, invalid state that must not be rendered until the model is manually made valid.
| 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.
| positions | vertex positions of the mesh. |
| indices | triangle vertex indices of the mesh. Must have a size that is divisible by 3. Each index must be less than positions.size(). |
| normals | normals of the vertices. Must either be empty or have the same size as positions. If empty, normals will be generated automatically. |
| tangents | tangents of the vertices. Must either be empty or have the same size as positions. If empty, tangents will be generated automatically. |
| textureCoordinatesChannel0 | channel 0 texture coordinates of the vertices. Must either be empty or have the same size as positions. |
| textureCoordinatesChannel1 | channel 1 texture coordinates of the vertices. Must either be empty or have the same size as positions. |
| colors | colors of the vertices. Must either be empty or have the same size as positions. |
| material | material 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. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
| 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.
| polytope | convex polytope to model. |
| transformation | transformation to apply to each of the polytope vertices in the new model. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
| 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:
| filesystem | filepath to load the files from. |
| filepath | input filepath of the model file to load. |
| options | model options, see ModelOptions. |
| File::Error | on failure to open a file. |
| resource::Error | on failure to load a valid model. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
| 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.
| asset | glTF asset to assign the model from. |
| loadImage | function to use to load the images required by the asset given their relative filepaths and image options. |
| loadBufferData | function to use to load the buffer contents required by the asset given their relative filepaths. |
| options | model options, see ModelOptions. |
| resource::Error | on failure to load a valid model. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
| any | exception thrown by the loadImage callback. |
| any | exception thrown by the loadBufferData callback. |
| 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.
| asset | OBJ asset to assign the model from. |
| materialLibrary | material library to get materials from, which should contain the materials loaded from the files specified by obj::Asset::materialLibraryFilenames. |
| loadImage | function to use to load the images required by the materials in the asset given their relative filepaths and image options. |
| options | model options, see ModelOptions. |
| resource::Error | on failure to load a valid model. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
| any | exception thrown by the loadImage callback. |
|
inlinenodiscardnoexcept |
Find the index of an animation with a specific name.
| name | name of the animation to search for. |
|
inlinenodiscard |
Get the index of an animation with a specific name.
| name | name of the animation to search for. |
| std::out_of_range | if the given animation wasn't found. |
|
inlinenodiscard |
Get the animation at a specific index.
| index | index of the animation to get. |
| std::out_of_range | if the given index is out of range. |
|
inlinenodiscard |
Get the animation with a specific name.
| name | name of the animation to search for. |
| std::out_of_range | if the animation wasn't found. |
|
inlinenodiscardnoexcept |
Try to get the animation with a specific name.
| name | name of the animation to search for. |
|
inlinenodiscardnoexcept |
Find the index of a joint with a specific name.
| name | name of the joint to search for. |
|
inlinenodiscard |
Get the index of a joint with a specific name.
| name | name of the joint to search for. |
| std::out_of_range | if the given joint wasn't found. |
|
inlinenodiscardnoexcept |
Find the index of the root joint of a skin with a specific name.
| name | name of the skin whose root joint to search for. |
|
inlinenodiscard |
Get the index of the root joint of a skin with a specific name.
| name | name of the skin whose root joint to search for. |
| std::out_of_range | if the given skin wasn't found. |
|
inlinenodiscardnoexcept |
Find the index of a texture with a specific name.
| name | name of the texture to search for. |
|
inlinenodiscard |
Get the index of a texture with a specific name.
| name | name of the texture to search for. |
| std::out_of_range | if the given texture wasn't found. |
|
inlinenodiscardnoexcept |
Find the index of a material with a specific name.
| name | name of the material to search for. |
|
inlinenodiscard |
Get the index of a material with a specific name.
| name | name of the material to search for. |
| std::out_of_range | if the given material wasn't found. |
|
inlinenodiscardnoexcept |
Find the index of a light with a specific name.
| name | name of the light to search for. |
|
inlinenodiscard |
Get the index of a light with a specific name.
| name | name of the light to search for. |
| std::out_of_range | if the given light wasn't found. |
|
inlinenodiscardnoexcept |
Find the index of a collision layer with a specific name.
| name | name of the collision layer to search for. |
|
inlinenodiscard |
Get the index of a collision layer with a specific name.
| name | name of the collision layer to search for. |
| std::out_of_range | if the given collision layer wasn't found. |
|
staticconstexpr |
Maximum number of collision layers in a model.
| Buffer<byte> grem::resource::Model::morphTargetData {} |
Morph target data of the model. Indexed by meshes.
Layout of mesh data in the model. Indexed by instances.
| Pose grem::resource::Model::bindPose {} |
Initial bind pose of the model. Indexed by instances, lights, physicsObjects, jointMap and skinMap.
| ArrayList<JointIndex> grem::resource::Model::jointParentIndices {} |
Indices of the parent joint of each joint of the model.
Colliders of each joint in the model.
| 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.
| JointCount grem::resource::Model::staticJointCount = 0 |
Number of unskinned joints at the beginning of the joint array.
Animations of the model. Indexed by animationMap.
| ArrayList<AnimationChannel> grem::resource::Model::animationChannels {} |
Animation channels of the model. Indexed by animations.
| ArrayList<float> grem::resource::Model::keyframeInputTimePoints {} |
Keyframe input time points of animation channels. Indexed by animationChannels.
| Buffer<byte> grem::resource::Model::keyframeOutputValueData {} |
Keyframe output value data of animation channels. Indexed by animationChannels.
Textures of the model. Indexed by materials and textureMap.
Materials of the model. Indexed by instances and materialMap.
| ArrayList<PhysicsObject> grem::resource::Model::physicsObjects {} |
Physics objects in the model. Indexed by physicsJoints and jointPhysicsObjectIndices.
| ArrayList<PhysicsJoint> grem::resource::Model::physicsJoints {} |
Physics joints in the model.
| Box<3, float> grem::resource::Model::bindPoseBoundingBox {} |
Local axis-aligned bounding box of all meshes' vertex positions in the initial bind pose.
| float grem::resource::Model::bindPoseBoundingRadius = 0.0f |
Maximum distance from the origin of all meshes' vertex positions in the initial bind pose.
| JointMap grem::resource::Model::jointMap {} |
Map from joint names to their index in the joint array.
| JointMap grem::resource::Model::skinMap {} |
Map from skin names to the index of their root joint in the joint array.
| AnimationMap grem::resource::Model::animationMap {} |
Map from animation names to their index in the animation array.
| TextureMap grem::resource::Model::textureMap {} |
Map from texture names to their index in the texture array.
| MaterialMap grem::resource::Model::materialMap {} |
Map from material names to their index in the material array.
| LightMap grem::resource::Model::lightMap {} |
Map from light names to their index in the light array.
| CollisionLayerMap grem::resource::Model::collisionLayerMap {} |
Map from collision layer names to their index in a collision layer set.