Convenience wrapper that owns mesh, textures, descriptors, and pipeline state. More...
#include <mxvk/include/mxvk/mxvk_abstract_model.hpp>
Public Member Functions | |
| void | cleanup (VK_Window *window) |
| Destroy all owned Vulkan resources. | |
| void | enableExtendedFragmentUniforms () |
| Use binding 1 for fragment uniforms and binding 2 for model transforms. | |
| bool | isLoaded () const |
| True once the model has been uploaded to GPU buffers. | |
| void | load (VK_Window *window, const std::string &modelPath, const std::string &textureManifestPath, const std::string &textureBasePath, float scale=1.0f) |
| Load mesh/texture resources and build Vulkan state. | |
| void | load (VK_Window *window, MXModel &&model, const std::string &textureManifestPath, const std::string &textureBasePath, float scale=1.0f) |
| Consume pre-parsed mesh data and build Vulkan state. | |
| const MXModel & | model () const |
| Access the underlying mesh object. | |
| glm::vec3 | modelAxisExtent () const |
| Per-axis extent (max - min) of the source mesh's bounding box. | |
| glm::vec3 | modelCenterOffset () const |
| Access the computed center offset used for normalization. | |
| float | modelRenderScale () const |
| Access the computed render scale used for normalization. | |
| VKAbstractModel & | operator= (const VKAbstractModel &)=delete |
| VKAbstractModel & | operator= (VKAbstractModel &&)=delete |
| void | render (VkCommandBuffer cmd, uint32_t imageIndex, bool wireframe=false) const |
| Record draw commands for this model. | |
| void | renderWithPushConstants (VkCommandBuffer cmd, uint32_t imageIndex, size_t textureIndex, const UniformBufferObject &ubo, bool wireframe=false) |
| Record one draw using push constants for per-draw transforms and an explicit texture slot. | |
| void | resize (VK_Window *window) |
| Rebuild swapchain-dependent resources after resize. | |
| void | setAlphaBlending (bool enabled) |
| Enable or disable alpha blending for this model pipeline. | |
| void | setBackfaceCulling (bool enabled) |
| Enable or disable backface culling for this model pipeline. | |
| void | setFragmentPushConstants (const ModelFragmentPushConstants &constants) |
| Set sprite-compatible push constants used by custom fragment shaders. | |
| void | setShaders (VK_Window *window, const std::string &vertSpv, const std::string &fragSpv) |
| Configure custom shader paths and rebuild pipelines. | |
| void | updateFragmentUBO (uint32_t imageIndex, const ModelFragmentUniforms &uniforms) |
| Update extended fragment uniforms for one swapchain image. | |
| bool | updatePrimaryTexture (const void *pixels, int width, int height, int pitch=0) |
| Upload raw RGBA pixels into the primary model texture. | |
| void | updateUBO (uint32_t imageIndex, const UniformBufferObject &ubo) |
| Update one per-frame UBO payload. | |
| VKAbstractModel ()=default | |
| VKAbstractModel (const VKAbstractModel &)=delete | |
| VKAbstractModel (VKAbstractModel &&)=delete | |
| ~VKAbstractModel ()=default | |
Convenience wrapper that owns mesh, textures, descriptors, and pipeline state.
This class is intended to be recorded from inside VK_Window::onRecordCustomRendering() so it participates in the same dynamic-rendering pass as sprites/text.
Definition at line 67 of file mxvk_abstract_model.hpp.
|
default |
|
default |
|
delete |
|
delete |
| void mxvk::VKAbstractModel::cleanup | ( | VK_Window * | window | ) |
Destroy all owned Vulkan resources.
| window | Active MXVK window. |
Definition at line 461 of file mxvk_abstract_model.cpp.
| void mxvk::VKAbstractModel::enableExtendedFragmentUniforms | ( | ) |
Use binding 1 for fragment uniforms and binding 2 for model transforms.
Call before load().
Definition at line 214 of file mxvk_abstract_model.cpp.
|
inlinenodiscard |
True once the model has been uploaded to GPU buffers.
Definition at line 192 of file mxvk_abstract_model.hpp.
| void mxvk::VKAbstractModel::load | ( | VK_Window * | window, |
| const std::string & | modelPath, | ||
| const std::string & | textureManifestPath, | ||
| const std::string & | textureBasePath, | ||
| float | scale = 1.0f ) |
Load mesh/texture resources and build Vulkan state.
| window | Active MXVK window. |
| modelPath | Path to .obj or .mxmod mesh file. |
| textureManifestPath | Optional texture manifest path (.tex or .mtl-like text). |
| textureBasePath | Optional base path for texture files in the manifest. |
| scale | Uniform mesh scale. |
Definition at line 81 of file mxvk_abstract_model.cpp.
| void mxvk::VKAbstractModel::load | ( | VK_Window * | window, |
| MXModel && | model, | ||
| const std::string & | textureManifestPath, | ||
| const std::string & | textureBasePath, | ||
| float | scale = 1.0f ) |
Consume pre-parsed mesh data and build Vulkan state.
| window | Active MXVK window. |
| model | Pre-parsed CPU-side model data. |
| textureManifestPath | Optional texture manifest path (.tex or .mtl-like text). |
| textureBasePath | Optional base path for texture files in the manifest. |
| scale | Uniform mesh scale. Kept for API compatibility. |
Definition at line 126 of file mxvk_abstract_model.cpp.
|
inlinenodiscard |
Access the underlying mesh object.
Definition at line 184 of file mxvk_abstract_model.hpp.
|
inlinenodiscard |
Per-axis extent (max - min) of the source mesh's bounding box.
Definition at line 190 of file mxvk_abstract_model.hpp.
|
inlinenodiscard |
Access the computed center offset used for normalization.
Definition at line 186 of file mxvk_abstract_model.hpp.
|
inlinenodiscard |
Access the computed render scale used for normalization.
Definition at line 188 of file mxvk_abstract_model.hpp.
|
delete |
|
delete |
| void mxvk::VKAbstractModel::render | ( | VkCommandBuffer | cmd, |
| uint32_t | imageIndex, | ||
| bool | wireframe = false ) const |
Record draw commands for this model.
| cmd | Active command buffer, inside a dynamic rendering scope. |
| imageIndex | Current swapchain image index. |
| wireframe | Render using the optional wireframe pipeline when available. |
Definition at line 345 of file mxvk_abstract_model.cpp.
| void mxvk::VKAbstractModel::renderWithPushConstants | ( | VkCommandBuffer | cmd, |
| uint32_t | imageIndex, | ||
| size_t | textureIndex, | ||
| const UniformBufferObject & | ubo, | ||
| bool | wireframe = false ) |
Record one draw using push constants for per-draw transforms and an explicit texture slot.
| cmd | Active command buffer, inside a dynamic rendering scope. |
| imageIndex | Current swapchain image index. |
| textureIndex | Texture slot to bind for all submeshes in this draw. |
| ubo | Transform/effect payload copied into vertex-stage push constants. |
| wireframe | Render using the optional wireframe pipeline when available. |
Definition at line 387 of file mxvk_abstract_model.cpp.
| void mxvk::VKAbstractModel::resize | ( | VK_Window * | window | ) |
Rebuild swapchain-dependent resources after resize.
| window | Active MXVK window. |
Definition at line 440 of file mxvk_abstract_model.cpp.
| void mxvk::VKAbstractModel::setAlphaBlending | ( | bool | enabled | ) |
Enable or disable alpha blending for this model pipeline.
| enabled | True to blend fragment alpha and avoid depth writes. |
Definition at line 192 of file mxvk_abstract_model.cpp.
| void mxvk::VKAbstractModel::setBackfaceCulling | ( | bool | enabled | ) |
Enable or disable backface culling for this model pipeline.
| enabled | True to cull backfaces, false to disable culling. |
Definition at line 181 of file mxvk_abstract_model.cpp.
| void mxvk::VKAbstractModel::setFragmentPushConstants | ( | const ModelFragmentPushConstants & | constants | ) |
Set sprite-compatible push constants used by custom fragment shaders.
Definition at line 228 of file mxvk_abstract_model.cpp.
| void mxvk::VKAbstractModel::setShaders | ( | VK_Window * | window, |
| const std::string & | vertSpv, | ||
| const std::string & | fragSpv ) |
Configure custom shader paths and rebuild pipelines.
| window | Active MXVK window. |
| vertSpv | Vertex shader SPIR-V path. |
| fragSpv | Fragment shader SPIR-V path. |
Definition at line 169 of file mxvk_abstract_model.cpp.
| void mxvk::VKAbstractModel::updateFragmentUBO | ( | uint32_t | imageIndex, |
| const ModelFragmentUniforms & | uniforms ) |
Update extended fragment uniforms for one swapchain image.
Definition at line 221 of file mxvk_abstract_model.cpp.
|
nodiscard |
Upload raw RGBA pixels into the primary model texture.
| pixels | Pointer to RGBA8 pixel data. |
| width | Texture width in pixels. |
| height | Texture height in pixels. |
| pitch | Bytes per input row. When 0, defaults to width * 4. |
Definition at line 232 of file mxvk_abstract_model.cpp.
| void mxvk::VKAbstractModel::updateUBO | ( | uint32_t | imageIndex, |
| const UniformBufferObject & | ubo ) |
Update one per-frame UBO payload.
| imageIndex | Swapchain image index. |
| ubo | New transform values. |
Definition at line 203 of file mxvk_abstract_model.cpp.