Compare commits

...

6 Commits

Author SHA1 Message Date
William Moberg bdcb33d992 Mouse always unlocked on game start and on disconnecting (i.e when menu shows). 2016-03-10 12:46:06 +01:00
Viktor Ljung f26b24ef6b Merge pull request #195 from teamfisk/AnimationPickingFixes
Forgot one console spammer
2016-03-10 10:49:05 +01:00
viktorljung b0e9cd3965 Forgot one console spammer 2016-03-10 10:47:58 +01:00
Adam Byléhn 5e747f53db Merge pull request #194 from teamfisk/AnimationPickingFixes
Animation picking fixes
2016-03-10 10:33:29 +01:00
viktorljung 3a213be679 Picking on animated models fixed 2016-03-09 23:06:53 +01:00
viktorljung 4e6ff16e58 Shadows for animated models and removed spam in console 2016-03-09 22:43:04 +01:00
10 changed files with 118 additions and 11 deletions
+2 -1
View File
@@ -63,7 +63,8 @@ private:
GLuint m_DepthMap; GLuint m_DepthMap;
FrameBuffer m_DepthBuffer; FrameBuffer m_DepthBuffer;
ShaderProgram* m_ShadowProgram; ShaderProgram* m_ShadowProgram;
ShaderProgram* m_ShadowProgramSkinned;
std::array<glm::mat4, MAX_SPLITS> m_LightProjection; std::array<glm::mat4, MAX_SPLITS> m_LightProjection;
std::array<glm::mat4, MAX_SPLITS> m_LightView; std::array<glm::mat4, MAX_SPLITS> m_LightView;
@@ -3,6 +3,7 @@
#include "Core/System.h" #include "Core/System.h"
#include "Input/EInputCommand.h" #include "Input/EInputCommand.h"
#include "Network/EPlayerDisconnected.h"
class SpectatorCameraSystem : public ImpureSystem class SpectatorCameraSystem : public ImpureSystem
{ {
@@ -17,6 +18,8 @@ private:
EventRelay<SpectatorCameraSystem, Events::InputCommand> m_EInputCommand; EventRelay<SpectatorCameraSystem, Events::InputCommand> m_EInputCommand;
bool OnInputCommand(const Events::InputCommand& e); bool OnInputCommand(const Events::InputCommand& e);
EventRelay<SpectatorCameraSystem, Events::PlayerDisconnected> m_EDisconnect;
bool OnDisconnect(const Events::PlayerDisconnected& e);
}; };
#endif #endif
+3 -1
View File
@@ -29,4 +29,6 @@ K=TakeDamage,1500
F2=PerformanceTimingResetAllTimers F2=PerformanceTimingResetAllTimers
F3=PerformanceTimingCreateExcelData F3=PerformanceTimingCreateExcelData
Comma=SwapToClassPick Comma=SwapToClassPick
Period=SwapToTeamPick Period=SwapToTeamPick
Enter=PickClass,1
F5=DisconnectFromServer
+29
View File
@@ -0,0 +1,29 @@
#version 430
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
uniform mat4 Bones[100];
layout (location = 0) in vec3 Position;
layout (location = 4) in vec2 TextureCoords;
layout(location = 5) in vec4 BoneIndices;
layout(location = 6) in vec4 BoneWeights;
out VertexData{
vec2 TextureCoordinate;
}Output;
void main()
{
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])];
}
gl_Position = P * V * M * boneTransform * vec4(Position, 1.0);
Output.TextureCoordinate = TextureCoords;
}
+1
View File
@@ -47,6 +47,7 @@ EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame
Enable(); Enable();
} else { } else {
Disable(); Disable();
m_EventBroker->Publish(Events::UnlockMouse());
} }
} }
+6 -1
View File
@@ -1,4 +1,5 @@
#include "Network/Client.h" #include "Network/Client.h"
#include "Network/EPlayerDisconnected.h"
using namespace boost::asio::ip; using namespace boost::asio::ip;
Client::Client(World* world, EventBroker* eventBroker) Client::Client(World* world, EventBroker* eventBroker)
@@ -224,7 +225,7 @@ void Client::parseServerlist(Packet& packet)
void Client::parseKick() void Client::parseKick()
{ {
LOG_WARNING("You have been kicked from the server."); LOG_WARNING("You have been kicked from the server.");
m_IsConnected = false; disconnect();
} }
void Client::parseSpawnEvents() void Client::parseSpawnEvents()
@@ -464,6 +465,10 @@ void Client::disconnect()
Packet packet(MessageType::Disconnect, m_SendPacketID); Packet packet(MessageType::Disconnect, m_SendPacketID);
m_Reliable.Send(packet); m_Reliable.Send(packet);
m_Reliable.Disconnect(); m_Reliable.Disconnect();
Events::PlayerDisconnected e;
e.Entity = m_LocalPlayer.ID;
e.PlayerID = -1;
m_EventBroker->Publish(e);
createMainMenu(); createMainMenu();
} }
+3 -3
View File
@@ -127,12 +127,12 @@ void AnimationSystem::UpdateAnimations(double dt)
void AnimationSystem::UpdateWeights(double dt) void AnimationSystem::UpdateWeights(double dt)
{ {
for (auto it = m_AutoBlendQueues.begin(); it != m_AutoBlendQueues.end(); ) { for (auto it = m_AutoBlendQueues.begin(); it != m_AutoBlendQueues.end(); ) {
LOG_INFO("%s", it->first.Name().c_str()); /* LOG_INFO("%s", it->first.Name().c_str());
it->second.PrintQueue(); it->second.PrintQueue();*/
if(it->second.HasActiveBlendJob()) { if(it->second.HasActiveBlendJob()) {
AutoBlendQueue::AutoBlendJob& blendJob = it->second.GetActiveBlendJob(); AutoBlendQueue::AutoBlendJob& blendJob = it->second.GetActiveBlendJob();
LOG_INFO("%s", blendJob.RootNode.Name().c_str()); //LOG_INFO("%s", blendJob.RootNode.Name().c_str());
std::shared_ptr<BlendTree> blendTree = it->second.GetBlendTree(); std::shared_ptr<BlendTree> blendTree = it->second.GetBlendTree();
if (blendTree != nullptr) { if (blendTree != nullptr) {
if (blendJob.Duration != 0.0) { if (blendJob.Duration != 0.0) {
+1 -1
View File
@@ -219,7 +219,7 @@ void PickingPass::Draw(RenderScene& scene)
m_PickingSkinnedProgram->Bind(); m_PickingSkinnedProgram->Bind();
lastShader = m_PickingSkinnedProgram->GetHandle(); lastShader = m_PickingSkinnedProgram->GetHandle();
} }
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * modelJob->Matrix)); glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * modelJob->Matrix));
glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1]))); glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
std::vector<glm::mat4> frameBones; std::vector<glm::mat4> frameBones;
+55 -3
View File
@@ -156,7 +156,12 @@ void ShadowPass::InitializeShaderPrograms()
m_ShadowProgram->BindFragDataLocation(0, "ShadowMap"); m_ShadowProgram->BindFragDataLocation(0, "ShadowMap");
m_ShadowProgram->Link(); m_ShadowProgram->Link();
m_ShadowProgramSkinned = ResourceManager::Load<ShaderProgram>("#ShadowProgramSkinned");
m_ShadowProgramSkinned->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ShadowSkinned.vert.glsl")));
m_ShadowProgramSkinned->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Shadow.frag.glsl")));
m_ShadowProgramSkinned->Compile();
m_ShadowProgramSkinned->BindFragDataLocation(0, "ShadowMap");
m_ShadowProgramSkinned->Link();
} }
void ShadowPass::ClearBuffer() void ShadowPass::ClearBuffer()
@@ -212,8 +217,7 @@ void ShadowPass::Draw(RenderScene & scene)
ShadowPassState* state = new ShadowPassState(m_DepthBuffer.GetHandle()); ShadowPassState* state = new ShadowPassState(m_DepthBuffer.GetHandle());
m_ShadowProgram->Bind();
GLuint shaderHandle = m_ShadowProgram->GetHandle();
glViewport(0, 0, m_ResolutionSizeWidth, m_ResolutionSizeHeight); glViewport(0, 0, m_ResolutionSizeWidth, m_ResolutionSizeHeight);
for (int i = 0; i < m_CurrentNrOfSplits; i++) { for (int i = 0; i < m_CurrentNrOfSplits; i++) {
@@ -221,7 +225,11 @@ void ShadowPass::Draw(RenderScene & scene)
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_DepthMap, 0, i); glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_DepthMap, 0, i);
GLuint shaderHandle;
for (auto &job : scene.Jobs.DirectionalLight) { for (auto &job : scene.Jobs.DirectionalLight) {
auto directionalLightJob = std::dynamic_pointer_cast<DirectionalLightJob>(job); auto directionalLightJob = std::dynamic_pointer_cast<DirectionalLightJob>(job);
if (directionalLightJob) { if (directionalLightJob) {
@@ -232,9 +240,19 @@ void ShadowPass::Draw(RenderScene & scene)
//RadiusToLightspace(m_shadowFrusta[i]); //RadiusToLightspace(m_shadowFrusta[i]);
m_LightProjection[i] = glm::ortho(m_shadowFrusta[i].LRBT[LEFT], m_shadowFrusta[i].LRBT[RIGHT], m_shadowFrusta[i].LRBT[BOTTOM], m_shadowFrusta[i].LRBT[TOP], m_NearFarPlane[NEAR], m_NearFarPlane[FAR]); m_LightProjection[i] = glm::ortho(m_shadowFrusta[i].LRBT[LEFT], m_shadowFrusta[i].LRBT[RIGHT], m_shadowFrusta[i].LRBT[BOTTOM], m_shadowFrusta[i].LRBT[TOP], m_NearFarPlane[NEAR], m_NearFarPlane[FAR]);
m_ShadowProgram->Bind();
shaderHandle = m_ShadowProgram->GetHandle();
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i])); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i]));
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView[i])); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView[i]));
m_ShadowProgramSkinned->Bind();
shaderHandle = m_ShadowProgramSkinned->GetHandle();
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i]));
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView[i]));
GLERROR("ShadowLight ERROR"); GLERROR("ShadowLight ERROR");
for (auto &objectJob : scene.Jobs.OpaqueObjects) { for (auto &objectJob : scene.Jobs.OpaqueObjects) {
@@ -245,6 +263,23 @@ void ShadowPass::Draw(RenderScene & scene)
continue; continue;
} }
if(modelJob->Model->IsSkinned()) {
m_ShadowProgramSkinned->Bind();
shaderHandle = m_ShadowProgramSkinned->GetHandle();
std::vector<glm::mat4> frameBones;
if (modelJob->BlendTree != nullptr) {
frameBones = modelJob->BlendTree->GetFinalPose();
} else {
frameBones = modelJob->Skeleton->GetTPose();
}
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
} else {
m_ShadowProgram->Bind();
shaderHandle = m_ShadowProgram->GetHandle();
}
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), 1.f); glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), 1.f);
@@ -265,6 +300,23 @@ void ShadowPass::Draw(RenderScene & scene)
continue; continue;
} }
if (modelJob->Model->IsSkinned()) {
m_ShadowProgramSkinned->Bind();
shaderHandle = m_ShadowProgramSkinned->GetHandle();
std::vector<glm::mat4> frameBones;
if (modelJob->BlendTree != nullptr) {
frameBones = modelJob->BlendTree->GetFinalPose();
} else {
frameBones = modelJob->Skeleton->GetTPose();
}
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
} else {
m_ShadowProgram->Bind();
shaderHandle = m_ShadowProgram->GetHandle();
}
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), modelJob->Color.a); glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), modelJob->Color.a);
+15 -1
View File
@@ -8,6 +8,7 @@ SpectatorCameraSystem::SpectatorCameraSystem(SystemParams params)
, m_PickedTeam(-1) , m_PickedTeam(-1)
{ {
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &SpectatorCameraSystem::OnInputCommand); EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &SpectatorCameraSystem::OnInputCommand);
EVENT_SUBSCRIBE_MEMBER(m_EDisconnect, &SpectatorCameraSystem::OnDisconnect);
} }
void SpectatorCameraSystem::Update(double dt) void SpectatorCameraSystem::Update(double dt)
@@ -87,4 +88,17 @@ bool SpectatorCameraSystem::OnInputCommand(const Events::InputCommand& e)
} }
return true; return true;
} }
bool SpectatorCameraSystem::OnDisconnect(const Events::PlayerDisconnected& e)
{
// If local player gets disconnected, they should be set to
// the spectator camera next time a map loads that has one.
if (e.Entity == LocalPlayer.ID) {
m_CamSetToTeamPick = false;
// They will also be set to menu, so unlock mouse just in case they were in game with locked mouse.
Events::UnlockMouse unlock;
m_EventBroker->Publish(unlock);
}
return true;
}