Compare commits

...

46 Commits

Author SHA1 Message Date
verysecrethero f147929aa9 Moved the Dash CoolDown (CoolDownTimer) to the component (DashAbility). Fixed 2 warnings 2016-03-01 17:57:18 +01:00
Jace c60e1ba7e4 Merge pull request #144 from teamfisk/RenderSetingsV2
Render settings
2016-03-01 13:49:38 +01:00
Tobias Dahl 63d205f56a Merge pull request #146 from teamfisk/EditorKeyboardFix
Fixed editor keyboard shortcuts getting mixed up with GUI input actions
2016-03-01 13:46:01 +01:00
Jace 36f6ade87a Fixed editor keyboard shortcuts getting mixed up with GUI input actions 2016-03-01 13:38:51 +01:00
Teejoon 724d7b1586 Merge remote-tracking branch 'origin/master' into RenderSetingsV2
Conflicts:
	src/Engine/Rendering/DrawFinalPass.cpp
2016-03-01 12:56:00 +01:00
Teejoon 8cda614de4 Added transparent object that disappeared from the merge 2016-03-01 12:54:01 +01:00
Teejoon 77eaa45702 Merge remote-tracking branch 'origin/master' into HEAD
Conflicts:
	src/Engine/Rendering/CubeMapPass.cpp
	src/Engine/Rendering/DrawFinalPass.cpp
2016-03-01 12:11:27 +01:00
Tobias Dahl dfa224b4dd Merge pull request #142 from teamfisk/Respawning
Added CapturePointGameMode component with RespawnTime
2016-03-01 11:28:56 +01:00
Jace 86df8f14f4 Merge pull request #143 from teamfisk/Transparency-fix
Transparency fix
2016-03-01 11:26:26 +01:00
Tleety eaea645068 Reflectance should now work as an inverse of the specular alpha value. 2016-03-01 11:19:44 +01:00
Tleety 21bf7f4df3 Glow should now legit be working through transparency. 2016-03-01 11:03:16 +01:00
William Moberg e2b7e5400d Check so CapturePointGameMode pool exists and has a size. 2016-03-01 10:20:52 +01:00
William Moberg 658eace093 Added component CapturePointGameMode that contains respawntime. 2016-02-29 18:20:14 +01:00
Joachim Pettersson c106768939 Merge pull request #135 from teamfisk/JumpHeightAdjustment
Player jump speed can be adjusted
2016-02-29 17:37:25 +01:00
William Moberg c7dad79e72 Merge branch 'master' into JumpHeightAdjustment
# Conflicts:
#	resources/Schema/Components.xsd
#	resources/Schema/Entities/Player.xml
#	resources/Schema/Entities/PlayerRed.xml
#	src/Game/Systems/PlayerMovementSystem.cpp
2016-02-29 17:28:40 +01:00
Joachim Pettersson d37f8cc350 Merge pull request #141 from teamfisk/BoxModelCollision
Collision jittering + disappearing weapon
2016-02-29 17:13:34 +01:00
William Moberg 3c35c0a956 Frustum culling octree updates after collisions, no more disappearing weapons. 2016-02-29 15:50:26 +01:00
William Moberg d47a806c64 Made a easy hack to solve jittering when standing still. Jittering should still be present when moving, but at least it is less prominent when moving. 2016-02-29 15:49:23 +01:00
William Moberg 8e21c5a5e4 Reverts last WIP since it probably added code without improving anything.
Revert "WIP, should take shortest resolution even if forced upwards because of slopes, not solving the jittering problem though. + debug code."

This reverts commit db5170c699.
2016-02-29 15:38:36 +01:00
Teejoon df7ace6626 We only uses one depth buffer now 2016-02-29 11:44:29 +01:00
William Moberg db5170c699 WIP, should take shortest resolution even if forced upwards because of slopes, not solving the jittering problem though. + debug code. 2016-02-29 09:37:51 +01:00
Jace bb76c9d248 WIP multi-weapon behaviours 2016-02-29 06:58:57 +01:00
Teejoon 9cbc6f7755 Added GenerateTexture, GenerateMipMapTexture and DeleteTexture to CommonFunctions 2016-02-28 16:16:22 +01:00
Teejoon d3a245606a SSAO and Glow is no longe conflicting with each other.
Texture should get the id = 0 when they are deleted and not assigned a new texture after. Else they will start to conflict with each other.
2016-02-28 15:02:40 +01:00
Teejoon b320d8d1e4 WIP 2016-02-26 18:01:38 +01:00
Teejoon 62e22d3821 Fix 2016-02-26 13:32:16 +01:00
Teejoon 0805375483 Deleted SSAO sliders except Quality 2016-02-26 13:25:19 +01:00
Jace 0c60b637c3 Who's merging without compiling? 2016-02-26 12:52:10 +01:00
William Moberg d411de894f Merge pull request #140 from teamfisk/FixNetworkBugs
Death explosion should always get triggered now.
2016-02-26 12:01:19 +01:00
Teejoon f56705d921 You can now change the quality of SSAO by sliding the SSAO Quality 2016-02-26 11:51:20 +01:00
Jocke 18450ff4f3 Death explosion should always get triggered now. (I hope) 2016-02-26 11:08:05 +01:00
William Moberg 22b473a0b6 Merge pull request #139 from teamfisk/EditorCopyPaste
Editor copy paste
2016-02-26 11:01:18 +01:00
Jace f161fce719 Merge pull request #138 from teamfisk/PlayerAtOriginFix
Teleporting to origin on spawn fixed.
2016-02-25 17:55:03 +01:00
Jace 0343683678 Fixed cubemaps being generated over and over again each frame. 2016-02-25 17:51:40 +01:00
Jace 9e6c67596d Basic editor copy and paste. Doesn't actually copy the entity until you paste it. 2016-02-25 17:51:28 +01:00
William Moberg 89d0d5753f Fix for player teleporting to (0,0,0). Saves player previous position in CollisionSystem instead of Physics component so it won't be saved when editing Players. 2016-02-25 16:16:24 +01:00
Adam Byléhn 748a178801 Merge pull request #136 from teamfisk/FixNetworkBugs
Fix network bugs
2016-02-25 16:09:08 +01:00
Jocke eac9a9daf6 Pull request #136 Merge remote-tracking branch 'origin/master' into FixNetworkBugs
# Conflicts:
#	src/Engine/Network/Client.cpp
2016-02-25 16:07:06 +01:00
Jocke 059fe5c6c0 Fixed typo m_EPDoubleJump to m_EDoubleJump. 2016-02-25 16:04:27 +01:00
Joachim Pettersson fb465ede81 Merge pull request #134 from teamfisk/HUDDesync
Good job! 👍
2016-02-25 15:53:07 +01:00
Jocke f66fa7a183 Merge remote-tracking branch 'origin/master' into FixNetworkBugs
# Conflicts:
#	include/Engine/Network/Client.h
#	include/Engine/Network/MessageType.h
#	include/Engine/Network/Server.h
#	include/Engine/Network/TCPServer.h
#	src/Engine/Network/Client.cpp
#	src/Engine/Network/TCPServer.cpp
2016-02-25 15:13:11 +01:00
Jocke 508d8a6f00 Fixed memory leak in TCPServer::AcceptNewConnections caused by acceptor->async_accept().
Fixed some formating and comments.
2016-02-25 14:24:38 +01:00
William Moberg cd315bbaa0 Added DoubleJump component and JumpSpeed in Player component so jumpheight can be adjusted for regular jump and double jump. 2016-02-25 12:12:44 +01:00
stiffly 8ce6308649 In snapshot: now sends player information and also CP information. Now it is no longer true that they will arrive in pre order. Appropriate actions were therefor implemented. 2016-02-25 11:56:40 +01:00
stiffly f10958c268 Capturepoint logic is now purely done on the serverside. 2016-02-25 11:50:29 +01:00
Jocke fa13c1d065 Double jump is now working. 2016-02-23 18:24:46 +01:00
94 changed files with 2203 additions and 1072 deletions
@@ -24,6 +24,7 @@ public:
private: private:
Octree<EntityAABB>* m_Octree; Octree<EntityAABB>* m_Octree;
std::vector<EntityAABB> m_OctreeResult; std::vector<EntityAABB> m_OctreeResult;
std::unordered_map<EntityWrapper, glm::vec3> m_PrevPositions;
}; };
#endif #endif
+6
View File
@@ -29,16 +29,22 @@ struct EntityWrapper
EntityWrapper Parent(); EntityWrapper Parent();
EntityWrapper FirstChildByName(const std::string& name); EntityWrapper FirstChildByName(const std::string& name);
EntityWrapper FirstParentWithComponent(const std::string& componentType); EntityWrapper FirstParentWithComponent(const std::string& componentType);
EntityWrapper Clone(EntityWrapper parent = EntityWrapper::Invalid);
std::vector<EntityWrapper> ChildrenWithComponent(const std::string& componentType);
void DeleteChildren();
bool IsChildOf(EntityWrapper potentialParent); bool IsChildOf(EntityWrapper potentialParent);
bool Valid() const; bool Valid() const;
ComponentWrapper operator[](const char* componentName); ComponentWrapper operator[](const char* componentName);
ComponentWrapper operator[](const std::string& componentName);
bool operator==(const EntityWrapper& e) const; bool operator==(const EntityWrapper& e) const;
bool operator!=(const EntityWrapper& e) const; bool operator!=(const EntityWrapper& e) const;
explicit operator EntityID() const; explicit operator EntityID() const;
private: private:
EntityWrapper firstChildByNameRecursive(const std::string& name, EntityID parent); EntityWrapper firstChildByNameRecursive(const std::string& name, EntityID parent);
EntityWrapper cloneRecursive(EntityWrapper entity, EntityWrapper parent);
void childrenWithComponentRecursive(const std::string& componentType, EntityWrapper& entity, std::vector<EntityWrapper>& childrenWithComponent);
}; };
namespace std namespace std
+1 -1
View File
@@ -68,7 +68,7 @@ protected:
const std::string m_ComponentType; const std::string m_ComponentType;
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cPlayer, double dt) = 0; virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt) = 0;
}; };
class ImpureSystem : public virtual System class ImpureSystem : public virtual System
+1 -1
View File
@@ -40,7 +40,7 @@ public:
// Change the parent of an entity // Change the parent of an entity
void SetParent(EntityID entity, EntityID parent); void SetParent(EntityID entity, EntityID parent);
// Get children of an entity // Get children of an entity
const std::pair<std::unordered_multimap<EntityID, EntityID>::const_iterator, std::unordered_multimap<EntityID, EntityID>::const_iterator> GetChildren(EntityID entity); const std::pair<std::unordered_multimap<EntityID, EntityID>::const_iterator, std::unordered_multimap<EntityID, EntityID>::const_iterator> GetDirectChildren(EntityID entity);
// Get all component pools // Get all component pools
const std::unordered_map<std::string, ComponentPool*>& GetComponentPools() const { return m_ComponentPools; } const std::unordered_map<std::string, ComponentPool*>& GetComponentPools() const { return m_ComponentPools; }
// Get the entity children map // Get the entity children map
+8
View File
@@ -73,6 +73,12 @@ public:
// Called when the user means to rename an entity. // Called when the user means to rename an entity.
typedef std::function<void(EntityWrapper, const std::string&)> OnEntityChangeName_t; typedef std::function<void(EntityWrapper, const std::string&)> OnEntityChangeName_t;
void SetEntityChangeNameCallback(OnEntityChangeName_t f) { m_OnEntityChangeName = f; } void SetEntityChangeNameCallback(OnEntityChangeName_t f) { m_OnEntityChangeName = f; }
// Called when the user pastes an entity previously "copied"
// @param EntityWrapper The entity to copy
// @param EntityWrapper The entity to parent the new copy to
// @return The new copy of the entity
typedef std::function<EntityWrapper(EntityWrapper, EntityWrapper)> OnEntityPaste_t;
void SetEntityPasteCallback(OnEntityPaste_t f) { m_OnEntityPaste = f; }
// Called when the user means to attach a new component to an entity. // Called when the user means to attach a new component to an entity.
typedef std::function<void(EntityWrapper, const std::string&)> OnComponentAttach_t; typedef std::function<void(EntityWrapper, const std::string&)> OnComponentAttach_t;
void SetComponentAttachCallback(OnComponentAttach_t f) { m_OnComponentAttach = f; } void SetComponentAttachCallback(OnComponentAttach_t f) { m_OnComponentAttach = f; }
@@ -111,6 +117,7 @@ private:
std::string m_DroppedFile = ""; std::string m_DroppedFile = "";
bool m_Paused = false; bool m_Paused = false;
bool m_MouseLocked = false; bool m_MouseLocked = false;
EntityWrapper m_CopyTarget = EntityWrapper::Invalid;
// Callbacks // Callbacks
OnEntitySelectedCallback_t m_OnEntitySelected = nullptr; OnEntitySelectedCallback_t m_OnEntitySelected = nullptr;
@@ -124,6 +131,7 @@ private:
OnComponentDelete_t m_OnComponentDelete = nullptr; OnComponentDelete_t m_OnComponentDelete = nullptr;
OnWidgetMode_t m_OnWidgetMode = nullptr; OnWidgetMode_t m_OnWidgetMode = nullptr;
OnWidgetSpace_t m_OnWidgetSpace = nullptr; OnWidgetSpace_t m_OnWidgetSpace = nullptr;
OnEntityPaste_t m_OnEntityPaste = nullptr;
// Events // Events
EventRelay<EditorGUI, Events::KeyDown> m_EKeyDown; EventRelay<EditorGUI, Events::KeyDown> m_EKeyDown;
+1
View File
@@ -56,6 +56,7 @@ private:
void OnEntityDelete(EntityWrapper entity); void OnEntityDelete(EntityWrapper entity);
void OnEntityChangeParent(EntityWrapper entity, EntityWrapper parent); void OnEntityChangeParent(EntityWrapper entity, EntityWrapper parent);
void OnEntityChangeName(EntityWrapper entity, const std::string& name); void OnEntityChangeName(EntityWrapper entity, const std::string& name);
EntityWrapper OnEntityPaste(EntityWrapper entityToCopy, EntityWrapper parent);
void OnComponentAttach(EntityWrapper entity, const std::string& componentType); void OnComponentAttach(EntityWrapper entity, const std::string& componentType);
void OnComponentDelete(EntityWrapper entity, const std::string& componentType); void OnComponentDelete(EntityWrapper entity, const std::string& componentType);
void OnWidgetSpace(EditorGUI::WidgetSpace widgetSpace); void OnWidgetSpace(EditorGUI::WidgetSpace widgetSpace);
@@ -27,7 +27,7 @@ public:
virtual bool OnCommand(const Events::InputCommand& e) override; virtual bool OnCommand(const Events::InputCommand& e) override;
virtual void Reset(); virtual void Reset();
void AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer); void AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer, double& assaultDashCoolDownTimer);
virtual bool AssaultDashDoubleTapped() const { return m_AssaultDashDoubleTapped; } virtual bool AssaultDashDoubleTapped() const { return m_AssaultDashDoubleTapped; }
virtual bool PlayerIsDashing() const { return m_PlayerIsDashing; } virtual bool PlayerIsDashing() const { return m_PlayerIsDashing; }
@@ -41,7 +41,6 @@ protected:
bool m_Crouching = false; bool m_Crouching = false;
//assault dash membervariables - needed to calculate the doubletap- and dashlogic //assault dash membervariables - needed to calculate the doubletap- and dashlogic
double m_AssaultDashDoubleTapDeltaTime = 0.0; double m_AssaultDashDoubleTapDeltaTime = 0.0;
double m_AssaultDashCoolDownTimer = 0.0;
//i will let m_AssaultDashDoubleTapSensitivityTimer stay hardcoded, its not really a gamevariable (more an inputvariable), //i will let m_AssaultDashDoubleTapSensitivityTimer stay hardcoded, its not really a gamevariable (more an inputvariable),
//and its very unlikely that someone wants to change that value //and its very unlikely that someone wants to change that value
const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f; const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f;
@@ -191,21 +190,21 @@ bool FirstPersonInputController<EventContext>::OnLockMouse(const Events::LockMou
} }
template <typename EventContext> template <typename EventContext>
void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer) { void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer, double& assaultDashCoolDownTimer) {
m_AssaultDashDoubleTapDeltaTime += dt; m_AssaultDashDoubleTapDeltaTime += dt;
m_AssaultDashCoolDownTimer -= dt; assaultDashCoolDownTimer -= dt;
//cooldown = assaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work) //cooldown = assaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work)
if (m_AssaultDashCoolDownTimer > (assaultDashCoolDownMaxTimer - 0.25f)) { if (assaultDashCoolDownTimer > (assaultDashCoolDownMaxTimer - 0.25f)) {
m_PlayerIsDashing = true; m_PlayerIsDashing = true;
} else { } else {
m_PlayerIsDashing = false; m_PlayerIsDashing = false;
} }
//dashing with shift //dashing with shift
if (m_ShiftDashing && m_AssaultDashCoolDownTimer <= 0.0f) { if (m_ShiftDashing && assaultDashCoolDownTimer <= 0.0f) {
//player is dashing with shift //player is dashing with shift
//the wanted-direction is set in playermovement already so we dont need to check what direction we want to dash in! //the wanted-direction is set in playermovement already so we dont need to check what direction we want to dash in!
m_AssaultDashCoolDownTimer = assaultDashCoolDownMaxTimer; assaultDashCoolDownTimer = assaultDashCoolDownMaxTimer;
m_AssaultDashDoubleTapped = true; m_AssaultDashDoubleTapped = true;
m_AssaultDashDoubleTapDeltaTime = 0.f; m_AssaultDashDoubleTapDeltaTime = 0.f;
return; return;
@@ -227,7 +226,7 @@ void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool
} }
m_ValidDoubleTap = false; m_ValidDoubleTap = false;
if (!(m_AssaultDashCoolDownTimer <= 0.0f)) { if (!(assaultDashCoolDownTimer <= 0.0f)) {
//if we cant dash at the moment, then just reset the tap-sensitivity-timer //if we cant dash at the moment, then just reset the tap-sensitivity-timer
m_AssaultDashDoubleTapDeltaTime = 0.f; m_AssaultDashDoubleTapDeltaTime = 0.f;
return; return;
@@ -235,7 +234,7 @@ void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool
//ok, we have a valid tap, lets do it //ok, we have a valid tap, lets do it
m_AssaultDashDoubleTapped = true; m_AssaultDashDoubleTapped = true;
m_AssaultDashDoubleTapDeltaTime = 0.f; m_AssaultDashDoubleTapDeltaTime = 0.f;
m_AssaultDashCoolDownTimer = assaultDashCoolDownMaxTimer; assaultDashCoolDownTimer = assaultDashCoolDownMaxTimer;
Events::DashAbility e; Events::DashAbility e;
m_EventBroker->Publish(e); m_EventBroker->Publish(e);
+8 -5
View File
@@ -19,8 +19,10 @@
#include "Core/World.h" #include "Core/World.h"
#include "Core/EventBroker.h" #include "Core/EventBroker.h"
#include "Core/ConfigFile.h" #include "Core/ConfigFile.h"
#include "Core/EPlayerDeath.h"
#include "Input/EInputCommand.h" #include "Input/EInputCommand.h"
#include "Core/EPlayerDamage.h" #include "Core/EPlayerDamage.h"
#include "../Game/Events/EDoubleJump.h"
#include "Network/EInterpolate.h" #include "Network/EInterpolate.h"
#include "Network/SnapshotFilter.h" #include "Network/SnapshotFilter.h"
#include "Core/EPlayerSpawned.h" #include "Core/EPlayerSpawned.h"
@@ -47,7 +49,9 @@ public:
void Connect(std::string address, int port); void Connect(std::string address, int port);
void Update() override; void Update() override;
private:
UDPClient m_Unreliable;
TCPClient m_Reliable;
std::vector<Events::PlayerSpawned> m_PlayerSpawnEvents; std::vector<Events::PlayerSpawned> m_PlayerSpawnEvents;
void parseSpawnEvents(); void parseSpawnEvents();
// Save for children // Save for children
@@ -101,9 +105,9 @@ public:
void parseEntityDeletion(Packet& packet); void parseEntityDeletion(Packet& packet);
void parsePlayerDamage(Packet& packet); void parsePlayerDamage(Packet& packet);
void parseComponentDeletion(Packet& packet); void parseComponentDeletion(Packet& packet);
void parseDoubleJump(Packet& packet);
void InterpolateFields(Packet & packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType); void InterpolateFields(Packet & packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType);
void parseSnapshot(Packet& packet); void parseSnapshot(Packet& packet);
void UpdateLocalCapturePointHUD(EntityWrapper capturePointHUD);
void identifyPacketLoss(); void identifyPacketLoss();
void hasServerTimedOut(); void hasServerTimedOut();
EntityID createPlayer(); EntityID createPlayer();
@@ -127,11 +131,10 @@ public:
EventRelay<Client, Events::PlayerSpawned> m_EPlayerSpawned; EventRelay<Client, Events::PlayerSpawned> m_EPlayerSpawned;
bool OnPlayerSpawned(const Events::PlayerSpawned& e); bool OnPlayerSpawned(const Events::PlayerSpawned& e);
EventRelay< Client, Events::SearchForServers> m_ESearchForServers; EventRelay< Client, Events::SearchForServers> m_ESearchForServers;
EventRelay<Client, Events::DoubleJump> m_EDoubleJump;
bool OnDoubleJump(Events::DoubleJump & e);
bool OnSearchForServers(const Events::SearchForServers& e); bool OnSearchForServers(const Events::SearchForServers& e);
private:
UDPClient m_Unreliable;
UDPClient m_ServerlistRequest; UDPClient m_ServerlistRequest;
TCPClient m_Reliable;
std::vector<ServerInfo> m_Serverlist; std::vector<ServerInfo> m_Serverlist;
bool m_SearchingForServers = false; bool m_SearchingForServers = false;
std::clock_t m_StartSearchTime; std::clock_t m_StartSearchTime;
+1
View File
@@ -19,6 +19,7 @@ enum class MessageType
EntityDeleted, EntityDeleted,
ComponentDeleted, ComponentDeleted,
PlayerTransform, PlayerTransform,
OnDoubleJump,
ServerlistRequest, ServerlistRequest,
Invalid Invalid
}; };
+4 -3
View File
@@ -8,7 +8,6 @@
#include "Network/TCPServer.h" #include "Network/TCPServer.h"
#include "Network/UDPServer.h" #include "Network/UDPServer.h"
#include "Network/UDPClient.h" //LOL
#include "Network/MessageType.h" #include "Network/MessageType.h"
#include "Network/PlayerDefinition.h" #include "Network/PlayerDefinition.h"
#include "Core/World.h" #include "Core/World.h"
@@ -18,6 +17,7 @@
#include "Core/EPlayerDamage.h" #include "Core/EPlayerDamage.h"
#include "Network/EPlayerDisconnected.h" #include "Network/EPlayerDisconnected.h"
#include "Core/EPlayerSpawned.h" #include "Core/EPlayerSpawned.h"
#include "../Game/Events/EDoubleJump.h"
#include "Core/EEntityDeleted.h" #include "Core/EEntityDeleted.h"
#include "Core/EComponentDeleted.h" #include "Core/EComponentDeleted.h"
@@ -81,8 +81,9 @@ private:
void parseOnInputCommand(Packet& packet); void parseOnInputCommand(Packet& packet);
void parseClientPing(); void parseClientPing();
void parsePing(); void parsePing();
void parseUDPConnect(Packet & packet); bool parseDoubleJump(Packet& packet);
void parseTCPConnect(Packet & packet); void parseUDPConnect(Packet& packet);
void parseTCPConnect(Packet& packet);
void parseDisconnect(); void parseDisconnect();
void parseServerlistRequest(boost::asio::ip::udp::endpoint endpoint); void parseServerlistRequest(boost::asio::ip::udp::endpoint endpoint);
bool shouldSendToClient(EntityWrapper childEntity); bool shouldSendToClient(EntityWrapper childEntity);
+2 -3
View File
@@ -25,10 +25,9 @@ private:
std::unique_ptr<boost::asio::ip::tcp::acceptor> acceptor; std::unique_ptr<boost::asio::ip::tcp::acceptor> acceptor;
boost::shared_ptr<boost::asio::ip::tcp::socket> lastReceivedSocket; boost::shared_ptr<boost::asio::ip::tcp::socket> lastReceivedSocket;
void handle_accept(boost::shared_ptr<boost::asio::ip::tcp::socket> socket,
int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers,
const boost::system::error_code& error);
int readBuffer(PlayerDefinition& playerDefinition); int readBuffer(PlayerDefinition& playerDefinition);
PlayerID getPlayerIDFromEndpoint(const std::map<PlayerID, PlayerDefinition>& connectedPlayers,
boost::asio::ip::address address, unsigned short port);
int GetPort(); int GetPort();
std::string GetAddress(); std::string GetAddress();
int m_Port = 0; int m_Port = 0;
+15 -8
View File
@@ -12,7 +12,7 @@
class DrawBloomPass class DrawBloomPass
{ {
public: public:
DrawBloomPass(IRenderer* renderer /* ,Texture or finalpass*/ ); DrawBloomPass(IRenderer* renderer, ConfigFile* config);
~DrawBloomPass() { } ~DrawBloomPass() { }
void InitializeTextures(); void InitializeTextures();
void InitializeFrameBuffers(); void InitializeFrameBuffers();
@@ -23,26 +23,33 @@ public:
void FillGaussianBuffer(FrameBuffer* fb); void FillGaussianBuffer(FrameBuffer* fb);
void Draw(GLuint texture); void Draw(GLuint texture);
void ChangeQuality(int quality);
void OnWindowResize(); void OnWindowResize();
//Getters //Getters
//Return the blurred result of the texture that was sent into draw //Return the blurred result of the texture that was sent into draw
GLuint GaussianTexture() const { return m_GaussianTexture_vert; } GLuint GaussianTexture() const {
if (m_Quality == 0) {
return m_BlackTexture->m_Texture;
} else {
return m_GaussianTexture_vert;
}
}
private: private:
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const; Texture* m_BlackTexture;
Texture* m_WhiteTexture;
Model* m_ScreenQuad; Model* m_ScreenQuad;
const IRenderer* m_Renderer; const IRenderer* m_Renderer;
ConfigFile* m_Config;
//const LightCullingPass* m_LightCullingPass //const LightCullingPass* m_LightCullingPass
GLuint m_iterations = 9; int m_Iterations;
int m_Quality = 0;
GLuint m_GaussianTexture_horiz; GLuint m_GaussianTexture_horiz = 0;
GLuint m_GaussianTexture_vert; GLuint m_GaussianTexture_vert = 0;
FrameBuffer m_GaussianFrameBuffer_horiz; FrameBuffer m_GaussianFrameBuffer_horiz;
FrameBuffer m_GaussianFrameBuffer_vert; FrameBuffer m_GaussianFrameBuffer_vert;
+6 -7
View File
@@ -5,6 +5,7 @@
#include "DrawFinalPassState.h" #include "DrawFinalPassState.h"
#include "LightCullingPass.h" #include "LightCullingPass.h"
#include "CubeMapPass.h" #include "CubeMapPass.h"
#include "SSAOPass.h"
#include "FrameBuffer.h" #include "FrameBuffer.h"
#include "ShaderProgram.h" #include "ShaderProgram.h"
#include "Util/UnorderedMapVec2.h" #include "Util/UnorderedMapVec2.h"
@@ -14,12 +15,12 @@
class DrawFinalPass class DrawFinalPass
{ {
public: public:
DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass); DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass, GLuint* depthBuffer);
~DrawFinalPass() { } ~DrawFinalPass() { }
void InitializeTextures(); void InitializeTextures();
void InitializeFrameBuffers(); void InitializeFrameBuffers();
void InitializeShaderPrograms(); void InitializeShaderPrograms();
void Draw(RenderScene& scene, GLuint SSAOTexture); void Draw(RenderScene& scene);
void ClearBuffer(); void ClearBuffer();
void OnWindowResize(); void OnWindowResize();
@@ -34,11 +35,8 @@ public:
FrameBuffer* FinalPassFrameBufferLowRes() { return &m_FinalPassFrameBufferLowRes; } FrameBuffer* FinalPassFrameBufferLowRes() { return &m_FinalPassFrameBufferLowRes; }
private: 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 DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, RenderScene& scene); void DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, RenderScene& scene);
void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene, GLuint SSAOTexture); void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
void DrawShieldToStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene); void DrawShieldToStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
void DrawShieldedModelRenderQueue(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene); void DrawShieldedModelRenderQueue(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
void DrawToDepthBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene); void DrawToDepthBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
@@ -61,7 +59,7 @@ private:
GLuint m_SceneTexture; GLuint m_SceneTexture;
GLuint m_BloomTextureLowRes; GLuint m_BloomTextureLowRes;
GLuint m_SceneTextureLowRes; GLuint m_SceneTextureLowRes;
GLuint m_DepthBuffer; GLuint* m_DepthBuffer;
GLuint m_DepthBufferLowRes; GLuint m_DepthBufferLowRes;
GLuint m_CubeMapTexture; GLuint m_CubeMapTexture;
@@ -71,6 +69,7 @@ private:
const IRenderer* m_Renderer; const IRenderer* m_Renderer;
const LightCullingPass* m_LightCullingPass; const LightCullingPass* m_LightCullingPass;
const CubeMapPass* m_CubeMapPass; const CubeMapPass* m_CubeMapPass;
const SSAOPass* m_SSAOPass;
ShaderProgram* m_ForwardPlusProgram; ShaderProgram* m_ForwardPlusProgram;
ShaderProgram* m_ExplosionEffectProgram; ShaderProgram* m_ExplosionEffectProgram;
+2
View File
@@ -5,11 +5,13 @@
#include "../OpenGL.h" #include "../OpenGL.h"
#include "../GLM.h" #include "../GLM.h"
#include "../Core/Util/Rectangle.h" #include "../Core/Util/Rectangle.h"
#include "../Core/ConfigFile.h"
#include "Util/ScreenCoords.h" #include "Util/ScreenCoords.h"
#include "Camera.h" #include "Camera.h"
#include "RenderQueue.h" #include "RenderQueue.h"
#include "Model.h" #include "Model.h"
#include "../Core/World.h" //So temp #include "../Core/World.h" //So temp
#include "Util/CommonFunctions.h"
struct PickData struct PickData
+1 -3
View File
@@ -28,15 +28,13 @@ public:
const ShaderProgram& PickingProgram() const { return *m_PickingProgram; } const ShaderProgram& PickingProgram() const { return *m_PickingProgram; }
//const std::unordered_map<glm::ivec2, EntityID>& PickingColorsToEntity() const { return m_PickingColorsToEntity; } //const std::unordered_map<glm::ivec2, EntityID>& PickingColorsToEntity() const { return m_PickingColorsToEntity; }
GLuint PickingTexture() const { return m_PickingTexture; } GLuint PickingTexture() const { return m_PickingTexture; }
GLuint DepthBuffer() const { return m_DepthBuffer; } GLuint* DepthBuffer() { return &m_DepthBuffer; }
const FrameBuffer& PickingBuffer() const { return m_PickingBuffer; } const FrameBuffer& PickingBuffer() const { return m_PickingBuffer; }
PickData Pick(glm::vec2 screenCoord); PickData Pick(glm::vec2 screenCoord);
private: private:
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
EventBroker* m_EventBroker; EventBroker* m_EventBroker;
const IRenderer* m_Renderer; const IRenderer* m_Renderer;
+2
View File
@@ -24,6 +24,8 @@ public:
bool StencilFunc(GLenum func, GLint ref, GLuint mask); bool StencilFunc(GLenum func, GLint ref, GLuint mask);
bool StencilMask(GLuint mask); bool StencilMask(GLuint mask);
bool DepthMask(GLboolean flag); bool DepthMask(GLboolean flag);
bool DepthFunc(GLenum func);
bool AlphaFunc(GLenum func, GLclampf thresholder);
private: private:
std::vector<std::function<void(void)>> m_ResetFunctions; std::vector<std::function<void(void)>> m_ResetFunctions;
+6 -8
View File
@@ -32,8 +32,9 @@ class Renderer : public IRenderer
static void glfwFrameBufferCallback(GLFWwindow* window, int width, int height); static void glfwFrameBufferCallback(GLFWwindow* window, int width, int height);
public: public:
Renderer(EventBroker* eventBroker) Renderer(EventBroker* eventBroker, ConfigFile* config)
: m_EventBroker(eventBroker) : m_EventBroker(eventBroker)
, m_Config(config)
{ } { }
virtual void Initialize() override; virtual void Initialize() override;
@@ -47,6 +48,7 @@ private:
//----------------------Variables----------------------// //----------------------Variables----------------------//
static std::unordered_map <GLFWwindow*, Renderer*> m_WindowToRenderer; static std::unordered_map <GLFWwindow*, Renderer*> m_WindowToRenderer;
ConfigFile* m_Config;
EventBroker* m_EventBroker; EventBroker* m_EventBroker;
TextPass* m_TextPass; TextPass* m_TextPass;
@@ -61,12 +63,8 @@ private:
int m_DebugTextureToDraw = 0; int m_DebugTextureToDraw = 0;
int m_CubeMapTexture = 0; int m_CubeMapTexture = 0;
bool m_ResizeWindow = false; bool m_ResizeWindow = false;
float m_SSAO_Radius = 1.0f; int m_SSAO_Quality = 0;
float m_SSAO_Bias = 0.05f; int m_GLOW_Quality = 2;
float m_SSAO_Contrast = 1.5f;
float m_SSAO_IntensityScale = 1.0f;
int m_SSAO_NumOfSamples = 24;
int m_SSAO_NumOfTurns = 7;
PickingPass* m_PickingPass; PickingPass* m_PickingPass;
LightCullingPass* m_LightCullingPass; LightCullingPass* m_LightCullingPass;
+36 -12
View File
@@ -13,18 +13,32 @@
class SSAOPass class SSAOPass
{ {
public: public:
SSAOPass(IRenderer* rendere); SSAOPass(IRenderer* renderer, ConfigFile* config);
~SSAOPass() { ~SSAOPass() { };
delete m_DrawBloomPass;
}; void ChangeQuality(int quality);
void Draw(GLuint depthBuffer, Camera* camera); void Draw(GLuint depthBuffer, Camera* camera);
void Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int NumOfTurns); void Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int numOfTurns, int iterations, int quality);
void ClearBuffer(); void ClearBuffer();
void OnWindowResize(); void OnWindowResize();
//Return the SSAO of the texture sent to Draw //Return the SSAO of the texture sent to Draw
GLuint SSAOTexture() const { return m_DrawBloomPass->GaussianTexture(); } GLuint SSAOTexture() const {
if (m_Quality == 0) {
return m_WhiteTexture->m_Texture;
} else {
return m_Gaussian_vert;
}
}
int TextureQuality() const {
if (m_Quality == 0) {
return 13;
} else {
return m_TextureQuality;
}
}
private: private:
void InitializeTexture(); void InitializeTexture();
@@ -32,14 +46,13 @@ private:
void InitializeShaderProgram(); void InitializeShaderProgram();
void InitializeBuffer(); void InitializeBuffer();
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
//void blurHorizontal(GLuint depthBuffer); //void blurHorizontal(GLuint depthBuffer);
//void blurVertical(GLuint depthBuffer); //void blurVertical(GLuint depthBuffer);
Model* m_ScreenQuad; Model* m_ScreenQuad;
const IRenderer* m_Renderer; const IRenderer* m_Renderer;
ConfigFile* m_Config;
float m_Radius; float m_Radius;
float m_Bias; float m_Bias;
@@ -47,17 +60,28 @@ private:
float m_IntensityScale; float m_IntensityScale;
int m_NumOfSamples; int m_NumOfSamples;
int m_NumOfTurns; int m_NumOfTurns;
int m_Iterations;
int m_TextureQuality;
int m_Quality = 0;
GLuint m_SSAOTexture; Texture* m_WhiteTexture;
GLuint m_SSAOTexture = 0;
FrameBuffer m_SSAOFramBuffer; FrameBuffer m_SSAOFramBuffer;
GLuint m_SSAOViewSpaceZTexture; GLuint m_SSAOViewSpaceZTexture = 0;
FrameBuffer m_SSAOViewSpaceZFramBuffer; FrameBuffer m_SSAOViewSpaceZFramBuffer;
GLuint m_Gaussian_horiz = 0;
GLuint m_Gaussian_vert = 0;
FrameBuffer m_GaussianFrameBuffer_horiz;
FrameBuffer m_GaussianFrameBuffer_vert;
ShaderProgram* m_SSAOProgram; ShaderProgram* m_SSAOProgram;
ShaderProgram* m_SSAOViewSpaceZProgram; ShaderProgram* m_SSAOViewSpaceZProgram;
ShaderProgram* m_GaussianProgram_horiz;
DrawBloomPass* m_DrawBloomPass; ShaderProgram* m_GaussianProgram_vert;
}; };
#endif #endif
@@ -9,6 +9,10 @@
namespace CommonFunctions namespace CommonFunctions
{ {
Texture* LoadTexture(std::string path, bool threaded); Texture* LoadTexture(std::string path, bool threaded);
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type);
void GenerateMultiSampleTexture(GLuint* texture, int numSamples, glm::vec2 dimensions, GLint internalFormat);
void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps);
void DeleteTexture(GLuint* texture);
}; };
#endif #endif
+1 -1
View File
@@ -8,7 +8,7 @@ namespace Events
struct DoubleJump : public Event struct DoubleJump : public Event
{ {
EntityID entityID;
}; };
} }
@@ -34,9 +34,13 @@ private:
glm::vec3 m_LastPosition = glm::vec3(); glm::vec3 m_LastPosition = glm::vec3();
// The logic for making the sound play when player is moving // The logic for making the sound play when player is moving
void playerStep(double dt); void playerStep(double dt);
// Spawn a hexagon at origin of an Entity
void spawnHexagon(EntityWrapper target);
EventRelay<PlayerMovementSystem, Events::PlayerSpawned> m_EPlayerSpawned; EventRelay<PlayerMovementSystem, Events::PlayerSpawned> m_EPlayerSpawned;
bool OnPlayerSpawned(Events::PlayerSpawned& e); bool OnPlayerSpawned(Events::PlayerSpawned& e);
EventRelay<PlayerMovementSystem, Events::DoubleJump> m_EDoubleJump;
bool PlayerMovementSystem::OnDoubleJump(Events::DoubleJump & e);
void updateMovementControllers(double dt); void updateMovementControllers(double dt);
void updateVelocity(EntityWrapper player, double dt); void updateVelocity(EntityWrapper player, double dt);
+2 -4
View File
@@ -13,8 +13,6 @@ public:
PlayerSpawnSystem(SystemParams params); PlayerSpawnSystem(SystemParams params);
virtual void Update(double dt) override; virtual void Update(double dt) override;
static void SetRespawnTime(float respawnTime) { m_RespawnTime = respawnTime; };
private: private:
struct SpawnRequest struct SpawnRequest
@@ -31,8 +29,8 @@ private:
//EntityWrapper ID -> Player ID. //EntityWrapper ID -> Player ID.
std::map<EntityID, int> m_PlayerIDs; std::map<EntityID, int> m_PlayerIDs;
static float m_RespawnTime; float m_ForcedRespawnTime;
float m_Timer; bool m_DbgConfigForceRespawn;
EventRelay<PlayerSpawnSystem, Events::InputCommand> m_OnInputCommand; EventRelay<PlayerSpawnSystem, Events::InputCommand> m_OnInputCommand;
bool OnInputCommand(Events::InputCommand& e); bool OnInputCommand(Events::InputCommand& e);
@@ -1,37 +1,33 @@
#ifndef AssaultWeaponBehaviour_h__
#define AssaultWeaponBehaviour_h__
#include "Sound/EPlaySoundOnEntity.h" #include "Sound/EPlaySoundOnEntity.h"
#include "Collision/Collision.h" #include "Collision/Collision.h"
#include "Rendering/AnimationSystem.h"
#include "Core/ConfigFile.h" #include "Core/ConfigFile.h"
#include "WeaponBehaviour.h" #include "WeaponBehaviour.h"
#include "../SpawnerSystem.h" #include "../SpawnerSystem.h"
#include "Core/EPlayerDamage.h" #include "Core/EPlayerDamage.h"
#include "Core/EShoot.h" #include "Core/EShoot.h"
class AssaultWeaponBehaviour : public WeaponBehaviour<AssaultWeaponBehaviour>
class AssaultWeaponBehaviour : public WeaponBehaviour
{ {
public: public:
AssaultWeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree<EntityAABB>* collisionOctree, EntityWrapper weaponEntity); AssaultWeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree<EntityAABB>* collisionOctree)
: WeaponBehaviour(systemParams, "AssaultWeapon", renderer, collisionOctree)
virtual void Fire() override; { }
virtual void CeaseFire() override;
virtual void Reload() override;
virtual void Update(double dt) override; protected:
virtual void OnPrimaryFire(WeaponInfo& wi) override;
virtual void OnCeasePrimaryFire(WeaponInfo& wi) override;
virtual void OnReload(WeaponInfo& wi) override;
private: private:
EntityWrapper m_FirstPersonModel;
EntityWrapper m_ThirdPersonModel;
// State // State
bool m_Firing = false; bool m_Firing = false;
bool m_Reloading = false; bool m_Reloading = false;
double m_ReloadTimer = 0.0; double m_ReloadTimer = 0.0;
EntityWrapper m_FirstPersonReloadImpersonator;
EntityWrapper m_ThirdPersonReloadImpersonator;
double m_TimeSinceLastFire = 0.0; double m_TimeSinceLastFire = 0.0;
EntityWrapper m_FirstPersonReloadImpostor;
EventRelay<WeaponBehaviour, Events::AnimationComplete> m_EAnimationComplete;
bool OnAnimationComplete(Events::AnimationComplete& e);
bool hasAmmo(); bool hasAmmo();
void fireRound(); void fireRound();
@@ -47,3 +43,5 @@ private:
bool shoot(double damage); bool shoot(double damage);
void showHitMarker(); void showHitMarker();
}; };
#endif
@@ -0,0 +1,38 @@
#include "WeaponBehaviour.h"
#include "Collision/Collision.h"
#include "Core/EPlayerDamage.h"
#include "Rendering/ESetCamera.h"
class DefenderWeaponBehaviour : public WeaponBehaviour<DefenderWeaponBehaviour>
{
public:
DefenderWeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree<EntityAABB>* collisionOctree)
: System(systemParams)
, WeaponBehaviour(systemParams, "DefenderWeapon", renderer, collisionOctree)
, m_RandomEngine(m_RandomDevice())
{
EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &DefenderWeaponBehaviour::OnSetCamera);
}
void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cWeapon, double dt) override;
void UpdateWeapon(WeaponInfo& wi, double dt) override;
void OnPrimaryFire(WeaponInfo& wi) override;
void OnCeasePrimaryFire(WeaponInfo& wi) override;
bool OnInputCommand(WeaponInfo& wi, const Events::InputCommand& e) override;
private:
std::random_device m_RandomDevice;
std::mt19937 m_RandomEngine;
EntityWrapper m_CurrentCamera;
EventRelay<DefenderWeaponBehaviour, Events::SetCamera> m_ESetCamera;
bool OnSetCamera(const Events::SetCamera& e);
// Weapon functions
void fireShell(WeaponInfo& wi);
void dealDamage(WeaponInfo& wi, glm::vec3 direction, double damage);
// Utility
float traceRayDistance(glm::vec3 origin, glm::vec3 direction);
Camera cameraFromEntity(EntityWrapper camera);
};
+160 -13
View File
@@ -5,30 +5,177 @@
#include "Rendering/IRenderer.h" #include "Rendering/IRenderer.h"
#include "Core/Octree.h" #include "Core/Octree.h"
#include "Collision/EntityAABB.h" #include "Collision/EntityAABB.h"
#include "Input/EInputCommand.h"
#include "Systems/SpawnerSystem.h"
class WeaponBehaviour : public System template <typename ETYPE>
class WeaponBehaviour : public PureSystem
{ {
friend class WeaponSystem;
public: public:
WeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree<EntityAABB>* collisionOctree, EntityWrapper player) WeaponBehaviour(SystemParams params, std::string componentType, IRenderer* renderer, Octree<EntityAABB>* collisionOctree)
: System(systemParams) : System(params)
, PureSystem(componentType)
, m_Renderer(renderer) , m_Renderer(renderer)
, m_CollisionOctree(collisionOctree) , m_CollisionOctree(collisionOctree)
, m_Player(player) {
{ } EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &WeaponBehaviour::_OnInputCommand)
}
virtual ~WeaponBehaviour() = default; virtual ~WeaponBehaviour() = default;
WeaponBehaviour(const WeaponBehaviour&) = delete; virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt) override
WeaponBehaviour& operator=(const WeaponBehaviour &) = delete; {
auto weapon = getActiveWeapon(entity);
virtual void Fire() = 0; if (!weapon) {
virtual void CeaseFire() { } return;
virtual void Reload() { } } else {
virtual void Update(double dt) { } UpdateWeapon(*weapon, dt);
}
}
protected: protected:
struct WeaponInfo
{
std::string WeaponComponent;
EntityWrapper Player;
EntityWrapper WeaponEntity;
EntityWrapper FirstPersonEntity;
EntityWrapper ThirdPersonEntity;
ComponentWrapper GetComponent() { return WeaponEntity[WeaponComponent]; }
};
IRenderer* m_Renderer; IRenderer* m_Renderer;
Octree<EntityAABB>* m_CollisionOctree; Octree<EntityAABB>* m_CollisionOctree;
EntityWrapper m_Player; std::unordered_map<EntityWrapper, WeaponInfo> m_ActiveWeapons;
virtual void UpdateWeapon(WeaponInfo& wi, double dt) { }
virtual void OnPrimaryFire(WeaponInfo& wi) { }
virtual void OnCeasePrimaryFire(WeaponInfo& wi) { }
virtual void OnReload(WeaponInfo& wi) { }
virtual bool OnInputCommand(WeaponInfo& wi, const Events::InputCommand& e) { return false; }
private:
EventRelay<ETYPE, Events::InputCommand> m_EInputCommand;
bool _OnInputCommand(const Events::InputCommand& e)
{
EntityWrapper player = e.Player;
if (e.PlayerID == -1) {
player = LocalPlayer;
}
// Make sure the player is alive
if (!player.Valid()) {
return false;
}
// Make sure the player has this weapon
auto weapon = getWeaponComponent(player);
if (!weapon) {
return false;
}
// Weapon selection
if (e.Command == "SelectWeapon") {
if (static_cast<ComponentInfo::EnumType>(e.Value) == static_cast<ComponentInfo::EnumType>((*weapon)["Slot"])) {
selectWeapon(player);
}
}
// Only handle weapon actions if the weapon is active
auto activeWeapon = getActiveWeapon(player);
if (!activeWeapon) {
return false;
}
// Fire
if (e.Command == "PrimaryFire") {
if (e.Value > 0) {
OnPrimaryFire(*activeWeapon);
} else {
OnCeasePrimaryFire(*activeWeapon);
}
}
// Reload
if (e.Command == "Reload" && e.Value != 0) {
OnReload(*activeWeapon);
}
return OnInputCommand(*activeWeapon, e);
}
boost::optional<ComponentWrapper> getWeaponComponent(EntityWrapper player)
{
if (!player.HasComponent(m_ComponentType)) {
return boost::none;
}
return player[m_ComponentType];
}
boost::optional<WeaponInfo&> getActiveWeapon(EntityWrapper player)
{
auto it = m_ActiveWeapons.find(player);
if (it == m_ActiveWeapons.end()) {
return boost::none;
}
WeaponInfo& activeWeapon = it->second;
if (!activeWeapon.FirstPersonEntity.Valid() && !activeWeapon.ThirdPersonEntity.Valid()) {
return boost::none;
}
return activeWeapon;
}
void selectWeapon(EntityWrapper player)
{
// Find the weapon attachments matching the weapon type
std::vector<EntityWrapper> weaponAttachments = player.ChildrenWithComponent("WeaponAttachment");
EntityWrapper firstPersonAttachment;
EntityWrapper thirdPersonAttachment;
for (auto& attachment : weaponAttachments) {
ComponentWrapper cWeaponAttachment = attachment["WeaponAttachment"];
if ((std::string&)cWeaponAttachment["Weapon"] == m_ComponentType) {
ComponentWrapper::SubscriptProxy person = cWeaponAttachment["Person"];
if ((ComponentInfo::EnumType)person == person.Enum("FirstPerson")) {
firstPersonAttachment = attachment;
} else if ((ComponentInfo::EnumType)person == person.Enum("ThirdPerson")) {
thirdPersonAttachment = attachment;
}
}
}
if (!firstPersonAttachment.Valid() && !thirdPersonAttachment.Valid()) {
LOG_WARNING("No weapon attachment found for %s of player #%i", m_ComponentType.c_str(), player.ID);
return;
}
// Purge other weapon entities
for (auto& attachment : weaponAttachments) {
//if (attachment == firstPersonAttachment || attachment == thirdPersonAttachment) {
// continue;
//}
attachment.DeleteChildren();
}
// Spawn the weapon(s)
EntityWrapper firstPersonWeapon;
EntityWrapper thirdPersonWeapon;
if (firstPersonAttachment.Valid()) {
firstPersonWeapon = SpawnerSystem::Spawn(firstPersonAttachment, firstPersonAttachment);
}
if (thirdPersonAttachment.Valid()) {
thirdPersonWeapon = SpawnerSystem::Spawn(thirdPersonAttachment, thirdPersonAttachment);
}
m_ActiveWeapons[player].WeaponComponent = m_ComponentType;
m_ActiveWeapons[player].Player = player;
m_ActiveWeapons[player].WeaponEntity = player;
m_ActiveWeapons[player].FirstPersonEntity = firstPersonWeapon;
m_ActiveWeapons[player].ThirdPersonEntity = thirdPersonWeapon;
}
}; };
#endif #endif
+34 -1
View File
@@ -36,4 +36,37 @@ ResourceLoading=true
[Sound] [Sound]
BGMVolume=1.0 BGMVolume=1.0
SFXVolume=1.0 SFXVolume=1.0
Announcer=female Announcer=female
[SSAO]
Quality=0
[SSAO1]
Radius=1.0
Bias=0.02
Contrast=1.5
Intensity=1.0
NumSamples=8
NumTurns=3
NumIterations=5
TextureQuality=2
[SSAO2]
Radius=1.0
Bias=0.02
Contrast=1.5
Intensity=1.0
NumSamples=16
NumTurns=13
NumIterations=9
TextureQuality=1
[SSAO3]
Radius=1.0
Bias=0.02
Contrast=1.5
Intensity=1.0
NumSamples=24
NumTurns=17
NumIterations=13
TextureQuality=0
+4
View File
@@ -46,4 +46,8 @@
<xs:include schemaLocation="Components/Page.xsd"/> <xs:include schemaLocation="Components/Page.xsd"/>
<xs:include schemaLocation="Components/SpriteIndicator.xsd"/> <xs:include schemaLocation="Components/SpriteIndicator.xsd"/>
<xs:include schemaLocation="Components/Button.xsd"/> <xs:include schemaLocation="Components/Button.xsd"/>
<xs:include schemaLocation="Components/DoubleJump.xsd"/>
<xs:include schemaLocation="Components/WeaponAttachment.xsd"/>
<xs:include schemaLocation="Components/DefenderWeapon.xsd"/>
<xs:include schemaLocation="Components/CapturePointGameMode.xsd"/>
</xs:schema> </xs:schema>
@@ -8,4 +8,5 @@
<RPM>120</RPM> <RPM>120</RPM>
<ViewPunch>0.01</ViewPunch> <ViewPunch>0.01</ViewPunch>
<ReloadTime>2</ReloadTime> <ReloadTime>2</ReloadTime>
<Slot><Primary/></Slot>
</AssaultWeapon> </AssaultWeapon>
@@ -2,6 +2,7 @@
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types"> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
<xs:import schemaLocation="../Types.xsd" namespace="types"/> <xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:include schemaLocation="../Types/WeaponSlotEnum.xsd"/>
<xs:element name="AssaultWeapon"> <xs:element name="AssaultWeapon">
<xs:complexType> <xs:complexType>
@@ -28,6 +29,7 @@
<xs:element name="ReloadTime" type="t:double" minOccurs="0"> <xs:element name="ReloadTime" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>Time it takes to reload the weapon in seconds</xs:documentation></xs:annotation> <xs:annotation><xs:documentation>Time it takes to reload the weapon in seconds</xs:documentation></xs:annotation>
</xs:element> </xs:element>
<xs:element name="Slot" type="WeaponSlotEnum" minOccurs="0"/>
</xs:all> </xs:all>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<CapturePointGameMode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="CapturePointGameMode.xsd">
<RespawnTime>0.0</RespawnTime>
<MaxRespawnTime>8.0</MaxRespawnTime>
</CapturePointGameMode>
@@ -0,0 +1,18 @@
<?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="CapturePointGameMode">
<xs:complexType>
<xs:all>
<xs:element name="RespawnTime" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>The time since the last respawn wave. Players will be spawned when this reaches MaxRespawnTime.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="MaxRespawnTime" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>Players will be spawned when RespawnTime reaches this.</xs:documentation></xs:annotation>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<DashAbility xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="DashAbility.xsd"> <DashAbility xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="DashAbility.xsd">
<CoolDownMaxTimer>2.0</CoolDownMaxTimer> <CoolDownMaxTimer>2.0</CoolDownMaxTimer>
<CoolDownTimer>0.0</CoolDownTimer>
</DashAbility> </DashAbility>
+4 -1
View File
@@ -10,7 +10,10 @@
<xs:complexType> <xs:complexType>
<xs:all> <xs:all>
<xs:element name="CoolDownMaxTimer" type="t:double" minOccurs="0"> <xs:element name="CoolDownMaxTimer" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>This is the cooldown on dash</xs:documentation></xs:annotation> <xs:annotation><xs:documentation>This is the max cooldown on dash</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="CoolDownTimer" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>This is the current cooldown on dash</xs:documentation></xs:annotation>
</xs:element> </xs:element>
</xs:all> </xs:all>
</xs:complexType> </xs:complexType>
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<DefenderWeapon xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="DefenderWeapon.xsd">
<MagazineAmmo>8</MagazineAmmo>
<MagazineSize>8</MagazineSize>
<Ammo>64</Ammo>
<MaxAmmo>64</MaxAmmo>
<BaseDamage>90</BaseDamage>
<SpreadAngle>0.174533</SpreadAngle> <!-- 0.174533 = 10 degrees -->
<NumPellets>10</NumPellets>
<RPM>120</RPM>
<ViewPunch>0.01</ViewPunch>
<ReloadTime>0.5</ReloadTime>
<Slot><Primary/></Slot>
<IsFiring>false</IsFiring>
<TimeSinceLastFire>0</TimeSinceLastFire>
</DefenderWeapon>
+44
View File
@@ -0,0 +1,44 @@
<?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:include schemaLocation="../Types/WeaponSlotEnum.xsd"/>
<xs:element name="DefenderWeapon">
<xs:complexType>
<xs:all>
<xs:element name="MagazineAmmo" type="t:int" minOccurs="0">
<xs:annotation><xs:documentation>Ammo currently loaded into the magazine</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="MagazineSize" type="t:int" minOccurs="0">
<xs:annotation><xs:documentation>Max number of rounds in a magazine</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="Ammo" type="t:int" minOccurs="0">
<xs:annotation><xs:documentation>Current ammo carried</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="MaxAmmo" type="t:int" minOccurs="0">
<xs:annotation><xs:documentation>Maximum ammo able to be carried</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="BaseDamage" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>Damage dealt if all shotgun pellets hit</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="SpreadAngle" type="t:float" minOccurs="0">
<xs:annotation><xs:documentation>Spread angle in radians</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="NumPellets" type="t:int" minOccurs="0"/>
<xs:element name="RPM" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>Rate of fire in rounds per minute</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="ViewPunch" type="t:float" minOccurs="0">
<xs:annotation><xs:documentation>View punch in radians for each shell fired</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="ReloadTime" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>Time it takes to load ONE SHELL into the weapon in seconds</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="Slot" type="WeaponSlotEnum" minOccurs="0"/>
<xs:element name="IsFiring" type="t:bool" minOccurs="0"/>
<xs:element name="TimeSinceLastFire" type="t:double" minOccurs="0"/>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<DoubleJump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="DoubleJump.xsd">
<DoubleJumpSpeed>4.0</DoubleJumpSpeed>
</DoubleJump>
@@ -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="DoubleJump">
<xs:annotation><xs:documentation>Enables a Player to double jump.</xs:documentation></xs:annotation>
<xs:complexType>
<xs:all>
<xs:element name="DoubleJumpSpeed" type="t:float" minOccurs="0">
<xs:annotation><xs:documentation>Vertical velocity set on double jump.</xs:documentation></xs:annotation>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
-1
View File
@@ -2,7 +2,6 @@
<Physics xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Physics.xsd"> <Physics xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Physics.xsd">
<Velocity X="0" Y="0" Z="0"/> <Velocity X="0" Y="0" Z="0"/>
<Gravity>true</Gravity> <Gravity>true</Gravity>
<PrevOrigin X="-9876.5" Y="-9876.5" Z="-9876.5"/>
<IsOnGround>false</IsOnGround> <IsOnGround>false</IsOnGround>
<VerticalStepHeight>0.33</VerticalStepHeight> <VerticalStepHeight>0.33</VerticalStepHeight>
</Physics> </Physics>
-1
View File
@@ -13,7 +13,6 @@
<xs:annotation><xs:documentation>m/s^2</xs:documentation></xs:annotation> <xs:annotation><xs:documentation>m/s^2</xs:documentation></xs:annotation>
</xs:element> </xs:element>
<xs:element name="Gravity" type="t:bool" minOccurs="0"/> <xs:element name="Gravity" type="t:bool" minOccurs="0"/>
<xs:element name="PrevOrigin" type="t:Vector" minOccurs="0"/>
<xs:element name="IsOnGround" type="t:bool" minOccurs="0"/> <xs:element name="IsOnGround" type="t:bool" minOccurs="0"/>
<xs:element name="VerticalStepHeight" type="t:double" minOccurs="0"> <xs:element name="VerticalStepHeight" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>The largest height of a "stair-step" that can be walked over</xs:documentation></xs:annotation> <xs:annotation><xs:documentation>The largest height of a "stair-step" that can be walked over</xs:documentation></xs:annotation>
+2
View File
@@ -2,5 +2,7 @@
<Player xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Player.xsd"> <Player xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Player.xsd">
<MovementSpeed>3</MovementSpeed> <MovementSpeed>3</MovementSpeed>
<CrouchSpeed>1.5</CrouchSpeed> <CrouchSpeed>1.5</CrouchSpeed>
<JumpSpeed>4.0</JumpSpeed>
<CurrentWishDirection X="0" Y="0" Z="0"/> <CurrentWishDirection X="0" Y="0" Z="0"/>
<CurrentWeapon></CurrentWeapon>
</Player> </Player>
+4
View File
@@ -11,7 +11,11 @@
<xs:all> <xs:all>
<xs:element name="MovementSpeed" type="t:float" minOccurs="0"/> <xs:element name="MovementSpeed" type="t:float" minOccurs="0"/>
<xs:element name="CrouchSpeed" type="t:float" minOccurs="0"/> <xs:element name="CrouchSpeed" type="t:float" minOccurs="0"/>
<xs:element name="JumpSpeed" type="t:float" minOccurs="0">
<xs:annotation><xs:documentation>Vertical velocity set when jumping.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="CurrentWishDirection" type="t:Vector" minOccurs="0"/> <xs:element name="CurrentWishDirection" type="t:Vector" minOccurs="0"/>
<xs:element name="CurrentWeapon" type="t:string" minOccurs="0"/>
</xs:all> </xs:all>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
-3
View File
@@ -1,3 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Trigger xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Trigger.xsd">
</Trigger>
-17
View File
@@ -1,17 +0,0 @@
<?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="Weapon">
<xs:complexType>
<xs:all>
<xs:element name="MagSize" type="t:int" minOccurs="0"/>
<xs:element name="MaxAmmo" type="t:int" minOccurs="0"/>
<xs:element name="CurrentAmmoInMag" type="t:int" minOccurs="0"/>
<xs:element name="CurrentAmmo" type="t:int" minOccurs="0"/>
<xs:element name="RPM" type="t:double" minOccurs="0"/>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<WeaponAttachment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="WeaponAttachment.xsd">
<Weapon></Weapon>
<Person><FirstPerson/></Person>
</WeaponAttachment>
@@ -0,0 +1,28 @@
<?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:complexType name="PersonEnum" mixed="true">
<xs:complexContent>
<xs:extension base="t:enum">
<xs:choice>
<xs:element name="FirstPerson" type="t:int" fixed="0" minOccurs="0"/>
<xs:element name="ThirdPerson" type="t:int" fixed="1" minOccurs="0"/>
</xs:choice>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="WeaponAttachment">
<xs:annotation><xs:documentation>Combine with a spawner to define a weapon attachment point</xs:documentation></xs:annotation>
<xs:complexType>
<xs:all>
<xs:element name="Weapon" type="t:string" minOccurs="0">
<xs:annotation><xs:documentation>The weapon component type this attachment refers to</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="Person" type="PersonEnum" minOccurs="0"/>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
+99
View File
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity name="WeaponModel" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:BoneAttachment>
<BoneName>R_Arm_Weapon_Joint</BoneName>
</c:BoneAttachment>
<c:Model>
<Resource>Models/Weapons/Blue/AssaultWeaponBlue.mesh</Resource>
</c:Model>
<c:Transform>
<Position X="0.12043038" Y="-0.244988307" Z="-0.181454808"/>
<Orientation X="0.010404544" Y="-0.00268173823" Z="0.0428441577"/>
</c:Transform>
</Components>
<Children>
<Entity name="WeaponMuzzle">
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/RayBlue.xml</EntityFile>
</c:Spawner>
<c:Transform>
<Position X="0.00325386273" Y="0.0970000029" Z="-0.843000054"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="FirstPersonReloadSpawner">
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/ReloadEffectView.xml</EntityFile>
</c:Spawner>
<c:Transform/>
</Components>
<Children/>
</Entity>
<Entity name="AmmunitionHUD">
<Components>
<c:AmmunitionHUD/>
<c:Transform>
<Position X="-0.0430000015" Y="0.131501317" Z="-0.0670000017"/>
<Scale X="0.400000006" Y="0.400000006" Z="0.400000006"/>
</c:Transform>
</Components>
<Children>
<Entity name="AmmunitionHUDBackground">
<Components>
<c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<Color A="0.588235319" B="0" G="0" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="-0.00200000009"/>
<Scale X="0.119999997" Y="0.119999997" Z="0.119999997"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="AmmunitionText">
<Components>
<c:Transform/>
</Components>
<Children>
<Entity name="MagazineAmmo">
<Components>
<c:Text>
<Content>32</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Color A="1" B="3.92156863" G="1.17647064" R="0"/>
</c:Text>
<c:Transform>
<Scale X="0.0599999987" Y="0.0599999987" Z="0.0599999987"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="Ammo">
<Components>
<c:Text>
<Content>360</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Color A="1" B="3.92156863" G="1.17647064" R="0"/>
</c:Text>
<c:Transform>
<Position X="5.2833886e-05" Y="-0.0407950208" Z="0"/>
<Scale X="0.0399999991" Y="0.0399999991" Z="0.0399999991"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
+40
View File
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity name="ThirdPersonWeaponModel" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:BoneAttachment>
<BoneName>R_Arm_Weapon_Joint</BoneName>
</c:BoneAttachment>
<c:Model>
<Resource>Models/Weapons/Blue/AssaultWeaponBlue.mesh</Resource>
</c:Model>
<c:Transform>
<Position X="0.163429111" Y="1.0235405" Z="-0.215489209"/>
<Orientation X="-0.0631071255" Y="-0.0576644838" Z="0.118255548"/>
</c:Transform>
</Components>
<Children>
<Entity name="WeaponMuzzle">
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/RayBlue.xml</EntityFile>
</c:Spawner>
<c:Transform>
<Position X="0.00644115033" Y="0.096679531" Z="-0.436609417"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="ThirdPersonReloadSpawner">
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/ReloadEffectWorld.xml</EntityFile>
</c:Spawner>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
+40
View File
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity name="Shield" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Transform/>
</Components>
<Children>
<Entity name="Shield">
<Components>
<c:Model>
<Resource>Models/Core/UnitPlane.mesh</Resource>
</c:Model>
<c:Shield/>
<c:Transform>
<Scale X="1.11800003" Y="0.0320000015" Z="1.9180001"/>
<Orientation X="-1.57079995" Y="0" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="VisibleSide">
<Components>
<c:Shielded/>
<c:Model>
<Resource>Models/Core/UnitHexagon.mesh</Resource>
<Color A="0" B="1" G="0" R="0"/>
<Transparent>true</Transparent>
</c:Model>
<c:Transform>
<Position X="0" Y="0" Z="0.0179871861"/>
<Scale X="1.01900005" Y="0.0120000001" Z="1.91000009"/>
<Orientation X="-1.57079995" Y="0" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
+99
View File
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity name="WeaponModel" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:BoneAttachment>
<BoneName>R_Arm_Weapon_Joint</BoneName>
<PositionOffset X="0" Y="0.0480000004" Z="-0.183000013"/>
</c:BoneAttachment>
<c:Model>
<Resource>Models/Weapons/Blue/DefenderGunBlue.mesh</Resource>
</c:Model>
<c:Transform>
<Position X="0.120430306" Y="0.775375426" Z="1.36542225"/>
</c:Transform>
</Components>
<Children>
<Entity name="WeaponMuzzle">
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/RayBlue.xml</EntityFile>
</c:Spawner>
<c:Transform>
<Position X="0.00191565475" Y="0.0324025005" Z="-0.2021029"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="FirstPersonReloadSpawner">
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/ReloadEffectView.xml</EntityFile>
</c:Spawner>
<c:Transform/>
</Components>
<Children/>
</Entity>
<Entity name="AmmunitionHUD">
<Components>
<c:AmmunitionHUD/>
<c:Transform>
<Position X="-0.0490000024" Y="0.0520000011" Z="-0.063000001"/>
<Scale X="0.400000006" Y="0.400000006" Z="0.400000006"/>
</c:Transform>
</Components>
<Children>
<Entity name="AmmunitionHUDBackground">
<Components>
<c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<Color A="0.588235319" B="0" G="0" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="-0.00200000009"/>
<Scale X="0.119999997" Y="0.119999997" Z="0.119999997"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="AmmunitionText">
<Components>
<c:Transform/>
</Components>
<Children>
<Entity name="MagazineAmmo">
<Components>
<c:Text>
<Content>32</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Color A="1" B="3.92156863" G="1.17647064" R="0"/>
</c:Text>
<c:Transform>
<Scale X="0.0599999987" Y="0.0599999987" Z="0.0599999987"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="Ammo">
<Components>
<c:Text>
<Content>360</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Color A="1" B="3.92156863" G="1.17647064" R="0"/>
</c:Text>
<c:Transform>
<Position X="5.2833886e-05" Y="-0.0407950208" Z="0"/>
<Scale X="0.0399999991" Y="0.0399999991" Z="0.0399999991"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
+99
View File
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity name="WeaponModel" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:BoneAttachment>
<BoneName>R_Arm_Weapon_Joint</BoneName>
<PositionOffset X="0" Y="0.0480000004" Z="-0.183000013"/>
</c:BoneAttachment>
<c:Model>
<Resource>Models/Weapons/Red/DefenderGunRed.mesh</Resource>
</c:Model>
<c:Transform>
<Position X="0.120430306" Y="0.775375426" Z="1.36542225"/>
</c:Transform>
</Components>
<Children>
<Entity name="WeaponMuzzle">
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/RayRed.xml</EntityFile>
</c:Spawner>
<c:Transform>
<Position X="0.00191565475" Y="0.0324025005" Z="-0.2021029"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="FirstPersonReloadSpawner">
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/ReloadEffectView.xml</EntityFile>
</c:Spawner>
<c:Transform/>
</Components>
<Children/>
</Entity>
<Entity name="AmmunitionHUD">
<Components>
<c:AmmunitionHUD/>
<c:Transform>
<Position X="-0.0490000024" Y="0.0520000011" Z="-0.063000001"/>
<Scale X="0.400000006" Y="0.400000006" Z="0.400000006"/>
</c:Transform>
</Components>
<Children>
<Entity name="AmmunitionHUDBackground">
<Components>
<c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<Color A="0.588235319" B="0" G="0" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="-0.00200000009"/>
<Scale X="0.119999997" Y="0.119999997" Z="0.119999997"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="AmmunitionText">
<Components>
<c:Transform/>
</Components>
<Children>
<Entity name="MagazineAmmo">
<Components>
<c:Text>
<Content>32</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Color A="1" B="3.92156863" G="1.17647064" R="0"/>
</c:Text>
<c:Transform>
<Scale X="0.0599999987" Y="0.0599999987" Z="0.0599999987"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="Ammo">
<Components>
<c:Text>
<Content>360</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Color A="1" B="3.92156863" G="1.17647064" R="0"/>
</c:Text>
<c:Transform>
<Position X="5.2833886e-05" Y="-0.0407950208" Z="0"/>
<Scale X="0.0399999991" Y="0.0399999991" Z="0.0399999991"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
+41
View File
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity name="ThirdPersonWeaponModel" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:BoneAttachment>
<BoneName>R_Arm_Weapon_Joint</BoneName>
<PositionOffset X="0" Y="0.0320000015" Z="-0.165000007"/>
</c:BoneAttachment>
<c:Model>
<Resource>Models/Weapons/Blue/DefenderGunBlue.mesh</Resource>
</c:Model>
<c:Transform>
<Position X="0.162026152" Y="1.05794585" Z="-0.380744517"/>
<Orientation X="-0.0628969446" Y="-0.0509683639" Z="0.118739031"/>
</c:Transform>
</Components>
<Children>
<Entity name="WeaponMuzzle">
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/RayBlue.xml</EntityFile>
</c:Spawner>
<c:Transform>
<Position X="0.000284185546" Y="0.0318552479" Z="-0.193328083"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="ThirdPersonReloadSpawner">
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/ReloadEffectWorld.xml</EntityFile>
</c:Spawner>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
+41
View File
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity name="ThirdPersonWeaponModel" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:BoneAttachment>
<BoneName>R_Arm_Weapon_Joint</BoneName>
<PositionOffset X="0" Y="0.0320000015" Z="-0.165000007"/>
</c:BoneAttachment>
<c:Model>
<Resource>Models/Weapons/Red/DefenderGunRed.mesh</Resource>
</c:Model>
<c:Transform>
<Position X="0.162026152" Y="1.05794585" Z="-0.380744517"/>
<Orientation X="-0.0628969446" Y="-0.0509683639" Z="0.118739031"/>
</c:Transform>
</Components>
<Children>
<Entity name="WeaponMuzzle">
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/RayRed.xml</EntityFile>
</c:Spawner>
<c:Transform>
<Position X="0.000284185546" Y="0.0318552479" Z="-0.193328083"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="ThirdPersonReloadSpawner">
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/ReloadEffectWorld.xml</EntityFile>
</c:Spawner>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
+1 -252
View File
@@ -10,7 +10,7 @@
<Components> <Components>
<c:PlayerSpawn/> <c:PlayerSpawn/>
<c:Spawner> <c:Spawner>
<EntityFile>Schema/Entities/Player.xml</EntityFile> <EntityFile>Schema/Entities/PlayerRed.xml</EntityFile>
</c:Spawner> </c:Spawner>
<c:Team> <c:Team>
<Team> <Team>
@@ -118,257 +118,6 @@
</Entity> </Entity>
</Children> </Children>
</Entity> </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:AssaultWeapon>
<RPM>600</RPM>
</c:AssaultWeapon>
<c:Collidable/>
<c:DashAbility/>
<c:Health/>
<c:Physics>
<Velocity X="2.30999646e-23" Y="0" Z="1.05272533e-23"/>
</c:Physics>
<c:Player>
<MovementSpeed>5</MovementSpeed>
</c:Player>
<c:Team>
<Team>
<Red/>
</Team>
</c:Team>
<c:Transform>
<Position X="0" Y="0.0288832653" Z="2.64837074"/>
</c:Transform>
</Components>
<Children>
<Entity name="Camera">
<Components>
<c:Camera/>
<c:Transform>
<Position X="0" Y="1.27700007" 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"/>
</c:Text>
<c:Transform>
<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>
</Components>
<Children/>
</Entity>
<Entity name="CameraModel">
<Components>
<c:Model>
<Resource>Models/Widgets/Camera.mesh</Resource>
<Visible>false</Visible>
</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>
<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:Sprite>
<DiffuseTexture>Textures/Weapons/Crosshair/SmallThickHoleDot.png</DiffuseTexture>
<DepthSort>false</DepthSort>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="0.200000003"/>
<Scale X="0.0250000004" Y="0.0250000004" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="Hands">
<Components>
<c:Animation>
<AnimationName1>Idle</AnimationName1>
<Time1>1.9569972344146196</Time1>
<Speed1>1</Speed1>
</c:Animation>
<c:Model>
<Resource>Models/Characters/Assault/FirstPerson.mesh</Resource>
<Transparent>true</Transparent>
</c:Model>
<c:Transform/>
</Components>
<Children>
<Entity name="WeaponModel">
<Components>
<c:BoneAttachment>
<BoneName>R_Arm_Weapon_Joint</BoneName>
</c:BoneAttachment>
<c:Model>
<Resource>Models/Weapons/Blue/AssaultWeaponBlue.mesh</Resource>
<Transparent>true</Transparent>
</c:Model>
<c:Transform>
<Position X="0.120748013" Y="-0.228470564" Z="-0.151475638"/>
<Orientation X="0.010404693" Y="-0.00268176314" Z="0.0428441502"/>
</c:Transform>
</Components>
<Children>
<Entity name="WeaponMuzzle">
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/RayBlue.xml</EntityFile>
</c:Spawner>
<c:Transform>
<Position X="0.00325386273" Y="0.0970000029" Z="-0.843000054"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="FirstPersonReloadSpawner">
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/WeaponReloadEffect.xml</EntityFile>
</c:Spawner>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
<Entity name="ThirdPersonCamera">
<Components>
<c:Camera/>
<c:Model>
<Resource>Models/Widgets/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:Animation>
<AnimationName1>Idle</AnimationName1>
<Time1>1.8055945618467364</Time1>
<Speed1>1</Speed1>
</c:Animation>
<c:AnimationOffset>
<AnimationName>AimRifle</AnimationName>
<Time>0.5</Time>
</c:AnimationOffset>
<c:HiddenForLocalPlayer/>
<c:Model>
<Resource>Models/Characters/Assault/AssaultAnimations.mesh</Resource>
<Color A="1" B="0" G="0" R="1"/>
</c:Model>
<c:Transform/>
</Components>
<Children>
<Entity name="ThirdPersonWeaponModel">
<Components>
<c:BoneAttachment>
<BoneName>R_Arm_Weapon_Joint</BoneName>
</c:BoneAttachment>
<c:Model>
<Resource>Models/Weapons/Blue/AssaultWeaponBlue.mesh</Resource>
<Visible>false</Visible>
</c:Model>
<c:Transform>
<Position X="0.158578917" Y="1.02878916" Z="-0.215411991"/>
<Orientation X="-0.0626687407" Y="-0.0361274257" Z="0.120101407"/>
</c:Transform>
</Components>
<Children>
<Entity name="ThirdPersonWeaponMuzzle">
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/RayBlue.xml</EntityFile>
</c:Spawner>
<c:Transform>
<Position X="0.00644115033" Y="0.096679531" Z="-0.436609417"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</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> </Children>
</Entity> </Entity>
+74 -132
View File
@@ -7,24 +7,31 @@
<Size X="1" Y="1.60000002" Z="1"/> <Size X="1" Y="1.60000002" Z="1"/>
</c:AABB> </c:AABB>
<c:AssaultWeapon> <c:AssaultWeapon>
<RPM>600</RPM> <Slot>
<Secondary/>
</Slot>
</c:AssaultWeapon> </c:AssaultWeapon>
<c:Collidable/> <c:Collidable/>
<c:DashAbility/> <c:DefenderWeapon>
<TimeSinceLastFire>1.6944730461160304</TimeSinceLastFire>
</c:DefenderWeapon>
<c:DoubleJump/>
<c:Health/> <c:Health/>
<c:Physics> <c:Physics>
<PrevOrigin X="0" Y="0.772000015" Z="0"/>
<Velocity X="2.30999646e-23" Y="0" Z="1.05272533e-23"/> <Velocity X="2.30999646e-23" Y="0" Z="1.05272533e-23"/>
</c:Physics> </c:Physics>
<c:Player> <c:Player>
<MovementSpeed>5</MovementSpeed> <MovementSpeed>5</MovementSpeed>
<CurrentWeapon></CurrentWeapon>
</c:Player> </c:Player>
<c:Team> <c:Team>
<Team> <Team>
<Blue/> <Blue/>
</Team> </Team>
</c:Team> </c:Team>
<c:Transform/> <c:Transform>
<Position X="-1.42731023" Y="0.0288832653" Z="3.63052702"/>
</c:Transform>
</Components> </Components>
<Children> <Children>
@@ -304,7 +311,8 @@
</Children> </Children>
</Entity> </Entity>
</Children> </Children>
</Entity> <Entity name="KillFeed"> </Entity>
<Entity name="KillFeed">
<Components> <Components>
<c:KillFeed/> <c:KillFeed/>
<c:Transform> <c:Transform>
@@ -364,7 +372,7 @@
<Components> <Components>
<c:Animation> <c:Animation>
<AnimationName1>Idle</AnimationName1> <AnimationName1>Idle</AnimationName1>
<Time1>0.97725610639912475</Time1> <Time1>0.67172915251515519</Time1>
<Speed1>1</Speed1> <Speed1>1</Speed1>
<AnimationName2></AnimationName2> <AnimationName2></AnimationName2>
<AnimationName3></AnimationName3> <AnimationName3></AnimationName3>
@@ -376,100 +384,29 @@
<c:Transform/> <c:Transform/>
</Components> </Components>
<Children> <Children>
<Entity name="WeaponModel"> <Entity name="PrimaryAttachment">
<Components> <Components>
<c:BoneAttachment> <c:Spawner>
<BoneName>R_Arm_Weapon_Joint</BoneName> <EntityFile>Schema/Entities/DefenderWeaponView.xml</EntityFile>
</c:BoneAttachment> </c:Spawner>
<c:Model> <c:Transform/>
<Resource>Models/Weapons/Blue/AssaultWeaponBlue.mesh</Resource> <c:WeaponAttachment>
</c:Model> <Weapon>DefenderWeapon</Weapon>
<c:Transform> </c:WeaponAttachment>
<Position X="0.12043038" Y="-0.244988307" Z="-0.181454808"/>
<Orientation X="0.010404544" Y="-0.00268173823" Z="0.0428441577"/>
</c:Transform>
</Components> </Components>
<Children> <Children/>
<Entity name="WeaponMuzzle"> </Entity>
<Components> <Entity name="SecondaryAttachment">
<c:Spawner> <Components>
<EntityFile>Schema/Entities/RayBlue.xml</EntityFile> <c:Spawner>
</c:Spawner> <EntityFile>Schema/Entities/AssaultWeaponView.xml</EntityFile>
<c:Transform> </c:Spawner>
<Position X="0.00325386273" Y="0.0970000029" Z="-0.843000054"/> <c:Transform/>
</c:Transform> <c:WeaponAttachment>
</Components> <Weapon>AssaultWeapon</Weapon>
<Children/> </c:WeaponAttachment>
</Entity> </Components>
<Entity name="FirstPersonReloadSpawner"> <Children/>
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/ReloadEffectView.xml</EntityFile>
</c:Spawner>
<c:Transform/>
</Components>
<Children/>
</Entity>
<Entity name="AmmunitionHUD">
<Components>
<c:AmmunitionHUD/>
<c:Transform>
<Position X="-0.0430000015" Y="0.131501317" Z="-0.0670000017"/>
<Scale X="0.400000006" Y="0.400000006" Z="0.400000006"/>
</c:Transform>
</Components>
<Children>
<Entity name="AmmunitionHUDBackground">
<Components>
<c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<Color A="0.588235319" B="0" G="0" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="-0.00200000009"/>
<Scale X="0.119999997" Y="0.119999997" Z="0.119999997"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="AmmunitionText">
<Components>
<c:Transform/>
</Components>
<Children>
<Entity name="MagazineAmmo">
<Components>
<c:Text>
<Content>32</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Color A="1" B="3.92156863" G="1.17647064" R="0"/>
</c:Text>
<c:Transform>
<Scale X="0.0599999987" Y="0.0599999987" Z="0.0599999987"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="Ammo">
<Components>
<c:Text>
<Content>360</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Color A="1" B="3.92156863" G="1.17647064" R="0"/>
</c:Text>
<c:Transform>
<Position X="5.2833886e-05" Y="-0.0407950208" Z="0"/>
<Scale X="0.0399999991" Y="0.0399999991" Z="0.0399999991"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
</Children>
</Entity> </Entity>
</Children> </Children>
</Entity> </Entity>
@@ -493,7 +430,6 @@
<Components> <Components>
<c:Animation> <c:Animation>
<AnimationName1>Idle</AnimationName1> <AnimationName1>Idle</AnimationName1>
<Time1>0.87583812735846323</Time1>
<Speed1>1</Speed1> <Speed1>1</Speed1>
<AnimationName2></AnimationName2> <AnimationName2></AnimationName2>
<AnimationName3></AnimationName3> <AnimationName3></AnimationName3>
@@ -502,6 +438,7 @@
<AnimationName>AimRifle</AnimationName> <AnimationName>AimRifle</AnimationName>
<Time>0.5</Time> <Time>0.5</Time>
</c:AnimationOffset> </c:AnimationOffset>
<c:Shielded/>
<c:HiddenForLocalPlayer/> <c:HiddenForLocalPlayer/>
<c:Model> <c:Model>
<Resource>Models/Characters/Assault/AssaultAnimations.mesh</Resource> <Resource>Models/Characters/Assault/AssaultAnimations.mesh</Resource>
@@ -510,41 +447,35 @@
<c:Transform/> <c:Transform/>
</Components> </Components>
<Children> <Children>
<Entity name="ThirdPersonWeaponModel"> <Entity name="PrimaryAttachment">
<Components> <Components>
<c:BoneAttachment> <c:Spawner>
<BoneName>R_Arm_Weapon_Joint</BoneName> <EntityFile>Schema/Entities/DefenderWeaponWorld.xml</EntityFile>
</c:BoneAttachment> </c:Spawner>
<c:Model> <c:Transform/>
<Resource>Models/Weapons/Blue/AssaultWeaponBlue.mesh</Resource> <c:WeaponAttachment>
</c:Model> <Weapon>DefenderWeapon</Weapon>
<c:Transform> <Person>
<Position X="0.163429111" Y="1.0235405" Z="-0.215489209"/> <ThirdPerson/>
<Orientation X="-0.0631071255" Y="-0.0576644838" Z="0.118255548"/> </Person>
</c:Transform> </c:WeaponAttachment>
</Components> </Components>
<Children> <Children/>
<Entity name="ThirdPersonWeaponMuzzle"> </Entity>
<Components> <Entity name="SecondaryAttachment">
<c:Spawner> <Components>
<EntityFile>Schema/Entities/RayBlue.xml</EntityFile> <c:Spawner>
</c:Spawner> <EntityFile>Schema/Entities/AssaultWeaponWorld.xml</EntityFile>
<c:Transform> </c:Spawner>
<Position X="0.00644115033" Y="0.096679531" Z="-0.436609417"/> <c:Transform/>
</c:Transform> <c:WeaponAttachment>
</Components> <Weapon>AssaultWeapon</Weapon>
<Children/> <Person>
</Entity> <ThirdPerson/>
<Entity name="ThirdPersonReloadSpawner"> </Person>
<Components> </c:WeaponAttachment>
<c:Spawner> </Components>
<EntityFile>Schema/Entities/ReloadEffectWorld.xml</EntityFile> <Children/>
</c:Spawner>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
</Entity> </Entity>
</Children> </Children>
</Entity> </Entity>
@@ -610,6 +541,17 @@
</Components> </Components>
<Children/> <Children/>
</Entity> </Entity>
<Entity name="ShieldAttachment">
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/DefenderShield.xml</EntityFile>
</c:Spawner>
<c:Transform>
<Position X="0" Y="0.859000027" Z="-0.976999998"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children> </Children>
</Entity> </Entity>
+76 -135
View File
@@ -7,24 +7,31 @@
<Size X="1" Y="1.60000002" Z="1"/> <Size X="1" Y="1.60000002" Z="1"/>
</c:AABB> </c:AABB>
<c:AssaultWeapon> <c:AssaultWeapon>
<RPM>600</RPM> <Slot>
<Secondary/>
</Slot>
</c:AssaultWeapon> </c:AssaultWeapon>
<c:Collidable/> <c:Collidable/>
<c:DashAbility/> <c:DefenderWeapon>
<TimeSinceLastFire>1.6944730461160304</TimeSinceLastFire>
</c:DefenderWeapon>
<c:DoubleJump/>
<c:Health/> <c:Health/>
<c:Physics> <c:Physics>
<PrevOrigin X="0" Y="0.772000015" Z="0"/>
<Velocity X="2.30999646e-23" Y="0" Z="1.05272533e-23"/> <Velocity X="2.30999646e-23" Y="0" Z="1.05272533e-23"/>
</c:Physics> </c:Physics>
<c:Player> <c:Player>
<MovementSpeed>5</MovementSpeed> <MovementSpeed>5</MovementSpeed>
<CurrentWeapon></CurrentWeapon>
</c:Player> </c:Player>
<c:Team> <c:Team>
<Team> <Team>
<Red/> <Red/>
</Team> </Team>
</c:Team> </c:Team>
<c:Transform/> <c:Transform>
<Position X="0" Y="0.0288832653" Z="3.63052702"/>
</c:Transform>
</Components> </Components>
<Children> <Children>
@@ -365,7 +372,7 @@
<Components> <Components>
<c:Animation> <c:Animation>
<AnimationName1>Idle</AnimationName1> <AnimationName1>Idle</AnimationName1>
<Time1>1.2667383999985162</Time1> <Time1>0.67172915251515519</Time1>
<Speed1>1</Speed1> <Speed1>1</Speed1>
<AnimationName2></AnimationName2> <AnimationName2></AnimationName2>
<AnimationName3></AnimationName3> <AnimationName3></AnimationName3>
@@ -377,100 +384,29 @@
<c:Transform/> <c:Transform/>
</Components> </Components>
<Children> <Children>
<Entity name="WeaponModel"> <Entity name="PrimaryAttachment">
<Components> <Components>
<c:BoneAttachment> <c:Spawner>
<BoneName>R_Arm_Weapon_Joint</BoneName> <EntityFile>Schema/Entities/DefenderWeaponViewRed.xml</EntityFile>
</c:BoneAttachment> </c:Spawner>
<c:Model> <c:Transform/>
<Resource>Models/Weapons/Red/AssaultWeaponRed.mesh</Resource> <c:WeaponAttachment>
</c:Model> <Weapon>DefenderWeapon</Weapon>
<c:Transform> </c:WeaponAttachment>
<Position X="0.120430425" Y="-0.242105931" Z="-0.181454822"/>
<Orientation X="0.010404665" Y="-0.00268179877" Z="0.0428443067"/>
</c:Transform>
</Components> </Components>
<Children> <Children/>
<Entity name="WeaponMuzzle"> </Entity>
<Components> <Entity name="SecondaryAttachment">
<c:Spawner> <Components>
<EntityFile>Schema/Entities/RayRed.xml</EntityFile> <c:Spawner>
</c:Spawner> <EntityFile>Schema/Entities/AssaultWeaponView.xml</EntityFile>
<c:Transform> </c:Spawner>
<Position X="0.00325386273" Y="0.0970000029" Z="-0.843000054"/> <c:Transform/>
</c:Transform> <c:WeaponAttachment>
</Components> <Weapon>AssaultWeapon</Weapon>
<Children/> </c:WeaponAttachment>
</Entity> </Components>
<Entity name="FirstPersonReloadSpawner"> <Children/>
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/ReloadEffectViewRed.xml</EntityFile>
</c:Spawner>
<c:Transform/>
</Components>
<Children/>
</Entity>
<Entity name="AmmunitionHUD">
<Components>
<c:AmmunitionHUD/>
<c:Transform>
<Position X="-0.0430000015" Y="0.131501317" Z="-0.0670000017"/>
<Scale X="0.400000006" Y="0.400000006" Z="0.400000006"/>
</c:Transform>
</Components>
<Children>
<Entity name="AmmunitionHUDBackground">
<Components>
<c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<Color A="0.588235319" B="0" G="0" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="-0.00200000009"/>
<Scale X="0.119999997" Y="0.119999997" Z="0.119999997"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="AmmunitionText">
<Components>
<c:Transform/>
</Components>
<Children>
<Entity name="MagazineAmmo">
<Components>
<c:Text>
<Content>32</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Color A="1" B="3.92156863" G="1.17647064" R="0"/>
</c:Text>
<c:Transform>
<Scale X="0.0599999987" Y="0.0599999987" Z="0.0599999987"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity name="Ammo">
<Components>
<c:Text>
<Content>360</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Color A="1" B="3.92156863" G="1.17647064" R="0"/>
</c:Text>
<c:Transform>
<Position X="5.2833886e-05" Y="-0.0407950208" Z="0"/>
<Scale X="0.0399999991" Y="0.0399999991" Z="0.0399999991"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
</Children>
</Entity> </Entity>
</Children> </Children>
</Entity> </Entity>
@@ -494,7 +430,6 @@
<Components> <Components>
<c:Animation> <c:Animation>
<AnimationName1>Idle</AnimationName1> <AnimationName1>Idle</AnimationName1>
<Time1>0.26532318661337229</Time1>
<Speed1>1</Speed1> <Speed1>1</Speed1>
<AnimationName2></AnimationName2> <AnimationName2></AnimationName2>
<AnimationName3></AnimationName3> <AnimationName3></AnimationName3>
@@ -503,6 +438,7 @@
<AnimationName>AimRifle</AnimationName> <AnimationName>AimRifle</AnimationName>
<Time>0.5</Time> <Time>0.5</Time>
</c:AnimationOffset> </c:AnimationOffset>
<c:Shielded/>
<c:HiddenForLocalPlayer/> <c:HiddenForLocalPlayer/>
<c:Model> <c:Model>
<Resource>Models/Characters/Assault/AssaultAnimations.mesh</Resource> <Resource>Models/Characters/Assault/AssaultAnimations.mesh</Resource>
@@ -511,41 +447,35 @@
<c:Transform/> <c:Transform/>
</Components> </Components>
<Children> <Children>
<Entity name="ThirdPersonWeaponModel"> <Entity name="PrimaryAttachment">
<Components> <Components>
<c:BoneAttachment> <c:Spawner>
<BoneName>R_Arm_Weapon_Joint</BoneName> <EntityFile>Schema/Entities/DefenderWeaponWorldRed.xml</EntityFile>
</c:BoneAttachment> </c:Spawner>
<c:Model> <c:Transform/>
<Resource>Models/Weapons/Red/AssaultWeaponRed.mesh</Resource> <c:WeaponAttachment>
</c:Model> <Weapon>DefenderWeapon</Weapon>
<c:Transform> <Person>
<Position X="0.159282878" Y="1.0300566" Z="-0.216084003"/> <ThirdPerson/>
<Orientation X="-0.0626799241" Y="-0.0390551724" Z="0.119761385"/> </Person>
</c:Transform> </c:WeaponAttachment>
</Components> </Components>
<Children> <Children/>
<Entity name="ThirdPersonWeaponMuzzle"> </Entity>
<Components> <Entity name="SecondaryAttachment">
<c:Spawner> <Components>
<EntityFile>Schema/Entities/RayRed.xml</EntityFile> <c:Spawner>
</c:Spawner> <EntityFile>Schema/Entities/AssaultWeaponWorld.xml</EntityFile>
<c:Transform> </c:Spawner>
<Position X="0.00644115033" Y="0.096679531" Z="-0.436609417"/> <c:Transform/>
</c:Transform> <c:WeaponAttachment>
</Components> <Weapon>AssaultWeapon</Weapon>
<Children/> <Person>
</Entity> <ThirdPerson/>
<Entity name="ThirdPersonReloadSpawner"> </Person>
<Components> </c:WeaponAttachment>
<c:Spawner> </Components>
<EntityFile>Schema/Entities/ReloadEffectWorldRed.xml</EntityFile> <Children/>
</c:Spawner>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
</Entity> </Entity>
</Children> </Children>
</Entity> </Entity>
@@ -584,20 +514,20 @@
<Color A="1" B="0" G="1" R="0"/> <Color A="1" B="0" G="1" R="0"/>
</c:Text> </c:Text>
<c:Transform> <c:Transform>
<Position X="0.100000001" Y="1.50199997" Z="-0.248000011"/> <Position X="0.100000001" Y="1.50176644" Z="-0.248000011"/>
<Scale X="0.100000001" Y="0.113000005" Z="0.5"/> <Scale X="0.100000001" Y="0.113000005" Z="0.5"/>
<Orientation X="0" Y="3.14199996" Z="0"/> <Orientation X="0" Y="3.14199996" Z="0"/>
</c:Transform> </c:Transform>
</Components> </Components>
<Children/> <Children/>
</Entity> </Entity>
<Entity> <Entity name="Indicator">
<Components> <Components>
<c:Sprite> <c:Sprite>
<DiffuseTexture>Textures/Icons/Arrow.png</DiffuseTexture> <DiffuseTexture>Textures/Icons/Arrow.png</DiffuseTexture>
<DepthSort>false</DepthSort> <DepthSort>false</DepthSort>
<GlowMap></GlowMap> <GlowMap></GlowMap>
<Color A="1" B="0" G="0" R="1"/> <Color A="1" B="1" G="0.309803933" R="0"/>
</c:Sprite> </c:Sprite>
<c:HiddenForLocalPlayer/> <c:HiddenForLocalPlayer/>
<c:SpriteIndicator> <c:SpriteIndicator>
@@ -605,12 +535,23 @@
<VisibleForSingleTeamOnly>true</VisibleForSingleTeamOnly> <VisibleForSingleTeamOnly>true</VisibleForSingleTeamOnly>
</c:SpriteIndicator> </c:SpriteIndicator>
<c:Transform> <c:Transform>
<Position X="0" Y="1.84000003" Z="0"/> <Position X="0" Y="1.84019077" Z="0"/>
<Scale X="0.300000012" Y="0.300000012" Z="0.300000012"/> <Scale X="0.300000012" Y="0.300000012" Z="0.300000012"/>
</c:Transform> </c:Transform>
</Components> </Components>
<Children/> <Children/>
</Entity> </Entity>
<Entity name="ShieldAttachment">
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/DefenderShield.xml</EntityFile>
</c:Spawner>
<c:Transform>
<Position X="0" Y="0.859000027" Z="-0.976999998"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children> </Children>
</Entity> </Entity>
+2
View File
@@ -50,6 +50,8 @@
<xs:element ref="c:Menu" minOccurs="0"/> <xs:element ref="c:Menu" minOccurs="0"/>
<xs:element ref="c:Page" minOccurs="0"/> <xs:element ref="c:Page" minOccurs="0"/>
<xs:element ref="c:Button" minOccurs="0"/> <xs:element ref="c:Button" minOccurs="0"/>
<xs:element ref="c:WeaponAttachment" minOccurs="0"/>
<xs:element ref="c:DefenderWeapon" minOccurs="0"/>
</xs:all> </xs:all>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" xmlns:t="types">
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:complexType name="WeaponSlotEnum" mixed="true">
<xs:complexContent>
<xs:extension base="t:enum">
<xs:choice>
<xs:element name="Primary" type="t:int" fixed="1" minOccurs="0"/>
<xs:element name="Secondary" type="t:int" fixed="2" minOccurs="0"/>
</xs:choice>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
+6 -4
View File
@@ -13,6 +13,7 @@ uniform vec4 AmbientColor;
uniform float FillPercentage; uniform float FillPercentage;
uniform float GlowIntensity = 10; uniform float GlowIntensity = 10;
uniform vec3 CameraPosition; uniform vec3 CameraPosition;
uniform int SSAOQuality;
uniform vec2 DiffuseUVRepeat; uniform vec2 DiffuseUVRepeat;
uniform vec2 NormalUVRepeat; uniform vec2 NormalUVRepeat;
@@ -125,7 +126,7 @@ vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textu
void main() void main()
{ {
float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy), 0).r; float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy) >> int(SSAOQuality), 0).r;
ao = (clamp(1.0 - (1.0 - ao), 0.0, 1.0) + MIN_AMBIENT_LIGHT) / (1.0 + MIN_AMBIENT_LIGHT); ao = (clamp(1.0 - (1.0 - ao), 0.0, 1.0) + MIN_AMBIENT_LIGHT) / (1.0 + MIN_AMBIENT_LIGHT);
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate * DiffuseUVRepeat); vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate * DiffuseUVRepeat);
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat); vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat);
@@ -170,7 +171,8 @@ void main()
vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed);
color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel));
float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0; float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0;
color_result = color_result * clamp(1/specularTexel, 0, 1)*2 + reflectionColor * clamp(specularTexel, 0, 1)/2; vec4 reflectionTotal = reflectionColor * (1-specularTexel.a) * color_result.a;
color_result = color_result * clamp(1/specularTexel.a, 0, 1) + reflectionTotal;
//vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color;
@@ -181,9 +183,9 @@ void main()
} }
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1)); sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
//sceneColor = vec4(reflectionColor.xyz, 1); //sceneColor = vec4(reflectionColor.xyz, 1);
color_result += glowTexel*GlowIntensity; color_result.xyz += glowTexel.xyz*GlowIntensity;
bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), clamp(color_result.a, 0, 1)); bloomColor = vec4(max(color_result.xyz - 1.0, 0.0), clamp(color_result.a, 0, 1));
//Tiled Debug Code //Tiled Debug Code
/* /*
@@ -11,6 +11,7 @@ uniform vec4 DiffuseColor;
uniform vec4 FillColor; uniform vec4 FillColor;
uniform vec4 Color; uniform vec4 Color;
uniform vec4 AmbientColor; uniform vec4 AmbientColor;
uniform int SSAOQuality;
//Get bineded at the same time as the textures //Get bineded at the same time as the textures
uniform vec2 DiffuseUVRepeat1; uniform vec2 DiffuseUVRepeat1;
@@ -177,7 +178,7 @@ vec4 CalcBlendedNormal(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B,
void main() void main()
{ {
float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy), 0).r; float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy) >> int(SSAOQuality), 0).r;
ao = (clamp(1.0 - (1.0 - ao), 0.0, 1.0) + MIN_AMBIENT_LIGHT) / (1.0 + MIN_AMBIENT_LIGHT); ao = (clamp(1.0 - (1.0 - ao), 0.0, 1.0) + MIN_AMBIENT_LIGHT) / (1.0 + MIN_AMBIENT_LIGHT);
vec4 splatTexel = texture2D(SplatMapTexture, Input.TextureCoordinate); vec4 splatTexel = texture2D(SplatMapTexture, Input.TextureCoordinate);
+7 -12
View File
@@ -2,11 +2,11 @@
//Number of samples per pixel //Number of samples per pixel
uniform int uNumOfSamples; uniform int uNumOfSamples;
//#define NUM_SAMPLES (11) //#define uNumOfSamples (11)
//Number of turns around the cirle //Number of turns around the cirle
uniform int uNumOfTurns; uniform int uNumOfTurns;
//#define NUM_TURNS (7) //#define uNumOfTurns (7)
layout (binding = 0) uniform sampler2D ViewSpaceZ; layout (binding = 0) uniform sampler2D ViewSpaceZ;
@@ -16,15 +16,16 @@ uniform float uProjScale;
//#define ProjScale 500 //#define ProjScale 500
uniform float uRadius; uniform float uRadius;
//#define Radius 1.0f //#define uRadius 1.0f
uniform float uBias; uniform float uBias;
//#define Bias 0.012f //#define uBias 0.05f
uniform float uContrast; uniform float uContrast;
//#define IntensityDivR6 1 //#define uContrast 1.5f
uniform float uIntensityScale; uniform float uIntensityScale;
//#define uIntensityScale 1.0f
out float AO; out float AO;
@@ -88,13 +89,7 @@ void main() {
vec3 origin = getVSPosition(originScreenCoord); vec3 origin = getVSPosition(originScreenCoord);
float radius; float radius = min(origin.z, uRadius);
if(origin.z < uRadius){
radius = origin.z;
} else {
radius = uRadius;
}
vec3 originNormal = getVSFaceNormal(origin); vec3 originNormal = getVSFaceNormal(origin);
+5
View File
@@ -2,7 +2,12 @@
layout (location = 0) in vec3 Position; layout (location = 0) in vec3 Position;
out VertexData{
vec2 TextureCoordinate;
}Output;
void main() void main()
{ {
gl_Position = vec4(Position, 1.0); gl_Position = vec4(Position, 1.0);
Output.TextureCoordinate = (vec2(Position) + 1) / 2;
} }
+5 -1
View File
@@ -3,11 +3,15 @@
layout (binding = 0) uniform sampler2D DepthBuffer; layout (binding = 0) uniform sampler2D DepthBuffer;
uniform vec3 ClipInfo; uniform vec3 ClipInfo;
in VertexData{
vec2 TextureCoordinate;
}Input;
out float depthLinear; out float depthLinear;
//Just for Debug, should be depthLinear //Just for Debug, should be depthLinear
//out vec4 fragmentColor; //out vec4 fragmentColor;
void main() { void main() {
float depthSample = texelFetch(DepthBuffer, ivec2(gl_FragCoord.xy), 0).r; float depthSample = texture2D(DepthBuffer, Input.TextureCoordinate).r;
depthLinear = ClipInfo[0] / (ClipInfo[1] * depthSample + ClipInfo[2]); depthLinear = ClipInfo[0] / (ClipInfo[1] * depthSample + ClipInfo[2]);
//float depthLinear = (NearClip) / ( -depthSample + 1.0f); //float depthLinear = (NearClip) / ( -depthSample + 1.0f);
//fragmentColor = vec4(depthLinear, depthLinear, depthLinear, 1.0f); //fragmentColor = vec4(depthLinear, depthLinear, depthLinear, 1.0f);
+49 -44
View File
@@ -12,55 +12,56 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
if (!boundingBox) { if (!boundingBox) {
return; return;
} }
ComponentWrapper& cTransform = entity["Transform"]; ComponentWrapper& cTransform = entity["Transform"];
EntityAABB& boxA = *boundingBox; EntityAABB& boxA = *boundingBox;
bool everHitTheGround = false; bool everHitTheGround = false;
glm::vec3 size = boxA.Size(); auto prevPosIt = m_PrevPositions.find(entity);
float diameter = std::min(size.x, size.z); if (prevPosIt != m_PrevPositions.end()) {
glm::vec3 prevOrigin = (glm::vec3)cPhysics["PrevOrigin"]; glm::vec3 size = boxA.Size();
glm::vec3 toCurrentPos = boxA.Origin() - prevOrigin; float diameter = std::min(size.x, size.z);
float rayLength = glm::length(toCurrentPos) + 0.5f*diameter; glm::vec3 prevOrigin = prevPosIt->second;
//If the entity has moved farther than the size of its box, we need to handle it specially. glm::vec3 toCurrentPos = boxA.Origin() - prevOrigin;
bool traceCollision = rayLength > diameter; float rayLength = glm::length(toCurrentPos) + 0.5f*diameter;
//hack solution: If prevOrigin is less than -9000 in all dimensions, //If the entity has moved farther than the size of its box, we need to handle it specially.
//then it means it is not set, i.e. this is the first collision check for the entity. if (rayLength > diameter) {
if (traceCollision && glm::any(glm::greaterThan((glm::vec3)cPhysics["PrevOrigin"], glm::vec3(-9000.f)))) { Ray ray(prevOrigin, toCurrentPos);
Ray ray(prevOrigin, toCurrentPos); m_OctreeResult.clear();
m_OctreeResult.clear(); m_Octree->ObjectsPossiblyHitByRay(ray, m_OctreeResult);
m_Octree->ObjectsPossiblyHitByRay(ray, m_OctreeResult); for (auto& boxB : m_OctreeResult) {
for (auto& boxB : m_OctreeResult) { if (boxA.Entity == boxB.Entity) {
if (boxA.Entity == boxB.Entity) {
continue;
}
bool hit;
float dist;
if (boxB.Entity.HasComponent("Model")) {
RawModel* model;
std::string res = (std::string)boxB.Entity["Model"]["Resource"];
try {
model = ResourceManager::Load<RawModel, true>(res);
} catch (const std::exception&) {
continue; continue;
} }
float u, v; bool hit;
hit = Collision::RayVsModel(ray, model->Vertices(), model->m_Indices, Transform::ModelMatrix(boxB.Entity), dist, u, v); float dist;
} else { if (boxB.Entity.HasComponent("Model")) {
hit = Collision::RayVsAABB(ray, boxB, dist); RawModel* model;
} std::string res = (std::string)boxB.Entity["Model"]["Resource"];
if (hit && dist < rayLength) { try {
//Set the entity to where it was colliding, minus the maximum box size. model = ResourceManager::Load<RawModel, true>(res);
//TODO: Perhaps this should be done slightly more properly. } catch (const std::exception&) {
glm::vec3 newOriginPos = ray.Origin() + (dist - 0.707107f*diameter) * ray.Direction(); continue;
glm::vec3 resolve = newOriginPos - boxA.Origin(); }
(glm::vec3&)cTransform["Position"] += resolve; float u, v;
boxA = *Collision::EntityAbsoluteAABB(entity); hit = Collision::RayVsModel(ray, model->Vertices(), model->m_Indices, Transform::ModelMatrix(boxB.Entity), dist, u, v);
if (resolve.y > 0) { } else {
everHitTheGround = true; hit = Collision::RayVsAABB(ray, boxB, dist);
(bool)cPhysics["IsOnGround"] = true; }
((glm::vec3&)cPhysics["Velocity"]).y = 0.f; if (hit && dist < rayLength) {
//Set the entity to where it was colliding, minus the maximum box size.
//TODO: Perhaps this should be done slightly more properly.
glm::vec3 newOriginPos = ray.Origin() + (dist - 0.707107f*diameter) * ray.Direction();
glm::vec3 resolve = newOriginPos - boxA.Origin();
(glm::vec3&)cTransform["Position"] += resolve;
boxA = *Collision::EntityAbsoluteAABB(entity);
if (resolve.y > 0) {
everHitTheGround = true;
(bool)cPhysics["IsOnGround"] = true;
((glm::vec3&)cPhysics["Velocity"]).y = 0.f;
}
break;
} }
break;
} }
} }
} }
@@ -86,10 +87,13 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
glm::mat4 modelMatrix = Transform::ModelMatrix(boxB.Entity); glm::mat4 modelMatrix = Transform::ModelMatrix(boxB.Entity);
glm::vec3 inOutVelocity = (glm::vec3)cPhysics["Velocity"]; glm::vec3 inOutVelocity = (glm::vec3)cPhysics["Velocity"];
bool notMovingxz = glm::all(glm::lessThan(glm::abs(glm::vec2(inOutVelocity.x, inOutVelocity.z)), glm::vec2(0.01f))) && prevPosIt != m_PrevPositions.end();
bool isOnGround = (bool)cPhysics["IsOnGround"]; bool isOnGround = (bool)cPhysics["IsOnGround"];
float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"]; float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"];
if (Collision::AABBvsTriangles(boxA, model->Vertices(), model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) { if (Collision::AABBvsTriangles(boxA, model->Vertices(), model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) {
(glm::vec3&)cTransform["Position"] += resolutionVector; //Move the position to previous position if it is not moving in the xz-plane, else resolve with the resolution vector.
(glm::vec3&)cTransform["Position"] += notMovingxz ? prevPosIt->second - boxA.Origin() : resolutionVector;
boxA = *Collision::EntityAbsoluteAABB(entity);
cPhysics["Velocity"] = inOutVelocity; cPhysics["Velocity"] = inOutVelocity;
if (isOnGround) { if (isOnGround) {
everHitTheGround = true; everHitTheGround = true;
@@ -99,6 +103,7 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
} else if (Collision::AABBVsAABB(boxA, boxB, resolutionVector)) { } else if (Collision::AABBVsAABB(boxA, boxB, resolutionVector)) {
//Enter here if boxB has no Model. //Enter here if boxB has no Model.
(glm::vec3&)cTransform["Position"] += resolutionVector; (glm::vec3&)cTransform["Position"] += resolutionVector;
boxA = *Collision::EntityAbsoluteAABB(entity);
if (resolutionVector.y > 0) { if (resolutionVector.y > 0) {
everHitTheGround = true; everHitTheGround = true;
(bool)cPhysics["IsOnGround"] = true; (bool)cPhysics["IsOnGround"] = true;
@@ -112,5 +117,5 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
(bool)cPhysics["IsOnGround"] = false; (bool)cPhysics["IsOnGround"] = false;
} }
(glm::vec3&)cPhysics["PrevOrigin"] = boxA.Origin(); m_PrevPositions[entity] = boxA.Origin();
} }
+79 -1
View File
@@ -51,6 +51,40 @@ EntityWrapper EntityWrapper::FirstParentWithComponent(const std::string& compone
return EntityWrapper::Invalid; return EntityWrapper::Invalid;
} }
EntityWrapper EntityWrapper::Clone(EntityWrapper parent /*= Invalid*/)
{
if (!Valid()) {
return EntityWrapper::Invalid;
}
EntityWrapper clone = cloneRecursive(*this, EntityWrapper::Invalid);
this->World->SetParent(clone.ID, parent.ID);
return clone;
}
std::vector<EntityWrapper> EntityWrapper::ChildrenWithComponent(const std::string& componentType)
{
std::vector<EntityWrapper> childrenWithComponent;
childrenWithComponentRecursive(componentType, *this, childrenWithComponent);
return childrenWithComponent;
}
void EntityWrapper::DeleteChildren()
{
auto itPair = this->World->GetDirectChildren(this->ID);
if (itPair.first == itPair.second) {
return;
}
std::vector<EntityID> entitiesToDelete;
for (auto it = itPair.first; it != itPair.second; it++) {
entitiesToDelete.push_back(it->second);
}
for (auto& e : entitiesToDelete) {
this->World->DeleteEntity(e);
}
}
bool EntityWrapper::IsChildOf(EntityWrapper potentialParent) bool EntityWrapper::IsChildOf(EntityWrapper potentialParent)
{ {
EntityWrapper entity = *this; EntityWrapper entity = *this;
@@ -90,6 +124,11 @@ ComponentWrapper EntityWrapper::operator[](const char* componentName)
} }
} }
ComponentWrapper EntityWrapper::operator[](const std::string& componentName)
{
return this->operator[](componentName.c_str());
}
bool EntityWrapper::operator==(const EntityWrapper& e) const bool EntityWrapper::operator==(const EntityWrapper& e) const
{ {
return (this->ID == e.ID) && (this->World == e.World); return (this->ID == e.ID) && (this->World == e.World);
@@ -111,7 +150,7 @@ EntityWrapper EntityWrapper::firstChildByNameRecursive(const std::string& name,
return EntityWrapper::Invalid; return EntityWrapper::Invalid;
} }
auto itPair = this->World->GetChildren(parent); auto itPair = this->World->GetDirectChildren(parent);
if (itPair.first == itPair.second) { if (itPair.first == itPair.second) {
return EntityWrapper::Invalid; return EntityWrapper::Invalid;
} }
@@ -131,3 +170,42 @@ EntityWrapper EntityWrapper::firstChildByNameRecursive(const std::string& name,
return EntityWrapper::Invalid; return EntityWrapper::Invalid;
} }
EntityWrapper EntityWrapper::cloneRecursive(EntityWrapper entity, EntityWrapper parent)
{
EntityWrapper clone = EntityWrapper(entity.World, entity.World->CreateEntity(parent.ID));
entity.World->SetName(clone.ID, entity.Name());
// Clone components
for (auto& kv : entity.World->GetComponentPools()) {
if (kv.second->KnowsEntity(entity.ID)) {
ComponentWrapper c1 = kv.second->GetByEntity(entity.ID);
ComponentWrapper c2 = entity.World->AttachComponent(clone.ID, kv.first);
c1.Copy(c2);
}
}
// Clone children
auto children = entity.World->GetDirectChildren(entity.ID);
for (auto it = children.first; it != children.second; ++it) {
EntityWrapper child(entity.World, it->second);
cloneRecursive(child, clone);
}
return clone;
}
void EntityWrapper::childrenWithComponentRecursive(const std::string& componentType, EntityWrapper& entity, std::vector<EntityWrapper>& childrenWithComponent)
{
auto itPair = this->World->GetDirectChildren(entity.ID);
if (itPair.first == itPair.second) {
return;
}
for (auto it = itPair.first; it != itPair.second; ++it) {
EntityWrapper child = EntityWrapper(entity.World, it->second);
if (child.HasComponent(componentType)) {
childrenWithComponent.push_back(child);
}
childrenWithComponentRecursive(componentType, child, childrenWithComponent);
}
}
+2 -2
View File
@@ -33,8 +33,8 @@ void _LOG(_LOG_LEVEL logLevel, const char* file, const char* func, unsigned int
va_end(args); va_end(args);
if (logLevel == LOG_LEVEL_ERROR) { if (logLevel == LOG_LEVEL_ERROR) {
std::cerr << file << ":" << line << " " << func << std::endl; //std::cerr << file << ":" << line << " " << func << std::endl;
std::cerr << _LOG_LEVEL_PREFIX[logLevel] << message << std::endl; //std::cerr << _LOG_LEVEL_PREFIX[logLevel] << message << std::endl;
} else { } else {
std::cout << _LOG_LEVEL_PREFIX[logLevel] << message << std::endl; std::cout << _LOG_LEVEL_PREFIX[logLevel] << message << std::endl;
} }
+1 -1
View File
@@ -127,7 +127,7 @@ void World::SetParent(EntityID entity, EntityID parent)
m_EntityChildren.insert(std::make_pair(parent, entity)); m_EntityChildren.insert(std::make_pair(parent, entity));
} }
const std::pair<std::unordered_multimap<EntityID, EntityID>::const_iterator, std::unordered_multimap<EntityID, EntityID>::const_iterator> World::GetChildren(EntityID entity) const std::pair<std::unordered_multimap<EntityID, EntityID>::const_iterator, std::unordered_multimap<EntityID, EntityID>::const_iterator> World::GetDirectChildren(EntityID entity)
{ {
return m_EntityChildren.equal_range(entity); return m_EntityChildren.equal_range(entity);
} }
+18
View File
@@ -580,6 +580,11 @@ void EditorGUI::createWidgetToolButton(WidgetMode mode)
bool EditorGUI::OnKeyDown(const Events::KeyDown& e) bool EditorGUI::OnKeyDown(const Events::KeyDown& e)
{ {
ImGuiIO& io = ImGui::GetIO();
if (io.WantCaptureKeyboard) {
return false;
}
if (e.ModCtrl && e.KeyCode == GLFW_KEY_S) { if (e.ModCtrl && e.KeyCode == GLFW_KEY_S) {
if (m_CurrentSelection.Valid()) { if (m_CurrentSelection.Valid()) {
EntityWrapper baseParent = m_CurrentSelection; EntityWrapper baseParent = m_CurrentSelection;
@@ -598,6 +603,19 @@ bool EditorGUI::OnKeyDown(const Events::KeyDown& e)
entityImport(m_World); entityImport(m_World);
} }
if (e.ModCtrl && e.KeyCode == GLFW_KEY_C) {
m_CopyTarget = m_CurrentSelection;
}
if (e.ModCtrl && e.KeyCode == GLFW_KEY_V) {
if (m_OnEntityPaste != nullptr) {
EntityWrapper copy = m_OnEntityPaste(m_CopyTarget, m_CurrentSelection);
if (copy != EntityWrapper::Invalid) {
SelectEntity(copy);
}
}
}
if (e.KeyCode == GLFW_KEY_DELETE) { if (e.KeyCode == GLFW_KEY_DELETE) {
if (m_CurrentSelection.Valid()) { if (m_CurrentSelection.Valid()) {
entityDelete(m_CurrentSelection); entityDelete(m_CurrentSelection);
+6
View File
@@ -28,6 +28,7 @@ EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame
m_EditorGUI->SetEntityDeleteCallback(std::bind(&EditorSystem::OnEntityDelete, this, std::placeholders::_1)); m_EditorGUI->SetEntityDeleteCallback(std::bind(&EditorSystem::OnEntityDelete, this, std::placeholders::_1));
m_EditorGUI->SetEntityChangeParentCallback(std::bind(&EditorSystem::OnEntityChangeParent, this, std::placeholders::_1, std::placeholders::_2)); m_EditorGUI->SetEntityChangeParentCallback(std::bind(&EditorSystem::OnEntityChangeParent, this, std::placeholders::_1, std::placeholders::_2));
m_EditorGUI->SetEntityChangeNameCallback(std::bind(&EditorSystem::OnEntityChangeName, this, std::placeholders::_1, std::placeholders::_2)); m_EditorGUI->SetEntityChangeNameCallback(std::bind(&EditorSystem::OnEntityChangeName, this, std::placeholders::_1, std::placeholders::_2));
m_EditorGUI->SetEntityPasteCallback(std::bind(&EditorSystem::OnEntityPaste, this, std::placeholders::_1, std::placeholders::_2));
m_EditorGUI->SetComponentAttachCallback(std::bind(&EditorSystem::OnComponentAttach, this, std::placeholders::_1, std::placeholders::_2)); m_EditorGUI->SetComponentAttachCallback(std::bind(&EditorSystem::OnComponentAttach, this, std::placeholders::_1, std::placeholders::_2));
m_EditorGUI->SetComponentDeleteCallback(std::bind(&EditorSystem::OnComponentDelete, this, std::placeholders::_1, std::placeholders::_2)); m_EditorGUI->SetComponentDeleteCallback(std::bind(&EditorSystem::OnComponentDelete, this, std::placeholders::_1, std::placeholders::_2));
m_EditorGUI->SetWidgetModeCallback(std::bind(&EditorSystem::setWidgetMode, this, std::placeholders::_1)); m_EditorGUI->SetWidgetModeCallback(std::bind(&EditorSystem::setWidgetMode, this, std::placeholders::_1));
@@ -160,6 +161,11 @@ void EditorSystem::OnEntityChangeName(EntityWrapper entity, const std::string& n
} }
} }
EntityWrapper EditorSystem::OnEntityPaste(EntityWrapper entityToCopy, EntityWrapper parent)
{
return entityToCopy.Clone(parent);
}
void EditorSystem::OnComponentAttach(EntityWrapper entity, const std::string& componentType) void EditorSystem::OnComponentAttach(EntityWrapper entity, const std::string& componentType)
{ {
if (entity.Valid()) { if (entity.Valid()) {
+54 -21
View File
@@ -32,6 +32,7 @@ void Client::Connect(std::string address, int port)
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Client::OnInputCommand); EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Client::OnInputCommand);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Client::OnPlayerDamage); EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Client::OnPlayerDamage);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &Client::OnPlayerSpawned); EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &Client::OnPlayerSpawned);
EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &Client::OnDoubleJump);
EVENT_SUBSCRIBE_MEMBER(m_ESearchForServers, &Client::OnSearchForServers); EVENT_SUBSCRIBE_MEMBER(m_ESearchForServers, &Client::OnSearchForServers);
auto config = ResourceManager::Load<ConfigFile>("Config.ini"); auto config = ResourceManager::Load<ConfigFile>("Config.ini");
m_Address = address; m_Address = address;
@@ -140,6 +141,9 @@ void Client::parseMessageType(Packet& packet)
case MessageType::OnPlayerDamage: case MessageType::OnPlayerDamage:
parsePlayerDamage(packet); parsePlayerDamage(packet);
break; break;
case MessageType::OnDoubleJump:
parseDoubleJump(packet);
break;
default: default:
break; break;
} }
@@ -257,8 +261,14 @@ void Client::parseEntityDeletion(Packet & packet)
if (m_ServerIDToClientID.find(entityToDelete) != m_ServerIDToClientID.end()) { if (m_ServerIDToClientID.find(entityToDelete) != m_ServerIDToClientID.end()) {
EntityID localEntity = m_ServerIDToClientID.at(entityToDelete); EntityID localEntity = m_ServerIDToClientID.at(entityToDelete);
if (m_World->ValidEntity(localEntity)) { if (m_World->ValidEntity(localEntity)) {
m_World->DeleteEntity(localEntity); if (m_World->HasComponent(localEntity,"Player")) {
deleteFromServerClientMaps(entityToDelete, localEntity); Events::PlayerDeath e;
e.Player = EntityWrapper(m_World, localEntity);
m_EventBroker->Publish(e);
} else {
m_World->DeleteEntity(localEntity);
deleteFromServerClientMaps(entityToDelete, localEntity);
}
} }
} }
} }
@@ -272,6 +282,20 @@ void Client::parseComponentDeletion(Packet & packet)
} }
} }
void Client::parseDoubleJump(Packet & packet)
{
EntityID serverID = packet.ReadPrimitive<EntityID>();
if (!serverClientMapsHasEntity(serverID)) {
return;
}
Events::DoubleJump e;
e.entityID = m_ServerIDToClientID.at(serverID);
// If player is local player do not publish to prevent infinite feedback loop
if (e.entityID != m_LocalPlayer.ID) {
m_EventBroker->Publish(e);
}
}
void Client::updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID) void Client::updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID)
{ {
for (auto field : componentInfo.FieldsInOrder) { for (auto field : componentInfo.FieldsInOrder) {
@@ -348,9 +372,7 @@ void Client::parseSnapshot(Packet& packet)
EntityWrapper localEntity(m_World, localEntityID); EntityWrapper localEntity(m_World, localEntityID);
// Update entity // Update entity
if (m_World->HasComponent(localEntityID, componentType)) { if (m_World->HasComponent(localEntityID, componentType)) {
if (localEntity.Name() == "CapturePointHUD") { // TODO Fix memory leak here
UpdateLocalCapturePointHUD(localEntity);
}
SharedComponentWrapper newComponent = createSharedComponent(packet, localEntityID, componentInfo); SharedComponentWrapper newComponent = createSharedComponent(packet, localEntityID, componentInfo);
bool shouldApply = true; bool shouldApply = true;
// Apply potential filter function // Apply potential filter function
@@ -361,6 +383,7 @@ void Client::parseSnapshot(Packet& packet)
ComponentWrapper currentComponent = m_World->GetComponent(localEntityID, componentType); ComponentWrapper currentComponent = m_World->GetComponent(localEntityID, componentType);
memcpy(currentComponent.Data, newComponent.Data, componentInfo.Stride); memcpy(currentComponent.Data, newComponent.Data, componentInfo.Stride);
} }
//if (localEntity != m_LocalPlayer && !localEntity.IsChildOf(m_LocalPlayer)) { //if (localEntity != m_LocalPlayer && !localEntity.IsChildOf(m_LocalPlayer)) {
// updateFields(packet, componentInfo, localEntityID); // updateFields(packet, componentInfo, localEntityID);
//} else { //} else {
@@ -377,7 +400,11 @@ void Client::parseSnapshot(Packet& packet)
if (serverParentID == EntityID_Invalid) { if (serverParentID == EntityID_Invalid) {
newLocalEntityID = m_World->CreateEntity(EntityID_Invalid); newLocalEntityID = m_World->CreateEntity(EntityID_Invalid);
} else { } else {
newLocalEntityID = m_World->CreateEntity(m_ServerIDToClientID.at(serverParentID)); if (serverClientMapsHasEntity(serverParentID)) {
newLocalEntityID = m_World->CreateEntity(m_ServerIDToClientID.at(serverParentID));
} else {
newLocalEntityID = m_World->CreateEntity(EntityID_Invalid);
}
} }
m_World->SetName(newLocalEntityID, serverEntityName); m_World->SetName(newLocalEntityID, serverEntityName);
insertIntoServerClientMaps(serverEntityID, newLocalEntityID); insertIntoServerClientMaps(serverEntityID, newLocalEntityID);
@@ -387,26 +414,16 @@ void Client::parseSnapshot(Packet& packet)
} }
// Parent logic // Parent logic
// This should be enough beacause we know that the entities arives in pre-order (there will always be a parent) // This should be enough beacause we know that the entities arives in pre-order (there will always be a parent)
if (serverParentID != EntityID_Invalid) { if (serverParentID != EntityID_Invalid && serverClientMapsHasEntity(serverParentID)) {
EntityID localEntityID = m_ServerIDToClientID.at(serverEntityID); EntityID localEntityID = m_ServerIDToClientID.at(serverEntityID);
m_World->SetParent(localEntityID, m_ServerIDToClientID.at(serverParentID)); if (m_World->GetParent(localEntityID) != m_ServerIDToClientID.at(serverParentID)) {
m_World->SetParent(localEntityID, m_ServerIDToClientID.at(serverParentID));
}
} }
} }
parseSpawnEvents(); parseSpawnEvents();
} }
void Client::UpdateLocalCapturePointHUD(EntityWrapper capturePointHUD)
{
//auto children = m_World->GetChildren(capturePointHUD.ID);
//for (auto it = children.first; it != children.second; it++) {
// it->first
//}
//
//EntityWrapper& localHUD = m_LocalPlayer.FirstChildByName("HUD").FirstChildByName("CapturePointHUD");
//m_World->GetComponentPools()
}
void Client::disconnect() void Client::disconnect()
{ {
m_IsConnected = false; m_IsConnected = false;
@@ -469,6 +486,11 @@ bool Client::OnPlayerDamage(const Events::PlayerDamage & e)
if (e.Inflictor != m_LocalPlayer) { if (e.Inflictor != m_LocalPlayer) {
return false; return false;
} }
// Could this happen?
//if (!clientServerMapsHasEntity(e.Inflictor.ID)
// || !clientServerMapsHasEntity(e.Victim.ID)) {
// return;
//}
Packet packet(MessageType::OnPlayerDamage, m_SendPacketID); Packet packet(MessageType::OnPlayerDamage, m_SendPacketID);
packet.WritePrimitive(m_ClientIDToServerID.at(e.Inflictor.ID)); packet.WritePrimitive(m_ClientIDToServerID.at(e.Inflictor.ID));
@@ -503,7 +525,7 @@ void Client::parsePlayerDamage(Packet& packet)
Events::PlayerDamage e; Events::PlayerDamage e;
PlayerID victimID = packet.ReadPrimitive<EntityID>(); PlayerID victimID = packet.ReadPrimitive<EntityID>();
PlayerID inflictorID = packet.ReadPrimitive<EntityID>(); PlayerID inflictorID = packet.ReadPrimitive<EntityID>();
if(!serverClientMapsHasEntity(victimID) || !serverClientMapsHasEntity(inflictorID)){ if (!serverClientMapsHasEntity(victimID) || !serverClientMapsHasEntity(inflictorID)) {
return; return;
} }
e.Inflictor = EntityWrapper(m_World, m_ServerIDToClientID.at(victimID)); e.Inflictor = EntityWrapper(m_World, m_ServerIDToClientID.at(victimID));
@@ -515,6 +537,17 @@ void Client::parsePlayerDamage(Packet& packet)
} }
} }
bool Client::OnDoubleJump(Events::DoubleJump & e)
{
if (!clientServerMapsHasEntity(e.entityID) || e.entityID != m_LocalPlayer.ID) {
return false;
}
Packet packet(MessageType::OnDoubleJump);
packet.WritePrimitive(m_ClientIDToServerID.at(e.entityID));
m_Reliable.Send(packet);
return true;
}
void Client::sendLocalPlayerTransform() void Client::sendLocalPlayerTransform()
{ {
if (!m_LocalPlayer.Valid()) { if (!m_LocalPlayer.Valid()) {
+56 -43
View File
@@ -29,9 +29,8 @@ Server::~Server()
void Server::Update() void Server::Update()
{ {
PlayerDefinition pd;
m_Reliable.AcceptNewConnections(m_NextPlayerID, m_ConnectedPlayers); m_Reliable.AcceptNewConnections(m_NextPlayerID, m_ConnectedPlayers);
for (auto& kv : m_ConnectedPlayers) { for (auto& kv : m_ConnectedPlayers) {
while (kv.second.TCPSocket->available()) { while (kv.second.TCPSocket->available()) {
// Packet will get real data in receive // Packet will get real data in receive
@@ -47,6 +46,7 @@ void Server::Update()
} }
} }
PlayerDefinition pd;
while (m_Unreliable.IsSocketAvailable()) { while (m_Unreliable.IsSocketAvailable()) {
// Packet will get real data in receive // Packet will get real data in receive
Packet packet(MessageType::Invalid); Packet packet(MessageType::Invalid);
@@ -65,7 +65,7 @@ void Server::Update()
PlayerDefinition localArea; PlayerDefinition localArea;
localArea.Endpoint = boost::asio::ip::udp::endpoint(); localArea.Endpoint = boost::asio::ip::udp::endpoint();
m_ServerlistRequest.Receive(packet, localArea); m_ServerlistRequest.Receive(packet, localArea);
if(packet.GetMessageType() == MessageType::ServerlistRequest) { if (packet.GetMessageType() == MessageType::ServerlistRequest) {
packet.ReadPrimitive<int>(); // Pop size packet.ReadPrimitive<int>(); // Pop size
packet.ReadPrimitive<int>(); // Pop MsgType packet.ReadPrimitive<int>(); // Pop MsgType
packet.ReadPrimitive<int>(); // Pop packet ID packet.ReadPrimitive<int>(); // Pop packet ID
@@ -76,7 +76,7 @@ void Server::Update()
} }
// Check if players have disconnected // Check if players have disconnected
for (int i = 0; i < m_PlayersToDisconnect.size(); i++) { for (int i = 0; i < m_PlayersToDisconnect.size(); i++) {
disconnect(m_PlayersToDisconnect.at(i)); disconnect(m_PlayersToDisconnect.at(i));
} }
m_PlayersToDisconnect.clear(); m_PlayersToDisconnect.clear();
@@ -136,7 +136,10 @@ void Server::parseMessageType(Packet& packet)
parseOnPlayerDamage(packet); parseOnPlayerDamage(packet);
break; break;
case MessageType::PlayerTransform: case MessageType::PlayerTransform:
parsePlayerTransform(packet); parsePlayerTransform(packet);
break;
case MessageType::OnDoubleJump:
parseDoubleJump(packet);
break; break;
default: default:
break; break;
@@ -183,7 +186,7 @@ void Server::addInputCommandsToPacket(Packet& packet)
void Server::addPlayersToPacket(Packet & packet, EntityID entityID) void Server::addPlayersToPacket(Packet & packet, EntityID entityID)
{ {
auto itPair = m_World->GetChildren(entityID); auto itPair = m_World->GetDirectChildren(entityID);
std::unordered_map<std::string, ComponentPool*> worldComponentPools = m_World->GetComponentPools(); std::unordered_map<std::string, ComponentPool*> worldComponentPools = m_World->GetComponentPools();
// Loop through every child // Loop through every child
for (auto it = itPair.first; it != itPair.second; it++) { for (auto it = itPair.first; it != itPair.second; it++) {
@@ -191,49 +194,47 @@ void Server::addPlayersToPacket(Packet & packet, EntityID entityID)
// HACK: Only sync players for now, since the map turned out to be TOO LARGE to send in one snapshot and Simon's computer shits itself // HACK: Only sync players for now, since the map turned out to be TOO LARGE to send in one snapshot and Simon's computer shits itself
// HACK: Also checked CapturePointHUD for now. (this would get out of sync); // HACK: Also checked CapturePointHUD for now. (this would get out of sync);
EntityWrapper childEntity(m_World, childEntityID); EntityWrapper childEntity(m_World, childEntityID);
if (!shouldSendToClient(childEntity)) { if (shouldSendToClient(childEntity)) {
continue; // Write EntityID and parentsID and Entity name
} packet.WritePrimitive(childEntityID);
packet.WritePrimitive(entityID);
// Write EntityID and parentsID and Entity name packet.WriteString(m_World->GetName(childEntityID));
packet.WritePrimitive(childEntityID); // Write components to child
packet.WritePrimitive(entityID); int numberOfComponents = 0;
packet.WriteString(m_World->GetName(childEntityID)); for (auto& i : worldComponentPools) {
// Write components to child if (i.second->KnowsEntity(childEntityID)) {
int numberOfComponents = 0; numberOfComponents++;
for (auto& i : worldComponentPools) { }
if (i.second->KnowsEntity(childEntityID)) {
numberOfComponents++;
} }
} // Write how many components should be read
// Write how many components should be read packet.WritePrimitive(numberOfComponents);
packet.WritePrimitive(numberOfComponents); for (auto& i : worldComponentPools) {
for (auto& i : worldComponentPools) { // If the entity exist in the pool
// If the entity exist in the pool if (i.second->KnowsEntity(childEntityID)) {
if (i.second->KnowsEntity(childEntityID)) { ComponentWrapper componentWrapper = i.second->GetByEntity(childEntityID);
ComponentWrapper componentWrapper = i.second->GetByEntity(childEntityID); // ComponentType
// ComponentType packet.WriteString(componentWrapper.Info.Name);
packet.WriteString(componentWrapper.Info.Name); // Loop through fields
// Loop through fields for (auto& componentField : componentWrapper.Info.FieldsInOrder) {
for (auto& componentField : componentWrapper.Info.FieldsInOrder) { ComponentInfo::Field_t fieldInfo = componentWrapper.Info.Fields.at(componentField);
ComponentInfo::Field_t fieldInfo = componentWrapper.Info.Fields.at(componentField); if (fieldInfo.Type == "string") {
if (fieldInfo.Type == "string") { std::string& value = componentWrapper[componentField];
std::string& value = componentWrapper[componentField]; packet.WriteString(value);
packet.WriteString(value); } else {
} else { packet.WriteData(componentWrapper.Data + fieldInfo.Offset, fieldInfo.Stride);
packet.WriteData(componentWrapper.Data + fieldInfo.Offset, fieldInfo.Stride); }
} }
} }
} }
} }
// Go to to your children // Go to to your children
addChildrenToPacket(packet, childEntityID); addPlayersToPacket(packet, childEntityID);
} }
} }
void Server::addChildrenToPacket(Packet & packet, EntityID entityID) void Server::addChildrenToPacket(Packet & packet, EntityID entityID)
{ {
auto itPair = m_World->GetChildren(entityID); auto itPair = m_World->GetDirectChildren(entityID);
std::unordered_map<std::string, ComponentPool*> worldComponentPools = m_World->GetComponentPools(); std::unordered_map<std::string, ComponentPool*> worldComponentPools = m_World->GetComponentPools();
// Loop through every child // Loop through every child
for (auto it = itPair.first; it != itPair.second; it++) { for (auto it = itPair.first; it != itPair.second; it++) {
@@ -343,7 +344,7 @@ void Server::parseTCPConnect(Packet & packet)
// Read packet ID // Read packet ID
m_PreviousPacketID = m_PacketID; // Set previous packet id m_PreviousPacketID = m_PacketID; // Set previous packet id
m_PacketID = packet.ReadPrimitive<int>(); //Read new packet id m_PacketID = packet.ReadPrimitive<int>(); //Read new packet id
LOG_INFO("Parsing connections"); LOG_INFO("Parsing connections");
// Check if player is already connected // Check if player is already connected
// Ska vara till lagd i TCPServer receive // Ska vara till lagd i TCPServer receive
@@ -455,8 +456,7 @@ bool Server::OnInputCommand(const Events::InputCommand & e)
} }
isReadingData = !isReadingData; isReadingData = !isReadingData;
m_SaveDataTimer = std::clock(); m_SaveDataTimer = std::clock();
} } else if (e.Command == "KickPlayer" && e.Value > 0) {
else if (e.Command == "KickPlayer" && e.Value > 0) {
kick(0); kick(0);
} }
@@ -507,7 +507,7 @@ bool Server::OnPlayerDamage(const Events::PlayerDamage& e)
packet.WritePrimitive(e.Damage); packet.WritePrimitive(e.Damage);
reliableBroadcast(packet); reliableBroadcast(packet);
return false; return true;
} }
void Server::parseClientPing() void Server::parseClientPing()
@@ -536,6 +536,12 @@ void Server::parsePing()
} }
} }
bool Server::parseDoubleJump(Packet & packet)
{
reliableBroadcast(packet);
return true;
}
void Server::parseOnInputCommand(Packet& packet) void Server::parseOnInputCommand(Packet& packet)
{ {
PlayerID player = -1; PlayerID player = -1;
@@ -595,8 +601,15 @@ void Server::parsePlayerTransform(Packet& packet)
bool Server::shouldSendToClient(EntityWrapper childEntity) bool Server::shouldSendToClient(EntityWrapper childEntity)
{ {
auto children = m_World->GetDirectChildren(childEntity.ID);
for (auto it = children.first; it != children.second; it++) {
EntityWrapper child(m_World, it->second);
if(child.HasComponent("CapturePoint")) {
return true;
}
}
return childEntity.HasComponent("Player") || childEntity.FirstParentWithComponent("Player").Valid() return childEntity.HasComponent("Player") || childEntity.FirstParentWithComponent("Player").Valid()
|| childEntity.HasComponent("CapturePoint") || childEntity.FirstParentWithComponent("CapturePoint").Valid(); || childEntity.HasComponent("CapturePoint");
} }
PlayerID Server::GetPlayerIDFromEndpoint() PlayerID Server::GetPlayerIDFromEndpoint()
+17 -23
View File
@@ -4,6 +4,8 @@ using namespace boost::asio::ip;
TCPServer::TCPServer() TCPServer::TCPServer()
{ {
acceptor = std::unique_ptr<tcp::acceptor>(new tcp::acceptor(m_IOService, tcp::endpoint(tcp::v4(), 27666))); acceptor = std::unique_ptr<tcp::acceptor>(new tcp::acceptor(m_IOService, tcp::endpoint(tcp::v4(), 27666)));
// Make the acceptor non-blocking so we wont get stuck in AcceptNewConnections().
acceptor->non_blocking(true);
m_Port = GetPort(); m_Port = GetPort();
m_Address = GetAddress(); m_Address = GetAddress();
} }
@@ -13,14 +15,24 @@ TCPServer::~TCPServer()
void TCPServer::AcceptNewConnections(int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers) void TCPServer::AcceptNewConnections(int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers)
{ {
boost::system::error_code error;
boost::shared_ptr<tcp::socket> newSocket = boost::shared_ptr<tcp::socket>(new tcp::socket(m_IOService)); boost::shared_ptr<tcp::socket> newSocket = boost::shared_ptr<tcp::socket>(new tcp::socket(m_IOService));
m_IOService.poll(); acceptor->accept(*newSocket, error);
acceptor->async_accept(*newSocket, // If no error occured add new tcp connection
boost::bind(&TCPServer::handle_accept, this, newSocket, boost::ref(nextPlayerID), boost::ref(connectedPlayers), if (!error) {
boost::asio::placeholders::error)); // Add tcp socket to connections
boost::asio::ip::tcp::no_delay option(true);
newSocket->set_option(option);
PlayerDefinition pd;
pd.StopTime = std::clock();
pd.TCPSocket = newSocket;
pd.TCPAddress = newSocket.get()->remote_endpoint().address();
pd.TCPPort = newSocket.get()->remote_endpoint().port();
connectedPlayers[nextPlayerID++] = pd;
}
} }
PlayerID GetPlayerIDFromEndpoint(const std::map<PlayerID, PlayerDefinition>& connectedPlayers, PlayerID TCPServer::getPlayerIDFromEndpoint(const std::map<PlayerID, PlayerDefinition>& connectedPlayers,
boost::asio::ip::address address, unsigned short port) boost::asio::ip::address address, unsigned short port)
{ {
for (auto& kv : connectedPlayers) { for (auto& kv : connectedPlayers) {
@@ -32,24 +44,6 @@ PlayerID GetPlayerIDFromEndpoint(const std::map<PlayerID, PlayerDefinition>& con
return -1; return -1;
} }
void TCPServer::handle_accept(boost::shared_ptr<tcp::socket> socket,
int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers,
const boost::system::error_code& error)
{
if (!error && GetPlayerIDFromEndpoint(connectedPlayers, socket->remote_endpoint().address(),
socket->remote_endpoint().port()) == -1) {
// Add tcp socket to connections
boost::asio::ip::tcp::no_delay option(true);
socket->set_option(option);
PlayerDefinition pd;
pd.StopTime = std::clock();
pd.TCPSocket = socket;
pd.TCPAddress = socket.get()->remote_endpoint().address();
pd.TCPPort = socket.get()->remote_endpoint().port();
connectedPlayers[nextPlayerID++] = pd;
}
}
void TCPServer::Send(Packet & packet, PlayerDefinition & playerDefinition) void TCPServer::Send(Packet & packet, PlayerDefinition & playerDefinition)
{ {
packet.UpdateSize(); packet.UpdateSize();
+1
View File
@@ -17,6 +17,7 @@ void CubeMapPass::LoadTextures(std::string input)
m_CubeMapTextures.push_back(img); m_CubeMapTextures.push_back(img);
} }
GenerateCubeMapTexture(); GenerateCubeMapTexture();
m_PreviusCubeMapTexture = input;
} }
} }
+59 -33
View File
@@ -1,19 +1,41 @@
#include "Rendering/DrawBloomPass.h" #include "Rendering/DrawBloomPass.h"
DrawBloomPass::DrawBloomPass(IRenderer* renderer) DrawBloomPass::DrawBloomPass(IRenderer* renderer, ConfigFile* config)
: m_Renderer(renderer)
, m_Config(config)
{ {
m_Renderer = renderer; InitializeTextures();
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh"); ChangeQuality(m_Config->Get<int>("GLOW.Quality", 2));
InitializeTextures();
InitializeBuffers();
InitializeShaderPrograms();
} }
void DrawBloomPass::InitializeTextures() void DrawBloomPass::InitializeTextures()
{ {
m_WhiteTexture = CommonFunctions::LoadTexture("Textures/Core/White.png", false); m_BlackTexture = CommonFunctions::LoadTexture("Textures/Core/Black.png", false);
}
void DrawBloomPass::ChangeQuality(int quality)
{
if (m_Quality == quality) {
return;
}
m_Quality = quality;
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh");
if (m_Quality == 0) {
CommonFunctions::DeleteTexture(&m_GaussianTexture_horiz);
CommonFunctions::DeleteTexture(&m_GaussianTexture_vert);
m_GaussianTexture_horiz = 0;
m_GaussianTexture_vert = 0;
return;
}
InitializeTextures();
InitializeBuffers();
InitializeShaderPrograms();
std::string qStr = std::to_string(m_Quality);
m_Iterations = m_Config->Get<float>("GLOW" + qStr + ".NumIterations", 0);
} }
void DrawBloomPass::InitializeShaderPrograms() void DrawBloomPass::InitializeShaderPrograms()
@@ -35,37 +57,45 @@ void DrawBloomPass::InitializeShaderPrograms()
} }
} }
void DrawBloomPass::InitializeBuffers() void DrawBloomPass::InitializeBuffers()
{ {
GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); CommonFunctions::GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0))); if (m_GaussianFrameBuffer_horiz.GetHandle() == 0) {
m_GaussianFrameBuffer_horiz.Generate(); m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0)));
}
m_GaussianFrameBuffer_horiz.Generate();
GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); CommonFunctions::GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
if (m_GaussianFrameBuffer_vert.GetHandle() == 0) {
m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0))); m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0)));
m_GaussianFrameBuffer_vert.Generate(); }
m_GaussianFrameBuffer_vert.Generate();
} }
void DrawBloomPass::ClearBuffer() void DrawBloomPass::ClearBuffer()
{ {
if (m_Quality == 0) {
return;
}
GLERROR("PRE"); GLERROR("PRE");
m_GaussianFrameBuffer_horiz.Bind(); m_GaussianFrameBuffer_horiz.Bind();
glClearColor(0.f, 0.f, 0.f, 0.f); glClearColor(0.f, 0.f, 0.f, 0.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
m_GaussianFrameBuffer_horiz.Unbind(); m_GaussianFrameBuffer_horiz.Unbind();
m_GaussianFrameBuffer_vert.Bind(); m_GaussianFrameBuffer_vert.Bind();
glClearColor(0.f, 0.f, 0.f, 0.f); glClearColor(0.f, 0.f, 0.f, 0.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
m_GaussianFrameBuffer_vert.Unbind(); m_GaussianFrameBuffer_vert.Unbind();
GLERROR("END"); GLERROR("END");
} }
void DrawBloomPass::Draw(GLuint texture) void DrawBloomPass::Draw(GLuint texture)
{ {
if (m_Quality == 0) {
return;
}
GLERROR("DrawBloomPass::Draw: Pre"); GLERROR("DrawBloomPass::Draw: Pre");
DrawBloomPassState state; DrawBloomPassState state;
@@ -84,11 +114,12 @@ void DrawBloomPass::Draw(GLuint texture)
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1 glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
//Iterate some times to make it more gaussian. //Iterate some times to make it more gaussian.
for (int i = 1; i < m_iterations; i++) { for (int i = 1; i < m_Iterations; i++) {
//Vertical pass //Vertical pass
m_GaussianFrameBuffer_vert.Bind(); m_GaussianFrameBuffer_vert.Bind();
m_GaussianProgram_vert->Bind(); m_GaussianProgram_vert->Bind();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz); glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz);
glBindVertexArray(m_ScreenQuad->VAO); glBindVertexArray(m_ScreenQuad->VAO);
@@ -96,16 +127,19 @@ void DrawBloomPass::Draw(GLuint texture)
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1 glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
//horizontal pass //horizontal pass
m_GaussianFrameBuffer_vert.Unbind();
m_GaussianFrameBuffer_horiz.Bind(); m_GaussianFrameBuffer_horiz.Bind();
m_GaussianProgram_horiz->Bind(); m_GaussianProgram_horiz->Bind();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_vert); glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_vert);
glBindVertexArray(m_ScreenQuad->VAO); glBindVertexArray(m_ScreenQuad->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1 glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
m_GaussianFrameBuffer_horiz.Unbind();
} }
//final vertical gaussian after the iterations are done //final vertical gaussian after the iterations are done
@@ -113,6 +147,7 @@ void DrawBloomPass::Draw(GLuint texture)
m_GaussianFrameBuffer_vert.Bind(); m_GaussianFrameBuffer_vert.Bind();
m_GaussianProgram_vert->Bind(); m_GaussianProgram_vert->Bind();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz); glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz);
glBindVertexArray(m_ScreenQuad->VAO); glBindVertexArray(m_ScreenQuad->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
@@ -125,20 +160,11 @@ void DrawBloomPass::Draw(GLuint texture)
void DrawBloomPass::OnWindowResize() void DrawBloomPass::OnWindowResize()
{ {
GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); if (m_Quality == 0) {
return;
}
CommonFunctions::GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
m_GaussianFrameBuffer_vert.Generate(); m_GaussianFrameBuffer_vert.Generate();
GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); CommonFunctions::GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
m_GaussianFrameBuffer_horiz.Generate(); m_GaussianFrameBuffer_horiz.Generate();
} }
void DrawBloomPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
{
glGenTextures(1, texture);
glBindTexture(GL_TEXTURE_2D, *texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, dimensions.x, dimensions.y, 0, format, type, nullptr);//TODO: Renderer: Fix the precision and Resolution
GLERROR("Texture initialization failed");
}
+38 -67
View File
@@ -1,9 +1,10 @@
#include "Rendering/DrawFinalPass.h" #include "Rendering/DrawFinalPass.h"
DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass, GLuint* depthBuffer)
DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass) : m_Renderer(renderer)
: m_Renderer(renderer) , m_LightCullingPass(lightCullingPass)
, m_LightCullingPass(lightCullingPass) , m_CubeMapPass(cubeMapPass)
, m_CubeMapPass(cubeMapPass) , m_SSAOPass(ssaoPass)
, m_DepthBuffer(depthBuffer)
{ {
//TODO: Make sure that uniforms are not sent into shader if not needed. //TODO: Make sure that uniforms are not sent into shader if not needed.
m_ShieldPixelRate = 8; m_ShieldPixelRate = 8;
@@ -23,19 +24,13 @@ void DrawFinalPass::InitializeTextures()
void DrawFinalPass::InitializeFrameBuffers() void DrawFinalPass::InitializeFrameBuffers()
{ {
glGenRenderbuffers(1, &m_DepthBuffer); CommonFunctions::GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
GLERROR("RenderBuffer generation");
GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
//GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); //GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); CommonFunctions::GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
//GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_FLOAT, 4); //GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_FLOAT, 4);
//GenerateTexture(&m_StencilTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_STENCIL, GL_STENCIL_INDEX8, GL_INT); //GenerateTexture(&m_StencilTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_STENCIL, GL_STENCIL_INDEX8, GL_INT);
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new RenderBuffer(&m_DepthBuffer, GL_DEPTH_STENCIL_ATTACHMENT))); m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(m_DepthBuffer, GL_DEPTH_STENCIL_ATTACHMENT)));
//m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_StencilTexture, GL_STENCIL_ATTACHMENT))); //m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_StencilTexture, GL_STENCIL_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_SceneTexture, GL_COLOR_ATTACHMENT0)));
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_BloomTexture, GL_COLOR_ATTACHMENT1))); m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_BloomTexture, GL_COLOR_ATTACHMENT1)));
@@ -47,9 +42,9 @@ void DrawFinalPass::InitializeFrameBuffers()
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, (int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, (int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate));
GLERROR("RenderBufferLowRes generation"); GLERROR("RenderBufferLowRes generation");
GenerateTexture(&m_SceneTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT); CommonFunctions::GenerateTexture(&m_SceneTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT);
//GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); //GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
GenerateTexture(&m_BloomTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT); CommonFunctions::GenerateTexture(&m_BloomTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT);
//GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_FLOAT, 4); //GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_FLOAT, 4);
//GenerateTexture(&m_StencilTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_STENCIL, GL_STENCIL_INDEX8, GL_INT); //GenerateTexture(&m_StencilTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_STENCIL, GL_STENCIL_INDEX8, GL_INT);
@@ -162,27 +157,26 @@ void DrawFinalPass::InitializeShaderPrograms()
m_FillDepthBufferProgram = ResourceManager::Load<ShaderProgram>("#FillDepthBufferProgram"); m_FillDepthBufferProgram = ResourceManager::Load<ShaderProgram>("#FillDepthBufferProgram");
m_FillDepthBufferProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/FillDepthBuffer.vert.glsl"))); m_FillDepthBufferProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/FillDepthBuffer.vert.glsl")));
m_FillDepthBufferProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/FillDepthBuffer.frag.glsl"))); //m_FillDepthBufferProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/FillDepthBuffer.frag.glsl")));
m_FillDepthBufferProgram->Compile(); m_FillDepthBufferProgram->Compile();
m_FillDepthBufferProgram->Link(); m_FillDepthBufferProgram->Link();
GLERROR("Creating DepthFill program"); GLERROR("Creating DepthFill program");
m_FillDepthBufferSkinnedProgram = ResourceManager::Load<ShaderProgram>("#FillDepthBufferProgramSkinned"); m_FillDepthBufferSkinnedProgram = ResourceManager::Load<ShaderProgram>("#FillDepthBufferProgramSkinned");
m_FillDepthBufferSkinnedProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/FillDepthBufferSkinned.vert.glsl"))); m_FillDepthBufferSkinnedProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/FillDepthBufferSkinned.vert.glsl")));
m_FillDepthBufferSkinnedProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/FillDepthBuffer.frag.glsl"))); //m_FillDepthBufferSkinnedProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/FillDepthBuffer.frag.glsl")));
m_FillDepthBufferSkinnedProgram->Compile(); m_FillDepthBufferSkinnedProgram->Compile();
m_FillDepthBufferSkinnedProgram->Link(); m_FillDepthBufferSkinnedProgram->Link();
GLERROR("Creating DepthFill program"); GLERROR("Creating DepthFill program");
} }
void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture) void DrawFinalPass::Draw(RenderScene& scene)
{ {
GLERROR("Pre"); GLERROR("Pre");
DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle()); DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle());
if (scene.ClearDepth) { if (scene.ClearDepth) {
//glClear(GL_DEPTH_BUFFER_BIT); //glClear(GL_DEPTH_BUFFER_BIT);
state->Disable(GL_DEPTH_TEST); state->Disable(GL_DEPTH_TEST);
state->DepthMask(GL_FALSE);
} }
//TODO: Do we need check for this or will it be per scene always? //TODO: Do we need check for this or will it be per scene always?
glClearStencil(0x00); glClearStencil(0x00);
@@ -191,12 +185,15 @@ void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture)
//Fill depth buffer //Fill depth buffer
state->StencilMask(0x00); state->StencilMask(0x00);
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene, SSAOTexture); DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
GLERROR("OpaqueObjects"); GLERROR("OpaqueObjects");
state->BlendFunc(GL_ONE, GL_ONE); //state->BlendFunc(GL_ONE, GL_ONE);
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene, SSAOTexture);
GLERROR("TransparentObjects");
state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
GLERROR("TransparentObjects");
//state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
DrawSprites(scene.Jobs.SpriteJob, scene); DrawSprites(scene.Jobs.SpriteJob, scene);
GLERROR("SpriteJobs"); GLERROR("SpriteJobs");
@@ -210,11 +207,11 @@ void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture)
//Draw Opaque shielded objects //Draw Opaque shielded objects
state->StencilFunc(GL_NOTEQUAL, 1, 0xFF); state->StencilFunc(GL_NOTEQUAL, 1, 0xFF);
state->StencilMask(0x00); state->StencilMask(0x00);
DrawModelRenderQueues(scene.Jobs.OpaqueShieldedObjects, scene, SSAOTexture); //might need changing DrawModelRenderQueues(scene.Jobs.OpaqueShieldedObjects, scene); //might need changing
GLERROR("Shielded Opaque object"); GLERROR("Shielded Opaque object");
//Draw Transparen Shielded objects //Draw Transparen Shielded objects
DrawModelRenderQueues(scene.Jobs.TransparentShieldedObjects, scene, SSAOTexture); //might need changing DrawModelRenderQueues(scene.Jobs.TransparentShieldedObjects, scene); //might need changing
GLERROR("Shielded Transparent objects"); GLERROR("Shielded Transparent objects");
GLERROR("END"); GLERROR("END");
@@ -250,9 +247,9 @@ void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture)
stateLowRes->Enable(GL_DEPTH_TEST); stateLowRes->Enable(GL_DEPTH_TEST);
stateLowRes->StencilFunc(GL_LEQUAL, 1, 0xFF); stateLowRes->StencilFunc(GL_LEQUAL, 1, 0xFF);
stateLowRes->StencilMask(0x00); stateLowRes->StencilMask(0x00);
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene, SSAOTexture); DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
GLERROR("OpaqueObjects"); GLERROR("OpaqueObjects");
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene, SSAOTexture); DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
GLERROR("TransparentObjects"); GLERROR("TransparentObjects");
glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
@@ -273,7 +270,7 @@ void DrawFinalPass::ClearBuffer()
glClearColor(0.f, 0.f, 0.f, 0.f); glClearColor(0.f, 0.f, 0.f, 0.f);
GLERROR("1"); GLERROR("1");
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
GLERROR("2"); GLERROR("2");
glDisable(GL_SCISSOR_TEST); glDisable(GL_SCISSOR_TEST);
@@ -288,7 +285,7 @@ void DrawFinalPass::ClearBuffer()
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
GLERROR("ViewPort,Scissor LowRes"); GLERROR("ViewPort,Scissor LowRes");
glClearColor(0.f, 0.f, 0.f, 0.f); glClearColor(0.f, 0.f, 0.f, 0.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
m_FinalPassFrameBuffer.Unbind(); m_FinalPassFrameBuffer.Unbind();
GLERROR("END"); GLERROR("END");
} }
@@ -297,50 +294,22 @@ void DrawFinalPass::ClearBuffer()
void DrawFinalPass::OnWindowResize() void DrawFinalPass::OnWindowResize()
{ {
//InitializeFrameBuffers(); //InitializeFrameBuffers();
glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); CommonFunctions::GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); CommonFunctions::GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
m_FinalPassFrameBuffer.Generate(); m_FinalPassFrameBuffer.Generate();
glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBufferLowRes); glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBufferLowRes);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, (int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, (int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate));
GenerateTexture(&m_SceneTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT); CommonFunctions::GenerateTexture(&m_SceneTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT);
GenerateTexture(&m_BloomTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT); CommonFunctions::GenerateTexture(&m_BloomTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT);
m_FinalPassFrameBufferLowRes.Generate(); m_FinalPassFrameBufferLowRes.Generate();
GLERROR("Error changing texture resolutions"); GLERROR("Error changing texture resolutions");
} }
void DrawFinalPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
{
glGenTextures(1, texture);
glBindTexture(GL_TEXTURE_2D, *texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, dimensions.x, dimensions.y, 0, format, type, nullptr);//TODO: Renderer: Fix the precision and Resolution
GLERROR("Texture initialization failed");
}
void DrawFinalPass::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const
{
glGenTextures(1, texture);
glBindTexture(GL_TEXTURE_2D, *texture);
glTexStorage2D(GL_TEXTURE_2D, numMipMaps, GL_RGBA8, dimensions.x, dimensions.y);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, dimensions.x, dimensions.y, format, type, texture);
glGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping);
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>>& jobs, RenderScene& scene, GLuint SSAOTexture)
{ {
GLuint forwardHandle = m_ForwardPlusProgram->GetHandle(); GLuint forwardHandle = m_ForwardPlusProgram->GetHandle();
GLERROR("forwardHandle"); GLERROR("forwardHandle");
@@ -364,7 +333,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO()); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO());
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, SSAOTexture); glBindTexture(GL_TEXTURE_2D, m_SSAOPass->SSAOTexture());
for (auto &job : jobs) { for (auto &job : jobs) {
auto explosionEffectJob = std::dynamic_pointer_cast<ExplosionEffectJob>(job); auto explosionEffectJob = std::dynamic_pointer_cast<ExplosionEffectJob>(job);
@@ -383,7 +352,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob); BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob);
glActiveTexture(GL_TEXTURE5); glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); glUniform3fv(glGetUniformLocation(explosionSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
std::vector<glm::mat4> frameBones; std::vector<glm::mat4> frameBones;
if (explosionEffectJob->AnimationOffset.animation != nullptr) { if (explosionEffectJob->AnimationOffset.animation != nullptr) {
@@ -401,7 +370,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
BindExplosionTextures(explosionHandle, explosionEffectJob); BindExplosionTextures(explosionHandle, explosionEffectJob);
glActiveTexture(GL_TEXTURE5); glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); glUniform3fv(glGetUniformLocation(explosionHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
} }
break; break;
@@ -463,7 +432,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
BindModelTextures(forwardSkinnedHandle, modelJob); BindModelTextures(forwardSkinnedHandle, modelJob);
glActiveTexture(GL_TEXTURE5); glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); glUniform3fv(glGetUniformLocation(forwardSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
std::vector<glm::mat4> frameBones; std::vector<glm::mat4> frameBones;
if (modelJob->AnimationOffset.animation != nullptr) { if (modelJob->AnimationOffset.animation != nullptr) {
@@ -753,6 +722,7 @@ void DrawFinalPass::DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, Rend
void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene) void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene)
{ {
glUniform1i(glGetUniformLocation(shaderHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
GLERROR("Bind 1 uniform"); GLERROR("Bind 1 uniform");
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix)); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix));
GLERROR("Bind 2 uniform"); GLERROR("Bind 2 uniform");
@@ -801,6 +771,7 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<E
void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene) void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene)
{ {
glUniform1i(glGetUniformLocation(shaderHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
GLERROR("Bind 1 uniform"); GLERROR("Bind 1 uniform");
GLint Location_M = glGetUniformLocation(shaderHandle, "M"); GLint Location_M = glGetUniformLocation(shaderHandle, "M");
glUniformMatrix4fv(Location_M, 1, GL_FALSE, glm::value_ptr(job->Matrix)); glUniformMatrix4fv(Location_M, 1, GL_FALSE, glm::value_ptr(job->Matrix));
@@ -8,6 +8,8 @@ DrawFinalPassState::DrawFinalPassState(GLuint frameBuffer)
Enable(GL_BLEND); Enable(GL_BLEND);
BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Enable(GL_DEPTH_TEST); Enable(GL_DEPTH_TEST);
DepthMask(GL_FALSE);
DepthFunc(GL_LEQUAL);
Enable(GL_CULL_FACE); Enable(GL_CULL_FACE);
Enable(GL_STENCIL_TEST); Enable(GL_STENCIL_TEST);
StencilFunc(GL_NOTEQUAL, 1, 0xFF); StencilFunc(GL_NOTEQUAL, 1, 0xFF);
+21 -21
View File
@@ -42,33 +42,33 @@ void FrameBuffer::Generate()
GLERROR("PRE"); GLERROR("PRE");
std::vector<GLenum> attachments; std::vector<GLenum> attachments;
if (m_BufferHandle == 0) {
glGenFramebuffers(1, &m_BufferHandle); glGenFramebuffers(1, &m_BufferHandle);
}
glBindFramebuffer(GL_FRAMEBUFFER, m_BufferHandle); glBindFramebuffer(GL_FRAMEBUFFER, m_BufferHandle);
GLERROR("1"); GLERROR("1");
for (auto it = m_Resources.begin(); it != m_Resources.end(); it++) { for (auto it = m_Resources.begin(); it != m_Resources.end(); it++) {
switch ((*it)->m_ResourceType) { switch ((*it)->m_ResourceType) {
case GL_TEXTURE_2D: case GL_TEXTURE_2D:
glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle, 0);
GLERROR("FrameBuffer generate: glFramebufferTexture2D"); GLERROR("FrameBuffer generate: glFramebufferTexture2D");
break; break;
case GL_RENDERBUFFER: case GL_RENDERBUFFER:
glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle); glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle);
GLERROR("FrameBuffer generate: glFramebufferRenderbuffer"); GLERROR("FrameBuffer generate: glFramebufferRenderbuffer");
break; break;
} }
GLERROR("2"); GLERROR("2");
if ((*it)->m_Attachment != GL_DEPTH_ATTACHMENT && (*it)->m_Attachment != GL_STENCIL_ATTACHMENT && (*it)->m_Attachment != GL_DEPTH_STENCIL_ATTACHMENT) { if ((*it)->m_Attachment != GL_DEPTH_ATTACHMENT && (*it)->m_Attachment != GL_STENCIL_ATTACHMENT && (*it)->m_Attachment != GL_DEPTH_STENCIL_ATTACHMENT) {
attachments.push_back((*it)->m_Attachment); attachments.push_back((*it)->m_Attachment);
} }
GLERROR("Attachment"); GLERROR("Attachment");
}
GLERROR("3");
}
GLERROR("3");
GLenum* bufferTextures = &attachments[0]; GLenum* bufferTextures = &attachments[0];
glDrawBuffers(attachments.size(), bufferTextures); glDrawBuffers(attachments.size(), bufferTextures);
+3 -16
View File
@@ -19,10 +19,10 @@ PickingPass::~PickingPass()
void PickingPass::InitializeTextures() void PickingPass::InitializeTextures()
{ {
GenerateTexture(&m_PickingTexture, GL_CLAMP_TO_BORDER, GL_LINEAR, CommonFunctions::GenerateTexture(&m_PickingTexture, GL_CLAMP_TO_BORDER, GL_LINEAR,
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RG8, GL_RG, GL_UNSIGNED_BYTE); glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RG8, GL_RG, GL_UNSIGNED_BYTE);
GenerateTexture(&m_DepthBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST, CommonFunctions::GenerateTexture(&m_DepthBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST,
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8); glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
} }
@@ -366,7 +366,7 @@ void PickingPass::ClearPicking()
m_PickingBuffer.Bind(); m_PickingBuffer.Bind();
glClearColor(0.f, 0.f, 0.f, 0.f); glClearColor(0.f, 0.f, 0.f, 0.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
m_PickingBuffer.Unbind(); m_PickingBuffer.Unbind();
GLERROR("END"); GLERROR("END");
} }
@@ -407,16 +407,3 @@ PickData PickingPass::Pick(glm::vec2 screenCoord)
pickData.World = pickInfo.World; pickData.World = pickInfo.World;
return pickData; return pickData;
} }
void PickingPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
{
//TODO: Renderer: Make this in a sparate class
glGenTextures(1, texture);
glBindTexture(GL_TEXTURE_2D, *texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, dimensions.x, dimensions.y, 0, format, type, nullptr);//TODO: Renderer: Fix the precision and Resolution
GLERROR("Texture initialization failed");
}
+1 -1
View File
@@ -9,11 +9,11 @@ PickingPassState::PickingPassState(GLuint frameBuffer)
Enable(GL_DEPTH_TEST); Enable(GL_DEPTH_TEST);
Enable(GL_CULL_FACE); Enable(GL_CULL_FACE);
Disable(GL_BLEND); Disable(GL_BLEND);
glm::vec4 clearColor = glm::vec4(0.f); glm::vec4 clearColor = glm::vec4(0.f);
//ClearColor(clearColor); //ClearColor(clearColor);
//Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
GLERROR("END"); GLERROR("END");
} }
PickingPassState::~PickingPassState() PickingPassState::~PickingPassState()
+20
View File
@@ -135,6 +135,26 @@ bool RenderState::DepthMask(GLboolean flag)
return !GLERROR("DepthMask"); return !GLERROR("DepthMask");
} }
bool RenderState::DepthFunc(GLenum func)
{
GLint original;
glGetIntegerv(GL_DEPTH_FUNC, &original);
m_ResetFunctions.push_back(std::bind(glDepthFunc, original));
glDepthFunc(func);
return !GLERROR("DepthFunc");
}
bool RenderState::AlphaFunc(GLenum func, GLclampf thresholder)
{
GLint originalFunc;
glGetIntegerv(GL_ALPHA_TEST_FUNC, &originalFunc);
GLint originalRef;
glGetIntegerv(GL_ALPHA_TEST_REF, &originalRef);
m_ResetFunctions.push_back(std::bind(glAlphaFunc, originalFunc, originalRef));
glAlphaFunc(func, thresholder);
return !GLERROR("AlphaFunc");
}
RenderState::~RenderState() RenderState::~RenderState()
{ {
for (auto& f : boost::adaptors::reverse(m_ResetFunctions)) { for (auto& f : boost::adaptors::reverse(m_ResetFunctions)) {
+26 -24
View File
@@ -4,6 +4,8 @@ std::unordered_map<GLFWwindow*, Renderer*> Renderer::m_WindowToRenderer;
void Renderer::Initialize() void Renderer::Initialize()
{ {
m_SSAO_Quality = m_Config->Get<int>("SSAO.Quality", 0);
m_GLOW_Quality = m_Config->Get<int>("GLOW.Quality", 0);
InitializeWindow(); InitializeWindow();
InitializeRenderPasses(); InitializeRenderPasses();
@@ -26,9 +28,9 @@ void Renderer::glfwFrameBufferCallback(GLFWwindow* window, int width, int height
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
Renderer* currentRenderer = m_WindowToRenderer[window]; Renderer* currentRenderer = m_WindowToRenderer[window];
currentRenderer->m_ViewportSize = Rectangle(width, height); currentRenderer->m_ViewportSize = Rectangle(width, height);
currentRenderer->m_PickingPass->OnWindowResize();
currentRenderer->m_DrawFinalPass->OnWindowResize(); currentRenderer->m_DrawFinalPass->OnWindowResize();
currentRenderer->m_LightCullingPass->OnWindowResize(); currentRenderer->m_LightCullingPass->OnWindowResize();
currentRenderer->m_PickingPass->OnWindowResize();
currentRenderer->m_DrawBloomPass->OnWindowResize(); currentRenderer->m_DrawBloomPass->OnWindowResize();
currentRenderer->m_SSAOPass->OnWindowResize(); currentRenderer->m_SSAOPass->OnWindowResize();
} }
@@ -107,6 +109,7 @@ void Renderer::Update(double dt)
void Renderer::Draw(RenderFrame& frame) void Renderer::Draw(RenderFrame& frame)
{ {
GLERROR("PRE"); GLERROR("PRE");
glBindFramebuffer(GL_FRAMEBUFFER, 0);
ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking\0Ambient Occlusion"); ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking\0Ambient Occlusion");
ImGui::Combo("CubeMap", &m_CubeMapTexture, "Nevada(512)\0Sky(1024)"); ImGui::Combo("CubeMap", &m_CubeMapTexture, "Nevada(512)\0Sky(1024)");
if(m_CubeMapTexture == 0) { if(m_CubeMapTexture == 0) {
@@ -115,19 +118,16 @@ void Renderer::Draw(RenderFrame& frame)
m_CubeMapPass->LoadTextures("Sky"); m_CubeMapPass->LoadTextures("Sky");
} }
ImGui::SliderFloat("SSAO sample radius", &m_SSAO_Radius, 0.01f, 5.0f); ImGui::SliderInt("SSAO Quality", &m_SSAO_Quality, 0, 3);
ImGui::SliderFloat("SSAO bias", &m_SSAO_Bias, 0.0f, 0.1f); ImGui::SliderInt("Glow Quality", &m_GLOW_Quality, 0, 3);
ImGui::SliderFloat("SSAO contrast", &m_SSAO_Contrast, 0.0f, 10.0f); m_SSAOPass->ChangeQuality(m_SSAO_Quality);
ImGui::SliderFloat("SSAO IntensityScale", &m_SSAO_IntensityScale, 0.0f, 10.0f); m_DrawBloomPass->ChangeQuality(m_GLOW_Quality);
ImGui::SliderInt("SSAO Number of Samples", &m_SSAO_NumOfSamples, 2, 100);
ImGui::SliderInt("SSAO Number of Turns", &m_SSAO_NumOfTurns, 0, 50);
m_SSAOPass->Setting(m_SSAO_Radius, m_SSAO_Bias, m_SSAO_Contrast, m_SSAO_IntensityScale, m_SSAO_NumOfSamples, m_SSAO_NumOfTurns);
GLERROR("SSAO Settings"); GLERROR("SSAO Settings");
//clear buffer 0 //clear buffer 0
glClearColor(0.f, 0.f, 0.f, 0.f); glClearColor(0.f, 0.f, 0.f, 0.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//Clear other buffers //Clear other buffers
PerformanceTimer::StartTimer("Renderer-ClearBuffers"); PerformanceTimer::StartTimer("Renderer-ClearBuffers");
m_PickingPass->ClearPicking(); m_PickingPass->ClearPicking();
m_DrawFinalPass->ClearBuffer(); m_DrawFinalPass->ClearBuffer();
@@ -136,18 +136,16 @@ void Renderer::Draw(RenderFrame& frame)
PerformanceTimer::StopTimer("Renderer-ClearBuffers"); PerformanceTimer::StopTimer("Renderer-ClearBuffers");
GLERROR("ClearBuffers"); GLERROR("ClearBuffers");
for (auto scene : frame.RenderScenes) { for (auto scene : frame.RenderScenes) {
PerformanceTimer::StartTimer("Renderer-Depth"); PerformanceTimer::StartTimer("Renderer-PickingPass");
m_PickingPass->Draw(*scene); m_PickingPass->Draw(*scene);
GLERROR("Drawing pickingpass"); GLERROR("Drawing pickingpass");
PerformanceTimer::StopTimer("Renderer-Depth"); PerformanceTimer::StopTimer("Renderer-PickingPass");
} }
PerformanceTimer::StartTimer("AO generation"); PerformanceTimer::StartTimer("Renderer-AO generation");
m_SSAOPass->Draw(m_PickingPass->DepthBuffer(), frame.RenderScenes.front()->Camera); m_SSAOPass->Draw(*m_PickingPass->DepthBuffer(), frame.RenderScenes.front()->Camera);
GLuint ao = m_SSAOPass->SSAOTexture(); PerformanceTimer::StopTimer("Renderer-AO generation");
PerformanceTimer::StopTimer("AO generation");
for (auto scene : frame.RenderScenes){ for (auto scene : frame.RenderScenes){
PerformanceTimer::StartTimer("Renderer-Depth");
PerformanceTimer::StartTimer("Renderer-Drawing PickingPass");
SortRenderJobsByDepth(*scene); SortRenderJobsByDepth(*scene);
GLERROR("SortByDepth"); GLERROR("SortByDepth");
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Generate Frustrums"); PerformanceTimer::StartTimerAndStopPrevious("Renderer-Generate Frustrums");
@@ -159,8 +157,8 @@ void Renderer::Draw(RenderFrame& frame)
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Light Culling"); PerformanceTimer::StartTimerAndStopPrevious("Renderer-Light Culling");
m_LightCullingPass->CullLights(*scene); m_LightCullingPass->CullLights(*scene);
GLERROR("LightCulling"); GLERROR("LightCulling");
m_DrawFinalPass->Draw(*scene, ao); PerformanceTimer::StartTimerAndStopPrevious("Renderer-Draw Geometry+Light");
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Draw Geometry+Light"); m_DrawFinalPass->Draw(*scene);
GLERROR("Draw Geometry+Light"); GLERROR("Draw Geometry+Light");
//m_DrawScenePass->Draw(*scene); //m_DrawScenePass->Draw(*scene);
@@ -207,8 +205,11 @@ void Renderer::Draw(RenderFrame& frame)
PerformanceTimer::StartTimer("Renderer-ImGuiRenderPass"); PerformanceTimer::StartTimer("Renderer-ImGuiRenderPass");
m_ImGuiRenderPass->Draw(); m_ImGuiRenderPass->Draw();
GLERROR("Imgui draw"); GLERROR("Imgui draw");
PerformanceTimer::StopTimer("Renderer-ImGuiRenderPass");
PerformanceTimer::StartTimer("Renderer-SwapBuffer");
glfwSwapBuffers(m_Window); glfwSwapBuffers(m_Window);
PerformanceTimer::StopTimer("Renderer-ImGuiRenderPass"); PerformanceTimer::StopTimer("Renderer-SwapBuffer");
} }
PickData Renderer::Pick(glm::vec2 screenCoord) PickData Renderer::Pick(glm::vec2 screenCoord)
@@ -248,9 +249,10 @@ void Renderer::InitializeRenderPasses()
m_PickingPass = new PickingPass(this, m_EventBroker); m_PickingPass = new PickingPass(this, m_EventBroker);
m_LightCullingPass = new LightCullingPass(this); m_LightCullingPass = new LightCullingPass(this);
m_CubeMapPass = new CubeMapPass(this); m_CubeMapPass = new CubeMapPass(this);
m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass); m_SSAOPass = new SSAOPass(this, m_Config);
m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass, m_SSAOPass, m_PickingPass->DepthBuffer());
m_DrawScreenQuadPass = new DrawScreenQuadPass(this); m_DrawScreenQuadPass = new DrawScreenQuadPass(this);
m_DrawBloomPass = new DrawBloomPass(this); m_DrawBloomPass = new DrawBloomPass(this, m_Config);
m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this); m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this);
m_SSAOPass = new SSAOPass(this);
} }
+184 -41
View File
@@ -1,84 +1,168 @@
#include "Rendering/SSAOPass.h" #include "Rendering/SSAOPass.h"
SSAOPass::SSAOPass(IRenderer* renderer) SSAOPass::SSAOPass(IRenderer* renderer, ConfigFile* config)
: m_Renderer(renderer)
, m_Config(config)
{ {
m_Renderer = renderer; m_WhiteTexture = CommonFunctions::LoadTexture("Textures/Core/White.png", false);
ChangeQuality(m_Config->Get<int>("SSAO.Quality", 0));
}
void SSAOPass::ChangeQuality(int quality)
{
if (m_Quality == quality) {
return;
}
m_Quality = quality;
if (m_Quality == 0) {
CommonFunctions::DeleteTexture(&m_SSAOTexture);
CommonFunctions::DeleteTexture(&m_SSAOViewSpaceZTexture);
CommonFunctions::DeleteTexture(&m_Gaussian_horiz);
CommonFunctions::DeleteTexture(&m_Gaussian_vert);
return;
}
std::string qStr = std::to_string(m_Quality);
Setting(
m_Config->Get<float>("SSAO" + qStr + ".Radius", 0.01),
m_Config->Get<float>("SSAO" + qStr + ".Bias", 0.012),
m_Config->Get<float>("SSAO" + qStr + ".Contrast", 1.0),
m_Config->Get<float>("SSAO" + qStr + ".Intensity", 1.0),
m_Config->Get<int>("SSAO" + qStr + ".NumSamples", 0),
m_Config->Get<int>("SSAO" + qStr + ".NumTurns", 0),
m_Config->Get<int>("SSAO" + qStr + ".NumIterations", 0),
m_Config->Get<int>("SSAO" + qStr + ".TextureQuality", 4)
);
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh"); m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh");
InitializeTexture(); InitializeTexture();
InitializeBuffer(); InitializeBuffer();
InitializeShaderProgram(); InitializeShaderProgram();
Setting(0.1f, 0.012f, 1.0f, 1.0f, 13, 7);
m_DrawBloomPass = new DrawBloomPass(renderer);
} }
void SSAOPass::InitializeShaderProgram() void SSAOPass::InitializeShaderProgram()
{ {
m_SSAOProgram = ResourceManager::Load<ShaderProgram>("##SSAOProgram"); m_SSAOProgram = ResourceManager::Load<ShaderProgram>("##SSAOProgram");
m_SSAOProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/SSAO.vert.glsl"))); if (m_SSAOProgram->GetHandle() == 0) {
m_SSAOProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/SSAO.frag.glsl"))); m_SSAOProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/SSAO.vert.glsl")));
m_SSAOProgram->Compile(); m_SSAOProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/SSAO.frag.glsl")));
m_SSAOProgram->Link(); m_SSAOProgram->Compile();
m_SSAOProgram->Link();
}
m_SSAOViewSpaceZProgram = ResourceManager::Load<ShaderProgram>("##SSAOViewSpaceZProgram"); m_SSAOViewSpaceZProgram = ResourceManager::Load<ShaderProgram>("##SSAOViewSpaceZProgram");
m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/SSAO.vert.glsl"))); if (m_SSAOViewSpaceZProgram->GetHandle() == 0) {
m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/SSAOViewSpaceZ.frag.glsl"))); m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/SSAO.vert.glsl")));
m_SSAOViewSpaceZProgram->Compile(); m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/SSAOViewSpaceZ.frag.glsl")));
m_SSAOViewSpaceZProgram->Link(); m_SSAOViewSpaceZProgram->Compile();
m_SSAOViewSpaceZProgram->Link();
}
m_GaussianProgram_horiz = ResourceManager::Load<ShaderProgram>("##GaussianProgramHoriz");
if (m_GaussianProgram_horiz->GetHandle() == 0) {
m_GaussianProgram_horiz->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Gaussian_horiz.vert.glsl")));
m_GaussianProgram_horiz->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Gaussian_horiz.frag.glsl")));
m_GaussianProgram_horiz->Compile();
m_GaussianProgram_horiz->Link();
}
m_GaussianProgram_vert = ResourceManager::Load<ShaderProgram>("##GaussianProgramVert");
if (m_GaussianProgram_vert->GetHandle() == 0) {
m_GaussianProgram_vert->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Gaussian_vert.vert.glsl")));
m_GaussianProgram_vert->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Gaussian_vert.frag.glsl")));
m_GaussianProgram_vert->Compile();
m_GaussianProgram_vert->Link();
}
} }
void SSAOPass::InitializeTexture() { void SSAOPass::InitializeTexture() {
GenerateTexture(&m_SSAOTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_R8, GL_RED, GL_FLOAT); CommonFunctions::GenerateTexture(&m_SSAOTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RED, GL_FLOAT);
GenerateTexture(&m_SSAOViewSpaceZTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_R32F, GL_RED, GL_FLOAT); CommonFunctions::GenerateTexture(&m_SSAOViewSpaceZTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R32F, GL_RED, GL_FLOAT);
CommonFunctions::GenerateTexture(&m_Gaussian_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RED, GL_FLOAT);
CommonFunctions::GenerateTexture(&m_Gaussian_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RED, GL_FLOAT);
} }
void SSAOPass::InitializeBuffer() void SSAOPass::InitializeBuffer()
{ {
m_SSAOFramBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SSAOTexture, GL_COLOR_ATTACHMENT0))); if (m_SSAOFramBuffer.GetHandle() == 0) {
m_SSAOFramBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SSAOTexture, GL_COLOR_ATTACHMENT0)));
}
m_SSAOFramBuffer.Generate(); m_SSAOFramBuffer.Generate();
m_SSAOViewSpaceZFramBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SSAOViewSpaceZTexture, GL_COLOR_ATTACHMENT0)));
if (m_SSAOViewSpaceZFramBuffer.GetHandle() == 0) {
m_SSAOViewSpaceZFramBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SSAOViewSpaceZTexture, GL_COLOR_ATTACHMENT0)));
}
m_SSAOViewSpaceZFramBuffer.Generate(); m_SSAOViewSpaceZFramBuffer.Generate();
if (m_GaussianFrameBuffer_horiz.GetHandle() == 0) {
m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_Gaussian_horiz, GL_COLOR_ATTACHMENT0)));
}
m_GaussianFrameBuffer_horiz.Generate();
if (m_GaussianFrameBuffer_vert.GetHandle() == 0) {
m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_Gaussian_vert, GL_COLOR_ATTACHMENT0)));
}
m_GaussianFrameBuffer_vert.Generate();
} }
void SSAOPass::ClearBuffer() void SSAOPass::ClearBuffer()
{ {
if (m_Quality == 0) {
return;
}
m_SSAOFramBuffer.Bind(); m_SSAOFramBuffer.Bind();
glClearColor(1.f, 1.f, 1.f, 1.f); glClearColor(1.f, 1.f, 1.f, 1.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
m_SSAOFramBuffer.Unbind(); m_SSAOFramBuffer.Unbind();
m_SSAOViewSpaceZFramBuffer.Bind(); m_SSAOViewSpaceZFramBuffer.Bind();
glClearColor(1.f, 1.f, 1.f, 1.f); glClearColor(1.f, 1.f, 1.f, 1.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
m_SSAOViewSpaceZFramBuffer.Unbind(); m_SSAOViewSpaceZFramBuffer.Unbind();
m_GaussianFrameBuffer_horiz.Bind();
glClearColor(1.f, 1.f, 1.f, 1.f);
glClear(GL_COLOR_BUFFER_BIT);
m_GaussianFrameBuffer_horiz.Unbind();
m_GaussianFrameBuffer_vert.Bind();
glClearColor(1.f, 1.f, 1.f, 1.f);
glClear(GL_COLOR_BUFFER_BIT);
m_GaussianFrameBuffer_vert.Unbind();
} }
void SSAOPass::Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int NumOfTurns) { void SSAOPass::Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int numOfTurns, int iterations, int quality) {
m_Radius = radius; m_Radius = radius;
m_Bias = bias; m_Bias = bias;
m_Contrast = contrast; m_Contrast = contrast;
m_IntensityScale = intensityScale; m_IntensityScale = intensityScale;
m_NumOfSamples = numOfSamples; m_NumOfSamples = numOfSamples;
m_NumOfTurns = NumOfTurns; m_NumOfTurns = numOfTurns;
} m_Iterations = iterations;
m_TextureQuality = quality;
void SSAOPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
{
glGenTextures(1, texture);
glBindTexture(GL_TEXTURE_2D, *texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, dimensions.x, dimensions.y, 0, format, type, nullptr);
GLERROR("Texture initialization failed");
} }
void SSAOPass::Draw(GLuint depthBuffer, Camera* camera) void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
{ {
if (m_Quality == 0) {
return;
}
SSAOPassState state; SSAOPassState state;
GLuint viewSpaceZPShaderHandle = m_SSAOViewSpaceZProgram->GetHandle(); GLuint viewSpaceZPShaderHandle = m_SSAOViewSpaceZProgram->GetHandle();
GLuint SSAOShaderHandle = m_SSAOProgram->GetHandle(); GLuint SSAOShaderHandle = m_SSAOProgram->GetHandle();
@@ -98,6 +182,7 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
(-1.0f), (-1.0f),
(+1.0f) (+1.0f)
);*/ );*/
glViewport(0, 0, (m_Renderer->GetViewportSize().Width >> m_TextureQuality), (m_Renderer->GetViewportSize().Height >> m_TextureQuality)); //JOHAN TODO: Get this into state
glUniform3fv(glGetUniformLocation(viewSpaceZPShaderHandle, "ClipInfo"), 1, glm::value_ptr(clipInfo)); glUniform3fv(glGetUniformLocation(viewSpaceZPShaderHandle, "ClipInfo"), 1, glm::value_ptr(clipInfo));
glBindVertexArray(m_ScreenQuad->VAO); glBindVertexArray(m_ScreenQuad->VAO);
@@ -107,9 +192,9 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
glm::vec4 projInfo = glm::vec4( glm::vec4 projInfo = glm::vec4(
((1.0 - camera->ProjectionMatrix()[0][2]) / camera->ProjectionMatrix()[0][0]), ((1.0 - camera->ProjectionMatrix()[0][2]) / camera->ProjectionMatrix()[0][0]),
(-2.0 / (m_Renderer->GetViewportSize().Width * camera->ProjectionMatrix()[0][0])), (-2.0 / ((m_Renderer->GetViewportSize().Width >> m_TextureQuality) * camera->ProjectionMatrix()[0][0])),
((1.0 + camera->ProjectionMatrix()[1][2]) / camera->ProjectionMatrix()[1][1]), ((1.0 + camera->ProjectionMatrix()[1][2]) / camera->ProjectionMatrix()[1][1]),
(-2.0 / (m_Renderer->GetViewportSize().Height * camera->ProjectionMatrix()[1][1])) (-2.0 / ((m_Renderer->GetViewportSize().Height >> m_TextureQuality) * camera->ProjectionMatrix()[1][1]))
); );
@@ -120,26 +205,84 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
glBindTexture(GL_TEXTURE_2D, m_SSAOViewSpaceZTexture); glBindTexture(GL_TEXTURE_2D, m_SSAOViewSpaceZTexture);
// How many pixel there are in a 1m long object 1m away from the camera // How many pixel there are in a 1m long object 1m away from the camera
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uProjScale"), m_Renderer->GetViewportSize().Height / (-2.0f * glm::tan(camera->FOV() * 0.5f))); glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uProjScale"), (m_Renderer->GetViewportSize().Height >> m_TextureQuality) / (-2.0f * glm::tan(camera->FOV() * 0.5f)));
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uRadius"), m_Radius); glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uRadius"), m_Radius);
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uBias"), m_Bias); glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uBias"), m_Bias);
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uContrast"), m_Contrast); glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uContrast"), m_Contrast);
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uIntensityScale"), m_IntensityScale); glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uIntensityScale"), m_IntensityScale);
glUniform1i(glGetUniformLocation(SSAOShaderHandle, "uNumOfSamples"), m_NumOfSamples); glUniform1i(glGetUniformLocation(SSAOShaderHandle, "uNumOfSamples"), m_NumOfSamples);
glUniform1i(glGetUniformLocation(SSAOShaderHandle, "uNumOfTurns"), m_NumOfTurns);; glUniform1i(glGetUniformLocation(SSAOShaderHandle, "uNumOfTurns"), m_NumOfTurns);
glUniform4fv(glGetUniformLocation(SSAOShaderHandle, "uProjInfo"), 1, glm::value_ptr(projInfo)); glUniform4fv(glGetUniformLocation(SSAOShaderHandle, "uProjInfo"), 1, glm::value_ptr(projInfo));
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1 glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
m_DrawBloomPass->ClearBuffer(); DrawBloomPassState BloomState;
m_DrawBloomPass->Draw(m_SSAOTexture); GLuint shaderHandle_horiz = m_GaussianProgram_horiz->GetHandle();
GLuint shaderHandle_vert = m_GaussianProgram_vert->GetHandle();
m_GaussianFrameBuffer_horiz.Bind();
m_GaussianProgram_horiz->Bind();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_SSAOTexture);
glBindVertexArray(m_ScreenQuad->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
//Iterate some times to make it more gaussian.
for (int i = 1; i < m_Iterations; i++) {
//Vertical pass
m_GaussianFrameBuffer_vert.Bind();
m_GaussianProgram_vert->Bind();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_Gaussian_horiz);
glBindVertexArray(m_ScreenQuad->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
//horizontal pass
m_GaussianFrameBuffer_vert.Unbind();
m_GaussianFrameBuffer_horiz.Bind();
m_GaussianProgram_horiz->Bind();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_Gaussian_vert);
glBindVertexArray(m_ScreenQuad->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
m_GaussianFrameBuffer_horiz.Unbind();
}
//final vertical gaussian after the iterations are done
m_GaussianFrameBuffer_vert.Bind();
m_GaussianProgram_vert->Bind();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_Gaussian_horiz);
glBindVertexArray(m_ScreenQuad->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
m_GaussianFrameBuffer_vert.Unbind();
glViewport(0, 0, (m_Renderer->GetViewportSize().Width), (m_Renderer->GetViewportSize().Height));
} }
void SSAOPass::OnWindowResize() { void SSAOPass::OnWindowResize() {
m_DrawBloomPass->OnWindowResize(); if (m_Quality == 0) {
return;
}
InitializeTexture(); InitializeTexture();
m_SSAOFramBuffer.Generate(); InitializeBuffer();
m_SSAOViewSpaceZFramBuffer.Generate();
} }
@@ -17,3 +17,46 @@ Texture* CommonFunctions::LoadTexture(std::string path, bool threaded)
return img; return img;
} }
void CommonFunctions::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type)
{
glDeleteTextures(1, texture);
glGenTextures(1, texture);
glBindTexture(GL_TEXTURE_2D, *texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, dimensions.x, dimensions.y, 0, format, type, nullptr);
GLERROR("Texture initialization failed");
}
void CommonFunctions::GenerateMultiSampleTexture(GLuint* texture, int numSamples, glm::vec2 dimensions, GLint internalFormat)
{
glDeleteTextures(1, texture);
glGenTextures(1, texture);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, *texture);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, numSamples, internalFormat, dimensions.x, dimensions.y, false);
GLERROR("Texture initialization failed");
}
void CommonFunctions::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps)
{
glGenTextures(1, texture);
glBindTexture(GL_TEXTURE_2D, *texture);
glTexStorage2D(GL_TEXTURE_2D, numMipMaps, GL_RGBA8, dimensions.x, dimensions.y);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, dimensions.x, dimensions.y, format, type, texture);
glGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping);
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 CommonFunctions::DeleteTexture(GLuint* texture)
{
glDeleteTextures(1, texture);
*texture = 0;
}
+7 -2
View File
@@ -31,22 +31,27 @@ glm::vec3 ScreenCoords::ToWorldPos(glm::vec2 screenCoord, float depth, float scr
ScreenCoords::PixelData ScreenCoords::ToPixelData(float x, float y, FrameBuffer* PickDataBuffer, GLuint DepthBuffer) ScreenCoords::PixelData ScreenCoords::ToPixelData(float x, float y, FrameBuffer* PickDataBuffer, GLuint DepthBuffer)
{ {
GLERROR("Pre");
PickDataBuffer->Bind(); PickDataBuffer->Bind();
unsigned char pdata[3]; unsigned char pdata[3];
glReadPixels(x, y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pdata); glReadPixels(x, y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pdata);
GLERROR("glReadPixels(pdata) Error");
PickDataBuffer->Unbind(); PickDataBuffer->Unbind();
glBindFramebuffer(GL_FRAMEBUFFER, DepthBuffer); glBindFramebuffer(GL_FRAMEBUFFER, DepthBuffer);
GLERROR("glBindFramebuffer(DepthBuffer) Error");
float depthData; float depthData;
glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depthData); glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depthData);
GLERROR("glReadPixels(depthData) Error");
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
GLERROR("glBindFramebuffer(0) Error");
PixelData p; PixelData p;
p.Color[0] = (int)pdata[0]; p.Color[0] = (int)pdata[0];
p.Color[1] = (int)pdata[1]; p.Color[1] = (int)pdata[1];
p.Depth = depthData; p.Depth = depthData;
GLERROR("ScreenCoords::ToPixelData Error"); GLERROR("End");
return p; return p;
} }
+10 -5
View File
@@ -16,7 +16,7 @@
#include "Game/Systems/PickupSpawnSystem.h" #include "Game/Systems/PickupSpawnSystem.h"
#include "Game/Systems/AmmoPickupSystem.h" #include "Game/Systems/AmmoPickupSystem.h"
#include "Game/Systems/DamageIndicatorSystem.h" #include "Game/Systems/DamageIndicatorSystem.h"
#include "Game/Systems/Weapon/WeaponSystem.h" #include "Game/Systems/Weapon/DefenderWeaponBehaviour.h"
#include "Rendering/AnimationSystem.h" #include "Rendering/AnimationSystem.h"
#include "Game/Systems/HealthHUDSystem.h" #include "Game/Systems/HealthHUDSystem.h"
#include "Rendering/BoneAttachmentSystem.h" #include "Rendering/BoneAttachmentSystem.h"
@@ -48,13 +48,12 @@ Game::Game(int argc, char* argv[])
ResourceManager::UseThreading = m_Config->Get<bool>("Multithreading.ResourceLoading", true); ResourceManager::UseThreading = m_Config->Get<bool>("Multithreading.ResourceLoading", true);
DisableMemoryPool::Value = m_Config->Get<bool>("Debug.DisableMemoryPool", false); DisableMemoryPool::Value = m_Config->Get<bool>("Debug.DisableMemoryPool", false);
LOG_LEVEL = static_cast<_LOG_LEVEL>(m_Config->Get<int>("Debug.LogLevel", 1)); LOG_LEVEL = static_cast<_LOG_LEVEL>(m_Config->Get<int>("Debug.LogLevel", 1));
PlayerSpawnSystem::SetRespawnTime(m_Config->Get<float>("Debug.RespawnTime", 15.0f));
// Create the core event broker // Create the core event broker
m_EventBroker = new EventBroker(); m_EventBroker = new EventBroker();
// Create the renderer // Create the renderer
m_Renderer = new Renderer(m_EventBroker); m_Renderer = new Renderer(m_EventBroker, m_Config);
m_Renderer->SetFullscreen(m_Config->Get<bool>("Video.Fullscreen", false)); m_Renderer->SetFullscreen(m_Config->Get<bool>("Video.Fullscreen", false));
m_Renderer->SetVSYNC(m_Config->Get<bool>("Video.VSYNC", false)); m_Renderer->SetVSYNC(m_Config->Get<bool>("Video.VSYNC", false));
m_Renderer->SetResolution(Rectangle::Rectangle( m_Renderer->SetResolution(Rectangle::Rectangle(
@@ -98,6 +97,10 @@ Game::Game(int argc, char* argv[])
m_NetworkClient->Connect(m_NetworkAddress, m_NetworkPort); m_NetworkClient->Connect(m_NetworkAddress, m_NetworkPort);
m_Renderer->SetWindowTitle(m_Renderer->WindowTitle() + " CLIENT"); m_Renderer->SetWindowTitle(m_Renderer->WindowTitle() + " CLIENT");
} }
} else {
// If network is disabled, pretend we're a server
m_IsClient = true;
m_IsServer = true;
} }
// Create Octrees // Create Octrees
@@ -120,7 +123,7 @@ Game::Game(int argc, char* argv[])
m_SystemPipeline->AddSystem<PlayerMovementSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<PlayerMovementSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<SpawnerSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<SpawnerSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<PlayerSpawnSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<PlayerSpawnSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<WeaponSystem>(updateOrderLevel, m_Renderer, m_OctreeCollision); m_SystemPipeline->AddSystem<DefenderWeaponBehaviour>(updateOrderLevel, m_Renderer, m_OctreeCollision);
m_SystemPipeline->AddSystem<LifetimeSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<LifetimeSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<CapturePointSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<CapturePointSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<CapturePointHUDSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<CapturePointHUDSystem>(updateOrderLevel);
@@ -135,7 +138,6 @@ Game::Game(int argc, char* argv[])
++updateOrderLevel; ++updateOrderLevel;
m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeCollision, "Collidable"); m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeCollision, "Collidable");
m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeTrigger, "Player"); m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeTrigger, "Player");
m_SystemPipeline->AddSystem<FillFrustumOctreeSystem>(updateOrderLevel, m_OctreeFrustrumCulling);
m_SystemPipeline->AddSystem<AnimationSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<AnimationSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<UniformScaleSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<UniformScaleSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<HealthHUDSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<HealthHUDSystem>(updateOrderLevel);
@@ -145,6 +147,9 @@ Game::Game(int argc, char* argv[])
m_SystemPipeline->AddSystem<BoneAttachmentSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<BoneAttachmentSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<CollisionSystem>(updateOrderLevel, m_OctreeCollision); m_SystemPipeline->AddSystem<CollisionSystem>(updateOrderLevel, m_OctreeCollision);
m_SystemPipeline->AddSystem<TriggerSystem>(updateOrderLevel, m_OctreeTrigger); m_SystemPipeline->AddSystem<TriggerSystem>(updateOrderLevel, m_OctreeTrigger);
// Octree for frustum culling must be updated after collisions, otherwise players frustum may be moved after tree is filled, and wrong things are culled.
++updateOrderLevel;
m_SystemPipeline->AddSystem<FillFrustumOctreeSystem>(updateOrderLevel, m_OctreeFrustrumCulling);
++updateOrderLevel; ++updateOrderLevel;
m_SystemPipeline->AddSystem<RenderSystem>(updateOrderLevel, m_Renderer, m_RenderFrame, m_OctreeFrustrumCulling); m_SystemPipeline->AddSystem<RenderSystem>(updateOrderLevel, m_Renderer, m_RenderFrame, m_OctreeFrustrumCulling);
++updateOrderLevel; ++updateOrderLevel;
@@ -13,6 +13,7 @@ bool MultiplayerSnapshotFilter::FilterComponent(EntityWrapper entity, SharedComp
component.Info.Name == "Transform" component.Info.Name == "Transform"
|| component.Info.Name == "Physics" || component.Info.Name == "Physics"
|| component.Info.Name == "AssaultWeapon" || component.Info.Name == "AssaultWeapon"
|| component.Info.Name == "DefenderWeapon"
|| component.Info.Name == "Animation" || component.Info.Name == "Animation"
|| component.Info.Name == "AnimationOffset" || component.Info.Name == "AnimationOffset"
|| entity.Name() == "PlayerName" || entity.Name() == "PlayerName"
+8 -3
View File
@@ -6,9 +6,11 @@ CapturePointSystem::CapturePointSystem(SystemParams params)
, PureSystem("CapturePoint") , PureSystem("CapturePoint")
{ {
//subscribe/listenTo playerdamage,healthpickup events (using the eventBroker) //subscribe/listenTo playerdamage,healthpickup events (using the eventBroker)
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch); if (!IsClient) {
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave); EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch);
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured); EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave);
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured);
}
} }
@@ -16,6 +18,9 @@ CapturePointSystem::CapturePointSystem(SystemParams params)
//NOTE: needs to run each frame, since we're possibly modifying the captureTimer for the capturePoints by dt //NOTE: needs to run each frame, since we're possibly modifying the captureTimer for the capturePoints by dt
void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, ComponentWrapper& cCapturePoint, double dt) void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, ComponentWrapper& cCapturePoint, double dt)
{ {
if (IsClient) {
return;
}
if (m_WinnerWasFound) { if (m_WinnerWasFound) {
return; return;
} }
+1 -1
View File
@@ -13,7 +13,7 @@ DamageIndicatorSystem::DamageIndicatorSystem(SystemParams params)
} }
void DamageIndicatorSystem::Update(double dt) { void DamageIndicatorSystem::Update(double dt) {
if (!IsServer) { if (!IsServer && LocalPlayer.Valid()) {
for (auto& iter = updateDamageIndicatorVector.begin(); iter != updateDamageIndicatorVector.end(); iter++) { for (auto& iter = updateDamageIndicatorVector.begin(); iter != updateDamageIndicatorVector.end(); iter++) {
if (!iter->spriteEntity.Valid()) { if (!iter->spriteEntity.Valid()) {
updateDamageIndicatorVector.erase(iter); updateDamageIndicatorVector.erase(iter);
+42 -14
View File
@@ -4,6 +4,7 @@ PlayerMovementSystem::PlayerMovementSystem(SystemParams params)
: System(params) : System(params)
{ {
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &PlayerMovementSystem::OnPlayerSpawned); EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &PlayerMovementSystem::OnPlayerSpawned);
EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &PlayerMovementSystem::OnDoubleJump);
} }
PlayerMovementSystem::~PlayerMovementSystem() PlayerMovementSystem::~PlayerMovementSystem()
@@ -36,7 +37,6 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
if (!player.Valid()) { if (!player.Valid()) {
continue; continue;
} }
// Aim pitch // Aim pitch
EntityWrapper cameraEntity = player.FirstChildByName("Camera"); EntityWrapper cameraEntity = player.FirstChildByName("Camera");
if (cameraEntity.Valid()) { if (cameraEntity.Valid()) {
@@ -48,7 +48,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
EntityWrapper playerModel = player.FirstChildByName("PlayerModel"); EntityWrapper playerModel = player.FirstChildByName("PlayerModel");
if (playerModel.Valid()) { if (playerModel.Valid()) {
ComponentWrapper cAnimationOffset = playerModel["AnimationOffset"]; ComponentWrapper cAnimationOffset = playerModel["AnimationOffset"];
float pitch = cameraOrientation.x + 0.2; float pitch = cameraOrientation.x + 0.2f;
double time = (pitch + glm::half_pi<float>()) / glm::pi<float>(); double time = (pitch + glm::half_pi<float>()) / glm::pi<float>();
cAnimationOffset["Time"] = time; cAnimationOffset["Time"] = time;
} }
@@ -66,7 +66,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
ComponentWrapper cPhysics = player["Physics"]; ComponentWrapper cPhysics = player["Physics"];
//Assault Dash Check //Assault Dash Check
if (player.HasComponent("DashAbility")) { if (player.HasComponent("DashAbility")) {
controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f, player["DashAbility"]["CoolDownMaxTimer"]); controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f, player["DashAbility"]["CoolDownMaxTimer"], player["DashAbility"]["CoolDownTimer"]);
} }
wishDirection = controller->Movement() * glm::inverse(glm::quat(ori)); wishDirection = controller->Movement() * glm::inverse(glm::quat(ori));
//this makes sure you can only dash in the 4 directions: forw,backw,left,right //this makes sure you can only dash in the 4 directions: forw,backw,left,right
@@ -116,25 +116,29 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity)); ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity));
} }
//you cant jump and dash at the same time - since there is no friction in the air and we would thus dash much further in the air if (isOnGround) {
if (!controller->PlayerIsDashing() && controller->Jumping() && !controller->Crouching() && (isOnGround || !controller->DoubleJumping())) { controller->SetDoubleJumping(false);
(bool)cPhysics["IsOnGround"] = false; }
//If player presses Jump and is not crouching.
if (controller->Jumping() && !controller->Crouching()) {
if (isOnGround) { if (isOnGround) {
controller->SetDoubleJumping(false); (bool)cPhysics["IsOnGround"] = false;
} else { velocity.y = player["Player"]["JumpSpeed"];
} else if (player.HasComponent("DoubleJump") && !controller->DoubleJumping()) {
//Enter here if player can double jump and is doing so.
(bool)cPhysics["IsOnGround"] = false;
velocity.y = player["DoubleJump"]["DoubleJumpSpeed"];
// If IsServer and network is off this will not work
if (IsClient) { if (IsClient) {
//put a hexagon at the players feet //put a hexagon at the players feet
auto hexagonEffect = ResourceManager::Load<EntityFile>("Schema/Entities/DoubleJumpHexagon.xml"); spawnHexagon(player);
EntityFileParser parser(hexagonEffect);
EntityID hexagonEffectID = parser.MergeEntities(m_World);
EntityWrapper hexagonEW = EntityWrapper(m_World, hexagonEffectID);
hexagonEW["Transform"]["Position"] = (glm::vec3)player["Transform"]["Position"];
controller->SetDoubleJumping(true); controller->SetDoubleJumping(true);
// Publish event for client to listen to
Events::DoubleJump e; Events::DoubleJump e;
e.entityID = player.ID;
m_EventBroker->Publish(e); m_EventBroker->Publish(e);
} }
} }
velocity.y = 4.f;
} }
if (player.HasComponent("AABB")) { if (player.HasComponent("AABB")) {
@@ -295,3 +299,27 @@ bool PlayerMovementSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
} }
return true; return true;
} }
bool PlayerMovementSystem::OnDoubleJump(Events::DoubleJump & e)
{
// If entity does not exist, exit
if (!EntityWrapper(m_World, e.entityID).Valid()) {
return false;
}
// If entity IsLocalPlayer, exit
if (e.entityID == m_LocalPlayer.ID) {
return false;
}
spawnHexagon(EntityWrapper(m_World, e.entityID));
return true;
}
void PlayerMovementSystem::spawnHexagon(EntityWrapper target)
{
//put a hexagon at the entitys... feet?
auto hexagonEffect = ResourceManager::Load<EntityFile>("Schema/Entities/DoubleJumpHexagon.xml");
EntityFileParser parser(hexagonEffect);
EntityID hexagonEffectID = parser.MergeEntities(m_World);
EntityWrapper hexagonEW = EntityWrapper(m_World, hexagonEffectID);
hexagonEW["Transform"]["Position"] = (glm::vec3)target["Transform"]["Position"];
}
+23 -12
View File
@@ -1,29 +1,40 @@
#include "Systems/PlayerSpawnSystem.h" #include "Systems/PlayerSpawnSystem.h"
//This should be set by the config anyway.
float PlayerSpawnSystem::m_RespawnTime = 15.0f;
PlayerSpawnSystem::PlayerSpawnSystem(SystemParams params) PlayerSpawnSystem::PlayerSpawnSystem(SystemParams params)
: System(params) : System(params)
, m_Timer(0.f) , m_DbgConfigForceRespawn(false)
{ {
EVENT_SUBSCRIBE_MEMBER(m_OnInputCommand, &PlayerSpawnSystem::OnInputCommand); EVENT_SUBSCRIBE_MEMBER(m_OnInputCommand, &PlayerSpawnSystem::OnInputCommand);
EVENT_SUBSCRIBE_MEMBER(m_OnPlayerSpawnerd, &PlayerSpawnSystem::OnPlayerSpawned); EVENT_SUBSCRIBE_MEMBER(m_OnPlayerSpawnerd, &PlayerSpawnSystem::OnPlayerSpawned);
EVENT_SUBSCRIBE_MEMBER(m_OnPlayerDeath, &PlayerSpawnSystem::OnPlayerDeath); EVENT_SUBSCRIBE_MEMBER(m_OnPlayerDeath, &PlayerSpawnSystem::OnPlayerDeath);
m_NetworkEnabled = ResourceManager::Load<ConfigFile>("Config.ini")->Get("Networking.StartNetwork", false); ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini");
m_NetworkEnabled = config->Get("Networking.StartNetwork", false);
m_ForcedRespawnTime = config->Get("Debug.RespawnTime", -1.0f);
m_DbgConfigForceRespawn = m_ForcedRespawnTime > 0;
} }
void PlayerSpawnSystem::Update(double dt) void PlayerSpawnSystem::Update(double dt)
{ {
//Increase timer. // If there are no CapturePointGameMode components we will just spawn immediately.
m_Timer += dt; // Should be able to support older maps with this.
if (m_Timer < m_RespawnTime) { // TODO: In the future we might want to return instead, to avoid spawning in the menu for instance.
return; auto pool = m_World->GetComponents("CapturePointGameMode");
if (pool != nullptr && pool->size() > 0)
{
// Take the first CapturePointGameMode component found.
ComponentWrapper& modeComponent = *pool->begin();
// Increase timer.
double& timer = (double&)modeComponent["RespawnTime"];
timer += dt;
double maxRespawnTime = m_DbgConfigForceRespawn ? m_ForcedRespawnTime : (double)modeComponent["MaxRespawnTime"];
if (timer < maxRespawnTime) {
return;
}
// If respawn time has passed, we spawn all players that have requested to be spawned.
timer = 0;
} }
//If respawn time has passed, we spawn all players that have requested to be spawned.
m_Timer = 0.f;
//If there are no spawn requests, return immediately, if we are client the SpawnRequests should always be empty. // If there are no spawn requests, return immediately, if we are client the SpawnRequests should always be empty.
if (m_SpawnRequests.size() == 0) { if (m_SpawnRequests.size() == 0) {
return; return;
} }
+1 -1
View File
@@ -36,7 +36,7 @@ EntityWrapper SpawnerSystem::Spawn(EntityWrapper spawner, EntityWrapper parent /
} }
// Find any SpawnPoints existing as children of spawner // Find any SpawnPoints existing as children of spawner
auto children = spawner.World->GetChildren(spawner.ID); auto children = spawner.World->GetDirectChildren(spawner.ID);
std::vector<EntityWrapper> spawnPoints; std::vector<EntityWrapper> spawnPoints;
for (auto kv = children.first; kv != children.second; ++kv) { for (auto kv = children.first; kv != children.second; ++kv) {
const EntityID& child = kv->second; const EntityID& child = kv->second;
@@ -1,13 +1,5 @@
#include "Systems/Weapon/AssaultWeaponBehaviour.h" #include "Systems/Weapon/AssaultWeaponBehaviour.h"
AssaultWeaponBehaviour::AssaultWeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree<EntityAABB>* collisionOctree, EntityWrapper player)
: WeaponBehaviour(systemParams, renderer, collisionOctree, player)
{
m_FirstPersonModel = m_Player.FirstChildByName("Hands");
m_ThirdPersonModel = m_Player.FirstChildByName("PlayerModel");
EVENT_SUBSCRIBE_MEMBER(m_EAnimationComplete, &AssaultWeaponBehaviour::OnAnimationComplete);
}
void AssaultWeaponBehaviour::Fire() void AssaultWeaponBehaviour::Fire()
{ {
m_TimeSinceLastFire = 0.0; m_TimeSinceLastFire = 0.0;
@@ -36,7 +28,7 @@ void AssaultWeaponBehaviour::Reload()
return; return;
} }
// Don't reload if we're completly out of ammo // Don't reload if we're completely out of ammo
if (ammo == 0) { if (ammo == 0) {
playEmptySound(); playEmptySound();
m_TimeSinceLastFire = -0.0f; // HACK: To make empty sound play with interval m_TimeSinceLastFire = -0.0f; // HACK: To make empty sound play with interval
@@ -56,14 +48,14 @@ void AssaultWeaponBehaviour::Update(double dt)
{ {
if (m_Reloading) { if (m_Reloading) {
m_ReloadTimer -= dt; m_ReloadTimer -= dt;
// Re-enable glow on reload impersonator half-way through the animation // Re-enable glow on reload impostor half-way through the animation
if (IsClient) { if (IsClient) {
if (m_ReloadTimer <= (double)m_Player["AssaultWeapon"]["ReloadTime"] / 2.0) { if (m_ReloadTimer <= (double)m_Player["AssaultWeapon"]["ReloadTime"] / 2.0) {
if (m_FirstPersonReloadImpersonator.Valid()) { if (m_FirstPersonReloadImpostor.Valid()) {
m_FirstPersonReloadImpersonator["Model"]["GlowMap"] = true; m_FirstPersonReloadImpostor["Model"]["GlowMap"] = true;
} }
if (m_ThirdPersonReloadImpersonator.Valid()) { if (m_ThirdPersonReloadImpostor.Valid()) {
m_ThirdPersonReloadImpersonator["Model"]["GlowMap"] = true; m_ThirdPersonReloadImpostor["Model"]["GlowMap"] = true;
} }
} }
} }
@@ -96,21 +88,6 @@ void AssaultWeaponBehaviour::Update(double dt)
} }
} }
bool AssaultWeaponBehaviour::OnAnimationComplete(Events::AnimationComplete& e)
{
if (e.Entity != m_FirstPersonModel) {
return false;
}
//if (e.Name == "ShootRifle") {
// if (!m_Firing) {
// playIdleAnimation();
// }
//}
return true;
}
bool AssaultWeaponBehaviour::hasAmmo() bool AssaultWeaponBehaviour::hasAmmo()
{ {
ComponentWrapper& cAssaultWeapon = m_Player["AssaultWeapon"]; ComponentWrapper& cAssaultWeapon = m_Player["AssaultWeapon"];
@@ -177,7 +154,6 @@ void AssaultWeaponBehaviour::spawnTracer()
float AssaultWeaponBehaviour::traceRayDistance(glm::vec3 origin, glm::vec3 direction) float AssaultWeaponBehaviour::traceRayDistance(glm::vec3 origin, glm::vec3 direction)
{ {
// TODO: Cast a ray and size tracer appropriately
float distance; float distance;
glm::vec3 pos; glm::vec3 pos;
auto entity = Collision::EntityFirstHitByRay(Ray(origin, direction), m_CollisionOctree, distance, pos); auto entity = Collision::EntityFirstHitByRay(Ray(origin, direction), m_CollisionOctree, distance, pos);
@@ -215,6 +191,12 @@ void AssaultWeaponBehaviour::playEmptySound()
void AssaultWeaponBehaviour::viewPunch() void AssaultWeaponBehaviour::viewPunch()
{ {
// Since we send absolute client orientations to server, running this server side would
// cause aim desync.
if (!IsClient) {
return;
}
EntityWrapper playerCamera = m_Player.FirstChildByName("Camera"); EntityWrapper playerCamera = m_Player.FirstChildByName("Camera");
if (!playerCamera.Valid()) { if (!playerCamera.Valid()) {
return; return;
@@ -323,8 +305,8 @@ void AssaultWeaponBehaviour::playReloadAnimation()
EntityWrapper firstPersonWeaponModel = m_Player.FirstChildByName("WeaponModel"); EntityWrapper firstPersonWeaponModel = m_Player.FirstChildByName("WeaponModel");
EntityWrapper reloadSpawner = m_Player.FirstChildByName("FirstPersonReloadSpawner"); EntityWrapper reloadSpawner = m_Player.FirstChildByName("FirstPersonReloadSpawner");
if (IsClient) { if (IsClient) {
m_FirstPersonReloadImpersonator = SpawnerSystem::Spawn(reloadSpawner, reloadSpawner); m_FirstPersonReloadImpostor = SpawnerSystem::Spawn(reloadSpawner, reloadSpawner);
firstPersonWeaponModel["Model"].Copy(m_FirstPersonReloadImpersonator["Model"]); firstPersonWeaponModel["Model"].Copy(m_FirstPersonReloadImpostor["Model"]);
} }
firstPersonWeaponModel["Model"]["Visible"] = false; firstPersonWeaponModel["Model"]["Visible"] = false;
} }
@@ -332,8 +314,8 @@ void AssaultWeaponBehaviour::playReloadAnimation()
EntityWrapper thirdPersonWeaponModel = m_Player.FirstChildByName("ThirdPersonWeaponModel"); EntityWrapper thirdPersonWeaponModel = m_Player.FirstChildByName("ThirdPersonWeaponModel");
EntityWrapper reloadSpawner = m_Player.FirstChildByName("ThirdPersonReloadSpawner"); EntityWrapper reloadSpawner = m_Player.FirstChildByName("ThirdPersonReloadSpawner");
if (IsClient) { if (IsClient) {
m_ThirdPersonReloadImpersonator = SpawnerSystem::Spawn(reloadSpawner, reloadSpawner); m_ThirdPersonReloadImpostor = SpawnerSystem::Spawn(reloadSpawner, reloadSpawner);
thirdPersonWeaponModel["Model"].Copy(m_ThirdPersonReloadImpersonator["Model"]); thirdPersonWeaponModel["Model"].Copy(m_ThirdPersonReloadImpostor["Model"]);
} }
thirdPersonWeaponModel["Model"]["Visible"] = false; thirdPersonWeaponModel["Model"]["Visible"] = false;
} }
@@ -371,7 +353,7 @@ bool AssaultWeaponBehaviour::shoot(double damage)
return false; return false;
} }
// Don't let us shoot ourselves in the foot // Don't let us shoot ourselves in the foot somehow
if (victim == LocalPlayer) { if (victim == LocalPlayer) {
return false; return false;
} }
@@ -0,0 +1,188 @@
#include "Systems/Weapon/DefenderWeaponBehaviour.h"
void DefenderWeaponBehaviour::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cWeapon, double dt)
{
(double&)cWeapon["TimeSinceLastFire"] += dt;
WeaponBehaviour::UpdateComponent(entity, cWeapon, dt);
}
void DefenderWeaponBehaviour::UpdateWeapon(WeaponInfo& wi, double dt)
{
ComponentWrapper cWeapon = wi.GetComponent();
bool isFiring = cWeapon["IsFiring"];
bool cooldownPassed = (double)cWeapon["TimeSinceLastFire"] >= (60.0 / (double)cWeapon["RPM"]);
bool isNotShielding = wi.Player.ChildrenWithComponent("Shield").size() == 0;
if (isFiring && cooldownPassed && isNotShielding) {
fireShell(wi);
}
}
void DefenderWeaponBehaviour::OnPrimaryFire(WeaponInfo& wi)
{
ComponentWrapper cWeapon = wi.GetComponent();
cWeapon["IsFiring"] = true;
bool cooldownPassed = (double)cWeapon["TimeSinceLastFire"] >= (60.0 / (double)cWeapon["RPM"]);
bool isNotShielding = wi.Player.ChildrenWithComponent("Shield").size() == 0;
if (cooldownPassed && isNotShielding) {
fireShell(wi);
}
}
void DefenderWeaponBehaviour::OnCeasePrimaryFire(WeaponInfo& wi)
{
ComponentWrapper cWeapon = wi.GetComponent();
cWeapon["IsFiring"] = false;
}
bool DefenderWeaponBehaviour::OnInputCommand(WeaponInfo& wi, const Events::InputCommand& e)
{
if (e.Command == "SpecialAbility" && IsServer) {
EntityWrapper attachment = wi.Player.FirstChildByName("ShieldAttachment");
if (attachment.Valid()) {
if (e.Value > 0) {
SpawnerSystem::Spawn(attachment, attachment);
} else {
attachment.DeleteChildren();
}
}
}
return false;
}
bool DefenderWeaponBehaviour::OnSetCamera(const Events::SetCamera& e)
{
m_CurrentCamera = e.CameraEntity;
return true;
}
void DefenderWeaponBehaviour::fireShell(WeaponInfo& wi)
{
ComponentWrapper cWeapon = wi.GetComponent();
cWeapon["TimeSinceLastFire"] = 0.0;
int numPellets = cWeapon["NumPellets"];
float spreadAngle = cWeapon["SpreadAngle"];
std::uniform_real_distribution<float> randomSpreadAngle(-spreadAngle, spreadAngle);
// Calculate pellet angles
// HACK: Random for now?
// TODO: Make distribution even for each quadrant
std::vector<glm::vec2> pelletAngles;
for (int i = 0; i < numPellets; i++) {
pelletAngles.push_back(glm::vec2(randomSpreadAngle(m_RandomEngine), randomSpreadAngle(m_RandomEngine)));
LOG_DEBUG("%f %f", pelletAngles[i].x, pelletAngles[i].y);
}
double pelletDamage = (double)cWeapon["BaseDamage"] / numPellets;
// Tracers
EntityWrapper weaponModelEntity;
if (wi.Player == LocalPlayer) {
weaponModelEntity = wi.FirstPersonEntity;
} else {
weaponModelEntity = wi.ThirdPersonEntity;
}
if (weaponModelEntity.Valid()) {
EntityWrapper spawner = weaponModelEntity.FirstChildByName("WeaponMuzzle");
for (auto& angles : pelletAngles) {
glm::vec3 direction = Transform::AbsoluteOrientation(spawner) * glm::quat(glm::vec3(angles, 0.f)) * glm::vec3(0, 0, -1);
float distance = traceRayDistance(Transform::AbsolutePosition(spawner), direction);
EntityWrapper ray = SpawnerSystem::Spawn(spawner);
((glm::vec3&)ray["Transform"]["Scale"]).z = (distance / 100.f);
glm::vec3& orientation = ray["Transform"]["Orientation"];
orientation.x += angles.x;
orientation.y += angles.y;
glm::vec3 trajectory = direction * distance;
dealDamage(wi, direction, pelletDamage);
}
}
}
void DefenderWeaponBehaviour::dealDamage(WeaponInfo& wi, glm::vec3 direction, double damage)
{
// Only deal damage client side
if (!IsClient) {
return;
}
// Only handle shooting for the local player
if (wi.Player != LocalPlayer) {
return;
}
// Make sure the player isn't shooting from the grave
if (!wi.Player.Valid()) {
return;
}
glm::vec3 maxRange = direction * 2.f;
EntityWrapper camera = wi.Player.FirstChildByName("Camera");
glm::vec3 cameraPosition = Transform::AbsolutePosition(camera);
if (!camera.Valid()) {
return;
}
Rectangle screenResolution = m_Renderer->GetViewportSize();
glm::vec2 centerScreen = glm::vec2(screenResolution.Width / 2, screenResolution.Height / 2);
glm::vec2 screenCoords = cameraFromEntity(m_CurrentCamera).WorldToScreen(cameraPosition + maxRange, m_Renderer->GetViewportSize());
PickData pickData = m_Renderer->Pick(centerScreen + screenCoords);
EntityWrapper victim(m_World, pickData.Entity);
if (!victim.Valid()) {
return;
}
// Don't let us shoot ourselves in the foot somehow
if (victim == LocalPlayer) {
return;
}
// Only care about players being hit
if (!victim.HasComponent("Player")) {
victim = victim.FirstParentWithComponent("Player");
}
if (!victim.Valid()) {
return;
}
// Check for friendly fire
if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)wi.Player["Team"]["Team"]) {
return;
}
// Deal damage!
Events::PlayerDamage ePlayerDamage;
ePlayerDamage.Inflictor = wi.Player;
ePlayerDamage.Victim = victim;
ePlayerDamage.Damage = damage;
m_EventBroker->Publish(ePlayerDamage);
LOG_DEBUG("Damage: %f", damage);
}
float DefenderWeaponBehaviour::traceRayDistance(glm::vec3 origin, glm::vec3 direction)
{
float distance;
glm::vec3 pos;
auto entity = Collision::EntityFirstHitByRay(Ray(origin, direction), m_CollisionOctree, distance, pos);
if (entity) {
return distance;
} else {
return 100.f;
}
}
Camera DefenderWeaponBehaviour::cameraFromEntity(EntityWrapper camera)
{
ComponentWrapper cTransform = camera["Transform"];
ComponentWrapper cCamera = camera["Camera"];
Camera cam(
(float)m_Renderer->Resolution().Width / m_Renderer->Resolution().Height,
(double)cCamera["FOV"],
(double)cCamera["NearClip"],
(double)cCamera["FarClip"]
);
cam.SetPosition(cTransform["Position"]);
cam.SetOrientation(glm::quat((const glm::vec3&)cTransform["Orientation"]));
return cam;
}
@@ -13,7 +13,7 @@ WeaponSystem::WeaponSystem(SystemParams params, IRenderer* renderer, Octree<Enti
void WeaponSystem::Update(double dt) void WeaponSystem::Update(double dt)
{ {
// TODO: Clear inactive weapons
} }
void WeaponSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cPlayer, double dt) void WeaponSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cPlayer, double dt)
@@ -72,20 +72,64 @@ bool WeaponSystem::OnInputCommand(Events::InputCommand& e)
void WeaponSystem::selectWeapon(EntityWrapper player, ComponentInfo::EnumType slot) void WeaponSystem::selectWeapon(EntityWrapper player, ComponentInfo::EnumType slot)
{ {
std::vector<EntityWrapper> weaponAttachments = player.ChildrenWithComponent("WeaponAttachment");
// Find the weapon attachments matching the slot selected
EntityWrapper firstPersonAttachment;
EntityWrapper thirdPersonAttachment;
for (auto& attachment : weaponAttachments) {
ComponentWrapper cWeaponAttachment = attachment["WeaponAttachment"];
if ((ComponentInfo::EnumType)cWeaponAttachment["Slot"] == slot) {
ComponentWrapper::SubscriptProxy person = cWeaponAttachment["Person"];
if (person == person.Enum("FirstPerson")) {
firstPersonAttachment = attachment;
} else if (person == person.Enum("ThirdPerson")) {
thirdPersonAttachment = attachment;
}
}
}
if (firstPersonAttachment.Valid() && thirdPersonAttachment.Valid()) {
LOG_WARNING("No weapon attachment found for slot %i of player #%i", slot, player.ID);
return;
}
// TODO: Delete old weapons
// Spawn the weapon(s)
EntityWrapper firstPersonWeapon;
EntityWrapper thirdPersonWeapon;
if (firstPersonAttachment.Valid()) {
firstPersonWeapon = SpawnerSystem::Spawn(firstPersonAttachment, firstPersonAttachment);
}
if (thirdPersonAttachment.Valid()) {
firstPersonWeapon = SpawnerSystem::Spawn(thirdPersonAttachment, thirdPersonAttachment);
}
// Create the correct behaviour
if (firstPersonWeapon.Valid()) {
if (firstPersonWeapon.HasComponent("AssaultWeapon") {
}
}
// Primary // Primary
if (slot == 1) { if (slot == 1) {
// TODO: if class... // TODO: if class...
if (m_ActiveWeapons.count(player) == 0) { nextBehaviour = std::make_shared<AssaultWeaponBehaviour>(m_SystemParams, m_Renderer, m_CollisionOctree, player);
m_ActiveWeapons.insert(std::make_pair(player, std::make_shared<AssaultWeaponBehaviour>(m_SystemParams, m_Renderer, m_CollisionOctree, player)));
} else {
//m_ActiveWeapons.erase(player);
}
} }
// Secondary // Secondary
if (slot == 2) { if (slot == 2) {
//m_ActiveWeapons[player] = std::make_shared<PistolWeaponBehaviour>(); //m_ActiveWeapons[player] = std::make_shared<PistolWeaponBehaviour>();
} }
if (nextBehaviour != nullptr) {
// TODO: Destroy previous behaviour and make new
if (m_ActiveWeapons.count(player) == 0) {
m_ActiveWeapons[player] = nextBehaviour;
}
}
} }
bool WeaponSystem::OnPlayerSpawned(Events::PlayerSpawned& e) bool WeaponSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
+2
View File
@@ -9,7 +9,9 @@ int main(int argc, char* argv[])
Game game(argc, argv); Game game(argc, argv);
while (game.Running()) { while (game.Running()) {
PerformanceTimer::StartTimer("Game-Tick");
game.Tick(); game.Tick();
PerformanceTimer::StopTimer("Game-Tick");
} }
return 0; return 0;