Skinned mesh stuff moved to class, added resources
This commit is contained in:
parent
26b02736d5
commit
7087d7d14e
19 changed files with 2637 additions and 14775 deletions
|
|
@ -6,9 +6,16 @@ if %ERRORLEVEL% EQU 0 (
|
|||
|
||||
mkdir "assets\shaders\skeletalanimation"
|
||||
xcopy "..\..\data\shaders\skeletalanimation\*.spv" "assets\shaders\skeletalanimation" /Y
|
||||
mkdir "assets\shaders\base"
|
||||
xcopy "..\..\data\shaders\base\*.spv" "assets\shaders\base" /Y
|
||||
|
||||
mkdir "assets\models\astroboy"
|
||||
xcopy "..\..\data\models\astroboy\*.*" "assets\models\astroboy" /Y
|
||||
mkdir "assets\models"
|
||||
xcopy "..\..\data\models\goblin.dae" "assets\models" /Y
|
||||
xcopy "..\..\data\models\plane_z.obj" "assets\models" /Y
|
||||
|
||||
mkdir "assets\textures"
|
||||
xcopy "..\..\data\textures\pattern_35_bc3.ktx" "assets\textures" /Y
|
||||
xcopy "..\..\data\textures\goblin_bc3.ktx" "assets\textures" /Y
|
||||
|
||||
mkdir "res\drawable"
|
||||
xcopy "..\..\android\images\icon.png" "res\drawable" /Y
|
||||
|
|
|
|||
|
|
@ -44,7 +44,9 @@ namespace vkMeshLoader
|
|||
VERTEX_LAYOUT_COLOR = 0x2,
|
||||
VERTEX_LAYOUT_UV = 0x3,
|
||||
VERTEX_LAYOUT_TANGENT = 0x4,
|
||||
VERTEX_LAYOUT_BITANGENT = 0x5
|
||||
VERTEX_LAYOUT_BITANGENT = 0x5,
|
||||
VERTEX_LAYOUT_DUMMY_FLOAT = 0x6,
|
||||
VERTEX_LAYOUT_DUMMY_VEC4 = 0x7
|
||||
} VertexLayout;
|
||||
|
||||
struct MeshBufferInfo
|
||||
|
|
@ -444,7 +446,18 @@ public:
|
|||
vertexBuffer.push_back(m_Entries[m].Vertices[i].m_binormal.y);
|
||||
vertexBuffer.push_back(m_Entries[m].Vertices[i].m_binormal.z);
|
||||
}
|
||||
// todo : add checks if vertex component exists
|
||||
// Dummy layout components for padding
|
||||
if (layoutDetail == vkMeshLoader::VERTEX_LAYOUT_DUMMY_FLOAT)
|
||||
{
|
||||
vertexBuffer.push_back(0.0f);
|
||||
}
|
||||
if (layoutDetail == vkMeshLoader::VERTEX_LAYOUT_DUMMY_VEC4)
|
||||
{
|
||||
vertexBuffer.push_back(0.0f);
|
||||
vertexBuffer.push_back(0.0f);
|
||||
vertexBuffer.push_back(0.0f);
|
||||
vertexBuffer.push_back(0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ protected:
|
|||
float frameTimer = 1.0f;
|
||||
// Frame counter to display fps
|
||||
uint32_t frameCounter = 0;
|
||||
uint32_t lastFPS = 0.0f;
|
||||
uint32_t lastFPS = 0;
|
||||
// Vulkan instance, stores all per-application states
|
||||
VkInstance instance;
|
||||
// Physical device (GPU) that Vulkan will ise
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Binary file not shown.
|
|
@ -1,3 +0,0 @@
|
|||
Copyright 2008 Sony Computer Entertainment Inc.
|
||||
Licensed under the Creative Commons Attribution Noncommercial Share Alike license.
|
||||
See license file or www.creativecommons.org for details.
|
||||
2181
data/models/goblin.dae
Normal file
2181
data/models/goblin.dae
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -1,2 +1,4 @@
|
|||
glslangvalidator -V mesh.vert -o mesh.vert.spv
|
||||
glslangvalidator -V mesh.frag -o mesh.frag.spv
|
||||
glslangvalidator -V texture.vert -o texture.vert.spv
|
||||
glslangvalidator -V texture.frag -o texture.frag.spv
|
||||
|
|
@ -8,27 +8,20 @@ layout (binding = 1) uniform sampler2D samplerColorMap;
|
|||
layout (location = 0) in vec3 inNormal;
|
||||
layout (location = 1) in vec3 inColor;
|
||||
layout (location = 2) in vec2 inUV;
|
||||
layout (location = 3) in vec3 inEyePos;
|
||||
layout (location = 3) in vec3 inViewVec;
|
||||
layout (location = 4) in vec3 inLightVec;
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 N = normalize(inNormal);
|
||||
vec3 L = normalize(vec3(1.0));
|
||||
|
||||
vec3 Eye = normalize(-inEyePos);
|
||||
vec3 Reflected = normalize(reflect(-inLightVec, inNormal));
|
||||
|
||||
vec4 IAmbient = vec4(vec3(0.25), 1.0);
|
||||
vec4 IDiffuse = vec4(1.0) * max(dot(inNormal, inLightVec), 0.0);
|
||||
|
||||
float specular = 0.75 * 0.0;
|
||||
vec4 ISpecular = vec4(0.5, 0.5, 0.5, 1.0) * pow(max(dot(Reflected, Eye), 0.0), 4.0) * specular;
|
||||
|
||||
vec4 color = texture(samplerColorMap, inUV) * vec4(inColor, 1.0);
|
||||
|
||||
outFragColor = vec4((IAmbient + IDiffuse) * color + (ISpecular * IDiffuse));
|
||||
|
||||
vec3 N = normalize(inNormal);
|
||||
vec3 L = normalize(inLightVec);
|
||||
vec3 V = normalize(inViewVec);
|
||||
vec3 R = reflect(-L, N);
|
||||
vec3 diffuse = max(dot(N, L), 0.0) * vec3(1.0);// * inColor;
|
||||
vec3 specular = pow(max(dot(R, V), 0.0), 32.0) * vec3(0.5);
|
||||
outFragColor = vec4(diffuse * color.rgb + specular, 1.0);
|
||||
}
|
||||
Binary file not shown.
|
|
@ -10,7 +10,7 @@ layout (location = 3) in vec3 inColor;
|
|||
layout (location = 4) in vec4 inBoneWeights;
|
||||
layout (location = 5) in ivec4 inBoneIDs;
|
||||
|
||||
#define MAX_BONES 128
|
||||
#define MAX_BONES 64
|
||||
|
||||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
|
|
@ -18,12 +18,13 @@ layout (binding = 0) uniform UBO
|
|||
mat4 model;
|
||||
mat4 bones[MAX_BONES];
|
||||
vec4 lightPos;
|
||||
vec4 viewPos;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) out vec3 outNormal;
|
||||
layout (location = 1) out vec3 outColor;
|
||||
layout (location = 2) out vec2 outUV;
|
||||
layout (location = 3) out vec3 outEyePos;
|
||||
layout (location = 3) out vec3 outViewVec;
|
||||
layout (location = 4) out vec3 outLightVec;
|
||||
|
||||
void main()
|
||||
|
|
@ -39,8 +40,8 @@ void main()
|
|||
|
||||
gl_Position = ubo.projection * ubo.model * boneTransform * vec4(inPos.xyz, 1.0);
|
||||
|
||||
outEyePos = (gl_Position).xyz;
|
||||
|
||||
vec4 lightPos = ubo.lightPos;
|
||||
outLightVec = normalize(lightPos.xyz - outEyePos);
|
||||
vec4 pos = ubo.model * vec4(inPos, 1.0);
|
||||
outNormal = mat3(inverse(transpose(ubo.model))) * inNormal;
|
||||
outLightVec = ubo.lightPos.xyz - pos.xyz;
|
||||
outViewVec = ubo.viewPos.xyz - pos.xyz;
|
||||
}
|
||||
Binary file not shown.
32
data/shaders/skeletalanimation/texture.frag
Normal file
32
data/shaders/skeletalanimation/texture.frag
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (binding = 1) uniform sampler2D samplerColorMap;
|
||||
|
||||
layout (location = 0) in vec2 inUV;
|
||||
layout (location = 1) in vec3 inNormal;
|
||||
layout (location = 2) in vec3 inViewVec;
|
||||
layout (location = 3) in vec3 inLightVec;
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = texture(samplerColorMap, inUV);
|
||||
|
||||
float distSqr = dot(inLightVec, inLightVec);
|
||||
vec3 lVec = inLightVec * inversesqrt(distSqr);
|
||||
|
||||
float invRadius = 1.0/4500.0;
|
||||
|
||||
float atten = max(clamp(1.0 - invRadius * sqrt(distSqr), 0.0, 1.0), 0.0);
|
||||
|
||||
// Fake drop shadow
|
||||
invRadius = 1.0/2500.0;
|
||||
float dropshadow = max(clamp(1.0 - invRadius * sqrt(distSqr), 0.0, 1.0), 0.0);
|
||||
|
||||
outFragColor = vec4(color.g * (1.0 - dropshadow));
|
||||
outFragColor.rgb *= atten;
|
||||
}
|
||||
BIN
data/shaders/skeletalanimation/texture.frag.spv
Normal file
BIN
data/shaders/skeletalanimation/texture.frag.spv
Normal file
Binary file not shown.
33
data/shaders/skeletalanimation/texture.vert
Normal file
33
data/shaders/skeletalanimation/texture.vert
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (location = 0) in vec3 inPos;
|
||||
layout (location = 1) in vec3 inNormal;
|
||||
layout (location = 2) in vec2 inUV;
|
||||
|
||||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
mat4 projection;
|
||||
mat4 model;
|
||||
vec4 lightPos;
|
||||
vec4 viewPos;
|
||||
vec2 uvOffset;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) out vec2 outUV;
|
||||
layout (location = 1) out vec3 outNormal;
|
||||
layout (location = 2) out vec3 outViewVec;
|
||||
layout (location = 3) out vec3 outLightVec;
|
||||
|
||||
void main()
|
||||
{
|
||||
outUV = inUV * 2.0 + ubo.uvOffset;
|
||||
vec4 pos = vec4(inPos, 1.0);
|
||||
gl_Position = ubo.projection * ubo.model * vec4(pos);
|
||||
|
||||
outNormal = mat3(ubo.model) * inNormal;
|
||||
outLightVec = ubo.lightPos.xyz - pos.xyz;
|
||||
outViewVec = ubo.viewPos.xyz - pos.xyz;
|
||||
}
|
||||
BIN
data/shaders/skeletalanimation/texture.vert.spv
Normal file
BIN
data/shaders/skeletalanimation/texture.vert.spv
Normal file
Binary file not shown.
BIN
data/textures/goblin_bc3.ktx
Normal file
BIN
data/textures/goblin_bc3.ktx
Normal file
Binary file not shown.
BIN
data/textures/pattern_35_bc3.ktx
Normal file
BIN
data/textures/pattern_35_bc3.ktx
Normal file
Binary file not shown.
|
|
@ -45,25 +45,14 @@ std::vector<vkMeshLoader::VertexLayout> vertexLayout =
|
|||
vkMeshLoader::VERTEX_LAYOUT_DUMMY_VEC4
|
||||
};
|
||||
|
||||
class VulkanExample : public VulkanExampleBase
|
||||
{
|
||||
public:
|
||||
struct {
|
||||
vkTools::VulkanTexture colorMap;
|
||||
vkTools::VulkanTexture floor;
|
||||
} textures;
|
||||
|
||||
struct {
|
||||
VkPipelineVertexInputStateCreateInfo inputState;
|
||||
std::vector<VkVertexInputBindingDescription> bindingDescriptions;
|
||||
std::vector<VkVertexInputAttributeDescription> attributeDescriptions;
|
||||
} vertices;
|
||||
|
||||
// Mesh related stuff
|
||||
|
||||
// Maximum number of bones per mesh
|
||||
// Must not be higher than same const in skinning shader
|
||||
#define MAX_BONES 64
|
||||
// Maximum number of bones per vertex
|
||||
#define MAX_BONES_PER_VERTEX 4
|
||||
|
||||
// Skinned mesh class
|
||||
|
||||
// Per-vertex bone IDs and weights
|
||||
struct VertexBoneData
|
||||
{
|
||||
|
|
@ -98,7 +87,9 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
struct Mesh {
|
||||
class SkinnedMesh
|
||||
{
|
||||
public:
|
||||
// Bone related stuff
|
||||
// Maps bone name with index
|
||||
std::map<std::string, uint32_t> boneMapping;
|
||||
|
|
@ -110,169 +101,16 @@ public:
|
|||
aiMatrix4x4 globalInverseTransform;
|
||||
// Per-vertex bone info
|
||||
std::vector<VertexBoneData> bones;
|
||||
// Bone transformations
|
||||
std::vector<aiMatrix4x4> boneTransforms;
|
||||
|
||||
float animationSpeed = 0.75f;
|
||||
|
||||
// Vulkan buffers
|
||||
vkMeshLoader::MeshBuffer meshBuffer;
|
||||
// Reference to assimp mesh
|
||||
// Required for animation
|
||||
VulkanMeshLoader *meshLoader;
|
||||
} mesh;
|
||||
|
||||
struct {
|
||||
vkTools::UniformData vsScene;
|
||||
vkTools::UniformData floor;
|
||||
} uniformData;
|
||||
|
||||
// Must not be higher than same const in skinning shader
|
||||
#define MAX_BONES 64
|
||||
|
||||
struct {
|
||||
glm::mat4 projection;
|
||||
glm::mat4 model;
|
||||
glm::mat4 bones[MAX_BONES];
|
||||
glm::vec4 lightPos = glm::vec4(0.0f, -250.0f, 250.0f, 1.0);
|
||||
glm::vec4 viewPos;
|
||||
} uboVS;
|
||||
|
||||
struct {
|
||||
glm::mat4 projection;
|
||||
glm::mat4 model;
|
||||
glm::vec4 lightPos = glm::vec4(0.0, 0.0f, -25.0f, 1.0);
|
||||
glm::vec4 viewPos;
|
||||
glm::vec2 uvOffset;
|
||||
} uboFloor;
|
||||
|
||||
struct {
|
||||
VkPipeline skinning;
|
||||
VkPipeline texture;
|
||||
} pipelines;
|
||||
|
||||
struct {
|
||||
vkMeshLoader::MeshBuffer floor;
|
||||
} meshes;
|
||||
|
||||
VkPipelineLayout pipelineLayout;
|
||||
VkDescriptorSet descriptorSet;
|
||||
VkDescriptorSetLayout descriptorSetLayout;
|
||||
|
||||
struct {
|
||||
VkDescriptorSet skinning;
|
||||
VkDescriptorSet floor;
|
||||
} descriptorSets;
|
||||
|
||||
float runningTime = 0.0f;
|
||||
|
||||
VulkanExample() : VulkanExampleBase(ENABLE_VALIDATION)
|
||||
{
|
||||
zoom = -166.0f;
|
||||
zoomSpeed = 2.5f;
|
||||
rotationSpeed = 0.5f;
|
||||
rotation = { -187.0f, 60.0f, 180.0f };
|
||||
title = "Vulkan Example - Skeletal animation";
|
||||
paused = true;
|
||||
cameraPos = { 0.0f, 0.0f, 12.0f };
|
||||
}
|
||||
|
||||
~VulkanExample()
|
||||
{
|
||||
// Clean up used Vulkan resources
|
||||
// Note : Inherited destructor cleans up resources stored in base class
|
||||
vkDestroyPipeline(device, pipelines.skinning, nullptr);
|
||||
|
||||
vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
|
||||
vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr);
|
||||
|
||||
// Destroy and free mesh resources
|
||||
vkMeshLoader::freeMeshBufferResources(device, &mesh.meshBuffer);
|
||||
|
||||
textureLoader->destroyTexture(textures.colorMap);
|
||||
|
||||
vkTools::destroyUniformData(device, &uniformData.vsScene);
|
||||
|
||||
delete(mesh.meshLoader);
|
||||
}
|
||||
|
||||
void buildCommandBuffers()
|
||||
{
|
||||
VkCommandBufferBeginInfo cmdBufInfo = vkTools::initializers::commandBufferBeginInfo();
|
||||
|
||||
VkClearValue clearValues[2];
|
||||
clearValues[0].color = { { 0.0f, 0.0f, 0.0f, 0.0f} };
|
||||
clearValues[1].depthStencil = { 1.0f, 0 };
|
||||
|
||||
VkRenderPassBeginInfo renderPassBeginInfo = vkTools::initializers::renderPassBeginInfo();
|
||||
renderPassBeginInfo.renderPass = renderPass;
|
||||
renderPassBeginInfo.renderArea.offset.x = 0;
|
||||
renderPassBeginInfo.renderArea.offset.y = 0;
|
||||
renderPassBeginInfo.renderArea.extent.width = width;
|
||||
renderPassBeginInfo.renderArea.extent.height = height;
|
||||
renderPassBeginInfo.clearValueCount = 2;
|
||||
renderPassBeginInfo.pClearValues = clearValues;
|
||||
|
||||
for (int32_t i = 0; i < drawCmdBuffers.size(); ++i)
|
||||
{
|
||||
renderPassBeginInfo.framebuffer = frameBuffers[i];
|
||||
|
||||
vkTools::checkResult(vkBeginCommandBuffer(drawCmdBuffers[i], &cmdBufInfo));
|
||||
|
||||
vkCmdBeginRenderPass(drawCmdBuffers[i], &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
|
||||
|
||||
VkViewport viewport = vkTools::initializers::viewport((float)width, (float)height, 0.0f, 1.0f);
|
||||
vkCmdSetViewport(drawCmdBuffers[i], 0, 1, &viewport);
|
||||
|
||||
VkRect2D scissor = vkTools::initializers::rect2D(width, height, 0, 0);
|
||||
vkCmdSetScissor(drawCmdBuffers[i], 0, 1, &scissor);
|
||||
|
||||
VkDeviceSize offsets[1] = { 0 };
|
||||
|
||||
// Skinned mesh
|
||||
vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &descriptorSet, 0, NULL);
|
||||
vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.skinning);
|
||||
|
||||
vkCmdBindVertexBuffers(drawCmdBuffers[i], VERTEX_BUFFER_BIND_ID, 1, &mesh.meshBuffer.vertices.buf, offsets);
|
||||
vkCmdBindIndexBuffer(drawCmdBuffers[i], mesh.meshBuffer.indices.buf, 0, VK_INDEX_TYPE_UINT32);
|
||||
vkCmdDrawIndexed(drawCmdBuffers[i], mesh.meshBuffer.indexCount, 1, 0, 0, 0);
|
||||
|
||||
// Floor
|
||||
vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &descriptorSets.floor, 0, NULL);
|
||||
vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.texture);
|
||||
|
||||
vkCmdBindVertexBuffers(drawCmdBuffers[i], VERTEX_BUFFER_BIND_ID, 1, &meshes.floor.vertices.buf, offsets);
|
||||
vkCmdBindIndexBuffer(drawCmdBuffers[i], meshes.floor.indices.buf, 0, VK_INDEX_TYPE_UINT32);
|
||||
vkCmdDrawIndexed(drawCmdBuffers[i], meshes.floor.indexCount, 1, 0, 0, 0);
|
||||
|
||||
vkCmdEndRenderPass(drawCmdBuffers[i]);
|
||||
|
||||
vkTools::checkResult(vkEndCommandBuffer(drawCmdBuffers[i]));
|
||||
}
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
VkResult err;
|
||||
|
||||
// Get next image in the swap chain (back/front buffer)
|
||||
err = swapChain.acquireNextImage(semaphores.presentComplete, ¤tBuffer);
|
||||
assert(!err);
|
||||
|
||||
submitPostPresentBarrier(swapChain.buffers[currentBuffer].image);
|
||||
|
||||
// Command buffer to be sumitted to the queue
|
||||
submitInfo.commandBufferCount = 1;
|
||||
submitInfo.pCommandBuffers = &drawCmdBuffers[currentBuffer];
|
||||
|
||||
// Submit to queue
|
||||
err = vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE);
|
||||
assert(!err);
|
||||
|
||||
submitPrePresentBarrier(swapChain.buffers[currentBuffer].image);
|
||||
|
||||
err = swapChain.queuePresent(queue, currentBuffer, semaphores.renderComplete);
|
||||
assert(!err);
|
||||
|
||||
err = vkQueueWaitIdle(queue);
|
||||
assert(!err);
|
||||
}
|
||||
|
||||
// Load bone information from ASSIMP mesh
|
||||
void loadBones(uint32_t meshIndex, const aiMesh* pMesh, std::vector<VertexBoneData>& Bones)
|
||||
|
|
@ -285,29 +123,47 @@ public:
|
|||
|
||||
std::string name(pMesh->mBones[i]->mName.data);
|
||||
|
||||
if (mesh.boneMapping.find(name) == mesh.boneMapping.end())
|
||||
if (boneMapping.find(name) == boneMapping.end())
|
||||
{
|
||||
// Bone not present, add new one
|
||||
index = mesh.numBones;
|
||||
mesh.numBones++;
|
||||
index = numBones;
|
||||
numBones++;
|
||||
BoneInfo bone;
|
||||
mesh.boneInfo.push_back(bone);
|
||||
mesh.boneInfo[index].offset = pMesh->mBones[i]->mOffsetMatrix;
|
||||
mesh.boneMapping[name] = index;
|
||||
boneInfo.push_back(bone);
|
||||
boneInfo[index].offset = pMesh->mBones[i]->mOffsetMatrix;
|
||||
boneMapping[name] = index;
|
||||
}
|
||||
else
|
||||
{
|
||||
index = mesh.boneMapping[name];
|
||||
index = boneMapping[name];
|
||||
}
|
||||
|
||||
for (uint32_t j = 0; j < pMesh->mBones[i]->mNumWeights; j++)
|
||||
{
|
||||
uint32_t vertexID = mesh.meshLoader->m_Entries[meshIndex].vertexBase + pMesh->mBones[i]->mWeights[j].mVertexId;
|
||||
uint32_t vertexID = meshLoader->m_Entries[meshIndex].vertexBase + pMesh->mBones[i]->mWeights[j].mVertexId;
|
||||
Bones[vertexID].add(index, pMesh->mBones[i]->mWeights[j].mWeight);
|
||||
}
|
||||
}
|
||||
boneTransforms.resize(numBones);
|
||||
}
|
||||
|
||||
// Recursive bone transformation for given animation time
|
||||
void update(float time)
|
||||
{
|
||||
float TicksPerSecond = (float)(meshLoader->pScene->mAnimations[0]->mTicksPerSecond != 0 ? meshLoader->pScene->mAnimations[0]->mTicksPerSecond : 25.0f);
|
||||
float TimeInTicks = time * TicksPerSecond;
|
||||
float AnimationTime = fmod(TimeInTicks, (float)meshLoader->pScene->mAnimations[0]->mDuration);
|
||||
|
||||
aiMatrix4x4 identity = aiMatrix4x4();
|
||||
readNodeHierarchy(AnimationTime, meshLoader->pScene->mRootNode, identity);
|
||||
|
||||
for (uint32_t i = 0; i < boneTransforms.size(); i++)
|
||||
{
|
||||
boneTransforms[i] = boneInfo[i].finalTransformation;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
// Find animation for a given node
|
||||
const aiNodeAnim* findNodeAnim(const aiAnimation* animation, const std::string nodeName)
|
||||
{
|
||||
|
|
@ -439,7 +295,7 @@ public:
|
|||
{
|
||||
std::string NodeName(pNode->mName.data);
|
||||
|
||||
const aiAnimation* pAnimation = mesh.meshLoader->pScene->mAnimations[0];
|
||||
const aiAnimation* pAnimation = meshLoader->pScene->mAnimations[0];
|
||||
|
||||
aiMatrix4x4 NodeTransformation(pNode->mTransformation);
|
||||
|
||||
|
|
@ -458,10 +314,10 @@ public:
|
|||
aiMatrix4x4 GlobalTransformation = ParentTransform * NodeTransformation;
|
||||
|
||||
// todo : replace name lookup with hash or index
|
||||
if (mesh.boneMapping.find(NodeName) != mesh.boneMapping.end())
|
||||
if (boneMapping.find(NodeName) != boneMapping.end())
|
||||
{
|
||||
uint32_t BoneIndex = mesh.boneMapping[NodeName];
|
||||
mesh.boneInfo[BoneIndex].finalTransformation = mesh.globalInverseTransform * GlobalTransformation * mesh.boneInfo[BoneIndex].offset;
|
||||
uint32_t BoneIndex = boneMapping[NodeName];
|
||||
boneInfo[BoneIndex].finalTransformation = globalInverseTransform * GlobalTransformation * boneInfo[BoneIndex].offset;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < pNode->mNumChildren; i++)
|
||||
|
|
@ -469,50 +325,201 @@ public:
|
|||
readNodeHierarchy(AnimationTime, pNode->mChildren[i], GlobalTransformation);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Recursive bone transformation
|
||||
// Results are stored in the Transforms vector
|
||||
void boneTransform(float time, std::vector<aiMatrix4x4>& boneTransforms)
|
||||
class VulkanExample : public VulkanExampleBase
|
||||
{
|
||||
float TicksPerSecond = (float)(mesh.meshLoader->pScene->mAnimations[0]->mTicksPerSecond != 0 ? mesh.meshLoader->pScene->mAnimations[0]->mTicksPerSecond : 25.0f);
|
||||
float TimeInTicks = time * TicksPerSecond;
|
||||
float AnimationTime = fmod(TimeInTicks, (float)mesh.meshLoader->pScene->mAnimations[0]->mDuration);
|
||||
public:
|
||||
struct {
|
||||
vkTools::VulkanTexture colorMap;
|
||||
vkTools::VulkanTexture floor;
|
||||
} textures;
|
||||
|
||||
aiMatrix4x4 identity = aiMatrix4x4();
|
||||
readNodeHierarchy(AnimationTime, mesh.meshLoader->pScene->mRootNode, identity);
|
||||
struct {
|
||||
VkPipelineVertexInputStateCreateInfo inputState;
|
||||
std::vector<VkVertexInputBindingDescription> bindingDescriptions;
|
||||
std::vector<VkVertexInputAttributeDescription> attributeDescriptions;
|
||||
} vertices;
|
||||
|
||||
boneTransforms.resize(mesh.numBones); // todo : resize only once
|
||||
SkinnedMesh *skinnedMesh;
|
||||
|
||||
for (uint32_t i = 0; i < boneTransforms.size(); i++)
|
||||
struct {
|
||||
vkTools::UniformData vsScene;
|
||||
vkTools::UniformData floor;
|
||||
} uniformData;
|
||||
|
||||
struct {
|
||||
glm::mat4 projection;
|
||||
glm::mat4 model;
|
||||
glm::mat4 bones[MAX_BONES];
|
||||
glm::vec4 lightPos = glm::vec4(0.0f, -250.0f, 250.0f, 1.0);
|
||||
glm::vec4 viewPos;
|
||||
} uboVS;
|
||||
|
||||
struct {
|
||||
glm::mat4 projection;
|
||||
glm::mat4 model;
|
||||
glm::vec4 lightPos = glm::vec4(0.0, 0.0f, -25.0f, 1.0);
|
||||
glm::vec4 viewPos;
|
||||
glm::vec2 uvOffset;
|
||||
} uboFloor;
|
||||
|
||||
struct {
|
||||
VkPipeline skinning;
|
||||
VkPipeline texture;
|
||||
} pipelines;
|
||||
|
||||
struct {
|
||||
vkMeshLoader::MeshBuffer floor;
|
||||
} meshes;
|
||||
|
||||
VkPipelineLayout pipelineLayout;
|
||||
VkDescriptorSet descriptorSet;
|
||||
VkDescriptorSetLayout descriptorSetLayout;
|
||||
|
||||
struct {
|
||||
VkDescriptorSet skinning;
|
||||
VkDescriptorSet floor;
|
||||
} descriptorSets;
|
||||
|
||||
float runningTime = 0.0f;
|
||||
|
||||
VulkanExample() : VulkanExampleBase(ENABLE_VALIDATION)
|
||||
{
|
||||
boneTransforms[i] = mesh.boneInfo[i].finalTransformation;
|
||||
zoom = -150.0f;
|
||||
zoomSpeed = 2.5f;
|
||||
rotationSpeed = 0.5f;
|
||||
rotation = { -182.5f, -38.5f, 180.0f };
|
||||
title = "Vulkan Example - Skeletal animation";
|
||||
cameraPos = { 0.0f, 0.0f, 12.0f };
|
||||
}
|
||||
|
||||
~VulkanExample()
|
||||
{
|
||||
// Clean up used Vulkan resources
|
||||
// Note : Inherited destructor cleans up resources stored in base class
|
||||
vkDestroyPipeline(device, pipelines.skinning, nullptr);
|
||||
|
||||
vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
|
||||
vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr);
|
||||
|
||||
|
||||
textureLoader->destroyTexture(textures.colorMap);
|
||||
|
||||
vkTools::destroyUniformData(device, &uniformData.vsScene);
|
||||
|
||||
// Destroy and free mesh resources
|
||||
vkMeshLoader::freeMeshBufferResources(device, &skinnedMesh->meshBuffer);
|
||||
delete(skinnedMesh->meshLoader);
|
||||
delete(skinnedMesh);
|
||||
}
|
||||
|
||||
void buildCommandBuffers()
|
||||
{
|
||||
VkCommandBufferBeginInfo cmdBufInfo = vkTools::initializers::commandBufferBeginInfo();
|
||||
|
||||
VkClearValue clearValues[2];
|
||||
clearValues[0].color = { { 0.0f, 0.0f, 0.0f, 0.0f} };
|
||||
clearValues[1].depthStencil = { 1.0f, 0 };
|
||||
|
||||
VkRenderPassBeginInfo renderPassBeginInfo = vkTools::initializers::renderPassBeginInfo();
|
||||
renderPassBeginInfo.renderPass = renderPass;
|
||||
renderPassBeginInfo.renderArea.offset.x = 0;
|
||||
renderPassBeginInfo.renderArea.offset.y = 0;
|
||||
renderPassBeginInfo.renderArea.extent.width = width;
|
||||
renderPassBeginInfo.renderArea.extent.height = height;
|
||||
renderPassBeginInfo.clearValueCount = 2;
|
||||
renderPassBeginInfo.pClearValues = clearValues;
|
||||
|
||||
for (int32_t i = 0; i < drawCmdBuffers.size(); ++i)
|
||||
{
|
||||
renderPassBeginInfo.framebuffer = frameBuffers[i];
|
||||
|
||||
vkTools::checkResult(vkBeginCommandBuffer(drawCmdBuffers[i], &cmdBufInfo));
|
||||
|
||||
vkCmdBeginRenderPass(drawCmdBuffers[i], &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
|
||||
|
||||
VkViewport viewport = vkTools::initializers::viewport((float)width, (float)height, 0.0f, 1.0f);
|
||||
vkCmdSetViewport(drawCmdBuffers[i], 0, 1, &viewport);
|
||||
|
||||
VkRect2D scissor = vkTools::initializers::rect2D(width, height, 0, 0);
|
||||
vkCmdSetScissor(drawCmdBuffers[i], 0, 1, &scissor);
|
||||
|
||||
VkDeviceSize offsets[1] = { 0 };
|
||||
|
||||
// Skinned mesh
|
||||
vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &descriptorSet, 0, NULL);
|
||||
vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.skinning);
|
||||
|
||||
vkCmdBindVertexBuffers(drawCmdBuffers[i], VERTEX_BUFFER_BIND_ID, 1, &skinnedMesh->meshBuffer.vertices.buf, offsets);
|
||||
vkCmdBindIndexBuffer(drawCmdBuffers[i], skinnedMesh->meshBuffer.indices.buf, 0, VK_INDEX_TYPE_UINT32);
|
||||
vkCmdDrawIndexed(drawCmdBuffers[i], skinnedMesh->meshBuffer.indexCount, 1, 0, 0, 0);
|
||||
|
||||
// Floor
|
||||
vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &descriptorSets.floor, 0, NULL);
|
||||
vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.texture);
|
||||
|
||||
vkCmdBindVertexBuffers(drawCmdBuffers[i], VERTEX_BUFFER_BIND_ID, 1, &meshes.floor.vertices.buf, offsets);
|
||||
vkCmdBindIndexBuffer(drawCmdBuffers[i], meshes.floor.indices.buf, 0, VK_INDEX_TYPE_UINT32);
|
||||
vkCmdDrawIndexed(drawCmdBuffers[i], meshes.floor.indexCount, 1, 0, 0, 0);
|
||||
|
||||
vkCmdEndRenderPass(drawCmdBuffers[i]);
|
||||
|
||||
vkTools::checkResult(vkEndCommandBuffer(drawCmdBuffers[i]));
|
||||
}
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
VkResult err;
|
||||
|
||||
// Get next image in the swap chain (back/front buffer)
|
||||
err = swapChain.acquireNextImage(semaphores.presentComplete, ¤tBuffer);
|
||||
assert(!err);
|
||||
|
||||
submitPostPresentBarrier(swapChain.buffers[currentBuffer].image);
|
||||
|
||||
// Command buffer to be sumitted to the queue
|
||||
submitInfo.commandBufferCount = 1;
|
||||
submitInfo.pCommandBuffers = &drawCmdBuffers[currentBuffer];
|
||||
|
||||
// Submit to queue
|
||||
err = vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE);
|
||||
assert(!err);
|
||||
|
||||
submitPrePresentBarrier(swapChain.buffers[currentBuffer].image);
|
||||
|
||||
err = swapChain.queuePresent(queue, currentBuffer, semaphores.renderComplete);
|
||||
assert(!err);
|
||||
|
||||
err = vkQueueWaitIdle(queue);
|
||||
assert(!err);
|
||||
}
|
||||
|
||||
// Load a mesh based on data read via assimp
|
||||
// The other example will use the VulkanMesh loader which has some additional functionality for loading meshes
|
||||
void loadMesh()
|
||||
{
|
||||
mesh.meshLoader = new VulkanMeshLoader();
|
||||
skinnedMesh = new SkinnedMesh();
|
||||
skinnedMesh->meshLoader = new VulkanMeshLoader();
|
||||
#if defined(__ANDROID__)
|
||||
mesh.meshLoader->assetManager = androidApp->activity->assetManager;
|
||||
skinnedMesh->meshLoader->assetManager = androidApp->activity->assetManager;
|
||||
#endif
|
||||
mesh.meshLoader->LoadMesh(getAssetPath() + "models/goblin_3ds.DAE", 0);
|
||||
skinnedMesh->meshLoader->LoadMesh(getAssetPath() + "models/goblin.dae", 0);
|
||||
|
||||
// Setup bones
|
||||
// One vertex bone info structure per vertex
|
||||
mesh.bones.resize(mesh.meshLoader->numVertices);
|
||||
skinnedMesh->bones.resize(skinnedMesh->meshLoader->numVertices);
|
||||
// Store global inverse transform matrix of root node
|
||||
mesh.globalInverseTransform = mesh.meshLoader->pScene->mRootNode->mTransformation;
|
||||
mesh.globalInverseTransform.Inverse();
|
||||
skinnedMesh->globalInverseTransform = skinnedMesh->meshLoader->pScene->mRootNode->mTransformation;
|
||||
skinnedMesh->globalInverseTransform.Inverse();
|
||||
// Load bones (weights and IDs)
|
||||
for (uint32_t m = 0; m < mesh.meshLoader->m_Entries.size(); m++)
|
||||
for (uint32_t m = 0; m < skinnedMesh->meshLoader->m_Entries.size(); m++)
|
||||
{
|
||||
aiMesh *paiMesh = mesh.meshLoader->pScene->mMeshes[m];
|
||||
aiMesh *paiMesh = skinnedMesh->meshLoader->pScene->mMeshes[m];
|
||||
if (paiMesh->mNumBones > 0)
|
||||
{
|
||||
loadBones(m, paiMesh, mesh.bones);
|
||||
skinnedMesh->loadBones(m, paiMesh, skinnedMesh->bones);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -520,23 +527,23 @@ public:
|
|||
std::vector<Vertex> vertexBuffer;
|
||||
// Iterate through all meshes in the file
|
||||
// and extract the vertex information used in this demo
|
||||
for (uint32_t m = 0; m < mesh.meshLoader->m_Entries.size(); m++)
|
||||
for (uint32_t m = 0; m < skinnedMesh->meshLoader->m_Entries.size(); m++)
|
||||
{
|
||||
for (uint32_t i = 0; i < mesh.meshLoader->m_Entries[m].Vertices.size(); i++)
|
||||
for (uint32_t i = 0; i < skinnedMesh->meshLoader->m_Entries[m].Vertices.size(); i++)
|
||||
{
|
||||
Vertex vertex;
|
||||
|
||||
vertex.pos = mesh.meshLoader->m_Entries[m].Vertices[i].m_pos;
|
||||
vertex.pos = skinnedMesh->meshLoader->m_Entries[m].Vertices[i].m_pos;
|
||||
vertex.pos.y = -vertex.pos.y;
|
||||
vertex.normal = mesh.meshLoader->m_Entries[m].Vertices[i].m_normal;
|
||||
vertex.uv = mesh.meshLoader->m_Entries[m].Vertices[i].m_tex;
|
||||
vertex.color = mesh.meshLoader->m_Entries[m].Vertices[i].m_color;
|
||||
vertex.normal = skinnedMesh->meshLoader->m_Entries[m].Vertices[i].m_normal;
|
||||
vertex.uv = skinnedMesh->meshLoader->m_Entries[m].Vertices[i].m_tex;
|
||||
vertex.color = skinnedMesh->meshLoader->m_Entries[m].Vertices[i].m_color;
|
||||
|
||||
// Fetch bone weights and IDs
|
||||
for (uint32_t j = 0; j < MAX_BONES_PER_VERTEX; j++)
|
||||
{
|
||||
vertex.boneWeights[j] = mesh.bones[mesh.meshLoader->m_Entries[m].vertexBase + i].weights[j];
|
||||
vertex.boneIDs[j] = mesh.bones[mesh.meshLoader->m_Entries[m].vertexBase + i].IDs[j];
|
||||
vertex.boneWeights[j] = skinnedMesh->bones[skinnedMesh->meshLoader->m_Entries[m].vertexBase + i].weights[j];
|
||||
vertex.boneIDs[j] = skinnedMesh->bones[skinnedMesh->meshLoader->m_Entries[m].vertexBase + i].IDs[j];
|
||||
}
|
||||
|
||||
vertexBuffer.push_back(vertex);
|
||||
|
|
@ -546,16 +553,16 @@ public:
|
|||
|
||||
// Generate index buffer from loaded mesh file
|
||||
std::vector<uint32_t> indexBuffer;
|
||||
for (uint32_t m = 0; m < mesh.meshLoader->m_Entries.size(); m++)
|
||||
for (uint32_t m = 0; m < skinnedMesh->meshLoader->m_Entries.size(); m++)
|
||||
{
|
||||
uint32_t indexBase = indexBuffer.size();
|
||||
for (uint32_t i = 0; i < mesh.meshLoader->m_Entries[m].Indices.size(); i++)
|
||||
for (uint32_t i = 0; i < skinnedMesh->meshLoader->m_Entries[m].Indices.size(); i++)
|
||||
{
|
||||
indexBuffer.push_back(mesh.meshLoader->m_Entries[m].Indices[i] + indexBase);
|
||||
indexBuffer.push_back(skinnedMesh->meshLoader->m_Entries[m].Indices[i] + indexBase);
|
||||
}
|
||||
}
|
||||
uint32_t indexBufferSize = indexBuffer.size() * sizeof(uint32_t);
|
||||
mesh.meshBuffer.indexCount = indexBuffer.size();
|
||||
skinnedMesh->meshBuffer.indexCount = indexBuffer.size();
|
||||
|
||||
bool useStaging = true;
|
||||
|
||||
|
|
@ -591,16 +598,16 @@ public:
|
|||
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
|
||||
vertexBufferSize,
|
||||
nullptr,
|
||||
&mesh.meshBuffer.vertices.buf,
|
||||
&mesh.meshBuffer.vertices.mem);
|
||||
&skinnedMesh->meshBuffer.vertices.buf,
|
||||
&skinnedMesh->meshBuffer.vertices.mem);
|
||||
// Index buffer
|
||||
createBuffer(
|
||||
VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
|
||||
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
|
||||
indexBufferSize,
|
||||
nullptr,
|
||||
&mesh.meshBuffer.indices.buf,
|
||||
&mesh.meshBuffer.indices.mem);
|
||||
&skinnedMesh->meshBuffer.indices.buf,
|
||||
&skinnedMesh->meshBuffer.indices.mem);
|
||||
|
||||
// Copy from staging buffers
|
||||
VkCommandBuffer copyCmd = VulkanExampleBase::createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
|
|
@ -611,7 +618,7 @@ public:
|
|||
vkCmdCopyBuffer(
|
||||
copyCmd,
|
||||
vertexStaging.buffer,
|
||||
mesh.meshBuffer.vertices.buf,
|
||||
skinnedMesh->meshBuffer.vertices.buf,
|
||||
1,
|
||||
©Region);
|
||||
|
||||
|
|
@ -619,7 +626,7 @@ public:
|
|||
vkCmdCopyBuffer(
|
||||
copyCmd,
|
||||
indexStaging.buffer,
|
||||
mesh.meshBuffer.indices.buf,
|
||||
skinnedMesh->meshBuffer.indices.buf,
|
||||
1,
|
||||
©Region);
|
||||
|
||||
|
|
@ -638,28 +645,28 @@ public:
|
|||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
|
||||
vertexBufferSize,
|
||||
vertexBuffer.data(),
|
||||
&mesh.meshBuffer.vertices.buf,
|
||||
&mesh.meshBuffer.vertices.mem);
|
||||
&skinnedMesh->meshBuffer.vertices.buf,
|
||||
&skinnedMesh->meshBuffer.vertices.mem);
|
||||
// Index buffer
|
||||
createBuffer(
|
||||
VK_BUFFER_USAGE_INDEX_BUFFER_BIT,
|
||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
|
||||
indexBufferSize,
|
||||
indexBuffer.data(),
|
||||
&mesh.meshBuffer.indices.buf,
|
||||
&mesh.meshBuffer.indices.mem);
|
||||
&skinnedMesh->meshBuffer.indices.buf,
|
||||
&skinnedMesh->meshBuffer.indices.mem);
|
||||
}
|
||||
}
|
||||
|
||||
void loadTextures()
|
||||
{
|
||||
textureLoader->loadTexture(
|
||||
getAssetPath() + "textures/goblin.ktx",
|
||||
getAssetPath() + "textures/goblin_bc3.ktx",
|
||||
VK_FORMAT_BC3_UNORM_BLOCK,
|
||||
&textures.colorMap);
|
||||
|
||||
textureLoader->loadTexture(
|
||||
getAssetPath() + "textures/stonefloor_color_specular_bc3.ktx",
|
||||
getAssetPath() + "textures/pattern_35_bc3.ktx",
|
||||
VK_FORMAT_BC3_UNORM_BLOCK,
|
||||
&textures.floor);
|
||||
}
|
||||
|
|
@ -983,18 +990,16 @@ public:
|
|||
}
|
||||
|
||||
// Update bones
|
||||
std::vector<aiMatrix4x4> boneTransforms;
|
||||
boneTransform(runningTime, boneTransforms);
|
||||
|
||||
for (uint32_t i = 0; i < boneTransforms.size(); i++)
|
||||
skinnedMesh->update(runningTime);
|
||||
for (uint32_t i = 0; i < skinnedMesh->boneTransforms.size(); i++)
|
||||
{
|
||||
uboVS.bones[i] = glm::transpose(glm::make_mat4(&boneTransforms[i].a1));
|
||||
uboVS.bones[i] = glm::transpose(glm::make_mat4(&skinnedMesh->boneTransforms[i].a1));
|
||||
}
|
||||
|
||||
memcpy(uniformData.vsScene.mapped, &uboVS, sizeof(uboVS));
|
||||
|
||||
// Update floor animation
|
||||
uboFloor.uvOffset.t -= 0.35f * frameTimer;
|
||||
uboFloor.uvOffset.t -= 0.5f * skinnedMesh->animationSpeed * frameTimer;
|
||||
memcpy(uniformData.floor.mapped, &uboFloor, sizeof(uboFloor));
|
||||
}
|
||||
|
||||
|
|
@ -1021,7 +1026,7 @@ public:
|
|||
draw();
|
||||
if (!paused)
|
||||
{
|
||||
runningTime += frameTimer * 0.75f;
|
||||
runningTime += frameTimer * skinnedMesh->animationSpeed;
|
||||
vkDeviceWaitIdle(device);
|
||||
updateUniformBuffers(false);
|
||||
}
|
||||
|
|
@ -1032,6 +1037,12 @@ public:
|
|||
vkDeviceWaitIdle(device);
|
||||
updateUniformBuffers(true);
|
||||
}
|
||||
|
||||
void changeAnimationSpeed(float delta)
|
||||
{
|
||||
skinnedMesh->animationSpeed += delta;
|
||||
std::cout << "Animation speed = " << skinnedMesh->animationSpeed << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
VulkanExample *vulkanExample;
|
||||
|
|
@ -1042,6 +1053,16 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||
if (vulkanExample != NULL)
|
||||
{
|
||||
vulkanExample->handleMessages(hWnd, uMsg, wParam, lParam);
|
||||
if (uMsg == WM_KEYDOWN)
|
||||
{
|
||||
switch (wParam)
|
||||
{
|
||||
case VK_ADD:
|
||||
case VK_SUBTRACT:
|
||||
vulkanExample->changeAnimationSpeed((wParam == VK_ADD) ? 0.1f : -0.1f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue