Picking animation fix
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
#ifndef PickingPass_h__
|
#ifndef PickingPass_h__
|
||||||
#define PickingPass_h__
|
#define PickingPass_h__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "IRenderer.h"
|
#include "IRenderer.h"
|
||||||
#include "PickingPassState.h"
|
#include "PickingPassState.h"
|
||||||
#include "FrameBuffer.h"
|
#include "FrameBuffer.h"
|
||||||
@@ -10,8 +8,7 @@
|
|||||||
#include "Util/UnorderedMapiVec2.h"
|
#include "Util/UnorderedMapiVec2.h"
|
||||||
#include "../Core/EventBroker.h"
|
#include "../Core/EventBroker.h"
|
||||||
#include "../Core/World.h"
|
#include "../Core/World.h"
|
||||||
|
#include "Rendering/Skeleton.h"
|
||||||
|
|
||||||
|
|
||||||
class PickingPass
|
class PickingPass
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,18 +3,15 @@
|
|||||||
uniform mat4 M;
|
uniform mat4 M;
|
||||||
uniform mat4 V;
|
uniform mat4 V;
|
||||||
uniform mat4 P;
|
uniform mat4 P;
|
||||||
|
uniform mat4 Bones[100];
|
||||||
|
|
||||||
layout(location = 0) in vec3 Position;
|
layout(location = 0) in vec3 Position;
|
||||||
layout(location = 1) in vec3 Normal;
|
layout(location = 1) in vec3 Normal;
|
||||||
layout(location = 2) in vec3 Tangent;
|
layout(location = 2) in vec3 Tangent;
|
||||||
layout(location = 3) in vec3 BiTangent;
|
layout(location = 3) in vec3 BiTangent;
|
||||||
layout(location = 4) in vec2 TextureCoords;
|
layout(location = 4) in vec2 TextureCoords;
|
||||||
layout(location = 5) in vec4 DiffuseVertexColor;
|
layout(location = 5) in vec4 BoneIndices;
|
||||||
layout(location = 6) in vec4 SpecularVertexColor;
|
layout(location = 6) in vec4 BoneWeights;
|
||||||
layout(location = 7) in vec4 BoneIndices1;
|
|
||||||
layout(location = 8) in vec4 BoneIndices2;
|
|
||||||
layout(location = 9) in vec4 BoneWeights1;
|
|
||||||
layout(location = 10) in vec4 BoneWeights2;
|
|
||||||
|
|
||||||
out VertexData{
|
out VertexData{
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
@@ -22,7 +19,14 @@ out VertexData{
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = P * V* M * vec4(Position, 1.0);
|
mat4 boneTransform = mat4(1);
|
||||||
|
if(BoneWeights[0] > 0.0f){
|
||||||
|
boneTransform = BoneWeights[0] * Bones[int(BoneIndices[0])]
|
||||||
|
+ BoneWeights[1] * Bones[int(BoneIndices[1])]
|
||||||
|
+ BoneWeights[2] * Bones[int(BoneIndices[2])]
|
||||||
|
+ BoneWeights[3] * Bones[int(BoneIndices[3])];
|
||||||
|
}
|
||||||
|
|
||||||
Output.Position = Position;
|
gl_Position = P*V*M*boneTransform * vec4(Position, 1.0);
|
||||||
|
Output.Position = (boneTransform * vec4(Position, 1.0)).xyz;
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,7 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
PickingPassState* state = new PickingPassState(m_PickingBuffer.GetHandle());
|
PickingPassState* state = new PickingPassState(m_PickingBuffer.GetHandle());
|
||||||
|
|
||||||
//TODO: Render: Add code for more jobs than modeljobs.
|
//TODO: Render: Add code for more jobs than modeljobs.
|
||||||
GLuint ShaderHandle = m_PickingProgram->GetHandle();
|
GLuint shaderHandle = m_PickingProgram->GetHandle();
|
||||||
m_PickingProgram->Bind();
|
m_PickingProgram->Bind();
|
||||||
|
|
||||||
if (scene.ClearDepth) {
|
if (scene.ClearDepth) {
|
||||||
@@ -75,18 +75,26 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]);
|
m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]);
|
||||||
if (m_ColorCounter[0] > 255) {
|
if (m_ColorCounter[0] > 255) {
|
||||||
m_ColorCounter[0] = 0;
|
m_ColorCounter[0] = 0;
|
||||||
m_ColorCounter[1]++;
|
m_ColorCounter[1] += 5;
|
||||||
} else {
|
} else {
|
||||||
m_ColorCounter[0]++;
|
m_ColorCounter[0] += 50;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_PickingColorsToEntity[glm::ivec2(pickColor[0], pickColor[1])] = pickInfo;
|
m_PickingColorsToEntity[glm::ivec2(pickColor[0], pickColor[1])] = pickInfo;
|
||||||
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||||
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
glUniform2fv(glGetUniformLocation(ShaderHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
glUniform2fv(glGetUniformLocation(shaderHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||||
|
|
||||||
|
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||||
|
|
||||||
|
if (modelJob->Animation != nullptr) {
|
||||||
|
std::vector<glm::mat4> frameBones = modelJob->Skeleton->GetFrameBones(*modelJob->Animation, modelJob->AnimationTime);
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
glBindVertexArray(modelJob->Model->VAO);
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
|
|||||||
Reference in New Issue
Block a user