Compare commits

..

42 Commits

Author SHA1 Message Date
Tleety 8102f3a2ea Working transparency in most common cases.
Transparency check is automatically set if the alpha color value is under 1
2016-01-27 12:59:44 +01:00
Tleety cbb17d22d4 WIP 2016-01-27 12:10:00 +01:00
Jace eb42217885 Merge pull request #38 from teamfisk/CoolDeathAnimation
Cool death animation
2016-01-27 10:51:22 +01:00
Jace 7e12d00874 Merge branch 'master' into CoolDeathAnimation
# Conflicts:
#	include/Engine/Rendering/ModelJob.h
#	resources/Shaders/ForwardPlus.frag.glsl
#	src/Engine/Rendering/DrawFinalPass.cpp
#	src/Engine/Rendering/RenderSystem.cpp
2016-01-27 10:43:23 +01:00
Jace 505a6c7396 Hiding first person models properly 2016-01-25 14:32:48 +01:00
Jace 8866dd6054 Merge remote-tracking branch 'origin/Networking' into ShootRays 2016-01-25 11:57:44 +01:00
Jace b6fd18baed Hacked in serverside effects 2016-01-25 11:56:40 +01:00
Jace 4245264029 Weapon RayZ
Weapon RayZ
2016-01-25 11:26:33 +01:00
stiffly 44baa47bba Merge remote-tracking branch 'origin/master' into CoolDeathAnimation
# Conflicts:
#	include/Engine/Common.h
#	include/Engine/Rendering/DrawFinalPass.h
#	include/Engine/Rendering/DrawScenePass.h
#	include/Engine/Rendering/RenderQueue.h
#	include/Engine/Rendering/Renderer.h
#	resources/Shaders/ForwardPlus.frag.glsl
#	resources/Shaders/ForwardPlus.vert.glsl
#	src/Engine/Rendering/DrawFinalPass.cpp
#	src/Engine/Rendering/DrawScenePass.cpp
#	src/Engine/Rendering/RenderSystem.cpp
#	src/Engine/Rendering/Renderer.cpp
#	src/Game/Game.cpp
2016-01-25 01:21:15 +01:00
Jace b95c1fdfa4 Merge remote-tracking branch 'origin/Menu'
# Conflicts:
#	include/Engine/Rendering/ModelJob.h
#	resources/Schema/Components.xsd
#	resources/Schema/Entities/Player.xml
#	resources/Schema/Entities/RenderingWorld.xml
#	src/Game/Game.cpp
2016-01-25 00:25:03 +01:00
Jace 7b348379ac Quaternions are never the solution. 2016-01-25 00:22:55 +01:00
Jace 04f6233d99 Crude animations 2016-01-24 23:44:29 +01:00
Jace d6cc1eaac4 Merge remote-tracking branch 'origin/Animations' 2016-01-24 23:06:59 +01:00
Jace d0de169613 Instagib! 2016-01-24 23:05:52 +01:00
viktorljung 79fe7693a6 picking values fixed 2016-01-24 23:05:45 +01:00
Jace b6ba8a5bd7 Network snapshot buffer size increased, needs to be looked over later 2016-01-24 23:05:26 +01:00
viktorljung f8b9606cdf Picking animation fix 2016-01-24 22:59:53 +01:00
viktorljung 84fddf02e2 Merge remote-tracking branch 'origin/master' into Animations 2016-01-24 22:42:12 +01:00
viktorljung d03b3fb071 Merge remote-tracking branch 'origin/master' into Menu
# Conflicts:
#	resources/Schema/Entities/Player.xml
2016-01-24 22:23:53 +01:00
viktorljung 7e92d6f53f Healthbar on player 2016-01-24 22:21:10 +01:00
Jace 47d2fb6a9b Fixed wrong drawing function used in PickingPass 2016-01-24 22:20:42 +01:00
viktorljung 0c557317a9 Merge remote-tracking branch 'origin/master' into Menu 2016-01-24 21:16:05 +01:00
viktorljung a304b00038 fixed crashes 2016-01-24 21:12:41 +01:00
viktorljung ada1bac2a7 Merge remote-tracking branch 'origin/master' into Menu
# Conflicts:
#	include/Engine/Rendering/RenderSystem.h
#	resources/Schema/Entities/RenderingWorld.xml
#	resources/Shaders/ForwardPlus.frag.glsl
#	src/Engine/Rendering/RenderSystem.cpp
2016-01-24 20:48:17 +01:00
viktorljung 8cf9caf7aa AnimationSystem working 2016-01-24 18:31:23 +01:00
viktorljung dd80323342 Merge remote-tracking branch 'origin/master' into Animations 2016-01-24 17:06:34 +01:00
viktorljung af2f017cb4 AnimationSystem base WIP 2016-01-24 17:05:34 +01:00
viktorljung aa3b8cd652 Fixed text color and removed debugging code 2016-01-24 13:37:07 +01:00
viktorljung fcba0a28b8 Merge branch 'master' into Menu 2016-01-23 18:27:48 +01:00
viktorljung aacfc47fb5 Merge remote-tracking branch 'origin/master' into Menu
# Conflicts:
#	resources/Shaders/ForwardPlus.frag.glsl
#	src/Engine/Rendering/DrawFinalPass.cpp
2016-01-23 15:12:19 +01:00
viktorljung 680a12d88f HealthMeter 2016-01-23 14:53:17 +01:00
viktorljung 46dff1a59c Merge remote-tracking branch 'origin/master' into Menu
# Conflicts:
#	include/Engine/Rendering/RenderSystem.h
#	src/Engine/Rendering/RenderSystem.cpp
2016-01-22 17:02:56 +01:00
Ayumiwii 382e00cff4 Randomness fixed
Redundant continue removed
Redundant cross product removed
2016-01-21 15:34:08 +01:00
Ayumiwii 77e1dacb6f Merge 2016-01-19 09:58:52 +01:00
Ayumiwii 37aa1eaa18 Merge remote-tracking branch 'origin/master' into CoolDeathAnimation
# Conflicts:
#	include/Engine/Rendering/DrawScenePass.h
#	include/Engine/Rendering/RenderQueue.h
#	include/Engine/Rendering/RenderQueueFactory.h
#	include/Engine/Rendering/Renderer.h
#	include/Game/Game.h
#	resources/Schema/Components.xsd
#	resources/Schema/Entities/Test.xml
#	resources/Schema/Types/Entity.xsd
#	src/Engine/Rendering/DrawScenePass.cpp
#	src/Engine/Rendering/RenderQueueFactory.cpp
#	src/Engine/Rendering/Renderer.cpp
#	src/Game/Game.cpp
2016-01-18 16:02:43 +01:00
Ayumiwii 1411964dcf hourglass assets fixed 2016-01-18 14:24:31 +01:00
Ayumiwii 35269315cc Rename the thingie 2016-01-18 13:51:32 +01:00
Ayumiwii 8f8b64f99c First pass that actually work
Not at all done, but it'll have to do for now
2016-01-18 11:50:00 +01:00
FakeShemp 923589524b Fix the accelaration (possibly)
I haven't tested so I might just have destroyed everything.
2016-01-12 21:25:15 +01:00
Ayumiwii 00eeed2e20 Broken stuff, refactoring 2016-01-12 16:16:42 +01:00
Ayumiwii 0630885d92 Many more things done 2016-01-11 19:59:45 +01:00
Ayumiwii 3467315aef Lots of things done 2016-01-08 16:42:59 +01:00
80 changed files with 2027 additions and 332 deletions
+1 -1
Submodule assets updated: 068fbb2d20...e4dc9529f2
+1
View File
@@ -5,6 +5,7 @@
#include <map>
#include <unordered_map>
#include <algorithm>
#include <array>
#include "Core/Util/Logging.h"
#include "Core/Util/IfDebug.h"
+4
View File
@@ -23,6 +23,7 @@ struct EntityWrapper
static const EntityWrapper Invalid;
const std::string Name();
bool HasComponent(const std::string& componentType);
EntityWrapper Parent();
EntityWrapper FirstChildByName(const std::string& name);
@@ -35,6 +36,9 @@ struct EntityWrapper
bool operator!=(const EntityWrapper& e) const;
explicit operator EntityID() const;
operator bool();
private:
EntityWrapper firstChildByNameRecursive(const std::string& name, EntityID parent);
};
namespace std
+2
View File
@@ -8,8 +8,10 @@
namespace Transform
{
glm::mat4 AbsoluteTransformation(EntityWrapper entity);
glm::vec3 AbsolutePosition(EntityWrapper entity);
glm::vec3 AbsolutePosition(World* world, EntityID entity);
glm::vec3 AbsoluteOrientationEuler(EntityWrapper entity);
glm::quat AbsoluteOrientation(EntityWrapper entity);
glm::quat AbsoluteOrientation(World* world, EntityID entity);
glm::vec3 AbsoluteScale(EntityWrapper entity);
+2
View File
@@ -2,6 +2,7 @@
#define Events_InputCommand_h__
#include "Core/EventBroker.h"
#include "Core/EntityWrapper.h"
namespace Events
{
@@ -10,6 +11,7 @@ struct InputCommand : Event
{
/** Numerical ID of the player. */
int PlayerID;
EntityWrapper Player;
/** The command that was sent. */
std::string Command;
/** The value of the command. */
-1
View File
@@ -43,7 +43,6 @@ private:
PacketID m_PacketID = 0;
PacketID m_PreviousPacketID = 0;
PacketID m_SendPacketID = 0;
AckBitPattern ackBitField = 0;
// Game logic
World* m_World;
+1 -3
View File
@@ -11,12 +11,10 @@
#include "Core/ConfigFile.h"
#include <fstream>
#include <iostream>
#include <bitset>
#define INPUTSIZE 4097
#define INPUTSIZE 32000
typedef unsigned int PlayerID;
typedef unsigned int PacketID;
typedef unsigned int AckBitPattern;
class Network
{
+3 -5
View File
@@ -11,12 +11,12 @@ class Packet
public:
// arg1: Type of message (Connect, Disconnect...)
// arg2: PacketID for identifying packet loss.
Packet(MessageType type, unsigned int& packetID, unsigned int lastReceivedPacket, unsigned int ackBitField);
Packet(MessageType type, unsigned int& packetID);
// Used to create packet from already existing data buffer.
Packet(char* data, const int sizeOfPacket);
Packet(MessageType type);
~Packet();
void Init(MessageType type, unsigned int& packetID, unsigned int lastReceivedPacket, unsigned int ackBitField);
void Init(MessageType type, unsigned int& packetID);
// Add primitive types like int, float, char...
template<typename T>
@@ -50,9 +50,7 @@ public:
// Pops the first element as if it was a string.
std::string ReadString();
char* ReadData(int SizeOfData);
// No purpose any more
//void ChangePacketID(unsigned int& packetID);
void ChangeHeaderInfo(unsigned int& packetID, unsigned int lastReceivedPacket, unsigned int ackBitField);
void ChangePacketID(unsigned int& packetID);
int Size() { return m_Offset; };
char* Data() { return m_Data; };
unsigned int DataReadSize() { return m_ReturnDataOffset; }
@@ -7,13 +7,7 @@ struct PlayerDefinition {
::EntityID EntityID = EntityID_Invalid;
std::string Name = "";
boost::asio::ip::udp::endpoint Endpoint;
// The ID of the last sent packet. (Local sequence number)
unsigned int PacketID;
// The ID of the last received packet. (Remote sequence number)
// This is sent as the ackNumber.
unsigned int LastPacketReceivedID;
// The bit pattern of the last 32 received packets.
unsigned int AckBitField;
std::clock_t StopTime;
};
+12 -12
View File
@@ -34,10 +34,11 @@ private:
// Sending messages to client logic
std::map<PlayerID, PlayerDefinition> m_ConnectedPlayers;
// HACK: Fix INPUTSIZE
char readBuffer[INPUTSIZE] = { 0 };
int bytesRead = 0;
// time for previouse message
std::clock_t previousPingMessage = std::clock();
std::clock_t previousePingMessage = std::clock();
std::clock_t previousSnapshotMessage = std::clock();
std::clock_t timOutTimer = std::clock();
// How often we send messages (milliseconds)
@@ -58,26 +59,25 @@ private:
PacketID m_PreviousPacketID = 0;
// Private member functions
void addChildrenToPacket(Packet& packet, EntityID entityID);
void broadcast(Packet& packet);
void checkForTimeOuts();
void disconnect(PlayerID playerID);
void identifyPacketLoss();
void kick(PlayerID player);
int receive(char* data);
void readFromClients();
void send(PlayerID playerID, Packet& packet);
void send(PlayerID player, Packet& packet);
void send(Packet& packet);
void broadcast(Packet& packet);
void sendSnapshot();
void addChildrenToPacket(Packet& packet, EntityID entityID);
void sendPing();
void parseClientPing(PlayerID playerID);
void parseConnect(Packet& packet, PlayerID playerID);
void parseDisconnect();
void checkForTimeOuts();
void disconnect(PlayerID playerID);
void parseMessageType(Packet& packet);
void parseOnInputCommand(Packet& packet);
void parseOnPlayerDamage(Packet& packet);
void parseConnect(Packet& packet);
void parseDisconnect();
void parseClientPing();
void parsePing();
void identifyPacketLoss();
void kick(PlayerID player);
PlayerID GetPlayerIDFromEndpoint(boost::asio::ip::udp::endpoint endpoint);
// Debug event
EventRelay<Server, Events::InputCommand> m_EInputCommand;
@@ -0,0 +1,29 @@
#ifndef AnimationSystem_h__
#define AnimationSystem_h__
#include "GLM.h"
#include "Common.h"
#include "Core/System.h"
#include "Core/ResourceManager.h"
#include "Rendering/Model.h"
#include "Rendering/EAnimationComplete.h"
#include "Rendering/Skeleton.h"
class AnimationSystem : public PureSystem
{
public:
AnimationSystem(World* world, EventBroker* eventBroker)
: System(world, eventBroker)
, PureSystem("Animation")
{
}
~AnimationSystem() { }
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& animationComponent, double dt) override;
private:
};
#endif
+8
View File
@@ -30,6 +30,13 @@ public:
private:
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const;
void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& job, RenderScene& scene);
void BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene);
void BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene);
void BindExplosionTextures(std::shared_ptr<ExplosionEffectJob>& job);
void BindModelTextures(std::shared_ptr<ModelJob>& job);
Texture* m_WhiteTexture;
Texture* m_BlackTexture;
@@ -43,6 +50,7 @@ private:
const LightCullingPass* m_LightCullingPass;
ShaderProgram* m_ForwardPlusProgram;
ShaderProgram* m_ExplosionEffectProgram;
};
#endif
@@ -0,0 +1,18 @@
#ifndef Events_AnimationComplete_h__
#define Events_AnimationComplete_h__
#include "../Core/EventBroker.h"
#include "../Core/EntityWrapper.h"
namespace Events
{
struct AnimationComplete : Event
{
EntityWrapper Entity;
std::string Name;
};
}
#endif
@@ -0,0 +1,106 @@
#ifndef ExplosionEffectJob_h__
#define ExplosionEffectJob_h__
#include <cstdint>
#include "../Common.h"
#include "../GLM.h"
#include "../Core/ComponentWrapper.h"
#include "Texture.h"
#include "Model.h"
#include "RenderJob.h"
#include "../Core/ResourceManager.h"
#include "Camera.h"
#include "../Core/World.h"
struct ExplosionEffectJob : ModelJob
{
ExplosionEffectJob(ComponentWrapper explosionEffectComponent, ::Model* model, Camera* camera, glm::mat4 matrix, ::RawModel::MaterialGroup matGroup, ComponentWrapper modelComponent, ::World* world, glm::vec4 fillColor, float fillPercentage)
: ModelJob(model, camera, matrix, matGroup, modelComponent, world, fillColor, fillPercentage)
{
ExplosionOrigin = (glm::vec3)explosionEffectComponent["ExplosionOrigin"];
TimeSinceDeath = (double)explosionEffectComponent["TimeSinceDeath"];
ExplosionDuration = (double)explosionEffectComponent["ExplosionDuration"];
EndColor = (glm::vec4)explosionEffectComponent["EndColor"];
Randomness = (bool)explosionEffectComponent["Randomness"];
RandomnessScalar = (double)explosionEffectComponent["RandomnessScalar"];
Velocity = (glm::vec2)explosionEffectComponent["Velocity"];
ColorByDistance = (bool)explosionEffectComponent["ColorByDistance"];
ExponentialAccelaration = (bool)explosionEffectComponent["ExponentialAccelaration"];
};
glm::vec3 ExplosionOrigin;
double TimeSinceDeath = 0.f; //Seconds
double ExplosionDuration = 2.f;
//bool Gravity = true;
//double GravityForce = 1.f; // Speed
//double ObjectRadius = 2.f; // TODO: Change this for object radius when it's available
glm::vec4 EndColor;
bool Randomness = false;
float RandomnessScalar = 1.f;
glm::vec2 Velocity;
bool ColorByDistance = false;
//bool ReverseAnimation = false;
//bool Wireframe = false;
bool ExponentialAccelaration = false;
std::array<float, 50> RandomNumbers = {
0.3257552917701f,
0.07601508315467f,
0.57408909014151f,
0.0f,
0.8618231368539f,
0.074957156588769f,
0.39413607511396f,
0.54579346698979f,
0.83222648353885f,
0.83635707285086f,
0.34473986148124f,
0.98092448710507f,
0.46346380070944f,
0.7308761201477f,
0.70832470371776f,
0.28268750909841f,
0.26291620883295f,
0.07685032816457f,
0.30760929515008f,
0.2781575388639f ,
0.016950582161988f ,
0.25787915254844f ,
0.76293767279151f ,
0.67730279903733f ,
0.49042877018937f ,
0.13002237823327f ,
0.62803373841012f ,
0.94525353747665f ,
0.32893980076953f ,
0.95952951719962f ,
0.056386206790985f ,
0.012030893476694f ,
0.93090049220757f,
0.83579883064879f,
0.79733513938139f,
0.8796381046435f ,
0.94160434600972f ,
0.76901855588379f ,
0.50253688101775f ,
0.82457069578793f ,
0.80157403359263f ,
0.87291810189975f ,
0.64679548919517f ,
0.42664138899494f ,
0.77171308303797f ,
0.75567959237643f ,
0.45190826265696f ,
0.59844922628181f ,
0.56534937655802f ,
0.195656257307f};
void CalculateHash() override
{
Hash = 0;
}
};
#endif
+20 -1
View File
@@ -13,10 +13,11 @@
#include "Camera.h"
#include "../Core/World.h"
#include "../Core/Transform.h"
#include "Skeleton.h"
struct ModelJob : RenderJob
{
ModelJob(Model* model, Camera* camera, glm::mat4 matrix, ::RawModel::MaterialGroup matGroup, ComponentWrapper modelComponent, World* world)
ModelJob(Model* model, Camera* camera, glm::mat4 matrix, ::RawModel::MaterialGroup matGroup, ComponentWrapper modelComponent, World* world, glm::vec4 fillColor, float fillPercentage)
: RenderJob()
{
Model = model;
@@ -37,6 +38,16 @@ struct ModelJob : RenderJob
glm::vec3 worldpos = glm::vec3(camera->ViewMatrix() * glm::vec4(abspos, 1));
Depth = worldpos.z;
World = world;
FillColor = fillColor;
FillPercentage = fillPercentage;
Skeleton = Model->m_RawModel->m_Skeleton;
if (world->HasComponent(Entity, "Animation") && Skeleton != nullptr) {
auto animationComponent = world->GetComponent(Entity, "Animation");
Animation = model->m_RawModel->m_Skeleton->GetAnimation(animationComponent["Name"]);
AnimationTime = (double)animationComponent["Time"];
}
};
unsigned int TextureID;
@@ -51,6 +62,11 @@ struct ModelJob : RenderJob
float Shininess = 0.f;
glm::vec4 Color;
const ::Model* Model = nullptr;
::Skeleton* Skeleton = nullptr;
const ::Skeleton::Animation* Animation = nullptr;
float AnimationTime = 0.f;
glm::vec4 DiffuseColor;
glm::vec4 SpecularColor;
glm::vec4 IncandescenceColor;
@@ -58,6 +74,9 @@ struct ModelJob : RenderJob
unsigned int EndIndex = 0;
World* World;
glm::vec4 FillColor = glm::vec4(0);
float FillPercentage = 0.0;
void CalculateHash() override
{
Hash = TextureID;
+1 -4
View File
@@ -1,8 +1,6 @@
#ifndef PickingPass_h__
#define PickingPass_h__
#include "IRenderer.h"
#include "PickingPassState.h"
#include "FrameBuffer.h"
@@ -10,8 +8,7 @@
#include "Util/UnorderedMapiVec2.h"
#include "../Core/EventBroker.h"
#include "../Core/World.h"
#include "Rendering/Skeleton.h"
class PickingPass
{
+5 -2
View File
@@ -14,11 +14,13 @@
#include "TextJob.h"
#include "PointLightJob.h"
#include "DirectionalLightJob.h"
#include "ExplosionEffectJob.h"
struct RenderScene
{
::Camera* Camera = nullptr;
std::list<std::shared_ptr<RenderJob>> ForwardJobs;
std::list<std::shared_ptr<RenderJob>> OpaqueObjects;
std::list<std::shared_ptr<RenderJob>> TransparentObjects;
std::list<std::shared_ptr<RenderJob>> PointLightJobs;
std::list<std::shared_ptr<RenderJob>> TextJobs;
std::list<std::shared_ptr<RenderJob>> DirectionalLightJobs;
@@ -27,7 +29,8 @@ struct RenderScene
void Clear()
{
ForwardJobs.clear();
OpaqueObjects.clear();
TransparentObjects.clear();
PointLightJobs.clear();
TextJobs.clear();
DirectionalLightJobs.clear();
+2 -1
View File
@@ -29,6 +29,7 @@ private:
const IRenderer* m_Renderer;
RenderFrame* m_RenderFrame;
Camera* m_Camera;
World* m_World;
EntityWrapper m_CurrentCamera = EntityWrapper::Invalid;
EntityWrapper m_LocalPlayer = EntityWrapper::Invalid;
@@ -40,7 +41,7 @@ private:
EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand;
bool OnInputCommand(const Events::InputCommand& e);
void fillModels(std::list<std::shared_ptr<RenderJob>>& jobs);
void fillModels(std::list<std::shared_ptr<RenderJob>>& opaqueJobs, std::list<std::shared_ptr<RenderJob>>& transparentJobs);
void fillLight(std::list<std::shared_ptr<RenderJob>>& jobs);
EventRelay<RenderSystem, Events::PlayerSpawned> m_EPlayerSpawned;
+2
View File
@@ -73,6 +73,8 @@ private:
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type);
//--------------------ShaderPrograms-------------------//
ShaderProgram* m_BasicForwardProgram;
ShaderProgram* m_ExplosionEffectProgram;
};
#endif
+24
View File
@@ -0,0 +1,24 @@
#include "Common.h"
#include "Core/System.h"
class ExplosionEffectSystem : public PureSystem
{
public:
ExplosionEffectSystem(World* world, EventBroker* eventBroker)
: System(world, eventBroker)
, PureSystem("ExplosionEffect")
{ }
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt) override
{
if ((double)component["TimeSinceDeath"] > (double)component["ExplosionDuration"]) {
(double)component["TimeSinceDeath"] = 0.f;
}
(double&)component["TimeSinceDeath"] += dt;
//if ((bool)Component["Gravity"] == true) {
// (bool)Component["ExponentialAccelaration"] = false;
//}
}
};
+1
View File
@@ -14,6 +14,7 @@
#include "Core/EKeyDown.h"
#include "Core/EntityFilePreprocessor.h"
#include "Core/SystemPipeline.h"
#include "ExplosionEffectSystem.h"
#include "Editor/EditorSystem.h"
#include "Core/EntityFile.h"
#include "Rendering/RenderSystem.h"
+1 -1
View File
@@ -24,7 +24,7 @@ public:
private:
//methods which will take care of specific events
EventRelay<HealthSystem, Events::PlayerDamage> m_EPlayerDamage;
bool HealthSystem::OnPlayerDamaged(const Events::PlayerDamage& e);
bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e);
EventRelay<HealthSystem, Events::PlayerHealthPickup> m_EPlayerHealthPickup;
bool HealthSystem::OnPlayerHealthPickup(const Events::PlayerHealthPickup& e);
+21
View File
@@ -0,0 +1,21 @@
#ifndef LifetimeSystem_h__
#define LifetimeSystem_h__
#include "Core/System.h"
class LifetimeSystem : public ImpureSystem, PureSystem
{
public:
LifetimeSystem(World* world, EventBroker* eventBroker)
: System(world, eventBroker)
, PureSystem("Lifetime")
{ }
virtual void Update(double dt) override;
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cLifetime, double dt) override;
private:
std::vector<EntityWrapper> m_Deletions;
};
#endif
+23
View File
@@ -0,0 +1,23 @@
#ifndef PlayerHUD_h__
#define PlayerHUD_h__
#include "../../Engine/Core/System.h"
#include "../../Engine/GLM.h"
#include "../../Engine/Rendering/ESetCamera.h"
#include <imgui/imgui.h>
class PlayerHUD : public ImpureSystem
{
public:
PlayerHUD(World* world, EventBroker* eventBrokerer);
~PlayerHUD();
virtual void Update(double dt) override;
private:
World* m_World;
EventBroker* m_EventBroker;
};
#endif
+3 -1
View File
@@ -11,6 +11,8 @@
#include "Core/EShoot.h"
#include "Core/EPlayerSpawned.h"
#include "Input/EInputCommand.h"
#include "Core/EntityFile.h"
#include "Core/EntityFileParser.h"
#include <tuple>
#include <vector>
@@ -33,7 +35,7 @@ private:
EventRelay<WeaponSystem, Events::PlayerSpawned> m_EPlayerSpawned;
bool WeaponSystem::OnPlayerSpawned(const Events::PlayerSpawned& e);
EventRelay<WeaponSystem, Events::Shoot> m_EShoot;
bool WeaponSystem::OnShoot(const Events::Shoot& e);
bool WeaponSystem::OnShoot(Events::Shoot& e);
EventRelay<WeaponSystem, Events::InputCommand> m_EInputCommand;
bool WeaponSystem::OnInputCommand(const Events::InputCommand& e);
};
+5
View File
@@ -12,6 +12,7 @@
<xs:include schemaLocation="Components/PointLight.xsd"/>
<xs:include schemaLocation="Components/DirectionalLight.xsd"/>
<xs:include schemaLocation="Components/Trigger.xsd"/>
<xs:include schemaLocation="Components/ExplosionEffect.xsd"/>
<xs:include schemaLocation="Components/Health.xsd"/>
<xs:include schemaLocation="Components/CapturePoint.xsd"/>
<xs:include schemaLocation="Components/Listener.xsd"/>
@@ -23,4 +24,8 @@
<xs:include schemaLocation="Components/Team.xsd"/>
<xs:include schemaLocation="Components/UniformScale.xsd"/>
<xs:include schemaLocation="Components/EditorWidget.xsd"/>
<xs:include schemaLocation="Components/HealthHUD.xsd"/>
<xs:include schemaLocation="Components/Animation.xsd"/>
<xs:include schemaLocation="Components/Fill.xsd"/>
<xs:include schemaLocation="Components/Lifetime.xsd"/>
</xs:schema>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Animation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Animation.xsd">
<Time>0</Time>
<Speed>0</Speed>
<Loop>true</Loop>
</Animation>
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:element name="Animation">
<xs:complexType>
<xs:all>
<xs:element name="Name" type="t:string" minOccurs="0"/>
<xs:element name="Time" type="t:double" minOccurs="0"/>
<xs:element name="Speed" type="t:double" minOccurs="0"/>
<xs:element name="Loop" type="t:bool" minOccurs="0"/>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<ExplosionEffect xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ExplosionEffect.xsd">
<ExplosionOrigin X="0" Y="0" Z="0"/>
<TimeSinceDeath>0</TimeSinceDeath>
<ExplosionDuration>2</ExplosionDuration>
<!--<Gravity>1</Gravity>-->
<!--<GravityForce>1</GravityForce>-->
<!--<ObjectRadius>2</ObjectRadius>-->
<EndColor R="0" G="0" B="0" A="0"/>
<Randomness>0</Randomness>
<RandomnessScalar>1</RandomnessScalar>
<Velocity X="2" Y="2"/>
<ColorByDistance>0</ColorByDistance>
<!--<ReverseAnimation>0</ReverseAnimation>-->
<!--<Wireframe>0</Wireframe>-->
<ExponentialAccelaration>0</ExponentialAccelaration>
</ExplosionEffect>
@@ -0,0 +1,57 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:element name="ExplosionEffect">
<xs:annotation>
<xs:documentation>A component that trigger the death effect</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:all>
<xs:element name="ExplosionOrigin" type="t:Vector" minOccurs="0">
<xs:annotation><xs:documentation>The position in which to spawn the component</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="TimeSinceDeath" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>Seconds since death</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="ExplosionDuration" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>How many seconds the death animation should be</xs:documentation></xs:annotation>
</xs:element>
<!--<xs:element name="Gravity" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Enable/disable gravity</xs:documentation></xs:annotation>
</xs:element>-->
<!--<xs:element name="GravityForce" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>The force of the gravity</xs:documentation></xs:annotation>
</xs:element>-->
<!--<xs:element name="ObjectRadius" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>Object radius (TO BE REMOVED AND AUTOMATED)</xs:documentation></xs:annotation>
</xs:element>-->
<xs:element name="EndColor" type="t:Color" minOccurs="0">
<xs:annotation><xs:documentation>The tint the polys end with</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="Randomness" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Add some randomness to the explosion</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="RandomnessScalar" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>Alter the power of the randomness</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="Velocity" type="t:Vector" minOccurs="0">
<xs:annotation><xs:documentation>The velocity factors (start/end)</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="ColorByDistance" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Change the color by its moved distance instead of by its time</xs:documentation></xs:annotation>
</xs:element>
<!--<xs:element name="ReverseAnimation" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Implosions are cooler</xs:documentation></xs:annotation>
</xs:element>-->
<!--<xs:element name="Wireframe" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Enable/disable wireframe</xs:documentation></xs:annotation>
</xs:element>-->
<xs:element name="ExponentialAccelaration" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Linear/Exponential accelaration</xs:documentation></xs:annotation>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
+5
View File
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Fill xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Fill.xsd">
<Percentage>0.0</Percentage>
<Color R="1" G="1" B="1" A="1"/>
</Fill>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:element name="Fill">
<xs:complexType>
<xs:all>
<xs:element name="Percentage" type="t:double" minOccurs="0"/>
<xs:element name="Color" type="t:Color" minOccurs="0"/>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Listener xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Listener.xsd"/>
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:element name="HealthHUD">
</xs:element>
</xs:schema>
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Lifetime xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Animation.xsd">
<Lifetime>0</Lifetime>
</Animation>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:element name="Lifetime">
<xs:complexType>
<xs:all>
<xs:element name="Lifetime" type="t:double" minOccurs="0"/>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
+1
View File
@@ -2,5 +2,6 @@
<Model xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Model.xsd">
<Resource></Resource>
<Color R="1" G="1" B="1" A="1"/>
<Transparent>false</Transparent>
<Visible>true</Visible>
</Model>
+3
View File
@@ -15,6 +15,9 @@
<xs:element name="Color" type="t:Color" minOccurs="0">
<xs:annotation><xs:documentation>Color tint</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="Transparent" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Wether the model is transparent or not</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="Visible" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Wether the model is visible or not</xs:documentation></xs:annotation>
</xs:element>
+1 -11
View File
@@ -5,16 +5,6 @@
<c:Transform/>
</Components>
<Children>
<Entity>
<Components>
<c:Model>
<Resource></Resource>
</c:Model>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
<Children/>
</Entity>
+78
View File
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity name="GotToGoFast" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Transform>
<Position X="0" Y="-0.00432979874" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Model>
<Resource>Models/Core/UnitSphere.mesh</Resource>
<Color A="1" B="1" G="39.2156868" R="392.15686"/>
</c:Model>
<c:RaptorCopter>
<Axis X="1.50000012" Y="-2.20000005" Z="2.10000014"/>
</c:RaptorCopter>
<c:Transform>
<Position X="0" Y="2.87819886" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Animation>
<Name>Run</Name>
<Time>0.56277947897317659</Time>
<Speed>1</Speed>
</c:Animation>
<c:ExplosionEffect>
<Velocity X="0" Y="1.10000002" Z="3.30000019"/>
<ExplosionOrigin X="-0.600000024" Y="1" Z="0"/>
<TimeSinceDeath>0.95625903442123672</TimeSinceDeath>
<EndColor A="0" B="0.815686285" G="1" R="0"/>
</c:ExplosionEffect>
<c:Model>
<Resource>Models/AssaultAnimated.mesh</Resource>
<Color A="1" B="392156.875" G="1" R="1"/>
</c:Model>
<c:Transform>
<Position X="0" Y="0.5" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Text>
<Content>pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew </Content>
<Resource>Fonts/DroidSans.ttf,60</Resource>
<Color A="0" B="0.972549021" G="3.92156863" R="39.2156868"/>
<Alignment>
<Left/>
</Alignment>
</c:Text>
<c:Transform>
<Position X="0.245514169" Y="0.817000031" Z="-0.883219421"/>
<Scale X="0.300000012" Y="0.300000012" Z="1"/>
<Orientation X="0" Y="1.52600002" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
<Entity>
<Components>
<c:DirectionalLight/>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
+115
View File
@@ -123,6 +123,121 @@
</Components>
<Children/>
</Entity>
<Entity name="BluSpawn">
<Components>
<c:PlayerSpawn/>
<c:Model>
<Resource>Models/Core/UnitCube.mesh</Resource>
<Visible>false</Visible>
</c:Model>
<c:Spawner>
<EntityFile>Schema/Entities/Player.xml</EntityFile>
</c:Spawner>
<c:Team>
<Team>
<Blue/>
</Team>
</c:Team>
<c:Transform>
<Position X="57.7363472" Y="1.18853188" Z="79.5"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:SpawnPoint/>
<c:Transform/>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:SpawnPoint/>
<c:Transform>
<Position X="-2.05988312" Y="0" Z="2.79573512"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Transform>
<Position X="1.85022807" Y="0" Z="-2.08909845"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Transform>
<Position X="2.98651481" Y="0" Z="-4.67667246"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Transform>
<Position X="-5.16323137" Y="0" Z="3.62892342"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="RedSpawn">
<Components>
<c:PlayerSpawn/>
<c:Model>
<Resource>Models/Core/UnitCube.mesh</Resource>
<Visible>false</Visible>
</c:Model>
<c:Spawner>
<EntityFile>Schema/Entities/Player.xml</EntityFile>
</c:Spawner>
<c:Team>
<Team>
<Red/>
</Team>
</c:Team>
<c:Transform>
<Position X="-60.2567062" Y="1.60000002" Z="-78.1000061"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:SpawnPoint/>
<c:Transform/>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Transform>
<Position X="0" Y="0" Z="2.24403"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Transform>
<Position X="2.20245028" Y="0" Z="-1.97843659"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Transform>
<Position X="4.79769945" Y="0" Z="-5.2088728"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
+117 -1
View File
@@ -146,7 +146,6 @@
</c:Team>
<c:Transform>
<Position X="0.300000012" Y="0.0270000007" Z="6.67400026"/>
<Orientation X="0" Y="3.20700026" Z="0"/>
</c:Transform>
</Components>
<Children>
@@ -178,6 +177,123 @@
</Entity>
</Children>
</Entity>
<Entity name="Player">
<Components>
<c:AABB>
<Origin X="0" Y="0.772000015" Z="0"/>
<Size X="1" Y="1.60000002" Z="1"/>
</c:AABB>
<c:Collidable/>
<c:Model/>
<c:Physics>
<Gravity>false</Gravity>
</c:Physics>
<c:Player>
<MovementSpeed>5</MovementSpeed>
</c:Player>
<c:Team>
<Team>
<Red/>
</Team>
</c:Team>
<c:Transform>
<Position X="-1.68112314" Y="0.0264999866" Z="3.06287026"/>
<Orientation X="0" Y="2.14675093" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity name="Camera">
<Components>
<c:Camera/>
<c:Transform>
<Position X="0" Y="1.37700009" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity name="PlayerName">
<Components>
<c:Text>
<Resource>Fonts/DroidSans.ttf,100</Resource>
<Color A="1" B="0" G="1" R="0"/>
<Visible>false</Visible>
</c:Text>
<c:Transform>
<Position X="0" Y="0.247910097" Z="-0.447844714"/>
<Scale X="0.100000001" Y="0.113000005" Z="0.5"/>
<Orientation X="0" Y="3.14199996" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="CameraModel">
<Components>
<c:Model>
<Resource>Models/Camera.mesh</Resource>
</c:Model>
<c:Transform>
<Position X="0" Y="0.0331346765" Z="-0.0792061687"/>
<Scale X="1.30000007" Y="1.50000012" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="ThirdPersonCamera">
<Components>
<c:Camera/>
<c:Model>
<Resource>Models/Camera.mesh</Resource>
<Visible>false</Visible>
</c:Model>
<c:Transform>
<Position X="-0.284000009" Y="1.83800006" Z="1.18900001"/>
<Orientation X="5.95600033" Y="0" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="PlayerModel">
<Components>
<c:Model>
<Resource>Models/AssaultHeadless.mesh</Resource>
<Color A="1" B="0" G="0" R="1"/>
</c:Model>
<c:Transform>
<Orientation X="0" Y="3.14159274" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="AABBStanding">
<Components>
<c:Model>
<Resource>Models/Core/UnitCube.mesh</Resource>
<Color A="0.427450985" B="1" G="1" R="1"/>
<Visible>false</Visible>
</c:Model>
<c:Transform>
<Position X="0" Y="0.772000015" Z="0"/>
<Scale X="1" Y="1.60000002" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="AABBCrouching">
<Components>
<c:Model>
<Resource>Models/Core/UnitCube.mesh</Resource>
<Color A="0.745098054" B="1" G="0" R="1"/>
<Visible>false</Visible>
</c:Model>
<c:Transform>
<Position X="0" Y="0.772000015" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
+75 -10
View File
@@ -2,13 +2,15 @@
<Entity name="Player" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Health/>
<c:AABB>
<Origin X="0" Y="0.772000015" Z="0"/>
<Size X="1" Y="1.60000002" Z="1"/>
</c:AABB>
<c:Collidable/>
<c:Model/>
<c:Physics/>
<c:Physics>
<Velocity X="2.30999646e-23" Y="0" Z="1.05272533e-23"/>
</c:Physics>
<c:Player>
<MovementSpeed>5</MovementSpeed>
</c:Player>
@@ -18,8 +20,7 @@
</Team>
</c:Team>
<c:Transform>
<Position X="-0.246963501" Y="0.0265000071" Z="3.01600003"/>
<Orientation X="0" Y="2.14675093" Z="0"/>
<Orientation X="0" Y="2.24449515" Z="0"/>
</c:Transform>
</Components>
@@ -37,10 +38,9 @@
<c:Text>
<Resource>Fonts/DroidSans.ttf,100</Resource>
<Color A="1" B="0" G="1" R="0"/>
<Visible>false</Visible>
</c:Text>
<c:Transform>
<Position X="0" Y="0.247910097" Z="-0.447844714"/>
<Position X="0.100000001" Y="0.248000011" Z="-0.248000011"/>
<Scale X="0.100000001" Y="0.113000005" Z="0.5"/>
<Orientation X="0" Y="3.14199996" Z="0"/>
</c:Transform>
@@ -51,6 +51,7 @@
<Components>
<c:Model>
<Resource>Models/Camera.mesh</Resource>
<Visible>false</Visible>
</c:Model>
<c:Transform>
<Position X="0" Y="0.0331346765" Z="-0.0792061687"/>
@@ -59,6 +60,67 @@
</Components>
<Children/>
</Entity>
<Entity name="HUD">
<Components>
<c:Transform>
<Position X="0" Y="0" Z="-0.5"/>
</c:Transform>
</Components>
<Children>
<Entity name="HealthBar">
<Components>
<c:Fill>
<Percentage>1</Percentage>
<Color A="0" B="1" G="0" R="0"/>
</c:Fill>
<c:HealthHUD/>
<c:Model>
<Resource>Models/Core/UnitHexagon.mesh</Resource>
<Color A="1" B="0.70588237" G="0.70588237" R="0.70588237"/>
</c:Model>
<c:Transform>
<Position X="-0.383000016" Y="-0.185000002" Z="0"/>
<Scale X="0.150000006" Y="0.150000006" Z="0.150000006"/>
<Orientation X="0" Y="0.594000041" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="Crosshair">
<Components>
<c:Model>
<Resource>Models/CrosshairQuad.mesh</Resource>
</c:Model>
<c:Transform>
<Position X="0" Y="0" Z="0.200000003"/>
<Scale X="0.00600000005" Y="1" Z="0.00600000005"/>
<Orientation X="1.57000005" Y="0" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="Weapon">
<Components>
<c:Model>
<Resource>Models/AssaultWeapon.mesh</Resource>
</c:Model>
<c:Transform>
<Position X="0.180000007" Y="-0.183000013" Z="0"/>
<Orientation X="0" Y="4.64700031" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="WeaponMuzzle">
<Components>
<c:Transform>
<Position X="0.215000004" Y="-0.153000012" Z="-0.266000003"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
<Entity name="ThirdPersonCamera">
@@ -77,13 +139,16 @@
</Entity>
<Entity name="PlayerModel">
<Components>
<c:Animation>
<Name>Hold Pos</Name>
<Time>0.9779997896222552</Time>
<Speed>1</Speed>
</c:Animation>
<c:Model>
<Resource>Models/AssaultHeadless.mesh</Resource>
<Resource>Models/AssaultAnimated.mesh</Resource>
<Color A="1" B="0" G="0" R="1"/>
</c:Model>
<c:Transform>
<Orientation X="0" Y="3.14159274" Z="0"/>
</c:Transform>
<c:Transform/>
</Components>
<Children/>
</Entity>
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Model>
<Resource>Models/Core/UnitCylinder.mesh</Resource>
<Color A="0" B="0" G="0" R="39.2156868"/>
</c:Model>
<c:Transform>
<Scale X="0.0400000028" Y="26.2000008" Z="0.0400000028"/>
<Orientation X="1.57070005" Y="0" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
+19
View File
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Lifetime>
<Lifetime>0.25</Lifetime>
</c:Lifetime>
<c:Model>
<Resource>Models/CylinderBullet.mesh</Resource>
<Color A="1" B="39.2156868" G="7.84313726" R="0"/>
</c:Model>
<c:Transform>
<Scale X="0.0109999999" Y="0.0289999992" Z="100"/>
</c:Transform>
</Components>
<Children/>
</Entity>
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Model>
<Resource>Models/Core/UnitCylinder.mesh</Resource>
<Color A="0" B="0" G="0" R="39.2156868"/>
</c:Model>
<c:Transform>
<Scale X="0.0400000028" Y="26.2000008" Z="0.0400000028"/>
<Orientation X="1.57070005" Y="0" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
+19
View File
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Lifetime>
<Lifetime>0.25</Lifetime>
</c:Lifetime>
<c:Model>
<Resource>Models/CylinderBullet.mesh</Resource>
<Color A="1" B="0" G="0.525490224" R="39.2156868"/>
</c:Model>
<c:Transform>
<Scale X="0.0110000009" Y="0.029000001" Z="100"/>
</c:Transform>
</Components>
<Children/>
</Entity>
+154 -65
View File
@@ -6,34 +6,115 @@
</Components>
<Children>
<Entity>
<Entity name="Player">
<Components>
<c:Camera>
<Name>ActionCamera</Name>
</c:Camera>
<c:Model>
<Resource>Models/Camera.mesh</Resource>
</c:Model>
<c:Health>
<Health>65.990005493164063</Health>
</c:Health>
<c:Player/>
<c:Transform>
<Position X="-0.504807115" Y="6.00582743" Z="9.68687439"/>
<Orientation X="-0.733036518" Y="0.000105090476" Z="5.12391125e-07"/>
<Position X="0" Y="0" Z="2.5"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Entity name="Model">
<Components>
<c:Text>
<Content>Camera #2</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment>0</Alignment>
</c:Text>
<c:Model>
<Resource>Models/Assault.obj</Resource>
<Color A="1" B="3.92156863" G="3.92156863" R="3.92156863"/>
</c:Model>
<c:Transform>
<Position X="0.700063765" Y="0.310270816" Z="-1"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
<Orientation X="0" Y="3.14159203" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="Camera">
<Components>
<c:Camera>
<FOV>80</FOV>
</c:Camera>
<c:Model>
<Resource>Models/Camera.mesh</Resource>
</c:Model>
<c:Transform>
<Position X="0" Y="1.39121652" Z="-0.043014247"/>
<Orientation X="6.28300047" Y="0" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity name="HUD">
<Components>
<c:Transform>
<Position X="0" Y="-0.000463247066" Z="-0.744767368"/>
</c:Transform>
</Components>
<Children>
<Entity name="Hexagon">
<Components>
<c:HealthHUD/>
<c:Fill>
<Percentage>0.65990006923675537</Percentage>
<Color A="0" B="0.659900069" G="0" R="0.340099931"/>
</c:Fill>
<c:Model>
<Resource>Models/Core/UnitHexagon.mesh</Resource>
<Color A="0.313725501" B="0.70588237" G="0.70588237" R="0.70588237"/>
</c:Model>
<c:Transform>
<Position X="-0.285538822" Y="-0.282350302" Z="-1.52214652e-05"/>
<Scale X="0.200000003" Y="0.200000003" Z="0.5"/>
<Orientation X="0" Y="0.666000009" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity name="Ammo">
<Components>
<c:Text>
<Content>24</Content>
<Resource>Fonts/DroidSans.ttf,60</Resource>
</c:Text>
<c:Transform>
<Position X="-1.43861985e-06" Y="0.0125972452" Z="0.0100018298"/>
<Scale X="0.349999994" Y="0.349999994" Z="0.200000003"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Text>
<Content>262</Content>
<Resource>Fonts/DroidSans.ttf,60</Resource>
</c:Text>
<c:Transform>
<Position X="-4.27209579e-06" Y="-0.0390000008" Z="5.43686883e-06"/>
<Scale X="0.65200001" Y="0.643000007" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
<Entity>
<Components>
<c:HealthHUD/>
<c:Text>
<Content>65/100</Content>
<Resource>Fonts/DroidSans.ttf,60</Resource>
<Color A="1" B="0.659900069" G="0" R="0.340099931"/>
</c:Text>
<c:Transform>
<Scale X="0.200000003" Y="0.200000003" Z="0.200000003"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
<Entity>
@@ -42,7 +123,7 @@
<Resource>Models/Core/UnitPlane.mesh</Resource>
</c:Model>
<c:Transform>
<Position X="0" Y="-1" Z="0.600000024"/>
<Position X="0" Y="-0.689623177" Z="0.600000024"/>
<Scale X="100" Y="1" Z="100"/>
</c:Transform>
</Components>
@@ -52,6 +133,7 @@
<Components>
<c:Model>
<Resource>Models/Assault.mesh</Resource>
<Color A="1" B="3.92156863" G="1" R="1"/>
</c:Model>
<c:Transform>
<Position X="-2.5" Y="0" Z="1"/>
@@ -64,6 +146,7 @@
<c:Text>
<Content>Welcome!</Content>
<Resource>Fonts/DroidSans.ttf,1280</Resource>
<Color A="0" B="3.92156863" G="3.92156863" R="3.92156863"/>
</c:Text>
<c:Transform>
<Position X="0" Y="0" Z="0.700000048"/>
@@ -74,32 +157,40 @@
<Entity>
<Components>
<c:RaptorCopter>
<Speed>2</Speed>
<Axis X="0" Y="1" Z="0"/>
<Speed>3</Speed>
<Axis X="0.200000003" Y="3.4000001" Z="0.5"/>
</c:RaptorCopter>
<c:Transform>
<Position X="0" Y="2.37320328" Z="0"/>
<Orientation X="0" Y="8252.15918" Z="0"/>
<Orientation X="758.058899" Y="20632.8691" Z="1320.68018"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Model>
<Resource>Models/Core/UnitSphere.obj</Resource>
<Color A="1" B="7.84313726" G="0" R="7.84313726"/>
</c:Model>
<c:PointLight>
<Color A="1" B="1" G="0" R="1"/>
<Radius>6</Radius>
<Radius>70</Radius>
<Intensity>0.5</Intensity>
</c:PointLight>
<c:Transform>
<Position X="-2.5" Y="0" Z="0"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Model>
<Resource>Models/Core/UnitSphere.obj</Resource>
<Color A="1" B="0" G="0" R="7.84313726"/>
</c:Model>
<c:PointLight>
<Color A="1" B="0" G="0" R="1"/>
<Radius>8</Radius>
<Radius>70</Radius>
</c:PointLight>
<c:Transform>
<Position X="-5" Y="0" Z="0"/>
@@ -111,21 +202,30 @@
</Entity>
<Entity>
<Components>
<c:Model>
<Resource>Models/Core/UnitSphere.obj</Resource>
<Color A="1" B="0" G="7.84313726" R="7.84313726"/>
</c:Model>
<c:PointLight>
<Color A="1" B="0" G="1" R="1"/>
<Radius>6</Radius>
<Radius>70</Radius>
<Intensity>0.5</Intensity>
</c:PointLight>
<c:Transform>
<Position X="0" Y="0" Z="-2.5"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Model>
<Resource>Models/Core/UnitSphere.obj</Resource>
<Color A="1" B="0" G="7.84313726" R="0"/>
</c:Model>
<c:PointLight>
<Color A="1" B="0" G="1" R="0"/>
<Radius>8</Radius>
<Radius>70</Radius>
</c:PointLight>
<c:Transform>
<Position X="0" Y="0" Z="-5"/>
@@ -137,21 +237,30 @@
</Entity>
<Entity>
<Components>
<c:Model>
<Resource>Models/Core/UnitSphere.obj</Resource>
<Color A="1" B="7.84313726" G="7.84313726" R="0"/>
</c:Model>
<c:PointLight>
<Color A="1" B="1" G="1" R="0"/>
<Radius>6</Radius>
<Radius>70</Radius>
<Intensity>0.5</Intensity>
</c:PointLight>
<c:Transform>
<Position X="0" Y="0" Z="2.5"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Model>
<Resource>Models/Core/UnitSphere.obj</Resource>
<Color A="1" B="7.84313726" G="0" R="0"/>
</c:Model>
<c:PointLight>
<Color A="1" B="1" G="0.00784313772" R="0"/>
<Radius>8</Radius>
<Color A="1" B="1" G="0" R="0"/>
<Radius>70</Radius>
</c:PointLight>
<c:Transform>
<Position X="0" Y="0" Z="5"/>
@@ -163,19 +272,28 @@
</Entity>
<Entity>
<Components>
<c:Model>
<Resource>Models/Core/UnitSphere.obj</Resource>
<Color A="1" B="7.84313726" G="7.84313726" R="7.84313726"/>
</c:Model>
<c:PointLight>
<Radius>6</Radius>
<Radius>70</Radius>
<Intensity>0.5</Intensity>
</c:PointLight>
<c:Transform>
<Position X="2.5" Y="0" Z="0"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Model>
<Resource>Models/Core/UnitSphere.obj</Resource>
<Color A="1" B="7.84313726" G="7.84313726" R="7.84313726"/>
</c:Model>
<c:PointLight>
<Radius>8</Radius>
<Radius>70</Radius>
</c:PointLight>
<c:Transform>
<Position X="5" Y="0" Z="0"/>
@@ -191,6 +309,7 @@
<Components>
<c:Model>
<Resource>Models/Assault.mesh</Resource>
<Color A="1" B="1" G="1" R="3.92156863"/>
</c:Model>
<c:Transform>
<Position X="2.5" Y="0" Z="1"/>
@@ -198,46 +317,15 @@
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Camera>
<Name>MainCamera</Name>
</c:Camera>
<c:Listener/>
<c:Model>
<Resource>Models/Camera.mesh</Resource>
<Visible>false</Visible>
</c:Model>
<c:Transform>
<Position X="-1.27354908" Y="5.18422079" Z="10.6223917"/>
<Orientation X="-0.436328411" Y="-0.0523675606" Z="1.67869363e-08"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Text>
<Content>Taiwan #1</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment>0</Alignment>
</c:Text>
<c:Transform>
<Position X="0.716896772" Y="0.296712071" Z="-1"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity>
<Entity name="DirectionalLight">
<Components>
<c:DirectionalLight>
<Color A="1" B="0.996078432" G="1" R="1"/>
<Intensity>0.80000001192092896</Intensity>
<Intensity>0.10000000149011612</Intensity>
</c:DirectionalLight>
<c:Model>
<Resource>Models/DirectionalLightWidget.mesh</Resource>
<Color A="1" B="0" G="3.92156863" R="3.92156863"/>
</c:Model>
<c:Transform>
<Position X="-0.0013256073" Y="1.89540339" Z="6.53467274"/>
@@ -250,6 +338,7 @@
<Components>
<c:Model>
<Resource>Models/Core/UnitCube.mesh</Resource>
<Color A="1" B="1" G="39.2156868" R="1"/>
</c:Model>
<c:Transform>
<Position X="-5.4082036" Y="0" Z="-1.84950542"/>
+32
View File
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity name="BluSpawn" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:PlayerSpawn/>
<c:Model>
<Resource>Models/Core/UnitCube.mesh</Resource>
</c:Model>
<c:Spawner>
<EntityFile>Schema/Entities/Player.xml</EntityFile>
</c:Spawner>
<c:Team>
<Team>
<Blue/>
</Team>
</c:Team>
<c:Transform>
<Position X="57.7363472" Y="1.18853188" Z="79.5"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:SpawnPoint/>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
+17
View File
@@ -18,6 +18,23 @@
</c:Transform>
<c:Camera>
</c:Camera>
<Orientation X="0.0" Y="0.0" Z="0"/>
<c:ExplosionEffect>
<ExplosionOrigin X="0" Y="0" Z="0"/>
<TimeSinceDeath>0</TimeSinceDeath>
<ExplosionDuration>2</ExplosionDuration>
<!--<Gravity>1</Gravity>-->
<!--<GravityForce>1</GravityForce>-->
<!--<ObjectRadius>2</ObjectRadius>-->
<EndColor R="0" G="0" B="0" A="0"/>
<Randomness>0</Randomness>
<RandomnessScalar>1</RandomnessScalar>
<Velocity X="2" Y="2"/>
<ColorByDistance>0</ColorByDistance>
<!--<ReverseAnimation>0</ReverseAnimation>-->
<!--<Wireframe>0</Wireframe>-->
<ExponentialAccelaration>0</ExponentialAccelaration>
</c:ExplosionEffect>
<c:Model>
<Resource>Models/Camera.mesh</Resource>
</c:Model>
+2
View File
@@ -15,6 +15,7 @@
<xs:element ref="c:Model" minOccurs="0"/>
<xs:element ref="c:RaptorCopter" minOccurs="0"/>
<xs:element ref="c:Player" minOccurs="0"/>
<xs:element ref="c:ExplosionEffect" minOccurs="0"/>
<xs:element ref="c:Camera" minOccurs="0"/>
<xs:element ref="c:Text" minOccurs="0"/>
<xs:element ref="c:AABB" minOccurs="0"/>
@@ -32,6 +33,7 @@
<xs:element ref="c:DirectionalLight" minOccurs="0"/>
<xs:element ref="c:UniformScale" minOccurs="0"/>
<xs:element ref="c:EditorWidget" minOccurs="0"/>
<xs:element ref="c:Lifetime" minOccurs="0"/>
</xs:all>
</xs:complexType>
</xs:element>
@@ -0,0 +1,25 @@
#version 430
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
uniform vec4 Color;
uniform sampler2D texture0;
in VertexData{
vec3 Position;
vec3 Normal;
vec2 TextureCoordinate;
vec4 DiffuseColor;
vec4 ExplosionColor;
}Input;
out vec4 fragmentColor;
void main()
{
vec4 texel = texture2D(texture0, Input.TextureCoordinate);
fragmentColor = texel * Input.DiffuseColor * Color + Input.ExplosionColor;
}
+179
View File
@@ -0,0 +1,179 @@
#version 430
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
uniform vec3 ExplosionOrigin;
uniform float TimeSinceDeath;
uniform float ExplosionDuration;
uniform vec4 EndColor;
uniform bool Randomness;
uniform float RandomNumbers[50];
uniform float RandomnessScalar;
uniform vec2 Velocity;
uniform bool ColorByDistance;
uniform bool ExponentialAccelaration;
in VertexData{
vec3 Position;
vec3 Normal;
vec2 TextureCoordinate;
vec4 ExplosionColor;
}Input[];
out VertexData{
vec3 Position;
vec3 Normal;
vec2 TextureCoordinate;
vec4 ExplosionColor;
}Output;
layout(triangles) in;
layout(triangle_strip, max_vertices = 3) out;
// returns a "random" number based on input parameter
float GetRandomNumber(int polygon_index)
{
int randomIndex = int(mod(polygon_index, 50));
return RandomNumbers[randomIndex];
}
float randomNumber = 0.0;
float randomDistance = 0.0;
void main()
{
// calculate middle of vectors
vec3 v1 = Input[1].Position - Input[0].Position;
vec3 v2 = Input[2].Position - Input[0].Position;
vec3 v3 = Input[2].Position - (v1 / 2);
vec3 v4 = Input[1].Position - (v2 / 2);
// calculate intersection
// normalize direction
vec3 dir1 = normalize(v1);
vec3 dir2 = normalize(v2);
vec3 vecA = Input[2].Position - Input[1].Position; //o2 - o1
vec3 vecB = cross(dir1, dir2);
mat3 matrisA = mat3(vecA, dir2, vecB);
float lengthA = length(vecB);
lengthA = lengthA * lengthA;
float s = determinant(matrisA) / lengthA;
// center position of triangle
vec3 centerOfTriangle = Input[1].Position + (s * dir1);
// center position of triangle to origin vector
vec3 origin2TriangleCenterVector = centerOfTriangle - ExplosionOrigin;
vec3 normalizedOrigin2TriangleCenterVector = normalize(origin2TriangleCenterVector);
// time percentage until end of explosion (0.0-1.0)
float timePercetage = TimeSinceDeath / ExplosionDuration;
// get a random number if randomness is enabled, otherwise the random number will be zero and won't affect the other algorithms
if (Randomness == true)
{
randomDistance = GetRandomNumber(gl_PrimitiveIDIn) * RandomnessScalar;
}
vec2 randomVelocity = Velocity * (randomDistance + 1.0);
// accelaration to use on current frame. is a interpolation between start and end value
float currentVelocity = mix(randomVelocity.x, randomVelocity.y, timePercetage);
if (ExponentialAccelaration == true)
{
currentVelocity = pow(currentVelocity, 2) / 2.0;
}
// distance between origin and the center of the current triangle
float origin2TriangleCenterDistance = length(origin2TriangleCenterVector);
// the distance from origin to the triangle center with eventual randomness added
float fullDistanceWithRandomness = origin2TriangleCenterDistance + randomDistance;
// vector from the triangle center to the explosion's shockwave
vec3 triangleCenter2ExplosionRadius = (normalizedOrigin2TriangleCenterVector * (TimeSinceDeath * currentVelocity)) - (normalizedOrigin2TriangleCenterVector * fullDistanceWithRandomness);
// if the triangle is inside the blast radius...
if (fullDistanceWithRandomness <= (TimeSinceDeath * currentVelocity))
{
float maxRadius = max(TimeSinceDeath * currentVelocity, (ExplosionDuration * currentVelocity));
float a = (randomVelocity.y - randomVelocity.x) / ExplosionDuration;
//float t = sqrt((2 * origin2TriangleCenterDistance) / a);
// if explosion color should be affected by distance instead of time...
if (ColorByDistance == true)
{
// calculate the max distance (s) the triangle will move
float s = (randomVelocity.x * ExplosionDuration) + (0.5 * a * pow(ExplosionDuration, 2));
Output.ExplosionColor = EndColor * (length(triangleCenter2ExplosionRadius) / s);
}
else
{
Output.ExplosionColor = EndColor * timePercetage;
}
// for every vertex on the triangle...
for (int i = 0; i < gl_in.length(); i++)
{
// move the triangle to the blast radius
vec3 ExplodedPosition = Input[i].Position + triangleCenter2ExplosionRadius;
// pass through vertex data
Output.Normal = Input[i].Normal;
Output.Position = Input[i].Position;
Output.TextureCoordinate = Input[i].TextureCoordinate;
// convert to model space for the gravity to always be in -y
vec4 ExplodedPositionInModelSpace = M * vec4(ExplodedPosition, 1.0);
// if there is gravity, apply it
//if (Gravity == true)
//{
// // ---DO THIS----> //ExplodedPositionInModelSpace.y = ExplodedPositionInModelSpace.y - TimeSinceHit;
//
// ExplodedPositionInModelSpace.y = ExplodedPositionInModelSpace.y - pow(TimeSinceDeath, 2);
//}
// convert to screen space
gl_Position = P*V * ExplodedPositionInModelSpace;
EmitVertex();
}
}
else
{
// if explosion color should be affected by distance instead of time...
if (ColorByDistance == true)
{
Output.ExplosionColor = vec4(0.0);
}
else
{
Output.ExplosionColor = EndColor * timePercetage;
}
// for every vertex on the triangle...
for(int i = 0; i < gl_in.length(); i++)
{
// pass through vertex data
Output.Normal = Input[i].Normal;
Output.Position = Input[i].Position;
Output.TextureCoordinate = Input[i].TextureCoordinate;
// no change in position, pass through vertex
gl_Position = gl_in[i].gl_Position;
EmitVertex();
}
}
//EndPrimitive();
}
@@ -0,0 +1,36 @@
#version 430
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 2) in vec3 Tangent;
layout(location = 3) in vec3 BiTangent;
layout(location = 4) in vec2 TextureCoords;
layout(location = 5) in vec4 DiffuseVertexColor;
layout(location = 6) in vec4 SpecularVertexColor;
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{
vec3 Position;
vec3 Normal;
vec2 TextureCoordinate;
vec4 DiffuseColor;
vec4 ExplosionColor;
}Output;
void main()
{
gl_Position = P*V*M * vec4(Position, 1.0);
Output.Position = Position;
Output.TextureCoordinate = TextureCoords;
Output.Normal = Normal;
Output.DiffuseColor = DiffuseVertexColor;
Output.ExplosionColor = vec4(0.0);
}
+20 -6
View File
@@ -6,9 +6,12 @@ uniform mat4 P;
uniform vec4 Color;
uniform vec4 DiffuseColor;
uniform vec2 ScreenDimensions;
uniform vec4 FillColor;
uniform float FillPercentage;
layout (binding = 0) uniform sampler2D DiffuseTexture;
layout (binding = 1) uniform sampler2D GlowMap;
#define TILE_SIZE 16
struct LightSource {
@@ -47,6 +50,7 @@ in VertexData{
vec3 Position;
vec3 Normal;
vec2 TextureCoordinate;
vec4 ExplosionColor;
}Input;
out vec4 sceneColor;
@@ -134,12 +138,23 @@ void main()
totalLighting.Specular += light_result.Specular;
}
//sceneColor += Input.DiffuseColor;
vec4 color_result = DiffuseColor * (totalLighting.Diffuse + totalLighting.Specular) * diffuseTexel * Color;
vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + totalLighting.Specular) * diffuseTexel * Color;
float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0;
if(pos <= FillPercentage) {
color_result += FillColor;
}
//bloomColor = vec4(0.3, 0.8, 0.6, 1.0);
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
//These if statements should be removed if they are slow.
color_result += glowTexel;
bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), 1.0);
/*
if(color_result.x > 1 || color_result.y > 1 || color_result.z > 1) {
@@ -147,11 +162,10 @@ void main()
} else {
bloomColor = vec4(0.0, 0.0, 0.0, 1.0);
} */
//sceneColor += Input.DiffuseColor * (totalLighting.Diffuse) * diffuseTexel * Color;
//sceneColor += Input.DiffuseColor + vec4(0.0, LightGrids.Data[currentTile].Amount/3, 0, 1);
//sceneColor = diffuseTexel * Input.DiffuseColor * Color;
//sceneColor += vec4(currentTile/3600.f, 0, 0, 1);
//Tiled Debug Code
/*
+2
View File
@@ -17,6 +17,7 @@ out VertexData{
vec3 Position;
vec3 Normal;
vec2 TextureCoordinate;
vec4 ExplosionColor;
}Output;
void main()
@@ -36,4 +37,5 @@ void main()
Output.Position = (boneTransform * vec4(Position, 1.0)).xyz;
Output.TextureCoordinate = TextureCoords;
Output.Normal = vec3(M * vec4(Normal, 0.0));
Output.ExplosionColor = vec4(0.0);
}
+12 -8
View File
@@ -3,18 +3,15 @@
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
uniform mat4 Bones[100];
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 2) in vec3 Tangent;
layout(location = 3) in vec3 BiTangent;
layout(location = 4) in vec2 TextureCoords;
layout(location = 5) in vec4 DiffuseVertexColor;
layout(location = 6) in vec4 SpecularVertexColor;
layout(location = 7) in vec4 BoneIndices1;
layout(location = 8) in vec4 BoneIndices2;
layout(location = 9) in vec4 BoneWeights1;
layout(location = 10) in vec4 BoneWeights2;
layout(location = 5) in vec4 BoneIndices;
layout(location = 6) in vec4 BoneWeights;
out VertexData{
vec3 Position;
@@ -22,7 +19,14 @@ out VertexData{
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;
}
+32 -12
View File
@@ -3,6 +3,11 @@
const EntityWrapper EntityWrapper::Invalid = EntityWrapper(nullptr, EntityID_Invalid);
const std::string EntityWrapper::Name()
{
return World->GetName(ID);
}
bool EntityWrapper::HasComponent(const std::string& componentName)
{
if (!Valid()) {
@@ -22,18 +27,7 @@ EntityWrapper EntityWrapper::Parent()
EntityWrapper EntityWrapper::FirstChildByName(const std::string& name)
{
auto itPair = this->World->GetChildren(this->ID);
if (itPair.first == itPair.second) {
return EntityWrapper::Invalid;
}
for (auto it = itPair.first; it != itPair.second; ++it) {
if (this->World->GetName(it->second) == name) {
return EntityWrapper(this->World, it->second);
}
}
return EntityWrapper::Invalid;
return firstChildByNameRecursive(name, this->ID);
}
EntityWrapper EntityWrapper::FirstParentWithComponent(const std::string& componentType)
@@ -108,3 +102,29 @@ EntityWrapper::operator bool()
return this->Valid();
}
EntityWrapper EntityWrapper::firstChildByNameRecursive(const std::string& name, EntityID parent)
{
if (!this->World->ValidEntity(parent)) {
return EntityWrapper::Invalid;
}
auto itPair = this->World->GetChildren(parent);
if (itPair.first == itPair.second) {
return EntityWrapper::Invalid;
}
for (auto it = itPair.first; it != itPair.second; ++it) {
std::string itName = this->World->GetName(it->second);
if (itName == name) {
return EntityWrapper(this->World, it->second);
} else if (it->second != EntityID_Invalid) {
EntityWrapper result = firstChildByNameRecursive(name, it->second);
if (result != EntityWrapper::Invalid) {
return result;
}
}
}
return EntityWrapper::Invalid;
}
+27
View File
@@ -1,5 +1,17 @@
#include "Core/Transform.h"
glm::mat4 Transform::AbsoluteTransformation(EntityWrapper entity)
{
glm::mat4 t = glm::mat4(1.f);
while (entity.Valid()) {
t = glm::translate((glm::vec3&)entity["Transform"]["Position"]) * glm::toMat4(glm::quat((glm::vec3&)entity["Transform"]["Orientation"])) * glm::scale((glm::vec3&)entity["Transform"]["Scale"]) * t;
entity = entity.Parent();
}
return t;
}
glm::vec3 Transform::AbsolutePosition(EntityWrapper entity)
{
return AbsolutePosition(entity.World, entity.ID);
@@ -19,6 +31,19 @@ glm::vec3 Transform::AbsolutePosition(World* world, EntityID entity)
return position;
}
glm::vec3 Transform::AbsoluteOrientationEuler(EntityWrapper entity)
{
glm::vec3 orientation;
while (entity.Valid()) {
ComponentWrapper transform = entity["Transform"];
orientation += (glm::vec3)transform["Orientation"];
entity = entity.Parent();
}
return orientation;
}
glm::quat Transform::AbsoluteOrientation(EntityWrapper entity)
{
return AbsoluteOrientation(entity.World, entity.ID);
@@ -62,6 +87,8 @@ glm::mat4 Transform::ModelMatrix(EntityWrapper entity)
glm::mat4 Transform::ModelMatrix(EntityID entity, World* world)
{
return AbsoluteTransformation(EntityWrapper(world, entity));
glm::vec3 position = Transform::AbsolutePosition(world, entity);
glm::quat orientation = Transform::AbsoluteOrientation(world, entity);
glm::vec3 scale = Transform::AbsoluteScale(world, entity);
+9
View File
@@ -1,4 +1,5 @@
#include "Editor/EditorGUI.h"
#include "Rendering/ESetCamera.h"
EditorGUI::EditorGUI(World* world, EventBroker* eventBroker)
: m_World(world)
@@ -305,6 +306,14 @@ bool EditorGUI::drawComponentNode(EntityWrapper entity, const ComponentInfo& ci)
}
}
if (ci.Name == "Camera") {
if (ImGui::Button("Activate")) {
Events::SetCamera e;
e.CameraEntity = entity;
m_EventBroker->Publish(e);
}
}
return true;
}
+6 -2
View File
@@ -48,8 +48,12 @@ void EditorRenderSystem::Update(double dt)
EntityWrapper entity(m_World, cModel.EntityID);
glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, entity.World);
for (auto matGroup : model->MaterialGroups()) {
std::shared_ptr<ModelJob> modelJob = std::make_shared<ModelJob>(model, scene.Camera, modelMatrix, matGroup, cModel, entity.World);
scene.ForwardJobs.push_back(modelJob);
std::shared_ptr<ModelJob> modelJob = std::make_shared<ModelJob>(model, scene.Camera, modelMatrix, matGroup, cModel, entity.World, glm::vec4(0), 0.f);
if(cModel["Transparent"]) {
scene.TransparentObjects.push_back(modelJob);
} else {
scene.OpaqueObjects.push_back(modelJob);
}
}
}
}
+1 -1
View File
@@ -203,7 +203,7 @@ bool EditorSystem::OnSetCamera(const Events::SetCamera& e)
m_ActualCamera = e.CameraEntity;
Events::SetCamera e2;
e2.CameraEntity = m_EditorCamera;
m_EventBroker->Publish(e2);
//m_EventBroker->Publish(e2);
}
return true;
}
+8 -8
View File
@@ -130,7 +130,7 @@ void Client::parsePing()
LOG_INFO("%i: response time with ctime(ms): %f", m_PacketID, m_DurationOfPingTime);
m_StartPingTime = std::clock();
Packet packet(MessageType::Ping, m_SendPacketID, m_PacketID, ackBitField);
Packet packet(MessageType::Ping, m_SendPacketID);
packet.WriteString("Ping recieved");
send(packet);
}
@@ -294,7 +294,7 @@ void Client::send(Packet& packet)
void Client::connect()
{
Packet packet(MessageType::Connect, m_SendPacketID, m_PacketID, ackBitField);
Packet packet(MessageType::Connect, m_SendPacketID);
packet.WriteString(m_PlayerName);
m_StartPingTime = std::clock();
send(packet);
@@ -304,7 +304,7 @@ void Client::disconnect()
{
m_PreviousPacketID = 0;
m_PacketID = 0;
Packet packet(MessageType::Disconnect, m_SendPacketID, m_PacketID, ackBitField);
Packet packet(MessageType::Disconnect, m_SendPacketID);
send(packet);
}
@@ -344,9 +344,9 @@ bool Client::OnInputCommand(const Events::InputCommand & e)
bool Client::OnPlayerDamage(const Events::PlayerDamage & e)
{
Packet packet(MessageType::OnPlayerDamage, m_SendPacketID, m_PacketID, ackBitField);
Packet packet(MessageType::OnPlayerDamage, m_SendPacketID);
packet.WritePrimitive(e.Damage);
packet.WritePrimitive(e.Player.ID);
packet.WritePrimitive(m_ClientIDToServerID.at(e.Player.ID));
send(packet);
return false;
}
@@ -368,7 +368,7 @@ void Client::sendLocalPlayerTransform()
ComponentWrapper cTransform = m_LocalPlayer["Transform"];
glm::vec3& position = cTransform["Position"];
glm::vec3& orientation = cTransform["Orientation"];
Packet packet(MessageType::PlayerTransform, m_SendPacketID, m_PacketID, ackBitField);
Packet packet(MessageType::PlayerTransform, m_SendPacketID);
packet.WritePrimitive(position.x);
packet.WritePrimitive(position.y);
packet.WritePrimitive(position.z);
@@ -413,7 +413,7 @@ EntityID Client::createPlayer()
void Client::sendInputCommands()
{
if (m_InputCommandBuffer.size() > 0) {
Packet packet(MessageType::OnInputCommand, m_SendPacketID, m_PacketID, ackBitField);
Packet packet(MessageType::OnInputCommand, m_SendPacketID);
for (int i = 0; i < m_InputCommandBuffer.size(); i++) {
packet.WriteString(m_InputCommandBuffer[i].Command);
packet.WritePrimitive(m_InputCommandBuffer[i].Value);
@@ -425,7 +425,7 @@ void Client::sendInputCommands()
void Client::becomePlayer()
{
Packet packet(MessageType::BecomePlayer, m_SendPacketID, m_PacketID, ackBitField);
Packet packet = Packet(MessageType::BecomePlayer, m_SendPacketID);
send(packet);
}
+9 -28
View File
@@ -1,9 +1,9 @@
#include "Network/Packet.h"
Packet::Packet(MessageType type, unsigned int& packetID, unsigned int lastReceivedPacket, unsigned int ackBitField)
Packet::Packet(MessageType type, unsigned int& packetID)
{
m_Data = new char[m_MaxPacketSize];
Init(type, packetID, lastReceivedPacket, ackBitField);
Init(type, packetID);
}
// Create message
@@ -21,9 +21,7 @@ Packet::Packet(MessageType type)
{
m_Data = new char[m_MaxPacketSize];
unsigned int dummy = 0;
// Dummy allocates memory for later insertion of
// correct values
Init(type, dummy, dummy, dummy);
Init(type, dummy);
}
Packet::~Packet()
@@ -31,17 +29,15 @@ Packet::~Packet()
delete[] m_Data;
}
void Packet::Init(MessageType type, unsigned int & packetID, unsigned int lastReceivedPacket, unsigned int ackBitField)
void Packet::Init(MessageType type, unsigned int & packetID)
{
m_ReturnDataOffset = 0;
m_Offset = 0;
// Create message header
// Add message type
int messageType = static_cast<int>(type);
WritePrimitive<int>(messageType);
WritePrimitive<unsigned int>(packetID);
WritePrimitive<unsigned int>(lastReceivedPacket);
WritePrimitive<unsigned int>(ackBitField);
Packet::WritePrimitive<int>(messageType);
Packet::WritePrimitive<int>(packetID);
packetID++;
m_HeaderSize = m_Offset;
}
@@ -91,31 +87,16 @@ char * Packet::ReadData(int SizeOfData)
return (m_Data + oldReturnDataOffset);
}
//void Packet::ChangePacketID(unsigned int & packetID)
//{
// packetID = packetID + 1;
// // Overwrite old PacketID
// memcpy(m_Data + sizeof(int), &packetID, sizeof(int));
//}
void Packet::ChangeHeaderInfo(unsigned int& packetID, unsigned int lastReceivedPacket, unsigned int ackBitField)
void Packet::ChangePacketID(unsigned int & packetID)
{
packetID = packetID + 1;
// Start at sizeOf(int) cause of MessageType
int offset = sizeof(int);
// Overwrite old PacketID
memcpy(m_Data + sizeof(unsigned int), &packetID, offset);
offset += sizeof(unsigned int);
// Overwrite old LastReceivedPacket
memcpy(m_Data + sizeof(unsigned int), &lastReceivedPacket, offset);
offset += sizeof(unsigned int);
// Overwrite old ackBitField
memcpy(m_Data + sizeof(unsigned int), &ackBitField, offset);
offset += sizeof(unsigned int);
memcpy(m_Data + sizeof(int), &packetID, sizeof(int));
}
void Packet::resizeData()
{
// Allocate memory to store our data in
char* holdData = new char[m_MaxPacketSize];
// Copy our data to the newly allocated memory
+25 -38
View File
@@ -32,16 +32,6 @@ void Server::Update()
m_EventBroker->Process<Server>();
if (isReadingData) {
Network::Update();
// Test bit patterns
//std::bitset<32> bitPattern;
//bitPattern[0].flip();
//bitPattern[15].flip();
//bitPattern[31].flip();
//std::cout << "bitPattern: " << bitPattern << '\n';
//unsigned int bitPatternInt = static_cast<unsigned int>(bitPattern.to_ulong());
//std::cout << "Int pattern: " << bitPatternInt << '\n';
//std::bitset<32> bitPatternRev(bitPatternInt);
//std::cout << "bitPatternReverted: " << bitPatternRev << '\n';
}
}
@@ -65,9 +55,9 @@ void Server::readFromClients()
}
// Send pings each
if (pingIntervalMs < (1000 * (currentTime - previousPingMessage) / (double)CLOCKS_PER_SEC)) {
if (pingIntervalMs < (1000 * (currentTime - previousePingMessage) / (double)CLOCKS_PER_SEC)) {
sendPing();
previousPingMessage = currentTime;
previousePingMessage = currentTime;
}
// Time out logic
@@ -79,19 +69,15 @@ void Server::readFromClients()
void Server::parseMessageType(Packet& packet)
{
PlayerID playerID = GetPlayerIDFromEndpoint(m_ReceiverEndpoint);
int messageType = packet.ReadPrimitive<int>(); // Read what type off message was sent from server
// Read packet ID
if (playerID != -1) {
// TODO: Bit pattern stuff!"#!"#
m_ConnectedPlayers[playerID].LastPacketReceivedID = packet.ReadPrimitive<PacketID>();
}
// Read packet ID
m_PreviousPacketID = m_PacketID; // Set previous packet id
m_PacketID = packet.ReadPrimitive<int>(); //Read new packet id
//identifyPacketLoss();
switch (static_cast<MessageType>(messageType)) {
case MessageType::Connect:
parseConnect(packet, playerID);
parseConnect(packet);
break;
case MessageType::Ping:
parsePing();
@@ -132,12 +118,12 @@ int Server::receive(char * data)
return length;
}
void Server::send(PlayerID playerID, Packet& packet)
void Server::send(PlayerID player, Packet& packet)
{
try {
int bytesSent = m_Socket.send_to(
boost::asio::buffer(packet.Data(), packet.Size()),
m_ConnectedPlayers[playerID].Endpoint,
m_ConnectedPlayers[player].Endpoint,
0);
// Network Debug data
if (isReadingData) {
@@ -147,7 +133,7 @@ void Server::send(PlayerID playerID, Packet& packet)
}
} catch (const boost::system::system_error& e) {
// TODO: Clean up invalid endpoints out of m_ConnectedPlayers later
m_ConnectedPlayers[playerID].Endpoint = boost::asio::ip::udp::endpoint();
m_ConnectedPlayers[player].Endpoint = boost::asio::ip::udp::endpoint();
}
}
@@ -169,11 +155,7 @@ void Server::send(Packet & packet)
void Server::broadcast(Packet& packet)
{
for (auto& kv : m_ConnectedPlayers) {
packet.ChangeHeaderInfo(
kv.second.PacketID,
kv.second.LastPacketReceivedID,
kv.second.AckBitField
);
packet.ChangePacketID(kv.second.PacketID);
send(kv.first, packet);
}
}
@@ -287,6 +269,7 @@ void Server::parseOnInputCommand(Packet& packet)
Events::InputCommand e;
e.Command = packet.ReadString();
e.PlayerID = player; // Set correct player id
e.Player = EntityWrapper(m_World, m_ConnectedPlayers.at(player).EntityID);
e.Value = packet.ReadPrimitive<float>();
m_EventBroker->Publish(e);
//LOG_INFO("Server::parseOnInputCommand: Command is %s. Value is %f. PlayerID is %i.", e.Command.c_str(), e.Value, e.PlayerID);
@@ -303,13 +286,20 @@ void Server::parseOnPlayerDamage(Packet & packet)
//LOG_DEBUG("Server::parseOnPlayerDamage: Command is %s. Value is %f. PlayerID is %i.", e.DamageAmount, e.PlayerDamagedID, e.TypeOfDamage.c_str());
}
void Server::parseConnect(Packet& packet, PlayerID playerID)
void Server::parseConnect(Packet& packet)
{
LOG_INFO("Parsing connections");
// Check if player is already connected
if (playerID != -1) {
if (GetPlayerIDFromEndpoint(m_ReceiverEndpoint) != -1) {
return;
}
for (auto& kv : m_ConnectedPlayers) {
if (kv.second.Endpoint.address() == m_ReceiverEndpoint.address() &&
kv.second.Endpoint.port() == m_ReceiverEndpoint.port()) {
// Already connected
return;
}
}
// Create a new player
PlayerDefinition pd;
pd.EntityID = 0; // Overlook this
@@ -317,11 +307,11 @@ void Server::parseConnect(Packet& packet, PlayerID playerID)
pd.Name = packet.ReadString();
pd.PacketID = 0;
pd.StopTime = std::clock();
Packet connnectPacket(MessageType::Connect, pd.PacketID, pd.LastPacketReceivedID, pd.AckBitField);
m_ConnectedPlayers[m_NextPlayerID++] = pd;
LOG_INFO("Spectator \"%s\" connected on IP: %s", pd.Name.c_str(), pd.Endpoint.address().to_string().c_str());
// Send a message to the player that connected
Packet connnectPacket(MessageType::Connect, pd.PacketID);
send(connnectPacket);
// Send notification that a player has connected
@@ -342,18 +332,15 @@ void Server::parseDisconnect()
}
}
void Server::parseClientPing(PlayerID player)
void Server::parseClientPing()
{
LOG_INFO("%i: Parsing ping", m_PacketID);
PlayerID player = GetPlayerIDFromEndpoint(m_ReceiverEndpoint);
if (player == -1) {
return;
}
// Return ping
Packet packet(
MessageType::Ping,
m_ConnectedPlayers[player].PacketID,
m_ConnectedPlayers[player].LastPacketReceivedID,
m_ConnectedPlayers[player].AckBitField
);
Packet packet(MessageType::Ping, m_ConnectedPlayers[player].PacketID);
packet.WriteString("Ping received");
send(packet);
}
+47
View File
@@ -0,0 +1,47 @@
#include "Rendering/AnimationSystem.h"
void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& animationComponent, double dt)
{
if(!entity.HasComponent("Model")) {
return;
}
Model* model;
try {
model = ResourceManager::Load<::Model, true>(entity["Model"]["Resource"]);
} catch (const std::exception&) {
return;
}
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
const Skeleton::Animation* animation = skeleton->GetAnimation(animationComponent["Name"]);
if(animation != nullptr) {
double animationSpeed = (double)animationComponent["Speed"];
if (animationSpeed != 0.0) {
double nextTime = (double)animationComponent["Time"] + animationSpeed * dt;
if (!(bool)animationComponent["Loop"] && glm::abs(nextTime) > animation->Duration) {
(double&)animationComponent["Time"] = glm::sign(nextTime) * animation->Duration;
(double&)animationComponent["Speed"] = 0.0;
Events::AnimationComplete e;
e.Entity = entity;
e.Name = (std::string)animationComponent["Name"];
m_EventBroker->Publish(e);
} else {
if (glm::abs(nextTime) > animation->Duration) {
(double&)animationComponent["Time"] = glm::abs(nextTime) - animation->Duration;
} else {
(double&)animationComponent["Time"] = nextTime;
}
}
}
}
}
+148 -59
View File
@@ -25,7 +25,7 @@ void DrawFinalPass::InitializeFrameBuffers()
//GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->Resolution().Width, m_Renderer->Resolution().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->Resolution().Width, m_Renderer->Resolution().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
//GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->Resolution().Width, m_Renderer->Resolution().Height), GL_RGB16F, GL_FLOAT, 4);
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new RenderBuffer(&m_DepthBuffer, GL_DEPTH_ATTACHMENT)));
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SceneTexture, GL_COLOR_ATTACHMENT0)));
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_BloomTexture, GL_COLOR_ATTACHMENT1)));
@@ -42,6 +42,15 @@ void DrawFinalPass::InitializeShaderPrograms()
m_ForwardPlusProgram->BindFragDataLocation(0, "sceneColor");
m_ForwardPlusProgram->BindFragDataLocation(1, "bloomColor");
m_ForwardPlusProgram->Link();
m_ExplosionEffectProgram = ResourceManager::Load<ShaderProgram>("#ExplosionEffectProgram");
m_ExplosionEffectProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardPlus.vert.glsl")));
m_ExplosionEffectProgram->AddShader(std::shared_ptr<Shader>(new GeometryShader("Shaders/ExplosionEffect.geom.glsl")));
m_ExplosionEffectProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlus.frag.glsl")));
m_ExplosionEffectProgram->Compile();
m_ExplosionEffectProgram->BindFragDataLocation(0, "sceneColor");
m_ExplosionEffectProgram->BindFragDataLocation(1, "bloomColor");
m_ExplosionEffectProgram->Link();
}
void DrawFinalPass::Draw(RenderScene& scene)
@@ -49,68 +58,15 @@ void DrawFinalPass::Draw(RenderScene& scene)
GLERROR("DrawFinalPass::Draw: Pre");
DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle());
m_ForwardPlusProgram->Bind();
GLuint shaderHandle = m_ForwardPlusProgram->GetHandle();
if (scene.ClearDepth) {
glClear(GL_DEPTH_BUFFER_BIT);
}
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO());
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO());
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO());
DrawModelRenderQueues(scene.OpaqueObjects, scene);
GLERROR("DrawFinalPass::Draw: OpaqueObjects");
DrawModelRenderQueues(scene.TransparentObjects, scene);
GLERROR("DrawFinalPass::Draw: TransparentObjects");
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()));
glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height);
//TODO: Render: Add code for more jobs than modeljobs.
for (auto &job : scene.ForwardJobs) {
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
if(modelJob) {
//TODO: Kolla upp "header/include/common" shader saken så man slipper skicka in asmycket uniforms
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(modelJob->Color));
glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(modelJob->DiffuseColor));
glActiveTexture(GL_TEXTURE0);
if(modelJob->DiffuseTexture != nullptr) {
glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture->m_Texture);
} else {
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
}
glActiveTexture(GL_TEXTURE1);
if (modelJob->IncandescenceTexture != nullptr) {
glBindTexture(GL_TEXTURE_2D, modelJob->IncandescenceTexture->m_Texture);
} else {
glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture);
}
/*if(modelJob->GlowMap != nullptr) {
glBindTexture(GL_TEXTURE_2D, modelJob->GlowMap->m_Texture);
} else {
glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture);
}*/
//TODO: Fixa så att modelsJobs kan spela upp olika animationer och så att den kan få in en tid istället för 1.0f - Hälsningar Johan och Andreas :)
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
auto animation = modelJob->Model->m_RawModel->m_Skeleton->GetAnimation("running");
if (animation != nullptr) {
std::vector<glm::mat4> frameBones = modelJob->Model->m_RawModel->m_Skeleton->GetFrameBones(
*animation,
0.0f
);
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
}
}
glBindVertexArray(modelJob->Model->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex * sizeof(unsigned int)));
}
}
GLERROR("DrawFinalPass::Draw: END");
delete state;
}
@@ -148,4 +104,137 @@ void DrawFinalPass::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
GLERROR("MipMap Texture initialization failed");
}
}
void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& job, RenderScene& scene)
{
GLuint forwardHandle = m_ForwardPlusProgram->GetHandle();
GLuint explosionHandle = m_ExplosionEffectProgram->GetHandle();
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO());
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO());
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO());
for(auto &job : job)
{
auto explosionEffectJob = std::dynamic_pointer_cast<ExplosionEffectJob>(job);
if(explosionEffectJob) {
//Bind program
m_ExplosionEffectProgram->Bind();
//Bind uniforms
BindExplosionUniforms(explosionHandle, explosionEffectJob, scene);
if (explosionEffectJob->Model->m_RawModel->m_Skeleton != nullptr) {
if (explosionEffectJob->Animation != nullptr) {
std::vector<glm::mat4> frameBones = explosionEffectJob->Skeleton->GetFrameBones(*explosionEffectJob->Animation, explosionEffectJob->AnimationTime);
glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
}
}
//bind textures
BindExplosionTextures(explosionEffectJob);
//draw
glBindVertexArray(explosionEffectJob->Model->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, explosionEffectJob->Model->ElementBuffer);
glDrawElements(GL_TRIANGLES, explosionEffectJob->EndIndex - explosionEffectJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(explosionEffectJob->StartIndex*sizeof(unsigned int)));
} else {
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
if (modelJob) {
//bind forward program
m_ForwardPlusProgram->Bind();
//bind uniforms
BindModelUniforms(forwardHandle, modelJob, scene);
//bind textures
BindModelTextures(modelJob);
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(forwardHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
}
}
//draw
glBindVertexArray(modelJob->Model->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex*sizeof(unsigned int)));
GLERROR("DrawFinalPass::Model: END");
}
}
}
}
void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene)
{
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()));
glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height);
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix));
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color));
glUniform3fv(glGetUniformLocation(shaderHandle, "ExplosionOrigin"), 1, glm::value_ptr(job->ExplosionOrigin));
glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), job->TimeSinceDeath);
glUniform1f(glGetUniformLocation(shaderHandle, "ExplosionDuration"), job->ExplosionDuration);
glUniform4fv(glGetUniformLocation(shaderHandle, "EndColor"), 1, glm::value_ptr(job->EndColor));
glUniform1i(glGetUniformLocation(shaderHandle, "Randomness"), job->Randomness);
glUniform1f(glGetUniformLocation(shaderHandle, "RandomnessScalar"), job->RandomnessScalar);
glUniform2fv(glGetUniformLocation(shaderHandle, "Velocity"), 1, glm::value_ptr(job->Velocity));
glUniform1i(glGetUniformLocation(shaderHandle, "ColorByDistance"), job->ColorByDistance);
glUniform1i(glGetUniformLocation(shaderHandle, "ExponentialAccelaration"), job->ExponentialAccelaration);
glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(job->DiffuseColor));
glUniform1fv(glGetUniformLocation(shaderHandle, "RandomNumbers"), 50, job->RandomNumbers.data());
}
void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene)
{
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()));
glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height);
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix));
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color));
glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(job->DiffuseColor));
glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(job->FillColor));
glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), job->FillPercentage);
}
void DrawFinalPass::BindExplosionTextures(std::shared_ptr<ExplosionEffectJob>& job)
{
glActiveTexture(GL_TEXTURE0);
if (job->DiffuseTexture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->DiffuseTexture->m_Texture);
} else {
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
}
glActiveTexture(GL_TEXTURE1);
if (job->IncandescenceTexture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture->m_Texture);
} else {
glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture);
}
}
void DrawFinalPass::BindModelTextures(std::shared_ptr<ModelJob>& job)
{
glActiveTexture(GL_TEXTURE0);
if (job->DiffuseTexture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->DiffuseTexture->m_Texture);
} else {
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
}
glActiveTexture(GL_TEXTURE1);
if (job->IncandescenceTexture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture->m_Texture);
} else {
glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture);
}
}
+63 -9
View File
@@ -48,7 +48,7 @@ void PickingPass::Draw(RenderScene& scene)
PickingPassState* state = new PickingPassState(m_PickingBuffer.GetHandle());
//TODO: Render: Add code for more jobs than modeljobs.
GLuint ShaderHandle = m_PickingProgram->GetHandle();
GLuint shaderHandle = m_PickingProgram->GetHandle();
m_PickingProgram->Bind();
if (scene.ClearDepth) {
@@ -56,7 +56,7 @@ void PickingPass::Draw(RenderScene& scene)
}
m_Camera = scene.Camera;
for (auto &job : scene.ForwardJobs) {
for (auto &job : scene.OpaqueObjects) {
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
if (modelJob) {
@@ -75,22 +75,76 @@ void PickingPass::Draw(RenderScene& scene)
m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]);
if (m_ColorCounter[0] > 255) {
m_ColorCounter[0] = 0;
m_ColorCounter[1]++;
m_ColorCounter[1] += 5;
} else {
m_ColorCounter[0]++;
m_ColorCounter[0] += 50;
}
}
m_PickingColorsToEntity[glm::ivec2(pickColor[0], pickColor[1])] = pickInfo;
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, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
glUniform2fv(glGetUniformLocation(ShaderHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
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, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
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);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
glDrawElementsBaseVertex(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, nullptr, modelJob->StartIndex);
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex * sizeof(unsigned int)));
}
}
for (auto &job : scene.TransparentObjects) {
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
if (modelJob) {
int pickColor[2] = { m_ColorCounter[0], m_ColorCounter[1] };
PickingInfo pickInfo;
pickInfo.Entity = modelJob->Entity;
pickInfo.World = modelJob->World;
pickInfo.Camera = scene.Camera;
auto color = m_EntityColors.find(std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera));
if (color != m_EntityColors.end()) {
pickColor[0] = color->second[0];
pickColor[1] = color->second[1];
} else {
m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]);
if (m_ColorCounter[0] > 255) {
m_ColorCounter[0] = 0;
m_ColorCounter[1] += 5;
} else {
m_ColorCounter[0] += 50;
}
}
m_PickingColorsToEntity[glm::ivec2(pickColor[0], pickColor[1])] = pickInfo;
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, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
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);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex * sizeof(unsigned int)));
}
}
+61 -7
View File
@@ -4,6 +4,7 @@ RenderSystem::RenderSystem(World* world, EventBroker* eventBroker, const IRender
: System(world, eventBroker)
, m_Renderer(renderer)
, m_RenderFrame(renderFrame)
, m_World(world)
{
EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &RenderSystem::OnSetCamera);
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &RenderSystem::OnInputCommand);
@@ -30,7 +31,7 @@ bool RenderSystem::OnSetCamera(Events::SetCamera& e)
return true;
}
void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& jobs)
void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& opaqueJobs, std::list<std::shared_ptr<RenderJob>>& transparentJobs)
{
auto models = m_World->GetComponents("Model");
if (models == nullptr) {
@@ -51,6 +52,12 @@ void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& jobs)
// Don't render the local player
if (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer)) {
if (!entity.HasComponent("HealthHUD") && entity.Name() != "Crosshair" && entity.Name() != "Weapon") { //Should work but needs to be fixed. Should only render the things "childed" to the local player camera
continue;
}
}
if ((entity.Name() == "Weapon" || entity.HasComponent("HealthHUD")) && !entity.IsChildOf(m_LocalPlayer)) {
continue;
}
@@ -68,10 +75,58 @@ void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& jobs)
}
}
float fillPercentage = 0.f;
glm::vec4 fillColor = glm::vec4(0);
if(m_World->HasComponent(modelComponent.EntityID, "Fill")) {
auto fillComponent = m_World->GetComponent(modelComponent.EntityID, "Fill");
fillPercentage = (float)(double)fillComponent["Percentage"];
fillColor = (glm::vec4)fillComponent["Color"];
}
glm::mat4 modelMatrix = Transform::ModelMatrix(modelComponent.EntityID, m_World);
for (auto matGroup : model->MaterialGroups()) {
std::shared_ptr<ModelJob> modelJob = std::shared_ptr<ModelJob>(new ModelJob(model, m_Camera, modelMatrix, matGroup, modelComponent, m_World));
jobs.push_back(modelJob);
if (m_World->HasComponent(modelComponent.EntityID, "ExplosionEffect")) {
auto explosionEffectComponent = m_World->GetComponent(modelComponent.EntityID, "ExplosionEffect");
std::shared_ptr<ExplosionEffectJob> explosionEffectJob = std::shared_ptr<ExplosionEffectJob>(new ExplosionEffectJob(
explosionEffectComponent,
model,
m_Camera,
modelMatrix,
matGroup,
modelComponent,
m_World,
fillColor,
fillPercentage
));
if(explosionEffectJob->Color.a != 1.f || explosionEffectJob->EndColor.a != 1.f || explosionEffectJob->DiffuseColor.a != 1.f) {
modelComponent["Transparent"] = true;
}
if (modelComponent["Transparent"]) {
transparentJobs.push_back(explosionEffectJob);
} else {
opaqueJobs.push_back(explosionEffectJob);
}
} else {
std::shared_ptr<ModelJob> modelJob = std::shared_ptr<ModelJob>(new ModelJob(
model,
m_Camera,
modelMatrix,
matGroup,
modelComponent,
m_World,
fillColor,
fillPercentage
));
if (modelJob->Color.a != 1.f || modelJob->DiffuseColor.a != 1.f) {
modelComponent["Transparent"] = true;
}
if (modelComponent["Transparent"]) {
transparentJobs.push_back(modelJob);
} else {
opaqueJobs.push_back(modelJob);
}
}
}
}
}
@@ -156,8 +211,8 @@ void RenderSystem::fillText(std::list<std::shared_ptr<RenderJob>>& jobs, World*
}
glm::mat4 modelMatrix = Transform::ModelMatrix(textComponent.EntityID, world);
std::shared_ptr<TextJob> modelJob = std::shared_ptr<TextJob>(new TextJob(modelMatrix, font, textComponent));
jobs.push_back(modelJob);
std::shared_ptr<TextJob> textJob = std::shared_ptr<TextJob>(new TextJob(modelMatrix, font, textComponent));
jobs.push_back(textJob);
}
}
@@ -177,12 +232,11 @@ void RenderSystem::Update(double dt)
m_Camera->SetOrientation(Transform::AbsoluteOrientation(m_CurrentCamera));
}
//Only supports opaque geometry atm
RenderScene scene;
scene.Camera = m_Camera;
scene.Viewport = Rectangle(1280, 720);
fillModels(scene.ForwardJobs);
fillModels(scene.OpaqueObjects, scene.TransparentObjects);
fillPointLights(scene.PointLightJobs, m_World);
fillDirectionalLights(scene.DirectionalLightJobs, m_World);
fillText(scene.TextJobs, m_World);
+11 -1
View File
@@ -63,6 +63,15 @@ void Renderer::InitializeWindow()
void Renderer::InitializeShaders()
{
m_BasicForwardProgram = ResourceManager::Load<ShaderProgram>("#m_BasicForwardProgram");
m_ExplosionEffectProgram = ResourceManager::Load<ShaderProgram>("#ExplosionEffectProgram");
//m_ExplosionEffectProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ExplosionEffect.vert.glsl")));
//m_ExplosionEffectProgram->AddShader(std::shared_ptr<Shader>(new GeometryShader("Shaders/ExplosionEffect.geom.glsl")));
//m_ExplosionEffectProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ExplosionEffect.frag.glsl")));
//m_ExplosionEffectProgram->Compile();
//m_ExplosionEffectProgram->Link();
}
void Renderer::InputUpdate(double dt)
@@ -98,6 +107,7 @@ void Renderer::Draw(RenderFrame& frame)
m_LightCullingPass->FillLightList(*scene);
m_LightCullingPass->CullLights(*scene);
m_DrawFinalPass->Draw(*scene);
//m_DrawScenePass->Draw(*scene);
GLERROR("Renderer::Draw m_DrawScenePass->Draw");
@@ -140,7 +150,7 @@ void Renderer::InitializeTextures()
void Renderer::SortRenderJobsByDepth(RenderScene &scene)
{
//Sort all forward jobs so transparency is good.
scene.ForwardJobs.sort(Renderer::DepthSort);
scene.TransparentObjects.sort(Renderer::DepthSort);
}
void Renderer::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type)
+9 -1
View File
@@ -10,6 +10,9 @@
#include "Core/EntityFileWriter.h"
#include "Game/Systems/CapturePointSystem.h"
#include "Game/Systems/WeaponSystem.h"
#include "Game/Systems/PlayerHUD.h"
#include "Game/Systems/LifetimeSystem.h"
#include "../Engine/Rendering/AnimationSystem.h"
Game::Game(int argc, char* argv[])
{
@@ -77,15 +80,20 @@ Game::Game(int argc, char* argv[])
// All systems with orderlevel 0 will be updated first.
unsigned int updateOrderLevel = 0;
m_SystemPipeline->AddSystem<RaptorCopterSystem>(updateOrderLevel);
//m_SystemPipeline->AddSystem<HealthSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<ExplosionEffectSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<HealthSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<PlayerMovementSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<InterpolationSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<SpawnerSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<PlayerSpawnSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<WeaponSystem>(updateOrderLevel, m_Renderer);
m_SystemPipeline->AddSystem<LifetimeSystem>(updateOrderLevel);
// Populate Octree with collidables
++updateOrderLevel;
m_SystemPipeline->AddSystem<CollidableOctreeSystem>(updateOrderLevel, m_OctreeCollision);
m_SystemPipeline->AddSystem<PlayerHUD>(updateOrderLevel);
m_SystemPipeline->AddSystem<AnimationSystem>(updateOrderLevel);
// Collision and TriggerSystem should update after player.
++updateOrderLevel;
m_SystemPipeline->AddSystem<CollisionSystem>(updateOrderLevel, m_OctreeCollision);
+9 -3
View File
@@ -45,10 +45,16 @@ void HealthSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& comp
}
}
bool HealthSystem::OnPlayerDamaged(const Events::PlayerDamage& e)
bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e)
{
//save the changed HP to a vector. it will be taken care of in UpdateComponent
//m_DeltaHealthVector.push_back(std::make_tuple(e.PlayerDamagedID, -e.DamageAmount));
ComponentWrapper cHealth = e.Player["Health"];
double& health = cHealth["Health"];
health -= e.Damage;
if (health <= 0.0) {
m_World->DeleteEntity(e.Player.ID);
}
return true;
}
+27
View File
@@ -0,0 +1,27 @@
#include "Systems/LifetimeSystem.h"
void LifetimeSystem::Update(double dt)
{
for (auto& e : m_Deletions) {
m_World->DeleteEntity(e.ID);
}
m_Deletions.clear();
}
void LifetimeSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cLifetime, double dt)
{
if (dt == 0.0) {
return;
}
if (!entity.Valid()) {
return;
}
double& lifetime = cLifetime["Lifetime"];
lifetime -= dt;
if (lifetime <= 0.0) {
m_Deletions.push_back(entity);
}
}
+57
View File
@@ -0,0 +1,57 @@
#include "Game/Systems/PlayerHUD.h"
PlayerHUD::PlayerHUD(World* world, EventBroker* eventBrokerer)
:System(world, eventBrokerer)
, m_World(world)
, m_EventBroker(eventBrokerer)
{
}
PlayerHUD::~PlayerHUD()
{
}
void PlayerHUD::Update(double dt)
{
auto healthHUDs = m_World->GetComponents("HealthHUD");
if (healthHUDs == nullptr) {
return;
}
for (auto& healthHUDComponent : *healthHUDs) {
EntityWrapper entity = EntityWrapper(m_World, healthHUDComponent.EntityID);
EntityWrapper entityIDParent = entity;
while (entityIDParent.Parent().Valid()) {
entityIDParent = entityIDParent.Parent();
if (entityIDParent.HasComponent("Health")) {
break;
}
}
if (entityIDParent.HasComponent("Health")) {
if (entity.HasComponent("Text")) {
std::string s = "";
s = s + std::to_string((int)(double)entityIDParent["Health"]["Health"]);
s = s + "/";
s = s + std::to_string((int)(double)entityIDParent["Health"]["MaxHealth"]);
float healthPercentage = (double)entityIDParent["Health"]["Health"]/(double)entityIDParent["Health"]["MaxHealth"];
(glm::vec4&)entity["Text"]["Color"] = glm::vec4(1.0 - healthPercentage, 0.f, healthPercentage, 1.f);
entity["Text"]["Content"] = s;
}
if(entity.HasComponent("Fill")) {
float healthPercentage = (double)entityIDParent["Health"]["Health"]/(double)entityIDParent["Health"]["MaxHealth"];
(glm::vec4&)entity["Fill"]["Color"] = glm::vec4(1.0 - healthPercentage, 0.f, healthPercentage, 0.f);
(double&)entity["Fill"]["Percentage"] = healthPercentage;
}
}
}
}
+31 -3
View File
@@ -36,15 +36,18 @@ void PlayerMovementSystem::Update(double dt)
glm::vec3& ori = cTransform["Orientation"];
ori.y += controller->Rotation().y;
float playerMovementSpeed = player["Player"]["MovementSpeed"];
float playerCrouchSpeed = player["Player"]["CrouchSpeed"];
if (player.HasComponent("Physics")) {
ComponentWrapper cPhysics = player["Physics"];
glm::vec3 wishDirection = controller->Movement() * glm::inverse(glm::quat(ori));
float wishSpeed;
if (controller->Crouching()) {
wishSpeed = player["Player"]["CrouchSpeed"];
wishSpeed = playerCrouchSpeed;
} else {
wishSpeed = player["Player"]["MovementSpeed"];
wishSpeed = playerMovementSpeed;
}
glm::vec3& velocity = cPhysics["Velocity"];
ImGui::Text("velocity: (%f, %f, %f)", velocity.x, velocity.y, velocity.z);
@@ -85,8 +88,33 @@ void PlayerMovementSystem::Update(double dt)
// size = glm::vec3(1.f, 1.6f, 1.f);
// }
//}
// Animations
EntityWrapper playerModel = player.FirstChildByName("PlayerModel");
if (playerModel.Valid()) {
ComponentWrapper cAnimation = playerModel["Animation"];
float movementLength = glm::length(groundVelocity);
if (glm::length(controller->Movement()) > 0.f) {
if (controller->Crouching()) {
cAnimation["Name"] = "Crouch Walk";
(double&)cAnimation["Speed"] = 1.f * -glm::sign(controller->Movement().z);
} else {
cAnimation["Name"] = "Run";
(double&)cAnimation["Speed"] = 2.f * -glm::sign(controller->Movement().z);
}
} else {
if (controller->Crouching()) {
cAnimation["Name"] = "Crouch";
(double&)cAnimation["Speed"] = 1.f;
} else {
cAnimation["Name"] = "Hold Pos";
(double&)cAnimation["Speed"] = 1.f;
}
}
}
}
controller->Reset();
}
}
+4 -4
View File
@@ -102,10 +102,10 @@ bool PlayerSpawnSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
}
// TODO: Set the player name to whatever
//EntityWrapper playerName = e.Player.FirstChildByName("PlayerName");
//if (playerName.Valid()) {
// playerName["Text"]["Content"] = ???;
//}
EntityWrapper playerName = e.Player.FirstChildByName("PlayerName");
if (playerName.Valid()) {
playerName["Text"]["Content"] = e.PlayerName;
}
return true;
}
+2 -1
View File
@@ -50,7 +50,8 @@ EntityWrapper SpawnerSystem::Spawn(EntityWrapper spawner, EntityWrapper parent /
// Set its position and orientation to that of the SpawnPoint
spawnedEntity["Transform"]["Position"] = Transform::AbsolutePosition(spawnPoint.World, spawnPoint.ID);
spawnedEntity["Transform"]["Orientation"] = glm::eulerAngles(Transform::AbsoluteOrientation(spawnPoint.World, spawnPoint.ID));
// TODO: Quaternions, bitch
//spawnedEntity["Transform"]["Orientation"] = glm::eulerAngles(Transform::AbsoluteOrientation(spawnPoint.World, spawnPoint.ID));
return spawnedEntity;
}
+60 -13
View File
@@ -25,28 +25,75 @@ bool WeaponSystem::OnPlayerSpawned(const Events::PlayerSpawned& e)
bool WeaponSystem::OnInputCommand(const Events::InputCommand& e)
{
// Only shoot client-side!
if (e.PlayerID != -1) {
return false;
}
// Only shoot if the player is alive
if (!m_LocalPlayer.Valid()) {
return false;
}
if (e.Command == "PrimaryFire" && e.Value > 0) {
Events::Shoot eShoot;
eShoot.Player = m_LocalPlayer;
if (e.PlayerID == -1) {
eShoot.Player = m_LocalPlayer;
} else {
eShoot.Player = e.Player;
}
m_EventBroker->Publish(eShoot);
}
return true;
}
bool WeaponSystem::OnShoot(const Events::Shoot& eShoot) {
bool WeaponSystem::OnShoot(Events::Shoot& eShoot)
{
if (!eShoot.Player.Valid()) {
return false;
}
// TODO: Weapon firing effects here
auto rayRed = ResourceManager::Load<EntityFile>("Schema/Entities/RayRed.xml");
auto rayBlue = ResourceManager::Load<EntityFile>("Schema/Entities/RayBlue.xml");
EntityWrapper weapon = eShoot.Player.FirstChildByName("WeaponMuzzle");
if (weapon.Valid()) {
EntityWrapper ray;
if ((ComponentInfo::EnumType)eShoot.Player["Team"]["Team"] == eShoot.Player["Team"]["Team"].Enum("Red")) {
EntityFileParser parser(rayRed);
EntityID rayID = parser.MergeEntities(m_World);
ray = EntityWrapper(m_World, rayID);
} else {
EntityFileParser parser(rayBlue);
EntityID rayID = parser.MergeEntities(m_World);
ray = EntityWrapper(m_World, rayID);
}
glm::mat4 transformation = Transform::AbsoluteTransformation(weapon);
glm::vec3 scale;
glm::vec3 translation;
glm::quat orientation;
glm::vec3 skew;
glm::vec4 perspective;
glm::decompose(transformation, scale, orientation, translation, skew, perspective);
// Matrix to euler angles
glm::vec3 euler;
euler.y = glm::asin(-transformation[0][2]);
if (cos(euler.y) != 0) {
euler.x = atan2(transformation[1][2], transformation[2][2]);
euler.z = atan2(transformation[0][1], transformation[0][0]);
} else {
euler.x = atan2(-transformation[2][0], transformation[1][1]);
euler.z = 0;
}
//LOG_DEBUG("rotation: %f %f %f", euler.x, euler.y, euler.z);
(glm::vec3&)ray["Transform"]["Position"] = translation;
(glm::vec3&)ray["Transform"]["Orientation"] = euler;
//(glm::vec3&)ray["Transform"]["Orientation"] = Transform::AbsoluteOrientationEuler(weapon);
}
// Only run further picking code client-side!
if (eShoot.Player != m_LocalPlayer) {
return false;
}
// Screen center, based on current resolution!
//TODO: check if player has enough ammo and if weapon has a cooldown or not
// TODO: check if player has enough ammo and if weapon has a cooldown or not
Rectangle screenResolution = m_Renderer->Resolution();
glm::vec2 centerScreen = glm::vec2(screenResolution.Width / 2, screenResolution.Height / 2);
+1 -1
View File
@@ -29,7 +29,7 @@ void RayTest(std::string fileName) {
Ray ray(glm::vec3(-50, 0, 0), glm::vec3(1, 0, 0));
//using a
//here, else we have to init the renderingsystem
here, else we have to init the renderingsystem
ResourceManager::RegisterType<RawModel>("RawModel");
auto unitBox = ResourceManager::Load<RawModel>(fileName);
BOOST_REQUIRE(unitBox != nullptr);
+2 -2
View File
@@ -69,8 +69,8 @@ GameHealthSystemTest::GameHealthSystemTest()
m_EventBroker->Publish(e3);
//damage player with 50
Events::PlayerDamage e;
e.Damage = 50.0f;
//e.Player = healthsID;
e.DamageAmount = 50.0f;
e.PlayerDamagedID = healthsID;
m_EventBroker->Publish(e);
//heal some other player with 40
Events::PlayerHealthPickup e2;