|
GREM 3.12.0
Game/Rendering Engine Modules for C++
|
Container for a set of 3D triangle mesh nodes stored on the GPU. More...
#include <GREM/graphics_3d/Model3D.hpp>
Classes | |
| struct | ShaderConfiguration |
| Configuration options for shading a mesh instance of a 3D model. More... | |
| struct | Vertex |
| Data layout for the attributes of a single vertex of a 3D model mesh. More... | |
| struct | Parameters |
| Parameters of a 3D model mesh. More... | |
| struct | Instance |
| Data layout for the attributes of a single instance of a 3D model mesh. More... | |
| struct | VertexShaderConstants |
| Struct of default vertex shader constants. More... | |
| struct | VertexShaderOutputs |
| Struct of fields output by the default vertex shader. More... | |
| struct | FragmentShaderConstants |
| Struct of default fragment shader constants. More... | |
| struct | FragmentShaderOutputs |
| Struct of fields output by the default fragment shader. More... | |
| struct | InverseBindPoseMatrixFields |
| Struct of shader fields representing the inverse bind matrix of a joint of a 3D model. More... | |
| struct | MorphTargetValueFields |
| Struct of shader fields representing the value of a morph target of a 3D model. More... | |
| struct | JointFields |
| Struct of shader fields representing a joint of a 3D model. More... | |
| struct | MorphTargetWeightFields |
| Struct of shader fields representing the state of a morph target weight of a 3D model. More... | |
| class | VertexShaderSelectorBase |
| Adapter for a function that selects which vertex shader to use for a given shader configuration. More... | |
| class | FragmentShaderSelectorBase |
| Adapter for a function that selects which fragment shader to use for a given shader configuration. More... | |
| class | ShaderPipelineSetBase |
| Shader pipeline set for drawing 3D models. More... | |
| class | ShaderPipelineSetBase< VertexShaderConstants, VertexShaderOutputs, meta::TypeList< ExtraVertexShaderBuffers... >, FragmentShaderConstants, FragmentShaderOutputs, meta::TypeList< ExtraFragmentShaderBuffers... > > |
| struct | Node |
| Node of a 3D model. More... | |
Public Types | |
| 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 3D model. More... | |
| using | Index = uint32_t |
| Data type used in the index buffer of a 3D model mesh. | |
| using | Mesh = graphics::Mesh<Vertex, Index, Parameters, Instance> |
| Type of a single mesh of a 3D model. | |
| using | InverseBindPoseMatrixBuffer = StorageBuffer<InverseBindPoseMatrixFields, "Model3DInverseBindPoseMatrices"> |
| Shader buffer for 3D model inverse bind-pose matrices. | |
| using | MorphTargetValueBuffer = StorageBuffer<MorphTargetValueFields, "Model3DMorphTargetValues"> |
| Shader buffer for 3D model morph target values. | |
| using | DataBuffers = BufferSet<InverseBindPoseMatrixBuffer, MorphTargetValueBuffer> |
| Set of shader buffers related to the static data of 3D models. | |
| using | JointBuffer = StorageBuffer<JointFields, "Model3DJoints"> |
| Shader buffer for 3D model joints. | |
| using | MorphTargetWeightBuffer = StorageBuffer<MorphTargetWeightFields, "Model3DMorphTargetWeights"> |
| Shader buffer for 3D model morph target weights. | |
| using | InstanceBuffers = BufferSet<JointBuffer, MorphTargetWeightBuffer> |
| Set of shader buffers related to the dynamic data of 3D model instances. | |
| template<typename Constants, typename Outputs, typename... ExtraBuffers> | |
| using | VertexShaderBase = graphics::VertexShader<Mesh, Constants, Outputs, Camera3D::ParameterBuffer, DataBuffers, InstanceBuffers, ExtraBuffers...> |
| Vertex shader for drawing 3D models. | |
| using | VertexShader = VertexShaderBase<VertexShaderConstants, VertexShaderOutputs> |
| Default vertex shader for drawing 3D models. | |
| template<typename Inputs, typename Constants, typename Outputs, typename... ExtraBuffers> | |
| using | FragmentShaderBase = graphics::FragmentShader<Mesh, Inputs, Constants, Outputs, Camera3D::ParameterBuffer, DataBuffers, InstanceBuffers, ExtraBuffers...> |
| Fragment shader for drawing 3D models. | |
| using | FragmentShader = FragmentShaderBase<VertexShaderOutputs, FragmentShaderConstants, FragmentShaderOutputs> |
| Default fragment shader type for drawing 3D models. | |
| using | ShaderPipeline = graphics::ShaderPipeline<Mesh> |
| Shader pipeline for drawing 3D models. | |
| using | ShaderPipelineSet = ShaderPipelineSetBase<VertexShaderConstants, VertexShaderOutputs, meta::TypeList<>, FragmentShaderConstants, FragmentShaderOutputs, meta::TypeList<>> |
| Default shader pipeline set for drawing 3D models. | |
Public Member Functions | |
| Model3D () noexcept=default | |
| Construct an invalid model that must be reassigned before use. | |
| Model3D (Device &device, Renderer3D &renderer3D, const resource::Model &model, const Model3DOptions &options={}, FunctionView< SharedPointer< TextureImplementation >(Device &, const resource::Model::Image &, const TextureImageUploadOptions &, const TextureSamplerOptions &)> loadTexture=loadTextureDefault) | |
| Construct a model from loaded model data. | |
| Model3D (Device &device, Renderer3D &renderer3D, resource::Model &&model, const Model3DOptions &options={}, FunctionView< SharedPointer< TextureImplementation >(Device &, const resource::Model::Image &, const TextureImageUploadOptions &, const TextureSamplerOptions &)> loadTexture=loadTextureDefault) | |
| Construct a model from loaded model data. | |
| ~Model3D () | |
| Destructor. | |
| Model3D (const Model3D &other) | |
| Copy constructor. | |
| Model3D (Model3D &&other) noexcept | |
| Move constructor. | |
| Model3D & | operator= (const Model3D &other) |
| Copy assignment. | |
| Model3D & | operator= (Model3D &&other) noexcept |
| Move assignment. | |
| operator bool () const noexcept | |
| Check if the model has a value. | |
| void | setNodeMeshParameters (size_t nodeIndex, const Parameters &newParameters) |
| Set the mesh parameters of a node in the model. | |
| void | setNodeMaterialType (size_t nodeIndex, MaterialType newMaterialType) |
| Set how to interpret the material parameters of a node in the model when shading. | |
| void | setNodeFrontFace (size_t nodeIndex, FrontFace newFrontFace) |
| Set the winding order of the front-facing faces of a node in the model. | |
| void | setNodeAlphaMasked (size_t nodeIndex, bool newAlphaMasked) |
| Set whether a node in the model is alpha masked or not. | |
| void | setNodeAlphaBlended (size_t nodeIndex, bool newAlphaBlended) |
| Set whether a node in the model is alpha blended or not. | |
| void | setNodeDoubleSided (size_t nodeIndex, bool newDoubleSided) |
| Set whether a node in the model is double-sided or not. | |
| Span< const Node > | getNodes () const noexcept |
| Get the nodes of the model. | |
| uint32_t | getInverseBindPoseMatrixOffset () const noexcept |
| Get the inverse bind-pose matrix offset of the model. | |
| uint32_t | getMorphTargetValueOffset () const noexcept |
| Get the morph target value offset of the model. | |
| const resource::Model::Pose & | getBindPose () const noexcept |
| Get the local bind pose of the model. | |
| resource::Model::JointCount | getJointCount () const noexcept |
| Get the number of joints in the model. | |
| resource::Model::JointCount | getStaticJointCount () const noexcept |
| Get the number of static joints in the model. | |
| resource::Model::MorphTargetWeightCount | getMorphTargetWeightCount () const noexcept |
| Get the number of morph target weights of the model. | |
| Span< const resource::Model::JointIndex > | getJointParentIndices () const noexcept |
| Get the indices of the parent joints of each joint of the model. | |
| Span< const resource::Model::Animation > | getAnimations () const noexcept |
| Get the animations of the model. | |
| Span< const resource::Model::AnimationChannel > | getAnimationChannels () const noexcept |
| Get the animation channels of the model. | |
| Span< const float > | getKeyframeInputTimePoints () const noexcept |
| Get the input timepoints of the animation channel keyframes of the model. | |
| Span< const byte > | getKeyframeOutputValueData () const noexcept |
| Get the output values of the animation channel keyframes of the model. | |
| Optional< resource::Model::AnimationIndex > | findAnimationIndex (StringView name) const noexcept |
| Find the index of an animation with a specific name. | |
| resource::Model::AnimationIndex | getAnimationIndex (StringView name) const |
| Get the index of an animation with a specific name. | |
| resource::Model::AnimationView | getAnimationAtIndex (resource::Model::AnimationIndex index) const |
| Get the animation at a specific index. | |
| resource::Model::AnimationView | getAnimation (StringView name) const |
| Get the animation with a specific name. | |
| Optional< resource::Model::AnimationView > | findAnimation (StringView name) const noexcept |
| Try to get the animation with a specific name. | |
| Optional< resource::Model::JointIndex > | findJointIndex (StringView name) const noexcept |
| Find the index of a joint with a specific name. | |
| resource::Model::JointIndex | getJointIndex (StringView name) const |
| Get the index of a joint with a specific name. | |
| Optional< resource::Model::JointIndex > | findSkinRootJointIndex (StringView name) const noexcept |
| Find the index of the root joint of a skin with a specific name. | |
| resource::Model::JointIndex | getSkinRootJointIndex (StringView name) const |
| Get the index of the root joint of a skin with a specific name. | |
| Box< 3, float > | getBindPoseBoundingBox () const noexcept |
| Get the local bounding box of the model in its bind pose. | |
| float | getBindPoseBoundingRadius () const noexcept |
| Get the local bounding radius of the model in its bind pose. | |
Static Public Attributes | |
| static constexpr auto | DEFAULT_VERTEX_SHADER_CONSTANTS |
| Default 3D model vertex shader constants. | |
| static constexpr auto | DEFAULT_FRAGMENT_SHADER_CONSTANTS |
| Default 3D model fragment shader constants. | |
| static constexpr auto | DEFAULT_SHADER_PIPELINE_OPTIONS |
| Default 3D model graphics pipeline configuration. | |
Container for a set of 3D triangle mesh nodes stored on the GPU.
| using grem::graphics::Model3D::Index = uint32_t |
Data type used in the index buffer of a 3D model mesh.
Meets the requirements of the grem::graphics::mesh_index concept.
Type of a single mesh of a 3D model.
| using grem::graphics::Model3D::InverseBindPoseMatrixBuffer = StorageBuffer<InverseBindPoseMatrixFields, "Model3DInverseBindPoseMatrices"> |
Shader buffer for 3D model inverse bind-pose matrices.
| using grem::graphics::Model3D::MorphTargetValueBuffer = StorageBuffer<MorphTargetValueFields, "Model3DMorphTargetValues"> |
Shader buffer for 3D model morph target values.
| using grem::graphics::Model3D::DataBuffers = BufferSet<InverseBindPoseMatrixBuffer, MorphTargetValueBuffer> |
Set of shader buffers related to the static data of 3D models.
| using grem::graphics::Model3D::JointBuffer = StorageBuffer<JointFields, "Model3DJoints"> |
Shader buffer for 3D model joints.
| using grem::graphics::Model3D::MorphTargetWeightBuffer = StorageBuffer<MorphTargetWeightFields, "Model3DMorphTargetWeights"> |
Shader buffer for 3D model morph target weights.
Set of shader buffers related to the dynamic data of 3D model instances.
| using grem::graphics::Model3D::VertexShaderBase = graphics::VertexShader<Mesh, Constants, Outputs, Camera3D::ParameterBuffer, DataBuffers, InstanceBuffers, ExtraBuffers...> |
Vertex shader for drawing 3D models.
| Constants | user-defined aggregate type of external constants that are declared in the shader. |
| Outputs | user-defined aggregate type of fields that are declared in the shader and passed to the next pipeline stage. |
| ExtraBuffers | list of buffers that the shader reads from in addition to the required 3D model buffers. |
| using grem::graphics::Model3D::VertexShader = VertexShaderBase<VertexShaderConstants, VertexShaderOutputs> |
Default vertex shader for drawing 3D models.
| using grem::graphics::Model3D::FragmentShaderBase = graphics::FragmentShader<Mesh, Inputs, Constants, Outputs, Camera3D::ParameterBuffer, DataBuffers, InstanceBuffers, ExtraBuffers...> |
Fragment shader for drawing 3D models.
| Inputs | user-defined aggregate type of fields that are passed into the shader from the previous pipeline stage. |
| Constants | user-defined aggregate type of external constants that are declared in the shader. |
| Outputs | user-defined aggregate type of fields that are declared in the shader and passed to the next pipeline stage. |
| ExtraBuffers | list of buffers that the shader reads from in addition to the required 3D model buffers. |
| using grem::graphics::Model3D::FragmentShader = FragmentShaderBase<VertexShaderOutputs, FragmentShaderConstants, FragmentShaderOutputs> |
Default fragment shader type for drawing 3D models.
Shader pipeline for drawing 3D models.
Default shader pipeline set for drawing 3D models.
|
strong |
Material type that specifies how the material parameters should be interpreted when shading a mesh instance of a 3D 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. |
|
defaultnoexcept |
Construct an invalid model that must be reassigned before use.
| grem::graphics::Model3D::Model3D | ( | Device & | device, |
| Renderer3D & | renderer3D, | ||
| const resource::Model & | model, | ||
| const Model3DOptions & | options = {}, | ||
| FunctionView< SharedPointer< TextureImplementation >(Device &, const resource::Model::Image &, const TextureImageUploadOptions &, const TextureSamplerOptions &)> | loadTexture = loadTextureDefault ) |
Construct a model from loaded model data.
| device | device to create the model for. Must outlive the model. |
| renderer3D | renderer to create the model for. Must be associated with the given device. Must outlive the model. |
| model | data to create the model from. |
| options | model options, see Model3DOptions. |
| loadTexture | function to use to load the textures from the images provided by the model. Defaults to creating a new texture. |
| graphics::Error | on failure to create the 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::graphics::Model3D::Model3D | ( | Device & | device, |
| Renderer3D & | renderer3D, | ||
| resource::Model && | model, | ||
| const Model3DOptions & | options = {}, | ||
| FunctionView< SharedPointer< TextureImplementation >(Device &, const resource::Model::Image &, const TextureImageUploadOptions &, const TextureSamplerOptions &)> | loadTexture = loadTextureDefault ) |
Construct a model from loaded model data.
| device | device to create the model for. Must outlive the model. |
| renderer3D | renderer to create the model for. Must be associated with the given device. Must outlive the model. |
| model | data to create the model from. |
| options | model options, see Model3DOptions. |
| loadTexture | function to use to load the textures from the images provided by the model. Defaults to creating a new texture. |
| graphics::Error | on failure to create the 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::graphics::Model3D::~Model3D | ( | ) |
Destructor.
| grem::graphics::Model3D::Model3D | ( | const Model3D & | other | ) |
Copy constructor.
|
noexcept |
Move constructor.
|
inlineexplicitnoexcept |
Check if the model has a value.
|
inline |
Set the mesh parameters of a node in the model.
| nodeIndex | index of the node whose parameters to update. Must be a valid node index. |
| newParameters | new parameter values to set. |
| graphics::Error | on failure to set the parameters. |
| 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. |
|
inline |
Set how to interpret the material parameters of a node in the model when shading.
| nodeIndex | index of the node to update. Must be a valid node index. |
| newMaterialType | new material type to set. |
|
inline |
Set the winding order of the front-facing faces of a node in the model.
| nodeIndex | index of the node to update. Must be a valid node index. |
| newFrontFace | new front face to set. |
|
inline |
Set whether a node in the model is alpha masked or not.
| nodeIndex | index of the node to update. Must be a valid node index. |
| newAlphaMasked | new alpha masked state to set. |
|
inline |
Set whether a node in the model is alpha blended or not.
| nodeIndex | index of the node to update. Must be a valid node index. |
| newAlphaBlended | new alpha blended state to set. |
|
inline |
Set whether a node in the model is double-sided or not.
| nodeIndex | index of the node to update. Must be a valid node index. |
| newDoubleSided | new double-sided state to set. |
Get the nodes of the model.
|
inlinenodiscardnoexcept |
Get the inverse bind-pose matrix offset of the model.
|
inlinenodiscardnoexcept |
Get the morph target value offset of the model.
|
inlinenodiscardnoexcept |
Get the local bind pose of the model.
|
inlinenodiscardnoexcept |
Get the number of joints in the model.
|
inlinenodiscardnoexcept |
Get the number of static joints in the model.
|
inlinenodiscardnoexcept |
Get the number of morph target weights of the model.
|
inlinenodiscardnoexcept |
Get the indices of the parent joints of each joint of the model.
|
inlinenodiscardnoexcept |
Get the animations of the model.
|
inlinenodiscardnoexcept |
Get the animation channels of the model.
|
inlinenodiscardnoexcept |
Get the input timepoints of the animation channel keyframes of the model.
|
inlinenodiscardnoexcept |
Get the output values of the animation channel keyframes of the model.
|
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 was not 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 |
Get the local bounding box of the model in its bind pose.
|
inlinenodiscardnoexcept |
Get the local bounding radius of the model in its bind pose.
|
staticconstexpr |
Default 3D model vertex shader constants.
|
staticconstexpr |
Default 3D model fragment shader constants.
|
staticconstexpr |
Default 3D model graphics pipeline configuration.
| Device* grem::graphics::Model3D::device = nullptr |
| Renderer3D* grem::graphics::Model3D::renderer3D = nullptr |
| RangeAllocation<uint32_t> grem::graphics::Model3D::inverseBindPoseMatrixRange {} |
| RangeAllocation<uint32_t> grem::graphics::Model3D::morphTargetValueRange {} |
| resource::Model::Pose grem::graphics::Model3D::bindPose {} |
| ArrayList<resource::Model::JointIndex> grem::graphics::Model3D::jointParentIndices {} |
| ArrayList<resource::Model::Animation> grem::graphics::Model3D::animations {} |
| ArrayList<resource::Model::AnimationChannel> grem::graphics::Model3D::animationChannels {} |
| ArrayList<float> grem::graphics::Model3D::keyframeInputTimePoints {} |
| Buffer<byte> grem::graphics::Model3D::keyframeOutputValueData {} |
| resource::Model::JointCount grem::graphics::Model3D::staticJointCount = 0 |
| Box<3, float> grem::graphics::Model3D::bindPoseBoundingBox {} |
| float grem::graphics::Model3D::bindPoseBoundingRadius = 0.0f |
| resource::Model::JointMap grem::graphics::Model3D::jointMap {} |
| resource::Model::JointMap grem::graphics::Model3D::skinMap {} |
| resource::Model::AnimationMap grem::graphics::Model3D::animationMap {} |