Compare commits
113 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b81f2b3240 | |||
| 03d77beff9 | |||
| 64e7bb1e94 | |||
| a33cd42ca3 | |||
| 9055d5f697 | |||
| 971beb29d8 | |||
| 2ee21e05d4 | |||
| 5987751add | |||
| 94b59af973 | |||
| 70f8237a16 | |||
| 99cbdd3c1e | |||
| ce22854168 | |||
| 35b0193f15 | |||
| f8e514d21e | |||
| fad25c6e16 | |||
| 4103c878ec | |||
| 40788c7400 | |||
| 59bdc614f2 | |||
| be628d9406 | |||
| 66f442f1af | |||
| 2542397511 | |||
| 7641ba49c7 | |||
| fe6fd0bbe3 | |||
| e3a44d37d2 | |||
| 428dca003d | |||
| 4fe9e4f1c3 | |||
| d61e605093 | |||
| c526a7af55 | |||
| 6a23a987b3 | |||
| 7c582898f4 | |||
| ff26e1235c | |||
| 6990e473b3 | |||
| c87e4d4fd6 | |||
| d4292d4b43 | |||
| 035c79564b | |||
| 379d211832 | |||
| 03a16b46b5 | |||
| 0bbaf1d576 | |||
| bc01e147c2 | |||
| 1bd4aa91ff | |||
| 7b5a2a5388 | |||
| bd2da7bc9f | |||
| b56824786c | |||
| 13161b4f57 | |||
| 5665c0f298 | |||
| 7ffbd8455f | |||
| 83713b3b6d | |||
| 7bae2d0873 | |||
| 9d3171540d | |||
| 2391a0dbe9 | |||
| 2961f198b3 | |||
| 455e59a04f | |||
| 39653a1e4c | |||
| 2cbeef4c69 | |||
| 192de80782 | |||
| 51a588657e | |||
| 73ab9bb4c6 | |||
| 73716c28e2 | |||
| a3b7bd7df5 | |||
| c4fb604617 | |||
| 214dad2afc | |||
| affcc5305b | |||
| 11025b5466 | |||
| 5e472cd69c | |||
| eba36b8492 | |||
| 55854f5c0d | |||
| 12a181c1ff | |||
| b131f56f5e | |||
| 24aac6a00d | |||
| 7236da09b4 | |||
| 6a3f585fb9 | |||
| 7b4826cb44 | |||
| 28d412f5c7 | |||
| 563fd4082e | |||
| 9c2e459e0c | |||
| 796e3eac79 | |||
| 8299b99e2f | |||
| c708f1582c | |||
| 782c1a388a | |||
| a188a3f7fa | |||
| ed7d00c1d8 | |||
| 30b1dab764 | |||
| 5a45f778e6 | |||
| 53cae25eb2 | |||
| 30ad238697 | |||
| 3cfbbbbf54 | |||
| d7b02e79c8 | |||
| 76274c326e | |||
| 7054822be2 | |||
| 7987d4b27c | |||
| df05f1909b | |||
| 8bcafc1151 | |||
| 7497ff39d2 | |||
| 97cbc55223 | |||
| 5cdf6db340 | |||
| 90f05442aa | |||
| 6ea490e215 | |||
| 3389b965eb | |||
| f1343e2f82 | |||
| c9dc9a3570 | |||
| 910b3d10e4 | |||
| e6224a4e96 | |||
| 6eeb3ea524 | |||
| 71404c8828 | |||
| 3974c649ab | |||
| 1670fb4e48 | |||
| 3955e1d60c | |||
| d25804e6f8 | |||
| 52765cc85b | |||
| d2984c6ae4 | |||
| 9f6fa40448 | |||
| de7c8e9234 | |||
| 4d5b835352 |
+1
-1
Submodule assets updated: 091ad5c01b...cfeeb1f880
@@ -28,6 +28,21 @@ bool RayVsAABB(const Ray& ray, const AABB& box);
|
|||||||
//Return true if the ray hits the box, also outputs distance from ray origin to intersection point in [outDistance].
|
//Return true if the ray hits the box, also outputs distance from ray origin to intersection point in [outDistance].
|
||||||
bool RayVsAABB(const Ray& ray, const AABB& box, float& outDistance);
|
bool RayVsAABB(const Ray& ray, const AABB& box, float& outDistance);
|
||||||
|
|
||||||
|
//Return true if the ray hits the triangle.
|
||||||
|
bool RayVsTriangle(const Ray& ray,
|
||||||
|
const glm::vec3& v0,
|
||||||
|
const glm::vec3& v1,
|
||||||
|
const glm::vec3& v2,
|
||||||
|
bool trueOnNegativeDistance = false);
|
||||||
|
//Return true if the ray hits the triangle, and the distance is less than outDistance.
|
||||||
|
bool RayVsTriangle(const Ray& ray,
|
||||||
|
const glm::vec3& v0,
|
||||||
|
const glm::vec3& v1,
|
||||||
|
const glm::vec3& v2,
|
||||||
|
float& outDistance,
|
||||||
|
float& outUCoord,
|
||||||
|
float& outVCoord,
|
||||||
|
bool trueOnNegativeDistance = false);
|
||||||
//Return true if the ray hits any of the triangles in the model. Stops checking when a hit is detected.
|
//Return true if the ray hits any of the triangles in the model. Stops checking when a hit is detected.
|
||||||
bool RayVsModel(const Ray& ray,
|
bool RayVsModel(const Ray& ray,
|
||||||
const std::vector<RawModel::Vertex>& modelVertices,
|
const std::vector<RawModel::Vertex>& modelVertices,
|
||||||
@@ -52,6 +67,9 @@ bool AABBvsTriangles(const AABB& box,
|
|||||||
const std::vector<RawModel::Vertex>& modelVertices,
|
const std::vector<RawModel::Vertex>& modelVertices,
|
||||||
const std::vector<unsigned int>& modelIndices,
|
const std::vector<unsigned int>& modelIndices,
|
||||||
const glm::mat4& modelMatrix,
|
const glm::mat4& modelMatrix,
|
||||||
|
glm::vec3& boxVelocity,
|
||||||
|
float verticalStepHeight,
|
||||||
|
bool& isOnGround,
|
||||||
glm::vec3& outResolutionVector);
|
glm::vec3& outResolutionVector);
|
||||||
|
|
||||||
//Return true if the boxes are intersecting.
|
//Return true if the boxes are intersecting.
|
||||||
|
|||||||
@@ -43,6 +43,11 @@ struct ComponentWrapper
|
|||||||
// Specialization for string literals
|
// Specialization for string literals
|
||||||
template <std::size_t N>
|
template <std::size_t N>
|
||||||
void SetField(std::string name, const char(&value)[N]) { Field<std::string>(name) = std::string(value); }
|
void SetField(std::string name, const char(&value)[N]) { Field<std::string>(name) = std::string(value); }
|
||||||
|
|
||||||
|
void Copy(ComponentWrapper& destination)
|
||||||
|
{
|
||||||
|
memcpy(destination.Data, this->Data, Info.Stride);
|
||||||
|
}
|
||||||
|
|
||||||
struct SubscriptProxy
|
struct SubscriptProxy
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#ifndef EPickupSpawned_h__
|
||||||
|
#define EPickupSpawned_h__
|
||||||
|
|
||||||
|
#include "Core/Event.h"
|
||||||
|
#include "Core/EntityWrapper.h"
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct PickupSpawned : Event
|
||||||
|
{
|
||||||
|
EntityWrapper Pickup;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -9,6 +9,7 @@ namespace Events
|
|||||||
|
|
||||||
struct PlayerDamage : Event
|
struct PlayerDamage : Event
|
||||||
{
|
{
|
||||||
|
//NOTE: this struct is missing information on what the damageSource is
|
||||||
EntityWrapper Player;
|
EntityWrapper Player;
|
||||||
double Damage;
|
double Damage;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#define EPlayerDeath_h__
|
#define EPlayerDeath_h__
|
||||||
|
|
||||||
#include "EventBroker.h"
|
#include "EventBroker.h"
|
||||||
#include "../Core/Entity.h"
|
#include "../Core/EntityWrapper.h"
|
||||||
|
|
||||||
namespace Events
|
namespace Events
|
||||||
{
|
{
|
||||||
@@ -10,8 +10,7 @@ namespace Events
|
|||||||
struct PlayerDeath : Event
|
struct PlayerDeath : Event
|
||||||
{
|
{
|
||||||
//KilledBy,KilledByWhat is optional for now. It might be used later in the playerlog-system
|
//KilledBy,KilledByWhat is optional for now. It might be used later in the playerlog-system
|
||||||
EntityID KilledBy;
|
EntityWrapper Player;
|
||||||
EntityID PlayerID;
|
|
||||||
std::string KilledByWhat;
|
std::string KilledByWhat;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2,16 +2,16 @@
|
|||||||
#define EPlayerHealthPickup_h__
|
#define EPlayerHealthPickup_h__
|
||||||
|
|
||||||
#include "EventBroker.h"
|
#include "EventBroker.h"
|
||||||
#include "../Core/Entity.h"
|
#include "../Core/EntityWrapper.h"
|
||||||
|
|
||||||
namespace Events
|
namespace Events
|
||||||
{
|
{
|
||||||
|
|
||||||
struct PlayerHealthPickup : Event
|
struct PlayerHealthPickup : Event
|
||||||
{
|
{
|
||||||
double HealthAmount;
|
EntityWrapper Player;
|
||||||
EntityID PlayerHealedID;
|
double HealthAmount;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public:
|
|||||||
m_ExtraMemory.push_back((char*)malloc(m_Stride));
|
m_ExtraMemory.push_back((char*)malloc(m_Stride));
|
||||||
//We should preferably not enter here to avoid performance issues. Set more numMaxElements in constructor instead.
|
//We should preferably not enter here to avoid performance issues. Set more numMaxElements in constructor instead.
|
||||||
if (!DisableMemoryPool::Value) {
|
if (!DisableMemoryPool::Value) {
|
||||||
LOG_WARNING("Allocated slots exceed Pool size, extra memory allocated dynamically. Pool size: %u, dynamic size: %u.", m_NumSlots, m_ExtraMemory.size());
|
LOG_DEBUG("Allocated slots exceed Pool size, extra memory allocated dynamically. Pool size: %u, dynamic size: %u.", m_NumSlots, m_ExtraMemory.size());
|
||||||
}
|
}
|
||||||
return m_ExtraMemory.back();
|
return m_ExtraMemory.back();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ struct Child
|
|||||||
std::vector<ContainedObject>& m_StaticObjectsRef;
|
std::vector<ContainedObject>& m_StaticObjectsRef;
|
||||||
std::vector<ContainedObject>& m_DynamicObjectsRef;
|
std::vector<ContainedObject>& m_DynamicObjectsRef;
|
||||||
|
|
||||||
bool hasChildren() const;
|
inline bool hasChildren() const { return m_Children[0] != nullptr; }
|
||||||
int childIndexContainingPoint(const glm::vec3& point) const;
|
int childIndexContainingPoint(const glm::vec3& point) const;
|
||||||
std::vector<int> childIndicesContainingBox(const AABB& box) const;
|
std::vector<int> childIndicesContainingBox(const AABB& box) const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,6 +7,10 @@
|
|||||||
class Ray
|
class Ray
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Ray()
|
||||||
|
: m_Origin(glm::vec3(0.f))
|
||||||
|
, m_Direction(glm::vec3(0, 0, 1))
|
||||||
|
{}
|
||||||
Ray(const glm::vec3& origin, const glm::vec3& dir)
|
Ray(const glm::vec3& origin, const glm::vec3& dir)
|
||||||
: m_Origin(origin)
|
: m_Origin(origin)
|
||||||
, m_Direction(glm::normalize(dir))
|
, m_Direction(glm::normalize(dir))
|
||||||
|
|||||||
@@ -200,13 +200,16 @@ static T* ResourceManager::Load(const std::string& resourceName, Resource* paren
|
|||||||
}
|
}
|
||||||
|
|
||||||
//If resource has already been cached and completely loaded.
|
//If resource has already been cached and completely loaded.
|
||||||
it = m_ResourceCache.find(cacheKey);
|
{
|
||||||
if (it != m_ResourceCache.end()) {
|
boost::lock_guard<decltype(m_Mutex)> guard(m_Mutex);
|
||||||
if (it->second != nullptr) {
|
it = m_ResourceCache.find(cacheKey);
|
||||||
return static_cast<T*>(it->second);
|
if (it != m_ResourceCache.end()) {
|
||||||
} else {
|
if (it->second != nullptr) {
|
||||||
//Don't return null on failure, exception instead.
|
return static_cast<T*>(it->second);
|
||||||
throw Resource::FailedLoadingException();
|
} else {
|
||||||
|
//Don't return null on failure, exception instead.
|
||||||
|
throw Resource::FailedLoadingException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ glm::vec3 AbsoluteScale(EntityWrapper entity);
|
|||||||
glm::vec3 AbsoluteScale(World* world, EntityID entity);
|
glm::vec3 AbsoluteScale(World* world, EntityID entity);
|
||||||
glm::mat4 ModelMatrix(EntityWrapper entity);
|
glm::mat4 ModelMatrix(EntityWrapper entity);
|
||||||
glm::mat4 ModelMatrix(EntityID entity, World* world);
|
glm::mat4 ModelMatrix(EntityID entity, World* world);
|
||||||
|
glm::vec3 TransformPoint(const glm::vec3& point, const glm::mat4& matrix);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "../GLM.h"
|
#include "../GLM.h"
|
||||||
#include "../Core/InputController.h"
|
#include "../Core/InputController.h"
|
||||||
#include "../Core/ELockMouse.h"
|
#include "../Core/ELockMouse.h"
|
||||||
|
#include "InputHandler.h"
|
||||||
|
|
||||||
template <typename EventContext>
|
template <typename EventContext>
|
||||||
class FirstPersonInputController : public InputController<EventContext>
|
class FirstPersonInputController : public InputController<EventContext>
|
||||||
@@ -25,6 +26,10 @@ 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);
|
||||||
|
virtual bool AssaultDashDoubleTapped() const { return m_AssaultDashDoubleTapped; }
|
||||||
|
virtual bool PlayerIsDashing() const { return m_PlayerIsDashing; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const int m_PlayerID;
|
const int m_PlayerID;
|
||||||
bool m_MouseLocked = false;
|
bool m_MouseLocked = false;
|
||||||
@@ -33,6 +38,22 @@ protected:
|
|||||||
bool m_Jumping = false;
|
bool m_Jumping = false;
|
||||||
bool m_DoubleJumping = false;
|
bool m_DoubleJumping = false;
|
||||||
bool m_Crouching = false;
|
bool m_Crouching = false;
|
||||||
|
//assault dash membervariables - needed to calculate the doubletap- and dashlogic
|
||||||
|
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),
|
||||||
|
//and its very unlikely that someone wants to change that value
|
||||||
|
const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f;
|
||||||
|
std::string m_AssaultDashTapDirection = "";
|
||||||
|
std::string m_CurrentDirectionVector = "";
|
||||||
|
bool m_AssaultDashDoubleTapped = false;
|
||||||
|
bool m_PlayerIsDashing = false;
|
||||||
|
bool m_ShiftDashing = false;
|
||||||
|
bool m_ValidDoubleTap = false;
|
||||||
|
|
||||||
|
//specialabilitys
|
||||||
|
bool m_MovementKeyDown = false;
|
||||||
|
bool m_SpecialAbilityKeyDown = false;
|
||||||
|
|
||||||
EventRelay<EventContext, Events::LockMouse> m_ELockMouse;
|
EventRelay<EventContext, Events::LockMouse> m_ELockMouse;
|
||||||
bool OnLockMouse(const Events::LockMouse& e);
|
bool OnLockMouse(const Events::LockMouse& e);
|
||||||
@@ -104,6 +125,26 @@ bool FirstPersonInputController<EventContext>::OnCommand(const Events::InputComm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (e.Command == "Forward" || e.Command == "Right") {
|
||||||
|
if (e.Value != 0) {
|
||||||
|
m_CurrentDirectionVector = e.Command == "Right" ? (e.Value > 0 ? "Right" : "Left") : (e.Value > 0 ? "Forward" : "Backward");
|
||||||
|
}
|
||||||
|
//if value = 0 then you have just released this key
|
||||||
|
if (e.Value != 0) {
|
||||||
|
m_MovementKeyDown = true;
|
||||||
|
//if you pressed the same key within m_AssaultDashDoubleTapSensitivityTimer then you have doubletapped it
|
||||||
|
if (m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer && m_AssaultDashTapDirection == m_CurrentDirectionVector) {
|
||||||
|
m_ValidDoubleTap = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//== 0
|
||||||
|
m_MovementKeyDown = false;
|
||||||
|
//you have just released the key, store what key it was and reset the doubletap-sensitivity-timer
|
||||||
|
m_AssaultDashTapDirection = m_CurrentDirectionVector;
|
||||||
|
m_AssaultDashDoubleTapDeltaTime = 0.f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (e.Command == "Jump") {
|
if (e.Command == "Jump") {
|
||||||
m_Jumping = e.Value > 0;
|
m_Jumping = e.Value > 0;
|
||||||
}
|
}
|
||||||
@@ -112,6 +153,19 @@ bool FirstPersonInputController<EventContext>::OnCommand(const Events::InputComm
|
|||||||
m_Crouching = e.Value > 0;
|
m_Crouching = e.Value > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (e.Command == "SpecialAbility") {
|
||||||
|
if (e.Value > 0) {
|
||||||
|
m_SpecialAbilityKeyDown = true;
|
||||||
|
} else {
|
||||||
|
m_SpecialAbilityKeyDown = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m_SpecialAbilityKeyDown && m_MovementKeyDown) {
|
||||||
|
m_ShiftDashing = true;
|
||||||
|
} else {
|
||||||
|
m_ShiftDashing = false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,4 +183,53 @@ bool FirstPersonInputController<EventContext>::OnLockMouse(const Events::LockMou
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename EventContext>
|
||||||
|
void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer) {
|
||||||
|
m_AssaultDashDoubleTapDeltaTime += dt;
|
||||||
|
m_AssaultDashCoolDownTimer -= dt;
|
||||||
|
//cooldown = assaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work)
|
||||||
|
if (m_AssaultDashCoolDownTimer > (assaultDashCoolDownMaxTimer - 0.25f)) {
|
||||||
|
m_PlayerIsDashing = true;
|
||||||
|
} else {
|
||||||
|
m_PlayerIsDashing = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//dashing with shift
|
||||||
|
if (m_ShiftDashing && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) {
|
||||||
|
//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!
|
||||||
|
m_AssaultDashCoolDownTimer = assaultDashCoolDownMaxTimer;
|
||||||
|
m_AssaultDashDoubleTapped = true;
|
||||||
|
m_AssaultDashDoubleTapDeltaTime = 0.f;
|
||||||
|
//moving to the side has priority
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//dashing with doubletap - check if doubletap to dash enabled
|
||||||
|
if (ResourceManager::Load<ConfigFile>("Input.ini")->Get<bool>("Keyboard.DoubleTapToDash", false)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//reset the DoubleTapped state in case we recently doubleTapped (doubletap will only happen during 1 frame)
|
||||||
|
if (m_AssaultDashDoubleTapped) {
|
||||||
|
m_AssaultDashDoubleTapped = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//check if we have received a valid doubletap
|
||||||
|
if (!m_ValidDoubleTap) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_ValidDoubleTap = false;
|
||||||
|
|
||||||
|
if (!(m_AssaultDashCoolDownTimer <= 0.0f && !isJumping)) {
|
||||||
|
//if we cant dash at the moment, then just reset the tap-sensitivity-timer
|
||||||
|
m_AssaultDashDoubleTapDeltaTime = 0.f;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//ok, we have a valid tap, lets do it
|
||||||
|
m_AssaultDashDoubleTapped = true;
|
||||||
|
m_AssaultDashDoubleTapDeltaTime = 0.f;
|
||||||
|
m_AssaultDashCoolDownTimer = assaultDashCoolDownMaxTimer;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -36,7 +36,7 @@ private:
|
|||||||
boost::asio::ip::udp::socket m_Socket;
|
boost::asio::ip::udp::socket m_Socket;
|
||||||
|
|
||||||
// Sending message to server logic
|
// Sending message to server logic
|
||||||
int bytesRead = -1;
|
size_t bytesRead = 0;
|
||||||
char readBuf[INPUTSIZE] = { 0 };
|
char readBuf[INPUTSIZE] = { 0 };
|
||||||
|
|
||||||
// Packet loss logic
|
// Packet loss logic
|
||||||
@@ -69,7 +69,7 @@ private:
|
|||||||
|
|
||||||
// Private member functions
|
// Private member functions
|
||||||
void readFromServer();
|
void readFromServer();
|
||||||
int receive(char* data);
|
size_t receive(char* data);
|
||||||
void send(Packet& packet);
|
void send(Packet& packet);
|
||||||
void connect();
|
void connect();
|
||||||
void disconnect();
|
void disconnect();
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ protected:
|
|||||||
unsigned int m_SaveDataIntervalMs = 1000;
|
unsigned int m_SaveDataIntervalMs = 1000;
|
||||||
std::clock_t m_SaveDataTimer;
|
std::clock_t m_SaveDataTimer;
|
||||||
unsigned int m_MaxConnections;
|
unsigned int m_MaxConnections;
|
||||||
unsigned int m_TimeoutMs;
|
double m_TimeoutMs;
|
||||||
void saveToFile();
|
void saveToFile();
|
||||||
void updateNetworkData();
|
void updateNetworkData();
|
||||||
void initialize();
|
void initialize();
|
||||||
|
|||||||
@@ -3,16 +3,16 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct NetworkData {
|
struct NetworkData {
|
||||||
unsigned int TotalTime = 0;
|
double TotalTime = 0;
|
||||||
unsigned int TotalDataReceived = 0;
|
size_t TotalDataReceived = 0;
|
||||||
unsigned int TotalDataSent = 0;
|
size_t TotalDataSent = 0;
|
||||||
unsigned int AmountOfMessagesReceived = 0;
|
size_t AmountOfMessagesReceived = 0;
|
||||||
unsigned int AmountOfMessagesSent = 0;
|
unsigned int AmountOfMessagesSent = 0;
|
||||||
// Interval based
|
// Interval based
|
||||||
unsigned int DataReceivedThisInterval = 0;
|
size_t DataReceivedThisInterval = 0;
|
||||||
unsigned int DataSentThisInterval = 0;
|
size_t DataSentThisInterval = 0;
|
||||||
// pair: first=reveived, second=send
|
// pair: first=reveived, second=send
|
||||||
std::vector<std::pair<unsigned int, unsigned int>> BandwidthBytes;
|
std::vector<std::pair<size_t, size_t>> BandwidthBytes;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -13,7 +13,7 @@ public:
|
|||||||
// arg2: PacketID for identifying packet loss.
|
// arg2: PacketID for identifying packet loss.
|
||||||
Packet(MessageType type, unsigned int& packetID);
|
Packet(MessageType type, unsigned int& packetID);
|
||||||
// Used to create packet from already existing data buffer.
|
// Used to create packet from already existing data buffer.
|
||||||
Packet(char* data, const int sizeOfPacket);
|
Packet(char* data, const size_t sizeOfPacket);
|
||||||
Packet(MessageType type);
|
Packet(MessageType type);
|
||||||
~Packet();
|
~Packet();
|
||||||
void Init(MessageType type, unsigned int& packetID);
|
void Init(MessageType type, unsigned int& packetID);
|
||||||
@@ -51,18 +51,18 @@ public:
|
|||||||
std::string ReadString();
|
std::string ReadString();
|
||||||
char* ReadData(int SizeOfData);
|
char* ReadData(int SizeOfData);
|
||||||
void ChangePacketID(unsigned int& packetID);
|
void ChangePacketID(unsigned int& packetID);
|
||||||
int Size() { return m_Offset; };
|
size_t Size() { return m_Offset; };
|
||||||
char* Data() { return m_Data; };
|
char* Data() { return m_Data; };
|
||||||
unsigned int DataReadSize() { return m_ReturnDataOffset; }
|
size_t DataReadSize() { return m_ReturnDataOffset; }
|
||||||
unsigned int MaxSize() { return m_MaxPacketSize; }
|
size_t MaxSize() { return m_MaxPacketSize; }
|
||||||
unsigned int HeaderSize() { return m_HeaderSize; }
|
size_t HeaderSize() { return m_HeaderSize; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char* m_Data;
|
char* m_Data;
|
||||||
unsigned int m_ReturnDataOffset = 0;
|
size_t m_ReturnDataOffset = 0;
|
||||||
int m_Offset = 0;
|
size_t m_Offset = 0;
|
||||||
unsigned int m_MaxPacketSize = 512;
|
size_t m_MaxPacketSize = 512;
|
||||||
unsigned int m_HeaderSize = 0;
|
size_t m_HeaderSize = 0;
|
||||||
void resizeData();
|
void resizeData();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -36,14 +36,14 @@ private:
|
|||||||
std::map<PlayerID, PlayerDefinition> m_ConnectedPlayers;
|
std::map<PlayerID, PlayerDefinition> m_ConnectedPlayers;
|
||||||
// HACK: Fix INPUTSIZE
|
// HACK: Fix INPUTSIZE
|
||||||
char readBuffer[INPUTSIZE] = { 0 };
|
char readBuffer[INPUTSIZE] = { 0 };
|
||||||
int bytesRead = 0;
|
size_t bytesRead = 0;
|
||||||
// time for previouse message
|
// time for previouse message
|
||||||
std::clock_t previousePingMessage = std::clock();
|
std::clock_t previousePingMessage = std::clock();
|
||||||
std::clock_t previousSnapshotMessage = std::clock();
|
std::clock_t previousSnapshotMessage = std::clock();
|
||||||
std::clock_t timOutTimer = std::clock();
|
std::clock_t timOutTimer = std::clock();
|
||||||
// How often we send messages (milliseconds)
|
// How often we send messages (milliseconds)
|
||||||
int pingIntervalMs;
|
float pingIntervalMs;
|
||||||
int snapshotInterval;
|
float snapshotInterval;
|
||||||
int checkTimeOutInterval = 100;
|
int checkTimeOutInterval = 100;
|
||||||
int m_NextPlayerID = 0;
|
int m_NextPlayerID = 0;
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ private:
|
|||||||
PacketID m_PreviousPacketID = 0;
|
PacketID m_PreviousPacketID = 0;
|
||||||
|
|
||||||
// Private member functions
|
// Private member functions
|
||||||
int receive(char* data);
|
size_t receive(char* data);
|
||||||
void readFromClients();
|
void readFromClients();
|
||||||
void send(PlayerID player, Packet& packet);
|
void send(PlayerID player, Packet& packet);
|
||||||
void send(Packet& packet);
|
void send(Packet& packet);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "ShaderProgram.h"
|
#include "ShaderProgram.h"
|
||||||
//#include "Util/UnorderedMapVec2.h"
|
//#include "Util/UnorderedMapVec2.h"
|
||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
|
#include "imgui/imgui.h"
|
||||||
|
|
||||||
class DrawBloomPass
|
class DrawBloomPass
|
||||||
{
|
{
|
||||||
@@ -26,27 +27,36 @@ public:
|
|||||||
|
|
||||||
//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 { return m_FinalBlurTexture; }
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
||||||
|
void BlurOneMipMapLevel(GLuint* texture, GLint iterations, GLint mipMapLevel);
|
||||||
|
|
||||||
Texture* m_WhiteTexture;
|
Texture* m_WhiteTexture;
|
||||||
Model* m_ScreenQuad;
|
Model* m_ScreenQuad;
|
||||||
|
|
||||||
const IRenderer* m_Renderer;
|
const IRenderer* m_Renderer;
|
||||||
//const LightCullingPass* m_LightCullingPass
|
//const LightCullingPass* m_LightCullingPass
|
||||||
GLuint m_iterations = 9;
|
//GLuint m_iterations = 5;
|
||||||
|
GLint m_DebugTextureToDraw = 0;
|
||||||
|
GLint m_Iterations = 3;
|
||||||
|
|
||||||
|
float m_ScreenSizes[10];
|
||||||
|
|
||||||
|
GLuint m_FinalBlurTexture;
|
||||||
GLuint m_GaussianTexture_horiz;
|
GLuint m_GaussianTexture_horiz;
|
||||||
GLuint m_GaussianTexture_vert;
|
GLuint m_GaussianTexture_vert;
|
||||||
|
|
||||||
FrameBuffer m_GaussianFrameBuffer_horiz;
|
FrameBuffer m_GaussianFrameBuffer_horiz;
|
||||||
FrameBuffer m_GaussianFrameBuffer_vert;
|
FrameBuffer m_GaussianFrameBuffer_vert;
|
||||||
|
FrameBuffer m_BlurredFinalTexture;
|
||||||
|
|
||||||
ShaderProgram* m_GaussianProgram_horiz;
|
ShaderProgram* m_GaussianProgram_horiz;
|
||||||
ShaderProgram* m_GaussianProgram_vert;
|
ShaderProgram* m_GaussianProgram_vert;
|
||||||
|
ShaderProgram* m_GaussianProgram_both;
|
||||||
|
ShaderProgram* m_CombineProgram;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "ShaderProgram.h"
|
#include "ShaderProgram.h"
|
||||||
//#include "Util/UnorderedMapVec2.h"
|
//#include "Util/UnorderedMapVec2.h"
|
||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
|
#include "imgui/imgui.h"
|
||||||
|
|
||||||
class DrawColorCorrectionPass
|
class DrawColorCorrectionPass
|
||||||
{
|
{
|
||||||
@@ -16,14 +17,13 @@ public:
|
|||||||
void InitializeFrameBuffers();
|
void InitializeFrameBuffers();
|
||||||
void InitializeShaderPrograms();
|
void InitializeShaderPrograms();
|
||||||
|
|
||||||
void Draw(GLuint sceneTexture, GLuint bloomTexture);
|
void Draw(GLuint sceneTexture, GLuint bloomTexture, GLuint sceneTextureLowRes, GLuint bloomTextureLowRes, GLfloat gamma, GLfloat exposure);
|
||||||
private:
|
private:
|
||||||
const IRenderer* m_Renderer;
|
const IRenderer* m_Renderer;
|
||||||
|
|
||||||
ShaderProgram* m_ColorCorrectionProgram;
|
ShaderProgram* m_ColorCorrectionProgram;
|
||||||
|
|
||||||
Model* m_ScreenQuad;
|
Model* m_ScreenQuad;
|
||||||
GLfloat m_Exposure;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -22,15 +22,23 @@ public:
|
|||||||
|
|
||||||
//Return the texture that is used in later stages to apply the bloom effect
|
//Return the texture that is used in later stages to apply the bloom effect
|
||||||
GLuint BloomTexture() const { return m_BloomTexture; }
|
GLuint BloomTexture() const { return m_BloomTexture; }
|
||||||
|
GLuint BloomTextureLowRes() const { return m_BloomTextureLowRes; }
|
||||||
//Return the texture with diffuse and lighting of the scene.
|
//Return the texture with diffuse and lighting of the scene.
|
||||||
GLuint SceneTexture() const { return m_SceneTexture; }
|
GLuint SceneTexture() const { return m_SceneTexture; }
|
||||||
|
GLuint SceneTextureLowRes() const { return m_SceneTextureLowRes; }
|
||||||
|
//Return the framebuffer used in the scene rendering stage.
|
||||||
FrameBuffer* FinalPassFrameBuffer() { return &m_FinalPassFrameBuffer; }
|
FrameBuffer* FinalPassFrameBuffer() { return &m_FinalPassFrameBuffer; }
|
||||||
|
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 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 GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const;
|
||||||
void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& job, RenderScene& scene);
|
|
||||||
|
void DrawModelRenderQueues(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 DrawToDepthBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
||||||
|
|
||||||
void BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene);
|
void BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene);
|
||||||
void BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene);
|
void BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene);
|
||||||
@@ -44,15 +52,24 @@ private:
|
|||||||
Texture* m_GreyTexture;
|
Texture* m_GreyTexture;
|
||||||
|
|
||||||
FrameBuffer m_FinalPassFrameBuffer;
|
FrameBuffer m_FinalPassFrameBuffer;
|
||||||
|
FrameBuffer m_FinalPassFrameBufferLowRes;
|
||||||
GLuint m_BloomTexture;
|
GLuint m_BloomTexture;
|
||||||
GLuint m_SceneTexture;
|
GLuint m_SceneTexture;
|
||||||
|
GLuint m_BloomTextureLowRes;
|
||||||
|
GLuint m_SceneTextureLowRes;
|
||||||
GLuint m_DepthBuffer;
|
GLuint m_DepthBuffer;
|
||||||
|
GLuint m_DepthBufferLowRes;
|
||||||
|
|
||||||
|
//maqke this component based i guess?
|
||||||
|
GLuint m_ShieldPixelRate = 16;
|
||||||
|
|
||||||
const IRenderer* m_Renderer;
|
const IRenderer* m_Renderer;
|
||||||
const LightCullingPass* m_LightCullingPass;
|
const LightCullingPass* m_LightCullingPass;
|
||||||
|
|
||||||
ShaderProgram* m_ForwardPlusProgram;
|
ShaderProgram* m_ForwardPlusProgram;
|
||||||
ShaderProgram* m_ExplosionEffectProgram;
|
ShaderProgram* m_ExplosionEffectProgram;
|
||||||
|
ShaderProgram* m_ShieldToStencilProgram;
|
||||||
|
ShaderProgram* m_FillDepthBufferProgram;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -12,4 +12,11 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DrawStencilState : public RenderState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DrawStencilState(GLuint frameBuffer);
|
||||||
|
~DrawStencilState();
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -19,27 +19,39 @@
|
|||||||
struct RenderScene
|
struct RenderScene
|
||||||
{
|
{
|
||||||
::Camera* Camera = nullptr;
|
::Camera* Camera = nullptr;
|
||||||
std::list<std::shared_ptr<RenderJob>> OpaqueObjects;
|
struct Queues {
|
||||||
std::list<std::shared_ptr<RenderJob>> TransparentObjects;
|
std::list<std::shared_ptr<RenderJob>> OpaqueObjects;
|
||||||
std::list<std::shared_ptr<RenderJob>> PointLightJobs;
|
std::list<std::shared_ptr<RenderJob>> TransparentObjects;
|
||||||
std::list<std::shared_ptr<RenderJob>> TextJobs;
|
std::list<std::shared_ptr<RenderJob>> OpaqueShieldedObjects;
|
||||||
std::list<std::shared_ptr<RenderJob>> DirectionalLightJobs;
|
std::list<std::shared_ptr<RenderJob>> TransparentShieldedObjects;
|
||||||
|
std::list<std::shared_ptr<RenderJob>> ShieldObjects;
|
||||||
|
std::list<std::shared_ptr<RenderJob>> PointLight;
|
||||||
|
std::list<std::shared_ptr<RenderJob>> Text;
|
||||||
|
std::list<std::shared_ptr<RenderJob>> DirectionalLight;
|
||||||
|
} Jobs;
|
||||||
|
|
||||||
Rectangle Viewport;
|
Rectangle Viewport;
|
||||||
bool ClearDepth = false;
|
bool ClearDepth = false;
|
||||||
|
glm::vec4 AmbientColor;
|
||||||
|
|
||||||
void Clear()
|
void Clear()
|
||||||
{
|
{
|
||||||
OpaqueObjects.clear();
|
Jobs.OpaqueObjects.clear();
|
||||||
TransparentObjects.clear();
|
Jobs.TransparentObjects.clear();
|
||||||
PointLightJobs.clear();
|
Jobs.OpaqueShieldedObjects.clear();
|
||||||
TextJobs.clear();
|
Jobs.TransparentShieldedObjects.clear();
|
||||||
DirectionalLightJobs.clear();
|
Jobs.ShieldObjects.clear();
|
||||||
|
Jobs.Text.clear();
|
||||||
|
Jobs.DirectionalLight.clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RenderFrame
|
struct RenderFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
//TODO: Getters
|
||||||
|
GLfloat Gamma = 2.2f;
|
||||||
|
GLfloat Exposure = 1.f;
|
||||||
|
|
||||||
void Add(RenderScene &scene)
|
void Add(RenderScene &scene)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define RenderState_h__
|
#define RenderState_h__
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <boost/range/adaptor/reversed.hpp>
|
||||||
#include "../Common.h"
|
#include "../Common.h"
|
||||||
#include "../OpenGL.h"
|
#include "../OpenGL.h"
|
||||||
#include "../GLM.h"
|
#include "../GLM.h"
|
||||||
@@ -19,6 +20,9 @@ public:
|
|||||||
bool BindFramebuffer(GLint framebuffer);
|
bool BindFramebuffer(GLint framebuffer);
|
||||||
bool BlendEquation(GLenum mode);
|
bool BlendEquation(GLenum mode);
|
||||||
bool BlendFunc(GLenum sfactor, GLenum dfactor);
|
bool BlendFunc(GLenum sfactor, GLenum dfactor);
|
||||||
|
bool StencilOp(GLenum sfail, GLenum dpfail, GLenum dppass);
|
||||||
|
bool StencilFunc(GLenum func, GLint ref, GLuint mask);
|
||||||
|
bool StencilMask(GLuint mask);
|
||||||
bool DepthMask(GLboolean flag);
|
bool DepthMask(GLboolean flag);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ private:
|
|||||||
EventRelay<RenderSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
EventRelay<RenderSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
||||||
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
||||||
|
|
||||||
void fillModels(std::list<std::shared_ptr<RenderJob>>& opaqueJobs, std::list<std::shared_ptr<RenderJob>>& transparentJobs);
|
void fillModels(RenderScene::Queues &jobs);
|
||||||
void fillText(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
void fillText(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||||
void fillPointLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
void fillPointLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||||
void fillDirectionalLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
void fillDirectionalLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ inline bool _GLERROR(const char* info, const char* file, const char* func, unsig
|
|||||||
GLenum error = glGetError();
|
GLenum error = glGetError();
|
||||||
if (error != GL_NO_ERROR)
|
if (error != GL_NO_ERROR)
|
||||||
{
|
{
|
||||||
_LOG(LOG_LEVEL_ERROR, file, func, line, "GL Error: %s, %i, %s", info, error, gluErrorString(error));
|
_LOG(LOG_LEVEL_ERROR, file, func, line, "GL Error: %s\nError code: %i, %s\n", info, error, gluErrorString(error));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
class HealthSystem : public PureSystem
|
class HealthSystem : public PureSystem
|
||||||
{
|
{
|
||||||
@@ -26,7 +27,7 @@ private:
|
|||||||
EventRelay<HealthSystem, Events::PlayerDamage> m_EPlayerDamage;
|
EventRelay<HealthSystem, Events::PlayerDamage> m_EPlayerDamage;
|
||||||
bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e);
|
bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e);
|
||||||
EventRelay<HealthSystem, Events::PlayerHealthPickup> m_EPlayerHealthPickup;
|
EventRelay<HealthSystem, Events::PlayerHealthPickup> m_EPlayerHealthPickup;
|
||||||
bool HealthSystem::OnPlayerHealthPickup(const Events::PlayerHealthPickup& e);
|
bool HealthSystem::OnPlayerHealthPickup(Events::PlayerHealthPickup& e);
|
||||||
|
|
||||||
//vector which will keep track of health changes
|
//vector which will keep track of health changes
|
||||||
std::vector<std::tuple<EntityID, double>> m_DeltaHealthVector;
|
std::vector<std::tuple<EntityID, double>> m_DeltaHealthVector;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class InterpolationSystem : public PureSystem
|
|||||||
glm::vec3 Position;
|
glm::vec3 Position;
|
||||||
glm::vec3 Scale;
|
glm::vec3 Scale;
|
||||||
glm::quat Orientation;
|
glm::quat Orientation;
|
||||||
double interpolationTime;
|
float interpolationTime;
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
InterpolationSystem(World* world, EventBroker* eventBroker);
|
InterpolationSystem(World* world, EventBroker* eventBroker);
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#ifndef PickupSpawnSystem_h__
|
||||||
|
#define PickupSpawnSystem_h__
|
||||||
|
|
||||||
|
#include "Core/System.h"
|
||||||
|
#include "Core/Transform.h"
|
||||||
|
#include "Core/ResourceManager.h"
|
||||||
|
#include "Core/EntityFileParser.h"
|
||||||
|
#include "Core/EPickupSpawned.h"
|
||||||
|
#include "Core/EPlayerHealthPickup.h"
|
||||||
|
#include "Engine/Collision/ETrigger.h"
|
||||||
|
#include "Common.h"
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
|
class PickupSpawnSystem : public ImpureSystem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PickupSpawnSystem(World* world, EventBroker* eventBroker);
|
||||||
|
|
||||||
|
virtual void Update(double dt) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
EventRelay<PickupSpawnSystem, Events::TriggerTouch> m_ETriggerTouch;
|
||||||
|
bool OnTriggerTouch(Events::TriggerTouch& e);
|
||||||
|
|
||||||
|
struct NewHealthPickup {
|
||||||
|
glm::vec3 Pos;
|
||||||
|
double HealthGain;
|
||||||
|
double RespawnTimer;
|
||||||
|
double DecreaseThisRespawnTimer;
|
||||||
|
};
|
||||||
|
std::vector<NewHealthPickup> m_ETriggerTouchVector;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
#ifndef PlayerDeathSystem_h__
|
||||||
|
#define PlayerDeathSystem_h__
|
||||||
|
|
||||||
|
#include "Core/System.h"
|
||||||
|
#include "Input/EInputCommand.h"
|
||||||
|
#include "GLM.h"
|
||||||
|
#include "Rendering/ESetCamera.h"
|
||||||
|
#include "Core/ConfigFile.h"
|
||||||
|
|
||||||
|
#include "Core/EntityFile.h"
|
||||||
|
#include "Core/EntityFileParser.h"
|
||||||
|
|
||||||
|
#include "Core/EPlayerDeath.h"
|
||||||
|
|
||||||
|
class PlayerDeathSystem : public ImpureSystem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PlayerDeathSystem(World* world, EventBroker* eventBroker);
|
||||||
|
|
||||||
|
virtual void Update(double dt) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
EventRelay<PlayerDeathSystem, Events::PlayerDeath> m_OnPlayerDeath;
|
||||||
|
bool OnPlayerDeath(Events::PlayerDeath& e);
|
||||||
|
|
||||||
|
void createDeathEffect(EntityWrapper player);
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif
|
||||||
@@ -20,4 +20,5 @@ private:
|
|||||||
|
|
||||||
EventRelay<PlayerMovementSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
EventRelay<PlayerMovementSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
||||||
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "Systems/SpawnerSystem.h"
|
#include "Systems/SpawnerSystem.h"
|
||||||
#include "Events/ESpawnerSpawn.h"
|
#include "Events/ESpawnerSpawn.h"
|
||||||
#include "Core/EPlayerSpawned.h"
|
#include "Core/EPlayerSpawned.h"
|
||||||
|
#include "Core/EPlayerDeath.h"
|
||||||
#include "Rendering/ESetCamera.h"
|
#include "Rendering/ESetCamera.h"
|
||||||
#include "Core/ConfigFile.h"
|
#include "Core/ConfigFile.h"
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ A=Right,-1
|
|||||||
R=Reload
|
R=Reload
|
||||||
Space=Jump
|
Space=Jump
|
||||||
LeftControl=Crouch
|
LeftControl=Crouch
|
||||||
LeftShift=Sprint
|
RightShift=Sprint
|
||||||
|
LeftShift=SpecialAbility
|
||||||
F1=ToggleEditor
|
F1=ToggleEditor
|
||||||
C=ConnectToServer
|
C=ConnectToServer
|
||||||
N=SwitchToServer
|
N=SwitchToServer
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
<xs:include schemaLocation="Components/AABB.xsd"/>
|
<xs:include schemaLocation="Components/AABB.xsd"/>
|
||||||
<xs:include schemaLocation="Components/PointLight.xsd"/>
|
<xs:include schemaLocation="Components/PointLight.xsd"/>
|
||||||
<xs:include schemaLocation="Components/DirectionalLight.xsd"/>
|
<xs:include schemaLocation="Components/DirectionalLight.xsd"/>
|
||||||
|
<xs:include schemaLocation="Components/SceneLight.xsd"/>
|
||||||
<xs:include schemaLocation="Components/Trigger.xsd"/>
|
<xs:include schemaLocation="Components/Trigger.xsd"/>
|
||||||
<xs:include schemaLocation="Components/ExplosionEffect.xsd"/>
|
<xs:include schemaLocation="Components/ExplosionEffect.xsd"/>
|
||||||
<xs:include schemaLocation="Components/Health.xsd"/>
|
<xs:include schemaLocation="Components/Health.xsd"/>
|
||||||
@@ -29,4 +30,8 @@
|
|||||||
<xs:include schemaLocation="Components/Fill.xsd"/>
|
<xs:include schemaLocation="Components/Fill.xsd"/>
|
||||||
<xs:include schemaLocation="Components/Lifetime.xsd"/>
|
<xs:include schemaLocation="Components/Lifetime.xsd"/>
|
||||||
<xs:include schemaLocation="Components/HiddenForLocalPlayer.xsd"/>
|
<xs:include schemaLocation="Components/HiddenForLocalPlayer.xsd"/>
|
||||||
|
<xs:include schemaLocation="Components/HealthPickup.xsd"/>
|
||||||
|
<xs:include schemaLocation="Components/DashAbility.xsd"/>
|
||||||
|
<xs:include schemaLocation="Components/Shield.xsd"/>
|
||||||
|
<xs:include schemaLocation="Components/Shielded.xsd"/>
|
||||||
</xs:schema>
|
</xs:schema>
|
||||||
@@ -7,10 +7,10 @@
|
|||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:all>
|
<xs:all>
|
||||||
<xs:element name="Origin" type="t:Vector" minOccurs="0">
|
<xs:element name="Origin" type="t:Vector" minOccurs="0">
|
||||||
<xs:annotation><xs:documentation>Middle point of the bounding box</xs:documentation></xs:annotation>
|
<xs:annotation><xs:documentation>Middle point of the bounding box, in model space</xs:documentation></xs:annotation>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
<xs:element name="Size" type="t:Vector" minOccurs="0">
|
<xs:element name="Size" type="t:Vector" minOccurs="0">
|
||||||
<xs:annotation><xs:documentation>Size of the bounding box</xs:documentation></xs:annotation>
|
<xs:annotation><xs:documentation>Size of the bounding box, in model space</xs:documentation></xs:annotation>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
</xs:all>
|
</xs:all>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<DashAbility xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="DashAbility.xsd">
|
||||||
|
<CoolDownMaxTimer>2.0</CoolDownMaxTimer>
|
||||||
|
</DashAbility>
|
||||||
@@ -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="DashAbility">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:documentation>A dash component for one of the classes</xs:documentation>
|
||||||
|
</xs:annotation>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:all>
|
||||||
|
<xs:element name="CoolDownMaxTimer" type="t:double" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>This is the cooldown on dash</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
</xs:all>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<HealthPickup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="HealthPickup.xsd">
|
||||||
|
<RespawnTimer>3</RespawnTimer>
|
||||||
|
<HealthGain>30</HealthGain>
|
||||||
|
</HealthPickup>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?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="HealthPickup">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:documentation>A Health Pickup</xs:documentation>
|
||||||
|
</xs:annotation>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:all>
|
||||||
|
<xs:element name="RespawnTimer" type="t:double" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>The respawn timer for a health pickup</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name="HealthGain" type="t:double" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>How much percent max-health the player will get when he picks the healthPickup up</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
</xs:all>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>
|
||||||
@@ -2,4 +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>
|
||||||
|
<IsOnGround>false</IsOnGround>
|
||||||
|
<VerticalStepHeight>0.33</VerticalStepHeight>
|
||||||
</Physics>
|
</Physics>
|
||||||
|
|||||||
@@ -13,6 +13,10 @@
|
|||||||
<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="IsOnGround" type="t:bool" 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:element>
|
||||||
</xs:all>
|
</xs:all>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<SceneLight xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="SceneLight.xsd">
|
||||||
|
<AmbientColor R="0.2" G="0.2" B="0.2" A="1"/>
|
||||||
|
<Visible>true</Visible>
|
||||||
|
<Gamma>2.2</Gamma>
|
||||||
|
<Exposure>1</Exposure>
|
||||||
|
</SceneLight>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?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="SceneLight">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:documentation>Some settings for the scene lighting</xs:documentation>
|
||||||
|
</xs:annotation>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:all>
|
||||||
|
<xs:element name="AmbientColor" type="t:Color" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>Color of the ambient light</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name="Visible" type="t:bool" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>Wether the ambient light should be applied or not</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name="Gamma" type="t:double" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>Gamma correction for the scene</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name="Exposure" type="t:double" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>The exposure of the camera</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
</xs:all>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Shield xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Shield.xsd">
|
||||||
|
</Shield>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?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="Shield">
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Shielded xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Shielded.xsd">
|
||||||
|
</Shielded>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?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="Shielded">
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity name="AssetBase" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCylinder.mesh</Resource>
|
||||||
|
<Color A="1" B="1.56862748" G="1.56862748" R="1.56862748"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="-0.231354833" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
|
||||||
|
<Children>
|
||||||
|
<Entity name="Light">
|
||||||
|
<Components>
|
||||||
|
<c:PointLight/>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0.663784981" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="RotationOrigin">
|
||||||
|
<Components>
|
||||||
|
<c:RaptorCopter>
|
||||||
|
<Speed>0.5</Speed>
|
||||||
|
<Axis X="0" Y="1" Z="0"/>
|
||||||
|
</c:RaptorCopter>
|
||||||
|
<c:Transform>
|
||||||
|
<Orientation X="0" Y="28.7916641" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity name="Asset">
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/AssaultWeaponBlue.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="1" Z="0"/>
|
||||||
|
<Orientation X="0.524000049" Y="0" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
|
||||||
|
</Entity>
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<c:AABB/>
|
<c:AABB/>
|
||||||
<c:CapturePoint/>
|
<c:CapturePoint/>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>C:\Users\123456\Workspace\TacticalZ\assets\Models\Core\UnitSphere.mesh</Resource>
|
<Resource>Models/Core/UnitSphere.mesh</Resource>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Team/>
|
<c:Team/>
|
||||||
<c:Transform/>
|
<c:Transform/>
|
||||||
|
|||||||
@@ -0,0 +1,164 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
|
<Components>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:AABB/>
|
||||||
|
<c:Collidable/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>../assets/Models/Test/ObstacleCourse.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0" Z="0.00638055196"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:DirectionalLight>
|
||||||
|
<Intensity>0.46000027656555176</Intensity>
|
||||||
|
</c:DirectionalLight>
|
||||||
|
<c:Transform>
|
||||||
|
<Orientation X="0" Y="2.59000015" Z="0.799000025"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:AABB/>
|
||||||
|
<c:Collidable/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>../assets/Models/Core/UnitCube.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-1.52309108" Y="5.72108126" Z="0"/>
|
||||||
|
<Scale X="5" Y="5" Z="5"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="BluSpawn">
|
||||||
|
<Components>
|
||||||
|
<c:PlayerSpawn/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Visible>false</Visible>
|
||||||
|
</c:Model>
|
||||||
|
<c:Spawner>
|
||||||
|
<EntityFile>Schema/Entities/Player.xml</EntityFile>
|
||||||
|
</c:Spawner>
|
||||||
|
<c:Team>
|
||||||
|
<Team>
|
||||||
|
<Blue/>
|
||||||
|
</Team>
|
||||||
|
</c:Team>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="1" Y="1.60000002" Z="1"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:SpawnPoint/>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:SpawnPoint/>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-2.05988312" Y="0" Z="2.79573512"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="1.85022807" Y="0" Z="-2.08909845"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="2.98651481" Y="0" Z="-4.67667246"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-5.16323137" Y="0" Z="3.62892342"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="RedSpawn">
|
||||||
|
<Components>
|
||||||
|
<c:PlayerSpawn/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Visible>false</Visible>
|
||||||
|
</c:Model>
|
||||||
|
<c:Spawner>
|
||||||
|
<EntityFile>Schema/Entities/Player.xml</EntityFile>
|
||||||
|
</c:Spawner>
|
||||||
|
<c:Team>
|
||||||
|
<Team>
|
||||||
|
<Red/>
|
||||||
|
</Team>
|
||||||
|
</c:Team>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-1.20000005" Y="1.60000002" Z="-8.40000057"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:SpawnPoint/>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0" Z="2.24403"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="2.20245028" Y="0" Z="-1.97843659"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="4.79769945" Y="0" Z="-5.2088728"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
|
||||||
|
</Entity>
|
||||||
@@ -1,122 +1,67 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
<Entity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xi="http://www.w3.org/2001/XInclude" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd" xmlns:c="components">
|
<Components>
|
||||||
<Components>
|
<c:Transform/>
|
||||||
<c:Transform>
|
</Components>
|
||||||
<Orientation X="0" Y="0" Z="0"/>
|
|
||||||
</c:Transform>
|
<Children>
|
||||||
<c:Model>
|
<Entity>
|
||||||
<Resource>Models/DummyScene.mesh</Resource>
|
<Components>
|
||||||
</c:Model>
|
<c:AABB/>
|
||||||
</Components>
|
<c:Collidable/>
|
||||||
<Children>
|
<c:Model>
|
||||||
<Entity>
|
<Resource>../assets/Models/Test/ObstacleCourse.mesh</Resource>
|
||||||
<Components>
|
</c:Model>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="-1.5"/>
|
<Position X="0" Y="0" Z="0.00638055196"/>
|
||||||
<Scale X="1" Y="1" Z="1"/>
|
</c:Transform>
|
||||||
</c:Transform>
|
</Components>
|
||||||
<c:Model>
|
<Children/>
|
||||||
<Resource>Models/Core/UnitSphere.mesh</Resource>
|
</Entity>
|
||||||
</c:Model>
|
<Entity>
|
||||||
</Components>
|
<Components>
|
||||||
</Entity>
|
<c:DirectionalLight>
|
||||||
<Entity>
|
<Intensity>0.46000027656555176</Intensity>
|
||||||
<Components>
|
</c:DirectionalLight>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="1.5"/>
|
<Orientation X="0" Y="2.59000015" Z="0.799000025"/>
|
||||||
<Scale X="2" Y="2" Z="2"/>
|
</c:Transform>
|
||||||
</c:Transform>
|
</Components>
|
||||||
<c:Model>
|
<Children/>
|
||||||
<Resource>Models/RotationWidgetX.mesh</Resource>
|
</Entity>
|
||||||
</c:Model>
|
<Entity>
|
||||||
<c:Trigger>
|
<Components>
|
||||||
</c:Trigger>
|
<c:AABB/>
|
||||||
</Components>
|
<c:Collidable/>
|
||||||
</Entity>
|
<c:Model>
|
||||||
<Entity>
|
<Resource>../assets/Models/Core/UnitCube.mesh</Resource>
|
||||||
<Components>
|
</c:Model>
|
||||||
<c:Player>
|
<c:Physics>
|
||||||
<Velocity X="0" Y="0" Z="0"/>
|
<Gravity>false</Gravity>
|
||||||
</c:Player>
|
</c:Physics>
|
||||||
<c:Transform>
|
<c:Player/>
|
||||||
<Position X="2.5"/>
|
<c:Transform>
|
||||||
</c:Transform>
|
<Position X="-8.80904388" Y="1.82786822" Z="7.97052002"/>
|
||||||
<c:Model>
|
<Scale X="0.100000001" Y="1" Z="0.100000001"/>
|
||||||
<Resource>Models/Core/UnitCube.mesh</Resource>
|
</c:Transform>
|
||||||
</c:Model>
|
</Components>
|
||||||
<c:AABB>
|
<Children/>
|
||||||
</c:AABB>
|
</Entity>
|
||||||
</Components>
|
<Entity>
|
||||||
</Entity>
|
<Components>
|
||||||
<Entity>
|
<c:AABB/>
|
||||||
<Components>
|
<c:Collidable/>
|
||||||
<c:Transform>
|
<c:Model>
|
||||||
<Position X="0" Y="-0"/>
|
<Resource>../assets/Models/Core/colorbox.mesh</Resource>
|
||||||
<Scale X="1" Y="1" Z="1"/>
|
</c:Model>
|
||||||
</c:Transform>
|
<c:Transform>
|
||||||
<!--<c:Move>
|
<Position X="-1.52309108" Y="5.72108126" Z="0"/>
|
||||||
<Speed>1</Speed>
|
<Scale X="5" Y="5" Z="5"/>
|
||||||
<Direction X="-1"/>
|
</c:Transform>
|
||||||
<Rotation Y="3.14"/>
|
</Components>
|
||||||
</c:Move>-->
|
<Children/>
|
||||||
</Components>
|
</Entity>
|
||||||
<Children>
|
</Children>
|
||||||
<Entity>
|
|
||||||
<Components>
|
</Entity>
|
||||||
<c:Transform>
|
|
||||||
<Position X="0" Y="0"/>
|
|
||||||
<Orientation X="0.0" Y="0" Z="1.0"/>
|
|
||||||
</c:Transform>
|
|
||||||
<c:Model>
|
|
||||||
<Resource>Models/Core/UnitRaptor.mesh</Resource>
|
|
||||||
<Color R="1" G="0.4" B="0.8"/>
|
|
||||||
</c:Model>
|
|
||||||
</Components>
|
|
||||||
<Children>
|
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="-0.01" Y="0.55"/>
|
|
||||||
<Orientation X="0" Y="0" Z="-1"/>
|
|
||||||
</c:Transform>
|
|
||||||
<c:RaptorCopter>
|
|
||||||
<Speed>20</Speed>
|
|
||||||
<Axis Y="1"/>
|
|
||||||
</c:RaptorCopter>
|
|
||||||
</Components>
|
|
||||||
<Children>
|
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="0" Y="0"/>
|
|
||||||
<Scale X="1.7" Y="0.03" Z="0.1"/>
|
|
||||||
<Orientation X="0" Y="0" Z="0"/>
|
|
||||||
</c:Transform>
|
|
||||||
<c:Model>
|
|
||||||
<Resource>Models/Core/UnitCube.mesh</Resource>
|
|
||||||
<Color R="1" G="0.4" B="0.8"/>
|
|
||||||
</c:Model>
|
|
||||||
</Components>
|
|
||||||
</Entity>
|
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="0" Y="0"/>
|
|
||||||
<Scale X="1.7" Y="0.03" Z="0.1"/>
|
|
||||||
<Orientation X="0" Y="1.57" Z="0"/>
|
|
||||||
</c:Transform>
|
|
||||||
<c:Model>
|
|
||||||
<Resource>Models/Core/UnitCube.mesh</Resource>
|
|
||||||
<Color R="1" G="0.4" B="0.8"/>
|
|
||||||
</c:Model>
|
|
||||||
</Components>
|
|
||||||
</Entity>
|
|
||||||
</Children>
|
|
||||||
</Entity>
|
|
||||||
</Children>
|
|
||||||
</Entity>
|
|
||||||
</Children>
|
|
||||||
</Entity>
|
|
||||||
</Children>
|
|
||||||
</Entity>
|
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
<Components>
|
<Components>
|
||||||
<c:Transform/>
|
<c:Transform>
|
||||||
|
<Position X="0" Y="-1" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
|
|
||||||
<Children>
|
<Children>
|
||||||
@@ -18,7 +20,7 @@
|
|||||||
</Components>
|
</Components>
|
||||||
<Children/>
|
<Children/>
|
||||||
</Entity>
|
</Entity>
|
||||||
<Entity>
|
<Entity name="Listener">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Camera/>
|
<c:Camera/>
|
||||||
<c:Listener/>
|
<c:Listener/>
|
||||||
@@ -38,18 +40,27 @@
|
|||||||
<Resource>Models/DirectionalLightWidget.mesh</Resource>
|
<Resource>Models/DirectionalLightWidget.mesh</Resource>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:RaptorCopter>
|
<c:RaptorCopter>
|
||||||
<Speed>1.0499999523162842</Speed>
|
<Speed>1</Speed>
|
||||||
<Axis X="0" Y="1" Z="0"/>
|
<Axis X="0" Y="1" Z="0"/>
|
||||||
</c:RaptorCopter>
|
</c:RaptorCopter>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="2.1529963" Y="6.59221172" Z="0.169116676"/>
|
<Position X="2.1529963" Y="6.59221172" Z="0.169116676"/>
|
||||||
<Orientation X="4.16300011" Y="1422.89319" Z="0"/>
|
<Orientation X="4.16300011" Y="7875.41211" Z="0"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children/>
|
<Children/>
|
||||||
</Entity>
|
</Entity>
|
||||||
<Entity name="AssaultTPose">
|
<Entity name="AssaultTPose">
|
||||||
<Components>
|
<Components>
|
||||||
|
<c:ExplosionEffect>
|
||||||
|
<ColorByDistance>true</ColorByDistance>
|
||||||
|
<Velocity X="0" Y="0" Z="0.300000012"/>
|
||||||
|
<ExplosionOrigin X="0" Y="1.30000007" Z="0"/>
|
||||||
|
<TimeSinceDeath>5.0498686575577523</TimeSinceDeath>
|
||||||
|
<ExplosionDuration>5</ExplosionDuration>
|
||||||
|
<EndColor A="1" B="1" G="0" R="0"/>
|
||||||
|
<RandomnessScalar>3</RandomnessScalar>
|
||||||
|
</c:ExplosionEffect>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models/Assault.mesh</Resource>
|
<Resource>Models/Assault.mesh</Resource>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
@@ -62,11 +73,26 @@
|
|||||||
<Entity name="SecondaryWeapon">
|
<Entity name="SecondaryWeapon">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models/SecondaryWeapon.mesh</Resource>
|
<Resource>Models/AssaultWeaponRed.mesh</Resource>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="-0.546139359" Y="0.853016734" Z="0.177482292"/>
|
<Position X="-0.560000002" Y="0.754308224" Z="0.181485131"/>
|
||||||
<Orientation X="1.47266471" Y="0.524984181" Z="1.243698"/>
|
<Orientation X="0.989000022" Y="0" Z="6.10900021"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="SecondaryWeaponRed">
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/DefenderGunRed.mesh</Resource>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
|
<NormalMap>false</NormalMap>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.515922487" Y="0.787437975" Z="0.132855967"/>
|
||||||
|
<Orientation X="0.989000022" Y="0" Z="0"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children/>
|
<Children/>
|
||||||
@@ -85,7 +111,7 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Animation>
|
<c:Animation>
|
||||||
<Name>Run</Name>
|
<Name>Run</Name>
|
||||||
<Time>0.62051775215976157</Time>
|
<Time>0.17818245776980568</Time>
|
||||||
<Speed>1</Speed>
|
<Speed>1</Speed>
|
||||||
</c:Animation>
|
</c:Animation>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
@@ -101,7 +127,7 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Animation>
|
<c:Animation>
|
||||||
<Name>Walk</Name>
|
<Name>Walk</Name>
|
||||||
<Time>0.28779680073140668</Time>
|
<Time>0.34546191187031372</Time>
|
||||||
<Speed>1</Speed>
|
<Speed>1</Speed>
|
||||||
</c:Animation>
|
</c:Animation>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
@@ -147,70 +173,6 @@
|
|||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children>
|
<Children>
|
||||||
<Entity name="NormalSphere">
|
|
||||||
<Components>
|
|
||||||
<c:Model>
|
|
||||||
<Resource>Models/NormalMapSphere.mesh</Resource>
|
|
||||||
</c:Model>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="1.82700014" Y="0" Z="-0.166000009"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children/>
|
|
||||||
</Entity>
|
|
||||||
<Entity name="SpecularSphere">
|
|
||||||
<Components>
|
|
||||||
<c:Model>
|
|
||||||
<Resource>Models/SpecularMapSphere.mesh</Resource>
|
|
||||||
</c:Model>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="-1.06487739" Y="0" Z="1.52336037"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children>
|
|
||||||
<Entity name="Rotationpoint">
|
|
||||||
<Components>
|
|
||||||
<c:RaptorCopter>
|
|
||||||
<Speed>1</Speed>
|
|
||||||
<Axis X="0.699999988" Y="1" Z="0.300000012"/>
|
|
||||||
</c:RaptorCopter>
|
|
||||||
<c:Transform>
|
|
||||||
<Orientation X="404.200684" Y="577.428955" Z="173.228897"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children>
|
|
||||||
<Entity name="PointLight">
|
|
||||||
<Components>
|
|
||||||
<c:Model>
|
|
||||||
<Resource>Models/Core/UnitSphere.mesh</Resource>
|
|
||||||
<Color A="1" B="0" G="3.92156863" R="3.92156863"/>
|
|
||||||
</c:Model>
|
|
||||||
<c:PointLight>
|
|
||||||
<Radius>3</Radius>
|
|
||||||
<Intensity>1.1399998664855957</Intensity>
|
|
||||||
</c:PointLight>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="0.600000024" Y="0.5" Z="0"/>
|
|
||||||
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children/>
|
|
||||||
</Entity>
|
|
||||||
</Children>
|
|
||||||
</Entity>
|
|
||||||
</Children>
|
|
||||||
</Entity>
|
|
||||||
<Entity name="GlowMap">
|
|
||||||
<Components>
|
|
||||||
<c:Model>
|
|
||||||
<Resource>Models/IncandescenceMapSphere.mesh</Resource>
|
|
||||||
</c:Model>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="-1.10000002" Y="0" Z="-1.80000007"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children/>
|
|
||||||
</Entity>
|
|
||||||
<Entity name="CombinedSpheres">
|
<Entity name="CombinedSpheres">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
@@ -227,7 +189,7 @@
|
|||||||
<Axis X="1" Y="1" Z="1"/>
|
<Axis X="1" Y="1" Z="1"/>
|
||||||
</c:RaptorCopter>
|
</c:RaptorCopter>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Orientation X="53.9495354" Y="53.9495354" Z="53.9495354"/>
|
<Orientation X="6484.80273" Y="6484.80273" Z="6484.80273"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children>
|
<Children>
|
||||||
@@ -284,8 +246,94 @@
|
|||||||
</Entity>
|
</Entity>
|
||||||
</Children>
|
</Children>
|
||||||
</Entity>
|
</Entity>
|
||||||
|
<Entity name="SphereRotationOrigin">
|
||||||
|
<Components>
|
||||||
|
<c:RaptorCopter>
|
||||||
|
<Speed>1</Speed>
|
||||||
|
<Axis X="0" Y="1" Z="0"/>
|
||||||
|
</c:RaptorCopter>
|
||||||
|
<c:Transform>
|
||||||
|
<Orientation X="0" Y="6281.02246" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity name="NormalSphere">
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/NormalMapSphere.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="1.82700014" Y="0" Z="-0.166000009"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="SpecularSphere">
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/SpecularMapSphere.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-1.06487739" Y="0" Z="1.52336037"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity name="Rotationpoint">
|
||||||
|
<Components>
|
||||||
|
<c:RaptorCopter>
|
||||||
|
<Speed>1</Speed>
|
||||||
|
<Axis X="0.699999988" Y="1" Z="0.300000012"/>
|
||||||
|
</c:RaptorCopter>
|
||||||
|
<c:Transform>
|
||||||
|
<Orientation X="4905.44824" Y="7008.50781" Z="2103.03223"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity name="PointLight">
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitSphere.mesh</Resource>
|
||||||
|
<Color A="1" B="0" G="3.92156863" R="3.92156863"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:PointLight>
|
||||||
|
<Radius>3</Radius>
|
||||||
|
<Intensity>1.1399998664855957</Intensity>
|
||||||
|
</c:PointLight>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.600000024" Y="0.5" Z="0"/>
|
||||||
|
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="GlowMap">
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/IncandescenceMapSphere.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-1.10000002" Y="0" Z="-1.80000007"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
</Children>
|
</Children>
|
||||||
</Entity>
|
</Entity>
|
||||||
|
<Entity name="SceneColors">
|
||||||
|
<Components>
|
||||||
|
<c:SceneLight>
|
||||||
|
<Gamma>1.3999999761581421</Gamma>
|
||||||
|
</c:SceneLight>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
</Children>
|
</Children>
|
||||||
|
|
||||||
</Entity>
|
</Entity>
|
||||||
|
|||||||
@@ -84,15 +84,6 @@
|
|||||||
</Components>
|
</Components>
|
||||||
<Children/>
|
<Children/>
|
||||||
</Entity>
|
</Entity>
|
||||||
<Entity name="Light">
|
|
||||||
<Components>
|
|
||||||
<c:PointLight/>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="0.400000006" Y="0.400000006" Z="0.400000006"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children/>
|
|
||||||
</Entity>
|
|
||||||
</Children>
|
</Children>
|
||||||
|
|
||||||
</Entity>
|
</Entity>
|
||||||
|
|||||||
@@ -8,6 +8,10 @@
|
|||||||
<Children>
|
<Children>
|
||||||
<Entity name="Scenemesh">
|
<Entity name="Scenemesh">
|
||||||
<Components>
|
<Components>
|
||||||
|
<c:AABB>
|
||||||
|
<Size X="150" Y="64" Z="180"/>
|
||||||
|
</c:AABB>
|
||||||
|
<c:Collidable/>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models\MapVersion1.mesh</Resource>
|
<Resource>Models\MapVersion1.mesh</Resource>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
@@ -139,7 +143,7 @@
|
|||||||
</Team>
|
</Team>
|
||||||
</c:Team>
|
</c:Team>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="57.7363472" Y="1.18853188" Z="79.5"/>
|
<Position X="57.7363472" Y="2.38900018" Z="79.5"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children>
|
<Children>
|
||||||
@@ -201,7 +205,7 @@
|
|||||||
</Team>
|
</Team>
|
||||||
</c:Team>
|
</c:Team>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="-60.2567062" Y="1.60000002" Z="-78.1000061"/>
|
<Position X="-60.2567062" Y="3.4000001" Z="-78.1000061"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children>
|
<Children>
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
|
<Components>
|
||||||
|
<c:AABB/>
|
||||||
|
<c:HealthPickup/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitSphere.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="1" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
<c:Trigger/>
|
||||||
|
</Components>
|
||||||
|
|
||||||
|
<Children/>
|
||||||
|
|
||||||
|
</Entity>
|
||||||
@@ -0,0 +1,294 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
|
<Components>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
|
||||||
|
<Children>
|
||||||
|
<Entity name="Scenemesh">
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models\MapVersion1.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="DirectionalLight">
|
||||||
|
<Components>
|
||||||
|
<c:DirectionalLight>
|
||||||
|
<Intensity>2</Intensity>
|
||||||
|
</c:DirectionalLight>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/DirectionalLightWidget.mesh</Resource>
|
||||||
|
<Visible>false</Visible>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="61.9050903" Z="0"/>
|
||||||
|
<Scale X="50" Y="50" Z="50"/>
|
||||||
|
<Orientation X="4.42700005" Y="0" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="PointLight">
|
||||||
|
<Components>
|
||||||
|
<c:PointLight>
|
||||||
|
<Radius>8</Radius>
|
||||||
|
<Intensity>2.7999999523162842</Intensity>
|
||||||
|
</c:PointLight>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.370978802" Y="1.88588905" Z="-0.55370003"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="PointLight">
|
||||||
|
<Components>
|
||||||
|
<c:PointLight>
|
||||||
|
<Radius>8</Radius>
|
||||||
|
<Intensity>2.7999999523162842</Intensity>
|
||||||
|
</c:PointLight>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="38.0347443" Y="1.88588905" Z="62.7340622"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:AABB/>
|
||||||
|
<c:Collidable/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-0.904668212" Y="0" Z="8.48177528"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:AABB/>
|
||||||
|
<c:Collidable/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-4.61666441" Y="0" Z="-8.51156044"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:AABB/>
|
||||||
|
<c:Collidable/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-7.56803513" Y="-0.0658408776" Z="0.59418112"/>
|
||||||
|
<Scale X="1.20000005" Y="0.900000036" Z="1.30000007"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:AABB/>
|
||||||
|
<c:Collidable/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="10.460474" Y="0" Z="-3.92580295"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:AABB/>
|
||||||
|
<c:Collidable/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="1.09146011" Y="-0.315138876" Z="-0.333906144"/>
|
||||||
|
<Scale X="150" Y="1" Z="180"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="BluSpawn">
|
||||||
|
<Components>
|
||||||
|
<c:PlayerSpawn/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Visible>false</Visible>
|
||||||
|
</c:Model>
|
||||||
|
<c:Spawner>
|
||||||
|
<EntityFile>Schema/Entities/Player.xml</EntityFile>
|
||||||
|
</c:Spawner>
|
||||||
|
<c:Team>
|
||||||
|
<Team>
|
||||||
|
<Blue/>
|
||||||
|
</Team>
|
||||||
|
</c:Team>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="57.7363472" Y="1.18853188" Z="79.5"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:SpawnPoint/>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:SpawnPoint/>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-2.05988312" Y="0" Z="2.79573512"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="1.85022807" Y="0" Z="-2.08909845"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="2.98651481" Y="0" Z="-4.67667246"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-5.16323137" Y="0" Z="3.62892342"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="RedSpawn">
|
||||||
|
<Components>
|
||||||
|
<c:PlayerSpawn/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||||
|
<Visible>false</Visible>
|
||||||
|
</c:Model>
|
||||||
|
<c:Spawner>
|
||||||
|
<EntityFile>Schema/Entities/Player.xml</EntityFile>
|
||||||
|
</c:Spawner>
|
||||||
|
<c:Team>
|
||||||
|
<Team>
|
||||||
|
<Red/>
|
||||||
|
</Team>
|
||||||
|
</c:Team>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-60.2567062" Y="1.60000002" Z="-78.1000061"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:SpawnPoint/>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0" Z="2.24403"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="2.20245028" Y="0" Z="-1.97843659"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="4.79769945" Y="0" Z="-5.2088728"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:AABB/>
|
||||||
|
<c:HealthPickup>
|
||||||
|
<RespawnTimer>1</RespawnTimer>
|
||||||
|
<HealthGain>22</HealthGain>
|
||||||
|
</c:HealthPickup>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitSphere.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="60" Y="1" Z="80"/>
|
||||||
|
</c:Transform>
|
||||||
|
<c:Trigger/>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:AABB/>
|
||||||
|
<c:HealthPickup>
|
||||||
|
<RespawnTimer>1</RespawnTimer>
|
||||||
|
<HealthGain>22</HealthGain>
|
||||||
|
</c:HealthPickup>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitSphere.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="60" Y="1" Z="80"/>
|
||||||
|
</c:Transform>
|
||||||
|
<c:Trigger/>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:AABB/>
|
||||||
|
<c:HealthPickup>
|
||||||
|
<RespawnTimer>4</RespawnTimer>
|
||||||
|
<HealthGain>44</HealthGain>
|
||||||
|
</c:HealthPickup>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitSphere.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="60" Y="1" Z="80"/>
|
||||||
|
</c:Transform>
|
||||||
|
<c:Trigger/>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
|
||||||
|
</Entity>
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
|
<Components>
|
||||||
|
<c:Collidable/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>../assets/Models/MapVersion1.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:AABB/>
|
||||||
|
<c:Collidable/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>../assets/Models/Core/UnitCube.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Physics>
|
||||||
|
<Gravity>false</Gravity>
|
||||||
|
</c:Physics>
|
||||||
|
<c:Player/>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-1.48400009" Y="3.68200016" Z="24.7580013"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:DirectionalLight/>
|
||||||
|
<c:Transform>
|
||||||
|
<Orientation X="3.80300021" Y="1.37800002" Z="4.10000038"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
|
||||||
|
</Entity>
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0" Z="-0.313012958"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Camera/>
|
||||||
|
<c:Listener/>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="2.56531811" Y="0.637967348" Z="0.202344239"/>
|
||||||
|
<Orientation X="2.68780756" Y="1.36143553" Z="3.14159179"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Collidable/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>../assets/Models/Core/Tri.obj</Resource>
|
||||||
|
<Color A="1" B="1" G="0.392156869" R="0"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Scale X="2" Y="2" Z="0.200000003"/>
|
||||||
|
<Orientation X="2.70100021" Y="2.37000012" Z="0.266000003"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>../assets/Models/Core/Tri.obj</Resource>
|
||||||
|
<Color A="1" B="0" G="0" R="1"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Orientation X="0" Y="3.14159274" Z="4.71238899"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:AABB/>
|
||||||
|
<c:Collidable/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>../assets/Models/Core/UnitCube.obj</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Physics/>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-1.95333278" Y="0.296304941" Z="2.56487775"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
|
||||||
|
</Entity>
|
||||||
@@ -6,22 +6,6 @@
|
|||||||
</Components>
|
</Components>
|
||||||
|
|
||||||
<Children>
|
<Children>
|
||||||
<Entity name="Ground">
|
|
||||||
<Components>
|
|
||||||
<c:AABB/>
|
|
||||||
<c:Collidable/>
|
|
||||||
<c:Model>
|
|
||||||
<Resource>Models/Core/UnitCube.mesh</Resource>
|
|
||||||
<Color A="1" B="0.513725519" G="0" R="1"/>
|
|
||||||
<Visible>false</Visible>
|
|
||||||
</c:Model>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="7" Y="-0.727000058" Z="-1.22800004"/>
|
|
||||||
<Scale X="50" Y="1.45100009" Z="50"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children/>
|
|
||||||
</Entity>
|
|
||||||
<Entity name="RedSpawn">
|
<Entity name="RedSpawn">
|
||||||
<Components>
|
<Components>
|
||||||
<c:PlayerSpawn/>
|
<c:PlayerSpawn/>
|
||||||
@@ -81,6 +65,10 @@
|
|||||||
</Entity>
|
</Entity>
|
||||||
<Entity name="ObstacleCourse">
|
<Entity name="ObstacleCourse">
|
||||||
<Components>
|
<Components>
|
||||||
|
<c:AABB>
|
||||||
|
<Size X="50" Y="50" Z="50"/>
|
||||||
|
</c:AABB>
|
||||||
|
<c:Collidable/>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models/Test/ObstacleCourse.mesh</Resource>
|
<Resource>Models/Test/ObstacleCourse.mesh</Resource>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
@@ -88,51 +76,6 @@
|
|||||||
</Components>
|
</Components>
|
||||||
<Children/>
|
<Children/>
|
||||||
</Entity>
|
</Entity>
|
||||||
<Entity name="ObstacleCoursePlayerBox">
|
|
||||||
<Components>
|
|
||||||
<c:AABB/>
|
|
||||||
<c:Collidable/>
|
|
||||||
<c:Model>
|
|
||||||
<Resource>Models/Core/UnitCube.mesh</Resource>
|
|
||||||
<Visible>false</Visible>
|
|
||||||
</c:Model>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="6.32800007" Y="0.807000041" Z="-2.2750001"/>
|
|
||||||
<Scale X="1" Y="1.60000002" Z="1"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children/>
|
|
||||||
</Entity>
|
|
||||||
<Entity name="ObstacleCourse1uHigh">
|
|
||||||
<Components>
|
|
||||||
<c:AABB/>
|
|
||||||
<c:Collidable/>
|
|
||||||
<c:Model>
|
|
||||||
<Resource>Models/Core/UnitCube.mesh</Resource>
|
|
||||||
<Visible>false</Visible>
|
|
||||||
</c:Model>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="9.11900043" Y="0.5" Z="-2.10900021"/>
|
|
||||||
<Scale X="1" Y="1" Z="8.1960001"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children/>
|
|
||||||
</Entity>
|
|
||||||
<Entity name="ObstacleCourseWhoTheFuckKnows">
|
|
||||||
<Components>
|
|
||||||
<c:AABB/>
|
|
||||||
<c:Collidable/>
|
|
||||||
<c:Model>
|
|
||||||
<Resource>Models/Core/UnitCube.mesh</Resource>
|
|
||||||
<Visible>false</Visible>
|
|
||||||
</c:Model>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="13.2370005" Y="1.28600001" Z="-1.71700013"/>
|
|
||||||
<Scale X="2.58000016" Y="2.58300018" Z="21.1860008"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children/>
|
|
||||||
</Entity>
|
|
||||||
<Entity name="BlueSpawn">
|
<Entity name="BlueSpawn">
|
||||||
<Components>
|
<Components>
|
||||||
<c:PlayerSpawn/>
|
<c:PlayerSpawn/>
|
||||||
@@ -197,7 +140,7 @@
|
|||||||
</Team>
|
</Team>
|
||||||
</c:Team>
|
</c:Team>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="-1.68112314" Y="0.0264999866" Z="3.06287026"/>
|
<Position X="-1.68112314" Y="0.0288829971" Z="3.06287026"/>
|
||||||
<Orientation X="0" Y="2.14675093" Z="0"/>
|
<Orientation X="0" Y="2.14675093" Z="0"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
|
|||||||
@@ -2,12 +2,15 @@
|
|||||||
<Entity name="Player" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
<Entity name="Player" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
<Components>
|
<Components>
|
||||||
<c:Health/>
|
|
||||||
<c:AABB>
|
<c:AABB>
|
||||||
<Origin X="0" Y="0.772000015" Z="0"/>
|
<Origin X="0" Y="0.772000015" Z="0"/>
|
||||||
<Size X="1" Y="1.60000002" Z="1"/>
|
<Size X="1" Y="1.60000002" Z="1"/>
|
||||||
</c:AABB>
|
</c:AABB>
|
||||||
|
<c:DashAbility>
|
||||||
|
<CoolDownMaxTimer>2.0</CoolDownMaxTimer>
|
||||||
|
</c:DashAbility>
|
||||||
<c:Collidable/>
|
<c:Collidable/>
|
||||||
|
<c:Health/>
|
||||||
<c:Physics>
|
<c:Physics>
|
||||||
<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>
|
||||||
@@ -20,7 +23,7 @@
|
|||||||
</Team>
|
</Team>
|
||||||
</c:Team>
|
</c:Team>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="8.60201447e-23" Y="0" Z="3.9201616e-23"/>
|
<Position X="9.56501799e-22" Y="-0.471999973" Z="4.35902473e-22"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
|
|
||||||
@@ -102,11 +105,11 @@
|
|||||||
<Entity name="Weapon">
|
<Entity name="Weapon">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models/AssaultWeapon.mesh</Resource>
|
<Resource>Models/AssaultWeaponRed.mesh</Resource>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0.180000007" Y="-0.183000013" Z="0"/>
|
<Position X="0.180000007" Y="-0.183000013" Z="0"/>
|
||||||
<Orientation X="0" Y="4.64700031" Z="0"/>
|
<Orientation X="0" Y="3.08300018" Z="0"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children/>
|
<Children/>
|
||||||
@@ -141,7 +144,7 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Animation>
|
<c:Animation>
|
||||||
<Name>Hold Pos</Name>
|
<Name>Hold Pos</Name>
|
||||||
<Time>0.73515426169631848</Time>
|
<Time>0.73506627647571587</Time>
|
||||||
<Speed>1</Speed>
|
<Speed>1</Speed>
|
||||||
</c:Animation>
|
</c:Animation>
|
||||||
<c:HiddenForLocalPlayer/>
|
<c:HiddenForLocalPlayer/>
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity name="Explosion" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
|
<Components>
|
||||||
|
<c:Animation>
|
||||||
|
<Name>Hold Pos</Name>
|
||||||
|
</c:Animation>
|
||||||
|
<c:Lifetime>
|
||||||
|
<Lifetime>2.5</Lifetime>
|
||||||
|
</c:Lifetime>
|
||||||
|
<c:ExplosionEffect>
|
||||||
|
<ColorByDistance>true</ColorByDistance>
|
||||||
|
<Velocity X="0" Y="7.76300049" Z="0"/>
|
||||||
|
<ExplosionOrigin X="0" Y="0.67900002" Z="0"/>
|
||||||
|
<ExponentialAccelaration>true</ExponentialAccelaration>
|
||||||
|
<ExplosionDuration>3</ExplosionDuration>
|
||||||
|
<EndColor A="0" B="0" G="0" R="1"/>
|
||||||
|
<Randomness>true</Randomness>
|
||||||
|
</c:ExplosionEffect>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/AssaultAnimated.mesh</Resource>
|
||||||
|
<Color A="1" B="0" G="0" R="1"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0" Z="3.46966481"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
|
||||||
|
<Children>
|
||||||
|
<Entity name="Camera">
|
||||||
|
<Components>
|
||||||
|
<c:Camera/>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="2.49700022" Z="4.31700039"/>
|
||||||
|
<Orientation X="5.95600033" Y="0" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
|
||||||
|
</Entity>
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,8 @@
|
|||||||
</c:Lifetime>
|
</c:Lifetime>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models/CylinderBullet.mesh</Resource>
|
<Resource>Models/CylinderBullet.mesh</Resource>
|
||||||
<Color A="1" B="39.2156868" G="7.84313726" R="0"/>
|
<Color A="0.156862751" B="39.2156868" G="7.84313726" R="0"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Scale X="0.0109999999" Y="0.0289999992" Z="100"/>
|
<Scale X="0.0109999999" Y="0.0289999992" Z="100"/>
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
</c:Lifetime>
|
</c:Lifetime>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models/CylinderBullet.mesh</Resource>
|
<Resource>Models/CylinderBullet.mesh</Resource>
|
||||||
<Color A="1" B="0" G="0.525490224" R="39.2156868"/>
|
<Color A="0.156862751" B="0" G="0.525490224" R="39.2156868"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Scale X="0.0110000009" Y="0.029000001" Z="100"/>
|
<Scale X="0.0110000009" Y="0.029000001" Z="100"/>
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity name="SoundEmitter" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
|
<Components>
|
||||||
|
<c:SoundEmitter/>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
|
||||||
|
<Children>
|
||||||
|
<Entity name="SoundEmitterText">
|
||||||
|
<Components>
|
||||||
|
<c:Text>
|
||||||
|
<Content>SoundEmitter</Content>
|
||||||
|
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||||
|
</c:Text>
|
||||||
|
<c:Transform>
|
||||||
|
<Scale X="0.5" Y="0.5" Z="0.5"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
|
||||||
|
</Entity>
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity name="SpawnerRedTeam" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
|
<Components>
|
||||||
|
<c:PlayerSpawn/>
|
||||||
|
<c:Spawner>
|
||||||
|
<EntityFile>Schema/Entities/Player.xml</EntityFile>
|
||||||
|
</c:Spawner>
|
||||||
|
<c:Team>
|
||||||
|
<Team>
|
||||||
|
<Red/>
|
||||||
|
</Team>
|
||||||
|
</c:Team>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
|
||||||
|
<Children>
|
||||||
|
<Entity name="SpawnPointRedTeam">
|
||||||
|
<Components>
|
||||||
|
<c:SpawnPoint/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Assault.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="1" Y="0" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="SpawnPointRedTeam">
|
||||||
|
<Components>
|
||||||
|
<c:SpawnPoint/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Assault.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-1" Y="0" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="SpawnPointRedTeam">
|
||||||
|
<Components>
|
||||||
|
<c:SpawnPoint/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Assault.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0" Z="1"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="SpawnPointRedTeam">
|
||||||
|
<Components>
|
||||||
|
<c:SpawnPoint/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Assault.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0" Z="-1"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
|
||||||
|
</Entity>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity name="SpawnPointRedTeam" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
|
<Components>
|
||||||
|
<c:SpawnPoint/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Assault.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="1.31625879" Y="0" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
|
||||||
|
<Children/>
|
||||||
|
|
||||||
|
</Entity>
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
|
<Components>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/Unithexagon.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Shield/>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="dl">
|
||||||
|
<Components>
|
||||||
|
<c:DirectionalLight/>
|
||||||
|
<c:Transform>
|
||||||
|
<Orientation X="0" Y="2.61800003" Z="0.756000042"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="sl">
|
||||||
|
<Components>
|
||||||
|
<c:SceneLight>
|
||||||
|
<Gamma>2.2000000476837158</Gamma>
|
||||||
|
</c:SceneLight>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
|
||||||
|
</Entity>
|
||||||
@@ -31,12 +31,15 @@
|
|||||||
<xs:element ref="c:PlayerSpawn" minOccurs="0"/>
|
<xs:element ref="c:PlayerSpawn" minOccurs="0"/>
|
||||||
<xs:element ref="c:Team" minOccurs="0"/>
|
<xs:element ref="c:Team" minOccurs="0"/>
|
||||||
<xs:element ref="c:DirectionalLight" minOccurs="0"/>
|
<xs:element ref="c:DirectionalLight" minOccurs="0"/>
|
||||||
|
<xs:element ref="c:SceneLight" minOccurs="0"/>
|
||||||
<xs:element ref="c:UniformScale" minOccurs="0"/>
|
<xs:element ref="c:UniformScale" minOccurs="0"/>
|
||||||
<xs:element ref="c:EditorWidget" minOccurs="0"/>
|
<xs:element ref="c:EditorWidget" minOccurs="0"/>
|
||||||
<xs:element ref="c:Lifetime" minOccurs="0"/>
|
<xs:element ref="c:Lifetime" minOccurs="0"/>
|
||||||
<xs:element ref="c:HiddenForLocalPlayer" minOccurs="0"/>
|
<xs:element ref="c:HiddenForLocalPlayer" minOccurs="0"/>
|
||||||
<xs:element ref="c:Fill" minOccurs="0"/>
|
<xs:element ref="c:Fill" minOccurs="0"/>
|
||||||
<xs:element ref="c:Animation" minOccurs="0"/>
|
<xs:element ref="c:Animation" minOccurs="0"/>
|
||||||
|
<xs:element ref="c:Shield" minOccurs="0"/>
|
||||||
|
<xs:element ref="c:Shielded" minOccurs="0"/>
|
||||||
</xs:all>
|
</xs:all>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
|||||||
@@ -2,7 +2,10 @@
|
|||||||
|
|
||||||
layout (binding = 0) uniform sampler2D SceneTexture;
|
layout (binding = 0) uniform sampler2D SceneTexture;
|
||||||
layout (binding = 1) uniform sampler2D BloomTexture;
|
layout (binding = 1) uniform sampler2D BloomTexture;
|
||||||
|
layout (binding = 2) uniform sampler2D SceneTextureLowRes;
|
||||||
|
layout (binding = 3) uniform sampler2D BloomTextureLowRes;
|
||||||
uniform float Exposure;
|
uniform float Exposure;
|
||||||
|
uniform float Gamma;
|
||||||
|
|
||||||
in VertexData{
|
in VertexData{
|
||||||
vec2 TextureCoordinate;
|
vec2 TextureCoordinate;
|
||||||
@@ -12,16 +15,24 @@ out vec4 fragmentColor;
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
const float gamma = 2.2;
|
|
||||||
vec4 hdrColor = texture(SceneTexture, Input.TextureCoordinate);
|
vec4 hdrColor = texture(SceneTexture, Input.TextureCoordinate);
|
||||||
vec4 bloomColor = texture(BloomTexture, Input.TextureCoordinate);
|
vec4 bloomColor = texture(BloomTexture, Input.TextureCoordinate);
|
||||||
|
vec4 hdrColorLowRes = texture(SceneTextureLowRes, Input.TextureCoordinate);
|
||||||
|
vec4 bloomColorLowRes = texture(BloomTextureLowRes, Input.TextureCoordinate);
|
||||||
hdrColor += bloomColor;
|
hdrColor += bloomColor;
|
||||||
|
hdrColorLowRes;
|
||||||
|
|
||||||
|
float hdrColorsum = hdrColorLowRes.r + hdrColorLowRes.g + hdrColorLowRes.b;
|
||||||
//Toon mapping thingy
|
//Toon mapping thingy
|
||||||
vec3 result = vec3(1.0) - exp(-hdrColor.rgb * Exposure);
|
vec3 result;
|
||||||
|
if(hdrColorsum > 0.0) {
|
||||||
|
result = vec3(1.0) - exp(-hdrColorLowRes.rgb * Exposure);
|
||||||
|
} else {
|
||||||
|
result = vec3(1.0) - exp(-hdrColor.rgb * Exposure);
|
||||||
|
}
|
||||||
|
|
||||||
//gamme correction
|
//gamme correction
|
||||||
result = pow(result, vec3(1.0 / gamma));
|
result = pow(result, vec3(1.0 / Gamma));
|
||||||
|
|
||||||
fragmentColor = vec4(result, 1.0);
|
fragmentColor = vec4(result, 1.0);
|
||||||
//fragmentColor = hdrColor;
|
//fragmentColor = hdrColor;
|
||||||
|
|||||||
@@ -17,15 +17,21 @@ uniform bool ExponentialAccelaration;
|
|||||||
in VertexData{
|
in VertexData{
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
|
vec3 Tangent;
|
||||||
|
vec3 BiTangent;
|
||||||
vec2 TextureCoordinate;
|
vec2 TextureCoordinate;
|
||||||
vec4 ExplosionColor;
|
vec4 ExplosionColor;
|
||||||
|
float ExplosionPercentageElapsed;
|
||||||
}Input[];
|
}Input[];
|
||||||
|
|
||||||
out VertexData{
|
out VertexData{
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
|
vec3 Tangent;
|
||||||
|
vec3 BiTangent;
|
||||||
vec2 TextureCoordinate;
|
vec2 TextureCoordinate;
|
||||||
vec4 ExplosionColor;
|
vec4 ExplosionColor;
|
||||||
|
float ExplosionPercentageElapsed;
|
||||||
}Output;
|
}Output;
|
||||||
|
|
||||||
layout(triangles) in;
|
layout(triangles) in;
|
||||||
@@ -114,12 +120,17 @@ void main()
|
|||||||
{
|
{
|
||||||
// calculate the max distance (s) the triangle will move
|
// calculate the max distance (s) the triangle will move
|
||||||
float s = (randomVelocity.x * ExplosionDuration) + (0.5 * a * pow(ExplosionDuration, 2));
|
float s = (randomVelocity.x * ExplosionDuration) + (0.5 * a * pow(ExplosionDuration, 2));
|
||||||
|
float te = (length(triangleCenter2ExplosionRadius) / s);
|
||||||
|
|
||||||
Output.ExplosionColor = EndColor * (length(triangleCenter2ExplosionRadius) / s);
|
Output.ExplosionColor = EndColor;
|
||||||
|
Output.ExplosionPercentageElapsed = te;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Output.ExplosionColor = EndColor * timePercetage;
|
Output.ExplosionColor = EndColor;
|
||||||
|
Output.ExplosionPercentageElapsed = timePercetage;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// for every vertex on the triangle...
|
// for every vertex on the triangle...
|
||||||
@@ -132,6 +143,8 @@ void main()
|
|||||||
Output.Normal = Input[i].Normal;
|
Output.Normal = Input[i].Normal;
|
||||||
Output.Position = Input[i].Position;
|
Output.Position = Input[i].Position;
|
||||||
Output.TextureCoordinate = Input[i].TextureCoordinate;
|
Output.TextureCoordinate = Input[i].TextureCoordinate;
|
||||||
|
Output.Tangent = Input[i].Tangent;
|
||||||
|
Output.BiTangent = Input[i].BiTangent;
|
||||||
|
|
||||||
// convert to model space for the gravity to always be in -y
|
// convert to model space for the gravity to always be in -y
|
||||||
vec4 ExplodedPositionInModelSpace = M * vec4(ExplodedPosition, 1.0);
|
vec4 ExplodedPositionInModelSpace = M * vec4(ExplodedPosition, 1.0);
|
||||||
@@ -154,11 +167,14 @@ void main()
|
|||||||
// if explosion color should be affected by distance instead of time...
|
// if explosion color should be affected by distance instead of time...
|
||||||
if (ColorByDistance == true)
|
if (ColorByDistance == true)
|
||||||
{
|
{
|
||||||
Output.ExplosionColor = vec4(0.0);
|
Output.ExplosionColor = EndColor;
|
||||||
|
Output.ExplosionPercentageElapsed = 0.0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Output.ExplosionColor = EndColor * timePercetage;
|
Output.ExplosionColor = EndColor;
|
||||||
|
Output.ExplosionPercentageElapsed = timePercetage;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// for every vertex on the triangle...
|
// for every vertex on the triangle...
|
||||||
@@ -168,7 +184,9 @@ void main()
|
|||||||
Output.Normal = Input[i].Normal;
|
Output.Normal = Input[i].Normal;
|
||||||
Output.Position = Input[i].Position;
|
Output.Position = Input[i].Position;
|
||||||
Output.TextureCoordinate = Input[i].TextureCoordinate;
|
Output.TextureCoordinate = Input[i].TextureCoordinate;
|
||||||
|
Output.Tangent = Input[i].Tangent;
|
||||||
|
Output.BiTangent = Input[i].BiTangent;
|
||||||
|
|
||||||
// no change in position, pass through vertex
|
// no change in position, pass through vertex
|
||||||
gl_Position = gl_in[i].gl_Position;
|
gl_Position = gl_in[i].gl_Position;
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
in VertexData{
|
||||||
|
vec3 Position;
|
||||||
|
}Input;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
uniform mat4 M;
|
||||||
|
uniform mat4 V;
|
||||||
|
uniform mat4 P;
|
||||||
|
|
||||||
|
layout(location = 0) in vec3 Position;
|
||||||
|
layout(location = 5) in vec4 BoneIndices;
|
||||||
|
layout(location = 6) in vec4 BoneWeights;
|
||||||
|
|
||||||
|
|
||||||
|
out VertexData{
|
||||||
|
vec3 Position;
|
||||||
|
}Output;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = P * V * M * vec4(Position, 1.0);
|
||||||
|
|
||||||
|
Output.Position = Position;
|
||||||
|
}
|
||||||
@@ -7,13 +7,13 @@ uniform vec4 Color;
|
|||||||
uniform vec4 DiffuseColor;
|
uniform vec4 DiffuseColor;
|
||||||
uniform vec2 ScreenDimensions;
|
uniform vec2 ScreenDimensions;
|
||||||
uniform vec4 FillColor;
|
uniform vec4 FillColor;
|
||||||
|
uniform vec4 AmbientColor;
|
||||||
uniform float FillPercentage;
|
uniform float FillPercentage;
|
||||||
layout (binding = 0) uniform sampler2D DiffuseTexture;
|
layout (binding = 0) uniform sampler2D DiffuseTexture;
|
||||||
layout (binding = 1) uniform sampler2D NormalMapTexture;
|
layout (binding = 1) uniform sampler2D NormalMapTexture;
|
||||||
layout (binding = 2) uniform sampler2D SpecularMapTexture;
|
layout (binding = 2) uniform sampler2D SpecularMapTexture;
|
||||||
layout (binding = 3) uniform sampler2D GlowMapTexture;
|
layout (binding = 3) uniform sampler2D GlowMapTexture;
|
||||||
|
|
||||||
|
|
||||||
#define TILE_SIZE 16
|
#define TILE_SIZE 16
|
||||||
|
|
||||||
struct LightSource {
|
struct LightSource {
|
||||||
@@ -55,13 +55,12 @@ in VertexData{
|
|||||||
vec3 BiTangent;
|
vec3 BiTangent;
|
||||||
vec2 TextureCoordinate;
|
vec2 TextureCoordinate;
|
||||||
vec4 ExplosionColor;
|
vec4 ExplosionColor;
|
||||||
|
float ExplosionPercentageElapsed;
|
||||||
}Input;
|
}Input;
|
||||||
|
|
||||||
out vec4 sceneColor;
|
out vec4 sceneColor;
|
||||||
out vec4 bloomColor;
|
out vec4 bloomColor;
|
||||||
|
|
||||||
vec4 scene_ambient = vec4(0.3,0.3,0.3,1);
|
|
||||||
|
|
||||||
struct LightResult {
|
struct LightResult {
|
||||||
vec4 Diffuse;
|
vec4 Diffuse;
|
||||||
vec4 Specular;
|
vec4 Specular;
|
||||||
@@ -120,6 +119,7 @@ void main()
|
|||||||
vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate);
|
vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate);
|
||||||
vec4 position = V * M * vec4(Input.Position, 1.0);
|
vec4 position = V * M * vec4(Input.Position, 1.0);
|
||||||
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, NormalMapTexture);
|
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, NormalMapTexture);
|
||||||
|
normal = normalize(normal);
|
||||||
//vec4 normal = normalize(V * vec4(Input.Normal, 0.0));
|
//vec4 normal = normalize(V * vec4(Input.Normal, 0.0));
|
||||||
vec4 viewVec = normalize(-position);
|
vec4 viewVec = normalize(-position);
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ void main()
|
|||||||
tilePos.y = int(gl_FragCoord.y/TILE_SIZE);
|
tilePos.y = int(gl_FragCoord.y/TILE_SIZE);
|
||||||
|
|
||||||
LightResult totalLighting;
|
LightResult totalLighting;
|
||||||
totalLighting.Diffuse = scene_ambient;
|
totalLighting.Diffuse = vec4(AmbientColor.rgb, 1.0);
|
||||||
int currentTile = int(floor(gl_FragCoord.x/TILE_SIZE) + (floor(gl_FragCoord.y/TILE_SIZE) * int(ScreenDimensions.x/TILE_SIZE)));
|
int currentTile = int(floor(gl_FragCoord.x/TILE_SIZE) + (floor(gl_FragCoord.y/TILE_SIZE) * int(ScreenDimensions.x/TILE_SIZE)));
|
||||||
|
|
||||||
int start = int(LightGrids.Data[currentTile].Start);
|
int start = int(LightGrids.Data[currentTile].Start);
|
||||||
@@ -150,8 +150,9 @@ void main()
|
|||||||
totalLighting.Specular += light_result.Specular;
|
totalLighting.Specular += light_result.Specular;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed);
|
||||||
vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color;
|
color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel));
|
||||||
|
//vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color;
|
||||||
|
|
||||||
|
|
||||||
float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0;
|
float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0;
|
||||||
@@ -160,7 +161,7 @@ void main()
|
|||||||
color_result += FillColor;
|
color_result += FillColor;
|
||||||
}
|
}
|
||||||
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
|
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
|
||||||
color_result += glowTexel;
|
color_result += glowTexel*3;
|
||||||
|
|
||||||
bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), 1.0);
|
bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), 1.0);
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ out VertexData{
|
|||||||
vec3 BiTangent;
|
vec3 BiTangent;
|
||||||
vec2 TextureCoordinate;
|
vec2 TextureCoordinate;
|
||||||
vec4 ExplosionColor;
|
vec4 ExplosionColor;
|
||||||
|
float ExplosionPercentageElapsed;
|
||||||
}Output;
|
}Output;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
@@ -41,5 +42,6 @@ void main()
|
|||||||
Output.Normal = vec3(M * vec4(Normal, 0.0));
|
Output.Normal = vec3(M * vec4(Normal, 0.0));
|
||||||
Output.Tangent = vec3(M * vec4(Tangent, 0.0));
|
Output.Tangent = vec3(M * vec4(Tangent, 0.0));
|
||||||
Output.BiTangent = vec3(M * vec4(BiTangent, 0.0));
|
Output.BiTangent = vec3(M * vec4(BiTangent, 0.0));
|
||||||
Output.ExplosionColor = vec4(0.0);
|
Output.ExplosionColor = vec4(1.0);
|
||||||
|
Output.ExplosionPercentageElapsed = 0.0;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#version 430
|
||||||
|
#extension GL_EXT_gpu_shader4 : enable
|
||||||
|
|
||||||
|
uniform int MipMapLevel;
|
||||||
|
uniform bool Horizontal;
|
||||||
|
uniform vec2 ScreenSize[5];
|
||||||
|
|
||||||
|
layout (binding = 0) uniform sampler2D Texture;
|
||||||
|
|
||||||
|
in VertexData{
|
||||||
|
vec2 TextureCoordinate;
|
||||||
|
}Input;
|
||||||
|
|
||||||
|
out vec4 fragmentColor;
|
||||||
|
|
||||||
|
uniform float offset[3] = float[]( 0.0, 1.3846153846, 3.2307692308 );
|
||||||
|
uniform float weight[5] = float[]( 0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541, 0.0162162162 );
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
//vec2 tex_offset = 1.0 / textureSize2D(Texture, 0);
|
||||||
|
vec3 result = textureLod(Texture, vec2(gl_FragCoord)/ScreenSize[0], MipMapLevel ).rgb * weight[0];
|
||||||
|
|
||||||
|
if(Horizontal) {
|
||||||
|
for( int i = 1; i<3; i++) {
|
||||||
|
result += textureLod( Texture, Input.TextureCoordinate + vec2(offset[i], 0.0), MipMapLevel ).rgb * weight[i];
|
||||||
|
result += textureLod( Texture, Input.TextureCoordinate - vec2(offset[i], 0.0), MipMapLevel ).rgb * weight[i];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for( int i = 1; i<3; i++) {
|
||||||
|
result += textureLod( Texture, Input.TextureCoordinate + vec2(0.0, offset[i]), MipMapLevel ).rgb * weight[i];
|
||||||
|
result += textureLod( Texture, Input.TextureCoordinate - vec2(0.0, offset[i]), MipMapLevel ).rgb * weight[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fragmentColor = vec4(result, 1.0);
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
layout (location = 0) in vec3 Position;
|
||||||
|
|
||||||
|
out VertexData{
|
||||||
|
vec2 TextureCoordinate;
|
||||||
|
}Output;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = vec4(Position, 1.0);
|
||||||
|
Output.TextureCoordinate = (vec2(Position) + 1) / 2;
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#version 430
|
#version 430
|
||||||
#extension GL_EXT_gpu_shader4 : enable
|
#extension GL_EXT_gpu_shader4 : enable
|
||||||
|
|
||||||
|
uniform int MipMapLevel;
|
||||||
layout (binding = 0) uniform sampler2D Texture;
|
layout (binding = 0) uniform sampler2D Texture;
|
||||||
|
|
||||||
in VertexData{
|
in VertexData{
|
||||||
@@ -14,11 +15,14 @@ uniform float weight[5] = float[](0.227027, 0.1945946, 0.1216216, 0.054054, 0.01
|
|||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec2 tex_offset = 1.0 / textureSize2D(Texture, 0);
|
vec2 tex_offset = 1.0 / textureSize2D(Texture, 0);
|
||||||
vec3 result = texture(Texture, Input.TextureCoordinate).rgb * weight[0];
|
vec3 result = textureLod(Texture, Input.TextureCoordinate, MipMapLevel).rgb * weight[0];
|
||||||
|
//vec3 result = texture(Texture, Input.TextureCoordinate).rgb * weight[0];
|
||||||
|
|
||||||
for(int i = 1; i < 5; ++i) {
|
for(int i = 1; i < 5; ++i) {
|
||||||
result += texture(Texture, Input.TextureCoordinate + vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
|
result += textureLod(Texture, Input.TextureCoordinate + vec2(tex_offset.x * i, 0.0), MipMapLevel).rgb * weight[i];
|
||||||
result += texture(Texture, Input.TextureCoordinate - vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
|
result += textureLod(Texture, Input.TextureCoordinate - vec2(tex_offset.x * i, 0.0), MipMapLevel).rgb * weight[i];
|
||||||
|
//result += texture(Texture, Input.TextureCoordinate + vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
|
||||||
|
//result += texture(Texture, Input.TextureCoordinate - vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
|
||||||
}
|
}
|
||||||
fragmentColor = vec4(result, 1.0);
|
fragmentColor = vec4(result, 1.0);
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#version 430
|
#version 430
|
||||||
#extension GL_EXT_gpu_shader4 : enable
|
#extension GL_EXT_gpu_shader4 : enable
|
||||||
|
|
||||||
|
uniform int MipMapLevel;
|
||||||
layout (binding = 0) uniform sampler2D Texture;
|
layout (binding = 0) uniform sampler2D Texture;
|
||||||
|
|
||||||
in VertexData{
|
in VertexData{
|
||||||
@@ -14,11 +15,14 @@ uniform float weight[5] = float[](0.227027, 0.1945946, 0.1216216, 0.054054, 0.01
|
|||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec2 tex_offset = 1.0 / textureSize2D(Texture, 0);
|
vec2 tex_offset = 1.0 / textureSize2D(Texture, 0);
|
||||||
vec3 result = texture(Texture, Input.TextureCoordinate).rgb * weight[0];
|
//vec3 result = texture(Texture, Input.TextureCoordinate).rgb * weight[0];
|
||||||
|
vec3 result = textureLod(Texture, Input.TextureCoordinate, MipMapLevel).rgb * weight[0];
|
||||||
|
|
||||||
for(int i = 1; i < 5; ++i) {
|
for(int i = 1; i < 5; ++i) {
|
||||||
result += texture(Texture, Input.TextureCoordinate + vec2(0.0, tex_offset.y * i)).rgb * weight[i];
|
result += textureLod(Texture, Input.TextureCoordinate + vec2(0.0, tex_offset.y * i), MipMapLevel).rgb * weight[i];
|
||||||
result += texture(Texture, Input.TextureCoordinate - vec2(0.0, tex_offset.y * i)).rgb * weight[i];
|
result += textureLod(Texture, Input.TextureCoordinate - vec2(0.0, tex_offset.y * i), MipMapLevel).rgb * weight[i];
|
||||||
|
//result += texture(Texture, Input.TextureCoordinate + vec2(0.0, tex_offset.y * i)).rgb * weight[i];
|
||||||
|
//result += texture(Texture, Input.TextureCoordinate - vec2(0.0, tex_offset.y * i)).rgb * weight[i];
|
||||||
}
|
}
|
||||||
fragmentColor = vec4(result, 1.0);
|
fragmentColor = vec4(result, 1.0);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
in VertexData{
|
||||||
|
vec3 Position;
|
||||||
|
}Input;
|
||||||
|
|
||||||
|
|
||||||
|
out vec4 fragmentColor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
fragmentColor = vec4(0.5, 0.0, 0.0, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
uniform mat4 M;
|
||||||
|
uniform mat4 V;
|
||||||
|
uniform mat4 P;
|
||||||
|
|
||||||
|
layout(location = 0) in vec3 Position;
|
||||||
|
|
||||||
|
|
||||||
|
out VertexData{
|
||||||
|
vec3 Position;
|
||||||
|
}Output;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = P * V * M * vec4(Position, 1.0);
|
||||||
|
|
||||||
|
Output.Position = Position;
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
layout (binding = 0) uniform sampler2D Texture0;
|
||||||
|
layout (binding = 1) uniform sampler2D Texture1;
|
||||||
|
|
||||||
|
in VertexData{
|
||||||
|
vec2 TextureCoordinate;
|
||||||
|
}Input;
|
||||||
|
|
||||||
|
out vec4 fragmentColor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec4 texel0 = texture(Texture0, Input.TextureCoordinate);
|
||||||
|
vec4 texel1 = texture(Texture1, Input.TextureCoordinate);
|
||||||
|
|
||||||
|
fragmentColor = texel0 + texel1;
|
||||||
|
//fragmentColor = vec4(1,0.5,0.7,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
layout (location = 0) in vec3 Position;
|
||||||
|
|
||||||
|
out VertexData{
|
||||||
|
vec2 TextureCoordinate;
|
||||||
|
}Output;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = vec4(Position, 1.0);
|
||||||
|
Output.TextureCoordinate = (vec2(Position) + 1) / 2;
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "Engine/GLM.h"
|
#include "Engine/GLM.h"
|
||||||
#include "Core/World.h"
|
#include "Core/World.h"
|
||||||
#include "Rendering/Model.h"
|
#include "Rendering/Model.h"
|
||||||
|
#include "imgui/imgui.h"
|
||||||
|
|
||||||
namespace Collision
|
namespace Collision
|
||||||
{
|
{
|
||||||
@@ -116,36 +117,79 @@ bool AABBVsAABB(const AABB& a, const AABB& b, glm::vec3& minimumTranslation)
|
|||||||
return glm::all(axisesIntersecting);
|
return glm::all(axisesIntersecting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RayVsTriangle(const Ray& ray,
|
||||||
|
const glm::vec3& v0,
|
||||||
|
const glm::vec3& v1,
|
||||||
|
const glm::vec3& v2,
|
||||||
|
bool trueOnNegativeDistance)
|
||||||
|
{
|
||||||
|
glm::vec3 e1 = v1 - v0; //v1 - v0
|
||||||
|
glm::vec3 e2 = v2 - v0; //v2 - v0
|
||||||
|
glm::vec3 m = ray.Origin() - v0;
|
||||||
|
glm::vec3 MxE1 = glm::cross(m, e1);
|
||||||
|
glm::vec3 DxE2 = glm::cross(ray.Direction(), e2);
|
||||||
|
float DetInv = glm::dot(e1, DxE2);
|
||||||
|
if (std::abs(DetInv) < FLT_EPSILON) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
DetInv = 1.0f / DetInv;
|
||||||
|
float u = glm::dot(m, DxE2) * DetInv;
|
||||||
|
float v = glm::dot(ray.Direction(), MxE1) * DetInv;
|
||||||
|
//u,v can be very close to 0 but still negative sometimes. added a deltafactor to compensate for that problem
|
||||||
|
if ((u + 0.001f) < 0 || (v + 0.001f) < 0 || 1 < u + v) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//Here, u and v are positive, u+v <= 1, and if distance is positive - triangle is hit.
|
||||||
|
return trueOnNegativeDistance || 0 <= glm::dot(e2, MxE1) * DetInv;
|
||||||
|
}
|
||||||
|
|
||||||
bool RayVsModel(const Ray& ray,
|
bool RayVsModel(const Ray& ray,
|
||||||
const std::vector<RawModel::Vertex>& modelVertices,
|
const std::vector<RawModel::Vertex>& modelVertices,
|
||||||
const std::vector<unsigned int>& modelIndices)
|
const std::vector<unsigned int>& modelIndices)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < modelIndices.size(); ++i) {
|
for (int i = 0; i < modelIndices.size(); ++i) {
|
||||||
glm::vec3 v0 = modelVertices[modelIndices[i]].Position;
|
glm::vec3 v0 = modelVertices[modelIndices[i]].Position;
|
||||||
glm::vec3 e1 = modelVertices[modelIndices[++i]].Position - v0; //v1 - v0
|
glm::vec3 v1 = modelVertices[modelIndices[++i]].Position;
|
||||||
glm::vec3 e2 = modelVertices[modelIndices[++i]].Position - v0; //v2 - v0
|
glm::vec3 v2 = modelVertices[modelIndices[++i]].Position;
|
||||||
glm::vec3 m = ray.Origin() - v0;
|
if (RayVsTriangle(ray, v0, v1, v2)) {
|
||||||
glm::vec3 MxE1 = glm::cross(m, e1);
|
|
||||||
glm::vec3 DxE2 = glm::cross(ray.Direction(), e2);
|
|
||||||
float DetInv = glm::dot(e1, DxE2);
|
|
||||||
if (std::abs(DetInv) < FLT_EPSILON) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
DetInv = 1.0f / DetInv;
|
|
||||||
float u = glm::dot(m, DxE2) * DetInv;
|
|
||||||
float v = glm::dot(ray.Direction(), MxE1) * DetInv;
|
|
||||||
//u,v can be very close to 0 but still negative sometimes. added a deltafactor to compensate for that problem
|
|
||||||
if ((u + 0.001f) < 0 || (v + 0.001f) < 0 || 1 < u + v) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
//Here, u and v are positive, u+v <= 1, and if distance is positive - triangle is hit.
|
|
||||||
if (0 <= glm::dot(e2, MxE1) * DetInv) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RayVsTriangle(const Ray& ray,
|
||||||
|
const glm::vec3& v0,
|
||||||
|
const glm::vec3& v1,
|
||||||
|
const glm::vec3& v2,
|
||||||
|
float& outDistance,
|
||||||
|
float& outUCoord,
|
||||||
|
float& outVCoord,
|
||||||
|
bool trueOnNegativeDistance)
|
||||||
|
{
|
||||||
|
glm::vec3 e1 = v1 - v0; //v1 - v0
|
||||||
|
glm::vec3 e2 = v2 - v0; //v2 - v0
|
||||||
|
glm::vec3 m = ray.Origin() - v0;
|
||||||
|
glm::vec3 MxE1 = glm::cross(m, e1);
|
||||||
|
glm::vec3 DxE2 = glm::cross(ray.Direction(), e2);//pVec
|
||||||
|
float DetInv = glm::dot(e1, DxE2);
|
||||||
|
if (std::abs(DetInv) < FLT_EPSILON) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
DetInv = 1.0f / DetInv;
|
||||||
|
float dist = glm::dot(e2, MxE1) * DetInv;
|
||||||
|
if (dist >= outDistance) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
outDistance = dist;
|
||||||
|
outUCoord = glm::dot(m, DxE2) * DetInv;
|
||||||
|
outVCoord = glm::dot(ray.Direction(), MxE1) * DetInv;
|
||||||
|
|
||||||
|
//u,v can be very close to 0 but still negative sometimes. added a deltafactor to compensate for that problem
|
||||||
|
//If u and v are positive, u+v <= 1, dist is positive, and less than closest.
|
||||||
|
return (0 <= (outUCoord + 0.001f) && 0 <= (outVCoord + 0.001f) && outUCoord + outVCoord <= 1 && (trueOnNegativeDistance || 0 <= dist));
|
||||||
|
}
|
||||||
|
|
||||||
bool RayVsModel(const Ray& ray,
|
bool RayVsModel(const Ray& ray,
|
||||||
const std::vector<RawModel::Vertex>& modelVertices,
|
const std::vector<RawModel::Vertex>& modelVertices,
|
||||||
const std::vector<unsigned int>& modelIndices,
|
const std::vector<unsigned int>& modelIndices,
|
||||||
@@ -157,26 +201,12 @@ bool RayVsModel(const Ray& ray,
|
|||||||
bool hit = false;
|
bool hit = false;
|
||||||
for (int i = 0; i < modelIndices.size(); ++i) {
|
for (int i = 0; i < modelIndices.size(); ++i) {
|
||||||
glm::vec3 v0 = modelVertices[modelIndices[i]].Position;
|
glm::vec3 v0 = modelVertices[modelIndices[i]].Position;
|
||||||
glm::vec3 e1 = modelVertices[modelIndices[++i]].Position - v0; //v1 - v0
|
glm::vec3 v1 = modelVertices[modelIndices[++i]].Position;
|
||||||
glm::vec3 e2 = modelVertices[modelIndices[++i]].Position - v0; //v2 - v0
|
glm::vec3 v2 = modelVertices[modelIndices[++i]].Position;
|
||||||
glm::vec3 m = ray.Origin() - v0;
|
float dist;
|
||||||
glm::vec3 MxE1 = glm::cross(m, e1);
|
float u;
|
||||||
glm::vec3 DxE2 = glm::cross(ray.Direction(), e2);//pVec
|
float v;
|
||||||
float DetInv = glm::dot(e1, DxE2);
|
if (RayVsTriangle(ray, v0, v1, v2, dist, u, v)) {
|
||||||
if (std::abs(DetInv) < FLT_EPSILON) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
DetInv = 1.0f / DetInv;
|
|
||||||
float dist = glm::dot(e2, MxE1) * DetInv;
|
|
||||||
if (dist >= outDistance) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
float u = glm::dot(m, DxE2) * DetInv;
|
|
||||||
float v = glm::dot(ray.Direction(), MxE1) * DetInv;
|
|
||||||
|
|
||||||
//u,v can be very close to 0 but still negative sometimes. added a deltafactor to compensate for that problem
|
|
||||||
//If u and v are positive, u+v <= 1, dist is positive, and less than closest.
|
|
||||||
if (0 <= (u + 0.001f) && 0 <= (v + 0.001f) && u + v <= 1 && 0 <= dist) {
|
|
||||||
outDistance = dist;
|
outDistance = dist;
|
||||||
outUCoord = u;
|
outUCoord = u;
|
||||||
outVCoord = v;
|
outVCoord = v;
|
||||||
@@ -199,43 +229,338 @@ bool RayVsModel(const Ray& ray,
|
|||||||
return hit;
|
return hit;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AABBvsTriangles(const AABB& box, const std::vector<RawModel::Vertex>& modelVertices, const std::vector<unsigned int>& modelIndices, const glm::mat4& modelMatrix, glm::vec3& outResolutionVector)
|
constexpr inline int signNonZero(float x)
|
||||||
{
|
{
|
||||||
bool hit = false;
|
return x < 0 ? -1 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline glm::vec3 signNonZero(const glm::vec3& x)
|
||||||
|
{
|
||||||
|
glm::vec3 r;
|
||||||
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
r[i] = (float)signNonZero(x[i]);
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool vectorHasLength(const T& vec)
|
||||||
|
{
|
||||||
|
return glm::any(glm::greaterThan(glm::abs(vec), T(0.0001f)));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rectangleVsTriangle(const glm::vec2& boxMin,
|
||||||
|
const glm::vec2& boxMax,
|
||||||
|
const std::array<glm::vec2, 3>& triPos,
|
||||||
|
glm::vec2& resolutionDirection,
|
||||||
|
float& resolutionDistanceSq,
|
||||||
|
bool& pushedFromTriNormal)
|
||||||
|
{
|
||||||
|
pushedFromTriNormal = false;
|
||||||
|
resolutionDistanceSq = INFINITY;
|
||||||
|
//Project along box normals (coordinate axes, since it's axis-aligned).
|
||||||
|
for (int ax = 0; ax < 2; ++ax) {
|
||||||
|
float minTri = INFINITY;
|
||||||
|
float maxTri = -INFINITY;
|
||||||
|
for (const glm::vec2& t : triPos) {
|
||||||
|
minTri = std::min(t[ax], minTri);
|
||||||
|
maxTri = std::max(t[ax], maxTri);
|
||||||
|
}
|
||||||
|
if (boxMax[ax] <= minTri || maxTri <= boxMin[ax]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Here: maxBox > minTri && minBox < maxTri
|
||||||
|
//Left is negative.
|
||||||
|
float leftRes = minTri - boxMax[ax];
|
||||||
|
float rightRes = maxTri - boxMin[ax];
|
||||||
|
float push = rightRes < -leftRes ? rightRes : leftRes;
|
||||||
|
float absPushSq = abs(push);
|
||||||
|
absPushSq *= absPushSq;
|
||||||
|
|
||||||
|
if (absPushSq < resolutionDistanceSq) {
|
||||||
|
resolutionDistanceSq = absPushSq;
|
||||||
|
resolutionDirection[1 - ax] = 0.f;
|
||||||
|
resolutionDirection[ax] = push;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Project along triangle normals.
|
||||||
|
//Put edges into normal vector, make normals in the loop.
|
||||||
|
std::array<glm::vec2, 3> triNormals = {
|
||||||
|
triPos[1] - triPos[0],
|
||||||
|
triPos[2] - triPos[1],
|
||||||
|
triPos[0] - triPos[2]
|
||||||
|
};
|
||||||
|
std::array<glm::vec2, 4> boxPos = {
|
||||||
|
boxMax,
|
||||||
|
glm::vec2(boxMax.x, boxMin.y),
|
||||||
|
glm::vec2(boxMin.x, boxMax.y),
|
||||||
|
boxMin
|
||||||
|
};
|
||||||
|
for (auto& normal : triNormals) {
|
||||||
|
if (!vectorHasLength(normal)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//Rotate edge to a normal.
|
||||||
|
normal = glm::normalize(glm::vec2(-normal.y, normal.x));
|
||||||
|
//Project triangle onto the normal.
|
||||||
|
float minTri = INFINITY;
|
||||||
|
float maxTri = -INFINITY;
|
||||||
|
for (const glm::vec2& point : triPos) {
|
||||||
|
float dot = glm::dot(normal, point);
|
||||||
|
minTri = std::min(dot, minTri);
|
||||||
|
maxTri = std::max(dot, maxTri);
|
||||||
|
}
|
||||||
|
//Project box onto the normal.
|
||||||
|
float minBox = INFINITY;
|
||||||
|
float maxBox = -INFINITY;
|
||||||
|
for (const glm::vec2& point : boxPos) {
|
||||||
|
float dot = glm::dot(normal, point);
|
||||||
|
minBox = std::min(dot, minBox);
|
||||||
|
maxBox = std::max(dot, maxBox);
|
||||||
|
}
|
||||||
|
if (maxBox <= minTri || maxTri <= minBox) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Here: maxBox > minTri && minBox < maxTri
|
||||||
|
//Left is negative.
|
||||||
|
float leftRes = minTri - maxBox;
|
||||||
|
float rightRes = maxTri - minBox;
|
||||||
|
float push = rightRes < -leftRes ? rightRes : leftRes;
|
||||||
|
float absPushSq = abs(push);
|
||||||
|
absPushSq *= absPushSq;
|
||||||
|
|
||||||
|
if (absPushSq < resolutionDistanceSq) {
|
||||||
|
resolutionDistanceSq = absPushSq;
|
||||||
|
resolutionDirection = push * normal;
|
||||||
|
pushedFromTriNormal = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr float SlopeConstant(float degrees)
|
||||||
|
{
|
||||||
|
return (1.0f - degrees / 90.f);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Returns true if the angle between horizon and the collision surface is less than 45 degrees.
|
||||||
|
constexpr bool FaceIsGround(float faceNormalY)
|
||||||
|
{
|
||||||
|
//TODO: Perhaps the 45 degrees could be saved in a component or in the config..
|
||||||
|
return faceNormalY > SlopeConstant(45.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
//An array containing 3 int pairs { 0, 2 }, { 0, 1 }, { 1, 2 }
|
||||||
|
constexpr std::array<std::pair<int, int>, 3> dimensionPairs({ std::pair<int, int>(0, 2), std::pair<int, int>(0, 1), std::pair<int, int>(1, 2) });
|
||||||
|
|
||||||
|
bool AABBvsTriangle(const AABB& box,
|
||||||
|
const std::array<glm::vec3, 3>& triPos,
|
||||||
|
const glm::vec3& originalBoxVelocity,
|
||||||
|
float verticalStepHeight,
|
||||||
|
bool& isOnGround,
|
||||||
|
glm::vec3& boxVelocity,
|
||||||
|
glm::vec3& outResolution)
|
||||||
|
{
|
||||||
|
//Check so we don't have a zero area triangle when calculating the normal.
|
||||||
|
//Also, don't check a triangle facing away from the player.
|
||||||
|
//Less checks, and we should be able to walk out from models if we are trapped inside.
|
||||||
|
glm::vec3 triNormal = glm::cross(triPos[1] - triPos[0], triPos[2] - triPos[0]);
|
||||||
|
if (!vectorHasLength(triNormal) || (glm::dot(triNormal, originalBoxVelocity) > 0)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
triNormal = glm::normalize(triNormal);
|
||||||
|
|
||||||
|
enum BoxTriResolveCase
|
||||||
|
{
|
||||||
|
ResolveDimX,
|
||||||
|
ResolveDimY,
|
||||||
|
ResolveDimZ,
|
||||||
|
Line, //Box edge colliding with triangle line.
|
||||||
|
Corner //Box corner colliding with the triangle face.
|
||||||
|
};
|
||||||
|
struct Resolution
|
||||||
|
{
|
||||||
|
Resolution()
|
||||||
|
: DistanceSq(INFINITY)
|
||||||
|
, Vector(0.f)
|
||||||
|
{}
|
||||||
|
BoxTriResolveCase Case;
|
||||||
|
float DistanceSq;
|
||||||
|
glm::vec3 Vector;
|
||||||
|
};
|
||||||
|
//The smallest resolution that solves the collision.
|
||||||
|
Resolution resolveShortest;
|
||||||
|
//The smallest resolution that solves the collision, that resolves upwards.
|
||||||
|
Resolution resolveUpwards;
|
||||||
|
//If player stands on the ground and collides with a ground triangle,
|
||||||
|
//we might step up onto it if the step is small enough.
|
||||||
|
bool canStairStepUp = isOnGround && FaceIsGround(triNormal.y);
|
||||||
|
|
||||||
const glm::vec3& origin = box.Origin();
|
const glm::vec3& origin = box.Origin();
|
||||||
|
const glm::vec3& half = box.HalfSize();
|
||||||
const glm::vec3& min = box.MinCorner();
|
const glm::vec3& min = box.MinCorner();
|
||||||
const glm::vec3& max = box.MaxCorner();
|
const glm::vec3& max = box.MaxCorner();
|
||||||
|
|
||||||
outResolutionVector.x = INFINITY;
|
//For each projection in xy-, xz-, and yx-planes.
|
||||||
|
for (std::pair<int, int> dim : dimensionPairs) {
|
||||||
for (int i = 0; i < modelIndices.size(); ++i) {
|
//2D Triangle.
|
||||||
glm::vec3 p = modelVertices[i].Position;
|
//Project triangle.
|
||||||
p = glm::vec3(modelMatrix * glm::vec4(p.x, p.y, p.z, 1));
|
std::array<glm::vec2, 3> t2D = {
|
||||||
|
glm::vec2(triPos[0][dim.first], triPos[0][dim.second]),
|
||||||
float distFromOrigin = glm::abs(origin.x - p.x);
|
glm::vec2(triPos[1][dim.first], triPos[1][dim.second]),
|
||||||
float penetration = box.HalfSize().x - distFromOrigin;
|
glm::vec2(triPos[2][dim.first], triPos[2][dim.second])
|
||||||
if (penetration > 0 && penetration < glm::abs(outResolutionVector.x)) {
|
};
|
||||||
if (p.x > origin.x) {
|
//Project box.
|
||||||
outResolutionVector.x = -penetration;
|
glm::vec2 boxMin(min[dim.first], min[dim.second]);
|
||||||
} else {
|
glm::vec2 boxMax(max[dim.first], max[dim.second]);
|
||||||
outResolutionVector.x = penetration;
|
glm::vec2 resolutionVector;
|
||||||
|
float resolutionDist;
|
||||||
|
bool pushedFromTriangleLine;
|
||||||
|
//if projections don't overlap, return false.
|
||||||
|
if (!rectangleVsTriangle(boxMin, boxMax, t2D, resolutionVector, resolutionDist, pushedFromTriangleLine)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
//Overwrite the smallest resolution if this is smaller.
|
||||||
|
if (resolutionDist < resolveShortest.DistanceSq) {
|
||||||
|
resolveShortest.Vector = glm::vec3(0.f);
|
||||||
|
resolveShortest.Vector[dim.first] = resolutionVector.x;
|
||||||
|
resolveShortest.Vector[dim.second] = resolutionVector.y;
|
||||||
|
resolveShortest.DistanceSq = resolutionDist;
|
||||||
|
//If we pushed away from triangle line (edge), or if we
|
||||||
|
//move the player along one coordinate axis (pick the dimension that isn't zero).
|
||||||
|
resolveShortest.Case = pushedFromTriangleLine ? Line : static_cast<BoxTriResolveCase>((abs(resolveShortest.Vector[dim.first]) < 0.0001f) ? dim.second : dim.first);
|
||||||
|
}
|
||||||
|
//Overwrite the smallest upward resolution if this is smaller, and resolves upwards.
|
||||||
|
constexpr int yAxis = 1;
|
||||||
|
bool resIsUpwardsIn3D = dim.first == yAxis && resolutionVector.x > 0 || dim.second == yAxis && resolutionVector.y > 0;
|
||||||
|
if (canStairStepUp && resIsUpwardsIn3D && resolutionDist < resolveUpwards.DistanceSq) {
|
||||||
|
resolveUpwards.Vector = glm::vec3(0.f);
|
||||||
|
resolveUpwards.Vector[dim.first] = resolutionVector.x;
|
||||||
|
resolveUpwards.Vector[dim.second] = resolutionVector.y;
|
||||||
|
resolveUpwards.DistanceSq = resolutionDist;
|
||||||
|
//If we pushed away from triangle line (edge), or if we
|
||||||
|
//move the player along one coordinate axis (pick the dimension that isn't zero).
|
||||||
|
resolveUpwards.Case = pushedFromTriangleLine ? Line : static_cast<BoxTriResolveCase>((abs(resolveUpwards.Vector[dim.first]) < 0.0001f) ? dim.second : dim.first);
|
||||||
}
|
}
|
||||||
hit = true;
|
|
||||||
}
|
}
|
||||||
//glm::vec3 pLocal = origin - p;
|
|
||||||
//for (int axis = 0; axis < 3; ++axis) {
|
|
||||||
// if (p[axis] < min[axis] || p[axis] > max[axis]) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (glm::abs(pLocal[axis]) < box.HalfSize()[axis]) {
|
|
||||||
// outResolutionVector[axis] = (glm::sign(pLocal[axis]) * box.HalfSize()[axis]) - pLocal[axis];
|
|
||||||
// hit = true;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//If the triangle does intersect any of the cube diagonals, it will
|
||||||
|
//intersect the cube diagonal that comes
|
||||||
|
//closest to being perpendicular to the plane of the triangle.
|
||||||
|
glm::vec3 diagonal = signNonZero(triNormal) * half;
|
||||||
|
//The triangle plane contains all points P in dot(triNormal, P) == dot(triNormal, v0)
|
||||||
|
//The diagonal line contains all points P in P = origin + diagonal * t.
|
||||||
|
float t = glm::dot(triNormal, triPos[0] - origin) / glm::dot(triNormal, diagonal);
|
||||||
|
//If intersection point between plane and diagonal is within the box.
|
||||||
|
if (glm::abs(t) > 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
glm::vec3 cornerResolution = (1+t) * diagonal;
|
||||||
|
//Overwrite the smallest resolution if cornerResolution is smaller.
|
||||||
|
float lenSq = glm::length2(cornerResolution);
|
||||||
|
if (lenSq < resolveShortest.DistanceSq) {
|
||||||
|
resolveShortest.Vector = cornerResolution;
|
||||||
|
resolveShortest.Case = Corner;
|
||||||
|
}
|
||||||
|
if (canStairStepUp && cornerResolution.y > 0 && lenSq < resolveUpwards.DistanceSq) {
|
||||||
|
resolveUpwards.Vector = cornerResolution;
|
||||||
|
resolveUpwards.Case = Corner;
|
||||||
|
resolveUpwards.DistanceSq = lenSq;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Force the resolution upwards if it is smaller than the threshold verticalStepHeight.
|
||||||
|
//Else take the shortest resolution.
|
||||||
|
bool takeUp = resolveUpwards.Vector.y > 0 && resolveUpwards.Vector.y < verticalStepHeight;
|
||||||
|
Resolution& bestResolve = takeUp ? resolveUpwards : resolveShortest;
|
||||||
|
outResolution = bestResolve.Vector;
|
||||||
|
|
||||||
|
glm::vec3 projNorm;
|
||||||
|
switch (bestResolve.Case) {
|
||||||
|
case ResolveDimY:
|
||||||
|
boxVelocity.y = 0.f;
|
||||||
|
if (outResolution.y > 0)
|
||||||
|
isOnGround = true;
|
||||||
|
case ResolveDimX:
|
||||||
|
case ResolveDimZ:
|
||||||
|
//If we get here, the resolution is along one coordinate axis.
|
||||||
|
//set velocity to 0 in y if it is along y-axis.
|
||||||
|
return true;
|
||||||
|
case Line:
|
||||||
|
projNorm = glm::normalize(outResolution);
|
||||||
|
break;
|
||||||
|
case Corner:
|
||||||
|
projNorm = triNormal;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//If the collision was not on steep wall or similarly (e.g. walking on the ground), force resolution in y only.
|
||||||
|
if (FaceIsGround(projNorm.y)) {
|
||||||
|
//Ensure that the player always is moved upwards, instead of sliding down.
|
||||||
|
float len = glm::length(outResolution);
|
||||||
|
float ang = glm::half_pi<float>() - glm::acos(outResolution.y / len);
|
||||||
|
if (len > 0.0000001f && ang > 0.0000001f) {
|
||||||
|
outResolution.x = 0;
|
||||||
|
outResolution.y = len / glm::sin(ang);
|
||||||
|
outResolution.z = 0;
|
||||||
|
}
|
||||||
|
//Also zero the vertical velocity, if it is positive, else project it onto the normal.
|
||||||
|
//Project the velocity onto the normal of the hit line/face.
|
||||||
|
//w = v - <v,n>*n, |n|==1.
|
||||||
|
boxVelocity.y = std::min(boxVelocity.y - glm::dot(boxVelocity, projNorm) * projNorm.y, 0.f);
|
||||||
|
isOnGround = true;
|
||||||
|
} else {
|
||||||
|
//Enter here if the triangle is a steep slope, and it is not facing downwards.
|
||||||
|
//Project the velocity onto the normal of the hit line/face.
|
||||||
|
//w = v - <v,n>*n, |n|==1.
|
||||||
|
//"ice cream"-effect, air resistance + projected velocity.
|
||||||
|
if (!isOnGround) {
|
||||||
|
boxVelocity = boxVelocity - glm::dot(boxVelocity, projNorm) * projNorm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AABBvsTriangles(const AABB& box,
|
||||||
|
const std::vector<RawModel::Vertex>& modelVertices,
|
||||||
|
const std::vector<unsigned int>& modelIndices,
|
||||||
|
const glm::mat4& modelMatrix,
|
||||||
|
glm::vec3& boxVelocity,
|
||||||
|
float verticalStepHeight,
|
||||||
|
bool& isOnGround,
|
||||||
|
glm::vec3& outResolutionVector)
|
||||||
|
{
|
||||||
|
bool hit = false;
|
||||||
|
|
||||||
|
bool everHitTheGround = false;
|
||||||
|
AABB newBox = box;
|
||||||
|
outResolutionVector = glm::vec3(0.f);
|
||||||
|
glm::vec3 originalBoxVelocity(boxVelocity);
|
||||||
|
for (int i = 0; i < modelIndices.size(); ) {
|
||||||
|
std::array<glm::vec3, 3> triVertices = {
|
||||||
|
Transform::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix),
|
||||||
|
Transform::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix),
|
||||||
|
Transform::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix)
|
||||||
|
};
|
||||||
|
glm::vec3 outVec;
|
||||||
|
bool collideWithGround = isOnGround;
|
||||||
|
if (AABBvsTriangle(newBox, triVertices, originalBoxVelocity, verticalStepHeight, collideWithGround, boxVelocity, outVec)) {
|
||||||
|
hit = true;
|
||||||
|
outResolutionVector += outVec;
|
||||||
|
newBox = AABB::FromOriginSize(newBox.Origin() + outVec, newBox.Size());
|
||||||
|
if (collideWithGround) {
|
||||||
|
everHitTheGround = isOnGround = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!everHitTheGround) {
|
||||||
|
isOnGround = false;
|
||||||
|
}
|
||||||
return hit;
|
return hit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "Collision/Collision.h"
|
#include "Collision/Collision.h"
|
||||||
#include "Collision/CollisionSystem.h"
|
#include "Collision/CollisionSystem.h"
|
||||||
#include "Core/AABB.h"
|
#include "Core/AABB.h"
|
||||||
|
#include "Rendering/Model.h"
|
||||||
|
|
||||||
void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt)
|
void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt)
|
||||||
{
|
{
|
||||||
@@ -25,33 +26,34 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Collision::AABBVsAABB(boxA, boxB, resolutionVector)) {
|
if (boxB.Entity.HasComponent("Model") && Collision::AABBVsAABB(boxA, boxB)) {
|
||||||
|
//Here we know boxB is a entity with Collideable, AABB, and Model.
|
||||||
|
RawModel* model;
|
||||||
|
try {
|
||||||
|
model = ResourceManager::Load<RawModel, true>(boxB.Entity["Model"]["Resource"]);
|
||||||
|
} catch (const std::exception&) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::mat4 modelMatrix = Transform::ModelMatrix(boxB.Entity);
|
||||||
|
|
||||||
|
glm::vec3 inOutVelocity = (glm::vec3)cPhysics["Velocity"];
|
||||||
|
bool isOnGround = (bool)cPhysics["IsOnGround"];
|
||||||
|
float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"];
|
||||||
|
if (Collision::AABBvsTriangles(boxA, model->m_Vertices, model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) {
|
||||||
|
(glm::vec3&)cTransform["Position"] += resolutionVector;
|
||||||
|
cPhysics["Velocity"] = inOutVelocity;
|
||||||
|
(bool)cPhysics["IsOnGround"] = isOnGround;
|
||||||
|
} else {
|
||||||
|
(bool)cPhysics["IsOnGround"] = false;
|
||||||
|
}
|
||||||
|
} else if (Collision::AABBVsAABB(boxA, boxB, resolutionVector)) {
|
||||||
|
//Enter here if boxB has no Model.
|
||||||
(glm::vec3&)cTransform["Position"] += resolutionVector;
|
(glm::vec3&)cTransform["Position"] += resolutionVector;
|
||||||
if (resolutionVector.y > 0) {
|
(bool)cPhysics["IsOnGround"] = resolutionVector.y > 0;
|
||||||
|
if ((bool)cPhysics["IsOnGround"]){
|
||||||
((glm::vec3&)cPhysics["Velocity"]).y = 0.f;
|
((glm::vec3&)cPhysics["Velocity"]).y = 0.f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// HACK: Temporarily collide against all collidable models since they're not in the octree yet
|
|
||||||
//auto otherCollidables = world->GetComponents("Model");
|
|
||||||
//for (auto& cModel : *otherCollidables) {
|
|
||||||
// if (cModel.EntityID == entity) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// if (!world->HasComponent(cModel.EntityID, "Collidable")) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// auto absPosition = RenderQueueFactory::AbsolutePosition(world, cModel.EntityID);
|
|
||||||
// auto absOrientation = RenderQueueFactory::AbsoluteOrientation(world, cModel.EntityID);
|
|
||||||
// auto absScale = RenderQueueFactory::AbsoluteScale(world, cModel.EntityID);
|
|
||||||
// glm::mat4 modelMatrix = glm::translate(absPosition); // *glm::toMat4(absOrientation) * glm::scale(absScale);
|
|
||||||
|
|
||||||
// auto model = ResourceManager::Load<Model>(cModel["Resource"]);
|
|
||||||
// glm::vec3 resolutionVector;
|
|
||||||
// if (Collision::AABBvsTriangles(boxA, model->m_Vertices, model->m_Indices, modelMatrix, resolutionVector)) {
|
|
||||||
// (glm::vec3&)cTransform["Position"] += resolutionVector;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -275,9 +275,4 @@ std::vector<int> Child::childIndicesContainingBox(const AABB& box) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Child::hasChildren() const
|
|
||||||
{
|
|
||||||
return m_Children[0] != nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -97,3 +97,7 @@ glm::mat4 Transform::ModelMatrix(EntityID entity, World* world)
|
|||||||
return modelMatrix;
|
return modelMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::vec3 Transform::TransformPoint(const glm::vec3& point, const glm::mat4& matrix)
|
||||||
|
{
|
||||||
|
return glm::vec3(matrix * glm::vec4(point.x, point.y, point.z, 1));
|
||||||
|
}
|
||||||
@@ -23,6 +23,12 @@ void EditorRenderSystem::Update(double dt)
|
|||||||
scene.Camera = m_EditorCamera;
|
scene.Camera = m_EditorCamera;
|
||||||
scene.Viewport = Rectangle(1920, 1080);
|
scene.Viewport = Rectangle(1920, 1080);
|
||||||
|
|
||||||
|
auto cSceneLight = m_World->GetComponents("SceneLight");
|
||||||
|
if (cSceneLight != nullptr) {
|
||||||
|
//these are hardcoded since they want special light treatment and a component just for widgets is stupid.
|
||||||
|
scene.AmbientColor = glm::vec4(0.8, 0.8, 0.8, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
auto models = m_World->GetComponents("Model");
|
auto models = m_World->GetComponents("Model");
|
||||||
if (models != nullptr) {
|
if (models != nullptr) {
|
||||||
for (auto& cModel : *models) {
|
for (auto& cModel : *models) {
|
||||||
@@ -49,10 +55,10 @@ void EditorRenderSystem::Update(double dt)
|
|||||||
glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, entity.World);
|
glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, entity.World);
|
||||||
for (auto matGroup : model->MaterialGroups()) {
|
for (auto matGroup : model->MaterialGroups()) {
|
||||||
std::shared_ptr<ModelJob> modelJob = std::make_shared<ModelJob>(model, scene.Camera, modelMatrix, matGroup, cModel, entity.World, glm::vec4(0), 0.f);
|
std::shared_ptr<ModelJob> modelJob = std::make_shared<ModelJob>(model, scene.Camera, modelMatrix, matGroup, cModel, entity.World, glm::vec4(0), 0.f);
|
||||||
if(cModel["Transparent"]) {
|
if (cModel["Transparent"]) {
|
||||||
scene.TransparentObjects.push_back(modelJob);
|
scene.Jobs.TransparentObjects.push_back(modelJob);
|
||||||
} else {
|
} else {
|
||||||
scene.OpaqueObjects.push_back(modelJob);
|
scene.Jobs.OpaqueObjects.push_back(modelJob);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -69,7 +75,7 @@ void EditorRenderSystem::Update(double dt)
|
|||||||
EntityWrapper entity(m_World, cPointLight.EntityID);
|
EntityWrapper entity(m_World, cPointLight.EntityID);
|
||||||
ComponentWrapper& cTransform = entity["Transform"];
|
ComponentWrapper& cTransform = entity["Transform"];
|
||||||
std::shared_ptr<PointLightJob> pointLightJob = std::make_shared<PointLightJob>(cTransform, cPointLight, entity.World);
|
std::shared_ptr<PointLightJob> pointLightJob = std::make_shared<PointLightJob>(cTransform, cPointLight, entity.World);
|
||||||
scene.PointLightJobs.push_back(pointLightJob);
|
scene.Jobs.PointLight.push_back(pointLightJob);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -258,11 +258,11 @@ void Client::parseSnapshot(Packet& packet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Client::receive(char* data)
|
size_t Client::receive(char* data)
|
||||||
{
|
{
|
||||||
boost::system::error_code error;
|
boost::system::error_code error;
|
||||||
|
|
||||||
int bytesReceived = m_Socket.receive_from(boost
|
size_t bytesReceived = m_Socket.receive_from(boost
|
||||||
::asio::buffer((void*)data, INPUTSIZE),
|
::asio::buffer((void*)data, INPUTSIZE),
|
||||||
m_ReceiverEndpoint,
|
m_ReceiverEndpoint,
|
||||||
0, error);
|
0, error);
|
||||||
@@ -390,7 +390,7 @@ void Client::identifyPacketLoss()
|
|||||||
bool Client::hasServerTimedOut()
|
bool Client::hasServerTimedOut()
|
||||||
{
|
{
|
||||||
// Time in ms
|
// Time in ms
|
||||||
float timeSincePing = 1000 * (std::clock() - m_StartPingTime) / static_cast<double>(CLOCKS_PER_SEC);
|
double timeSincePing = 1000 * (std::clock() - m_StartPingTime) / static_cast<double>(CLOCKS_PER_SEC);
|
||||||
if (timeSincePing > m_TimeoutMs) {
|
if (timeSincePing > m_TimeoutMs) {
|
||||||
// Clear everything and go to menu.
|
// Clear everything and go to menu.
|
||||||
LOG_INFO("Server has timed out, returning to menu, Beep Boop.");
|
LOG_INFO("Server has timed out, returning to menu, Beep Boop.");
|
||||||
|
|||||||
@@ -26,10 +26,10 @@ void Network::saveToFile()
|
|||||||
outfile << "Total messages received," + std::to_string(m_NetworkData.AmountOfMessagesReceived) + "\n";
|
outfile << "Total messages received," + std::to_string(m_NetworkData.AmountOfMessagesReceived) + "\n";
|
||||||
outfile << "Total messages sent," + std::to_string(m_NetworkData.AmountOfMessagesSent) + "\n";
|
outfile << "Total messages sent," + std::to_string(m_NetworkData.AmountOfMessagesSent) + "\n";
|
||||||
|
|
||||||
float messagesReceivedPerSec = (float)m_NetworkData.AmountOfMessagesReceived / (m_NetworkData.TotalTime / 1000);
|
double messagesReceivedPerSec = m_NetworkData.AmountOfMessagesReceived / (m_NetworkData.TotalTime / 1000);
|
||||||
float messagesSentPerSec = (float)m_NetworkData.AmountOfMessagesSent / (m_NetworkData.TotalTime / 1000);
|
double messagesSentPerSec = m_NetworkData.AmountOfMessagesSent / (m_NetworkData.TotalTime / 1000);
|
||||||
float dataReceivedPerSec = (float)m_NetworkData.TotalDataReceived / (m_NetworkData.TotalTime / 1000);
|
double dataReceivedPerSec = m_NetworkData.TotalDataReceived / (m_NetworkData.TotalTime / 1000);
|
||||||
float dataSentPerSec = (float)m_NetworkData.TotalDataSent / (m_NetworkData.TotalTime / 1000);
|
double dataSentPerSec = m_NetworkData.TotalDataSent / (m_NetworkData.TotalTime / 1000);
|
||||||
outfile << "Avarage messages received / s: " + std::to_string(messagesReceivedPerSec) + "\n";
|
outfile << "Avarage messages received / s: " + std::to_string(messagesReceivedPerSec) + "\n";
|
||||||
outfile << "Avarage messages sents / s: " + std::to_string(messagesSentPerSec) + "\n";
|
outfile << "Avarage messages sents / s: " + std::to_string(messagesSentPerSec) + "\n";
|
||||||
outfile << "Avarage data received B/s: " + std::to_string(dataReceivedPerSec) + "\n";
|
outfile << "Avarage data received B/s: " + std::to_string(dataReceivedPerSec) + "\n";
|
||||||
@@ -52,7 +52,7 @@ void Network::updateNetworkData()
|
|||||||
if (m_SaveDataIntervalMs < (1000 * (currentTime - m_SaveDataTimer) / (double)CLOCKS_PER_SEC)) {
|
if (m_SaveDataIntervalMs < (1000 * (currentTime - m_SaveDataTimer) / (double)CLOCKS_PER_SEC)) {
|
||||||
// Set values
|
// Set values
|
||||||
m_NetworkData.TotalTime += (1000 * (currentTime - m_SaveDataTimer) / (double)CLOCKS_PER_SEC);
|
m_NetworkData.TotalTime += (1000 * (currentTime - m_SaveDataTimer) / (double)CLOCKS_PER_SEC);
|
||||||
m_NetworkData.BandwidthBytes.push_back(std::pair<unsigned int, unsigned int>(m_NetworkData.DataReceivedThisInterval, m_NetworkData.DataSentThisInterval));
|
m_NetworkData.BandwidthBytes.push_back(std::pair<size_t, size_t>(m_NetworkData.DataReceivedThisInterval, m_NetworkData.DataSentThisInterval));
|
||||||
// Reset interval stuff
|
// Reset interval stuff
|
||||||
m_SaveDataTimer = std::clock();
|
m_SaveDataTimer = std::clock();
|
||||||
m_NetworkData.DataSentThisInterval = 0;
|
m_NetworkData.DataSentThisInterval = 0;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ Packet::Packet(MessageType type, unsigned int& packetID)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create message
|
// Create message
|
||||||
Packet::Packet(char* data, const int sizeOfPacket)
|
Packet::Packet(char* data, const size_t sizeOfPacket)
|
||||||
{
|
{
|
||||||
// Resize message
|
// Resize message
|
||||||
m_MaxPacketSize = sizeOfPacket;
|
m_MaxPacketSize = sizeOfPacket;
|
||||||
@@ -45,7 +45,7 @@ void Packet::Init(MessageType type, unsigned int & packetID)
|
|||||||
void Packet::WriteString(const std::string& str)
|
void Packet::WriteString(const std::string& str)
|
||||||
{
|
{
|
||||||
// Message, add one extra byte for null terminator
|
// Message, add one extra byte for null terminator
|
||||||
int sizeOfString = str.size() + 1;
|
size_t sizeOfString = str.size() + 1;
|
||||||
if (m_Offset + sizeOfString > m_MaxPacketSize) {
|
if (m_Offset + sizeOfString > m_MaxPacketSize) {
|
||||||
//LOG_WARNING("Package::WriteString(): Data size in packet exceeded maximum package size. New size is %i bytes\n", m_MaxPacketSize*2);
|
//LOG_WARNING("Package::WriteString(): Data size in packet exceeded maximum package size. New size is %i bytes\n", m_MaxPacketSize*2);
|
||||||
resizeData();
|
resizeData();
|
||||||
@@ -82,7 +82,7 @@ char * Packet::ReadData(int SizeOfData)
|
|||||||
//LOG_WARNING("packet ReadData(): Oh no! You are trying to remove things outside my memory kingdom");
|
//LOG_WARNING("packet ReadData(): Oh no! You are trying to remove things outside my memory kingdom");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
unsigned int oldReturnDataOffset = m_ReturnDataOffset;
|
size_t oldReturnDataOffset = m_ReturnDataOffset;
|
||||||
m_ReturnDataOffset += SizeOfData;
|
m_ReturnDataOffset += SizeOfData;
|
||||||
return (m_Data + oldReturnDataOffset);
|
return (m_Data + oldReturnDataOffset);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Server::Server() : m_Socket(m_IOService, boost::asio::ip::udp::endpoint(boost::a
|
|||||||
{
|
{
|
||||||
Network::initialize();
|
Network::initialize();
|
||||||
ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini");
|
ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||||
snapshotInterval = 1000 * config->Get<float>("Networking.SnapshotInterval", 0.05);
|
snapshotInterval = 1000 * config->Get<float>("Networking.SnapshotInterval", 0.05f);
|
||||||
pingIntervalMs = config->Get<float>("Networking.PingIntervalMs", 1000);
|
pingIntervalMs = config->Get<float>("Networking.PingIntervalMs", 1000);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ void Server::readFromClients()
|
|||||||
bytesRead = receive(readBuffer);
|
bytesRead = receive(readBuffer);
|
||||||
Packet packet(readBuffer, bytesRead);
|
Packet packet(readBuffer, bytesRead);
|
||||||
parseMessageType(packet);
|
parseMessageType(packet);
|
||||||
} catch (const std::exception& err) {
|
} catch (const std::exception&) {
|
||||||
//LOG_ERROR("%i: Read from client crashed %s", m_PacketID, err.what());
|
//LOG_ERROR("%i: Read from client crashed %s", m_PacketID, err.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,9 +103,9 @@ void Server::parseMessageType(Packet& packet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Server::receive(char * data)
|
size_t Server::receive(char * data)
|
||||||
{
|
{
|
||||||
unsigned int length = m_Socket.receive_from(
|
size_t length = m_Socket.receive_from(
|
||||||
boost::asio::buffer((void*)data
|
boost::asio::buffer((void*)data
|
||||||
, INPUTSIZE)
|
, INPUTSIZE)
|
||||||
, m_ReceiverEndpoint, 0);
|
, m_ReceiverEndpoint, 0);
|
||||||
@@ -121,7 +121,7 @@ int Server::receive(char * data)
|
|||||||
void Server::send(PlayerID player, Packet& packet)
|
void Server::send(PlayerID player, Packet& packet)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
int bytesSent = m_Socket.send_to(
|
size_t bytesSent = m_Socket.send_to(
|
||||||
boost::asio::buffer(packet.Data(), packet.Size()),
|
boost::asio::buffer(packet.Data(), packet.Size()),
|
||||||
m_ConnectedPlayers[player].Endpoint,
|
m_ConnectedPlayers[player].Endpoint,
|
||||||
0);
|
0);
|
||||||
@@ -131,7 +131,7 @@ void Server::send(PlayerID player, Packet& packet)
|
|||||||
m_NetworkData.DataSentThisInterval += packet.Size();
|
m_NetworkData.DataSentThisInterval += packet.Size();
|
||||||
m_NetworkData.AmountOfMessagesSent++;
|
m_NetworkData.AmountOfMessagesSent++;
|
||||||
}
|
}
|
||||||
} catch (const boost::system::system_error& e) {
|
} catch (const boost::system::system_error&) {
|
||||||
// TODO: Clean up invalid endpoints out of m_ConnectedPlayers later
|
// TODO: Clean up invalid endpoints out of m_ConnectedPlayers later
|
||||||
m_ConnectedPlayers[player].Endpoint = boost::asio::ip::udp::endpoint();
|
m_ConnectedPlayers[player].Endpoint = boost::asio::ip::udp::endpoint();
|
||||||
}
|
}
|
||||||
@@ -231,12 +231,12 @@ void Server::sendPing()
|
|||||||
|
|
||||||
void Server::checkForTimeOuts()
|
void Server::checkForTimeOuts()
|
||||||
{
|
{
|
||||||
int startPing = 1000 * m_StartPingTime
|
double startPing = 1000 * m_StartPingTime
|
||||||
/ static_cast<double>(CLOCKS_PER_SEC);
|
/ static_cast<double>(CLOCKS_PER_SEC);
|
||||||
|
|
||||||
for (int i = 0; i < m_ConnectedPlayers.size(); i++) {
|
for (int i = 0; i < m_ConnectedPlayers.size(); i++) {
|
||||||
if (m_ConnectedPlayers[i].Endpoint.address() != boost::asio::ip::address()) {
|
if (m_ConnectedPlayers[i].Endpoint.address() != boost::asio::ip::address()) {
|
||||||
int stopPing = 1000 * m_ConnectedPlayers[i].StopTime /
|
double stopPing = 1000 * m_ConnectedPlayers[i].StopTime /
|
||||||
static_cast<double>(CLOCKS_PER_SEC);
|
static_cast<double>(CLOCKS_PER_SEC);
|
||||||
if (startPing > stopPing + m_TimeoutMs) {
|
if (startPing > stopPing + m_TimeoutMs) {
|
||||||
LOG_INFO("User %i timed out!", i);
|
LOG_INFO("User %i timed out!", i);
|
||||||
|
|||||||
@@ -6,6 +6,18 @@ DrawBloomPass::DrawBloomPass(IRenderer* renderer)
|
|||||||
|
|
||||||
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh");
|
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh");
|
||||||
|
|
||||||
|
m_ScreenSizes[0] = 1920.f;
|
||||||
|
m_ScreenSizes[1] = 1053.f;
|
||||||
|
m_ScreenSizes[2] = 959.f;
|
||||||
|
m_ScreenSizes[3] = 525.f;
|
||||||
|
m_ScreenSizes[4] = 479.f;
|
||||||
|
m_ScreenSizes[5] = 262.f;
|
||||||
|
m_ScreenSizes[6] = 239.f;
|
||||||
|
m_ScreenSizes[7] = 130.f;
|
||||||
|
m_ScreenSizes[8] = 119.f;
|
||||||
|
m_ScreenSizes[9] = 64.f;
|
||||||
|
|
||||||
|
|
||||||
InitializeTextures();
|
InitializeTextures();
|
||||||
InitializeBuffers();
|
InitializeBuffers();
|
||||||
InitializeShaderPrograms();
|
InitializeShaderPrograms();
|
||||||
@@ -18,31 +30,51 @@ void DrawBloomPass::InitializeTextures()
|
|||||||
|
|
||||||
void DrawBloomPass::InitializeShaderPrograms()
|
void DrawBloomPass::InitializeShaderPrograms()
|
||||||
{
|
{
|
||||||
m_GaussianProgram_horiz = ResourceManager::Load<ShaderProgram>("##GaussianProgramHoriz");
|
m_GaussianProgram_horiz = ResourceManager::Load<ShaderProgram>("#GaussianProgramHoriz");
|
||||||
m_GaussianProgram_horiz->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Gaussian_horiz.vert.glsl")));
|
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->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Gaussian_horiz.frag.glsl")));
|
||||||
m_GaussianProgram_horiz->Compile();
|
m_GaussianProgram_horiz->Compile();
|
||||||
m_GaussianProgram_horiz->Link();
|
m_GaussianProgram_horiz->Link();
|
||||||
|
|
||||||
m_GaussianProgram_vert = ResourceManager::Load<ShaderProgram>("##GaussianProgramVert");
|
m_GaussianProgram_vert = ResourceManager::Load<ShaderProgram>("#GaussianProgramVert");
|
||||||
m_GaussianProgram_vert->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Gaussian_vert.vert.glsl")));
|
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->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Gaussian_vert.frag.glsl")));
|
||||||
m_GaussianProgram_vert->Compile();
|
m_GaussianProgram_vert->Compile();
|
||||||
m_GaussianProgram_vert->Link();
|
m_GaussianProgram_vert->Link();
|
||||||
|
|
||||||
|
m_GaussianProgram_both = ResourceManager::Load<ShaderProgram>("#GaussianProgramBoth");
|
||||||
|
m_GaussianProgram_both->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Gaussian_both.vert.glsl")));
|
||||||
|
m_GaussianProgram_both->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Gaussian_both.frag.glsl")));
|
||||||
|
m_GaussianProgram_both->Compile();
|
||||||
|
m_GaussianProgram_both->Link();
|
||||||
|
|
||||||
|
m_CombineProgram = ResourceManager::Load<ShaderProgram>("#CombineProgram");
|
||||||
|
m_CombineProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/TextureCombine.vert.glsl")));
|
||||||
|
m_CombineProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/TextureCombine.frag.glsl")));
|
||||||
|
m_CombineProgram->Compile();
|
||||||
|
m_CombineProgram->Link();
|
||||||
|
|
||||||
|
//Fixa nya combine shadern
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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);
|
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_HALF_FLOAT);
|
||||||
|
|
||||||
m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0)));
|
m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0)));
|
||||||
m_GaussianFrameBuffer_horiz.Generate();
|
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);
|
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_HALF_FLOAT);
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
|
GenerateTexture(&m_FinalBlurTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||||
|
|
||||||
|
m_BlurredFinalTexture.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_FinalBlurTexture, GL_COLOR_ATTACHMENT0)));
|
||||||
|
m_BlurredFinalTexture.Generate();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -60,65 +92,123 @@ void DrawBloomPass::ClearBuffer()
|
|||||||
|
|
||||||
void DrawBloomPass::Draw(GLuint texture)
|
void DrawBloomPass::Draw(GLuint texture)
|
||||||
{
|
{
|
||||||
GLERROR("DrawBloomPass::Draw: Pre");
|
|
||||||
|
|
||||||
|
|
||||||
|
ImGui::Combo("DebugBloom", &m_DebugTextureToDraw, "ALL\0First\0SEcond\0Third\0Fourth\0Fifth");
|
||||||
|
ImGui::SliderInt("Iterations", &m_Iterations, 0, 10);
|
||||||
|
|
||||||
|
if (m_DebugTextureToDraw == 1)
|
||||||
|
BlurOneMipMapLevel(&texture, m_Iterations, 1);
|
||||||
|
else if (m_DebugTextureToDraw == 2)
|
||||||
|
BlurOneMipMapLevel(&texture, m_Iterations, 2);
|
||||||
|
else if (m_DebugTextureToDraw == 3)
|
||||||
|
BlurOneMipMapLevel(&texture, m_Iterations, 3);
|
||||||
|
else if (m_DebugTextureToDraw == 4)
|
||||||
|
BlurOneMipMapLevel(&texture, m_Iterations, 4);
|
||||||
|
else if (m_DebugTextureToDraw == 0) {
|
||||||
|
BlurOneMipMapLevel(&texture, m_Iterations, 1);
|
||||||
|
BlurOneMipMapLevel(&texture, m_Iterations, 2);
|
||||||
|
BlurOneMipMapLevel(&texture, m_Iterations, 3);
|
||||||
|
BlurOneMipMapLevel(&texture, m_Iterations, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawBloomPass::BlurOneMipMapLevel(GLuint* texture, GLint iterations, GLint mipMapLevel)
|
||||||
|
{
|
||||||
|
GLERROR("PRE");
|
||||||
|
|
||||||
|
//new code
|
||||||
DrawBloomPassState state;
|
DrawBloomPassState state;
|
||||||
|
//Loop through and blur texture at mipmap level
|
||||||
GLuint shaderHandle_horiz = m_GaussianProgram_horiz->GetHandle();
|
GLuint shaderHandle_horiz = m_GaussianProgram_horiz->GetHandle();
|
||||||
GLuint shaderHandle_vert = m_GaussianProgram_vert->GetHandle();
|
GLuint shaderHandle_vert = m_GaussianProgram_vert->GetHandle();
|
||||||
|
|
||||||
|
|
||||||
//Horizontal pass, first use the given texture then save it to the horizontal framebuffer.
|
//First horiz pass
|
||||||
m_GaussianFrameBuffer_horiz.Bind();
|
m_GaussianFrameBuffer_horiz.Bind();
|
||||||
m_GaussianProgram_horiz->Bind();
|
m_GaussianProgram_horiz->Bind();
|
||||||
|
GLERROR("Bind");
|
||||||
|
|
||||||
|
|
||||||
|
glUniform1i(glGetUniformLocation(shaderHandle_horiz, "MipMapLevel"), mipMapLevel);
|
||||||
|
//glUniform2fv(glGetUniformLocation(m_GaussianProgram_both->GetHandle(), "ScreenSize"), 5, m_ScreenSizes);
|
||||||
|
//glUniform1i(glGetUniformLocation(m_GaussianProgram_both->GetHandle(), "Horizontal"), true);
|
||||||
|
GLERROR("1");
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
glBindTexture(GL_TEXTURE_2D, *texture);
|
||||||
|
|
||||||
|
|
||||||
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].EndIndex - m_ScreenQuad->MaterialGroups()[0].StartIndex +1
|
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].EndIndex - m_ScreenQuad->MaterialGroups()[0].StartIndex +1
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].StartIndex);
|
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].StartIndex);
|
||||||
|
GLERROR("2");
|
||||||
|
|
||||||
//Iterate some times to make it more gaussian.
|
|
||||||
for (int i = 1; i < m_iterations; i++) {
|
//Loop through vert, then horiz and save to respective textures X number of times.
|
||||||
|
for (int i = 1; i < iterations; i++) {
|
||||||
//Vertical pass
|
//Vertical pass
|
||||||
m_GaussianFrameBuffer_vert.Bind();
|
m_GaussianFrameBuffer_vert.Bind();
|
||||||
m_GaussianProgram_vert->Bind();
|
m_GaussianProgram_vert->Bind();
|
||||||
|
|
||||||
|
//glUniform1i(glGetUniformLocation(m_GaussianProgram_both->GetHandle(), "Horizontal"), false);
|
||||||
|
|
||||||
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);
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].EndIndex - m_ScreenQuad->MaterialGroups()[0].StartIndex +1
|
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].EndIndex - m_ScreenQuad->MaterialGroups()[0].StartIndex +1
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].StartIndex);
|
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].StartIndex);
|
||||||
|
GLERROR("3");
|
||||||
|
|
||||||
//horizontal pass
|
//horizontal pass
|
||||||
|
|
||||||
m_GaussianFrameBuffer_horiz.Bind();
|
m_GaussianFrameBuffer_horiz.Bind();
|
||||||
m_GaussianProgram_horiz->Bind();
|
m_GaussianProgram_horiz->Bind();
|
||||||
|
|
||||||
|
//glUniform1i(glGetUniformLocation(m_GaussianProgram_both->GetHandle(), "Horizontal"), true);
|
||||||
|
|
||||||
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].EndIndex - m_ScreenQuad->MaterialGroups()[0].StartIndex +1
|
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].EndIndex - m_ScreenQuad->MaterialGroups()[0].StartIndex +1
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].StartIndex);
|
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].StartIndex);
|
||||||
|
GLERROR("4");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//final vertical gaussian after the iterations are done
|
//the final vertical iteration.
|
||||||
|
|
||||||
m_GaussianFrameBuffer_vert.Bind();
|
m_GaussianFrameBuffer_vert.Bind();
|
||||||
m_GaussianProgram_vert->Bind();
|
m_GaussianProgram_vert->Bind();
|
||||||
|
|
||||||
|
//glUniform1i(glGetUniformLocation(m_GaussianProgram_both->GetHandle(), "Horizontal"), false);
|
||||||
|
|
||||||
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);
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].EndIndex - m_ScreenQuad->MaterialGroups()[0].StartIndex +1
|
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].EndIndex - m_ScreenQuad->MaterialGroups()[0].StartIndex +1
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].StartIndex);
|
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].StartIndex);
|
||||||
|
GLERROR("5");
|
||||||
|
|
||||||
GLERROR("DrawBloomPass::Draw: END");
|
//Combine the the new blurred texture into the final texture
|
||||||
|
m_BlurredFinalTexture.Bind();
|
||||||
|
m_CombineProgram->Bind();
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_FinalBlurTexture);
|
||||||
|
glActiveTexture(GL_TEXTURE1);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_vert);
|
||||||
|
|
||||||
|
glBindVertexArray(m_ScreenQuad->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
||||||
|
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].EndIndex - m_ScreenQuad->MaterialGroups()[0].StartIndex +1
|
||||||
|
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].StartIndex);
|
||||||
|
|
||||||
|
GLERROR("END");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawBloomPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
|
void DrawBloomPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
|
||||||
@@ -132,3 +222,5 @@ void DrawBloomPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum fil
|
|||||||
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, dimensions.x, dimensions.y, 0, format, type, nullptr);//TODO: Renderer: Fix the precision and Resolution
|
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");
|
GLERROR("Texture initialization failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ DrawColorCorrectionPass::DrawColorCorrectionPass(IRenderer* renderer)
|
|||||||
m_Renderer = renderer;
|
m_Renderer = renderer;
|
||||||
|
|
||||||
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh");
|
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh");
|
||||||
m_Exposure = 0.4; //TODO: Renderer: Fixa så att denna går att ändra på genom komponent eller setting.
|
|
||||||
|
|
||||||
InitializeShaderPrograms();
|
InitializeShaderPrograms();
|
||||||
}
|
}
|
||||||
@@ -19,7 +18,7 @@ void DrawColorCorrectionPass::InitializeShaderPrograms()
|
|||||||
m_ColorCorrectionProgram->Link();
|
m_ColorCorrectionProgram->Link();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture)
|
void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLuint sceneTextureLowRes, GLuint bloomTextureLowRes, GLfloat gamma, GLfloat exposure)
|
||||||
{
|
{
|
||||||
//glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
//glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
GLERROR("DrawScreenQuadPass::Draw: Pre");
|
GLERROR("DrawScreenQuadPass::Draw: Pre");
|
||||||
@@ -27,12 +26,17 @@ void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture)
|
|||||||
DrawScreenQuadPassState state = DrawScreenQuadPassState();
|
DrawScreenQuadPassState state = DrawScreenQuadPassState();
|
||||||
m_ColorCorrectionProgram->Bind();
|
m_ColorCorrectionProgram->Bind();
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Exposure"), m_Exposure);
|
glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Exposure"), exposure);
|
||||||
|
glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Gamma"), gamma);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, sceneTexture);
|
glBindTexture(GL_TEXTURE_2D, sceneTexture);
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, bloomTexture);
|
glBindTexture(GL_TEXTURE_2D, bloomTexture);
|
||||||
|
glActiveTexture(GL_TEXTURE2);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, sceneTextureLowRes);
|
||||||
|
glActiveTexture(GL_TEXTURE3);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, bloomTextureLowRes);
|
||||||
|
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
glBindVertexArray(m_ScreenQuad->VAO);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass)
|
DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass)
|
||||||
{
|
{
|
||||||
|
//TODO: Make sure that uniforms are not sent into shader if not needed.
|
||||||
m_Renderer = renderer;
|
m_Renderer = renderer;
|
||||||
m_LightCullingPass = lightCullingPass;
|
m_LightCullingPass = lightCullingPass;
|
||||||
|
m_ShieldPixelRate = 8;
|
||||||
InitializeTextures();
|
InitializeTextures();
|
||||||
InitializeShaderPrograms();
|
InitializeShaderPrograms();
|
||||||
InitializeFrameBuffers();
|
InitializeFrameBuffers();
|
||||||
@@ -21,18 +23,39 @@ void DrawFinalPass::InitializeFrameBuffers()
|
|||||||
{
|
{
|
||||||
glGenRenderbuffers(1, &m_DepthBuffer);
|
glGenRenderbuffers(1, &m_DepthBuffer);
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer);
|
glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer);
|
||||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
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_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);
|
//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_RGBA, GL_UNSIGNED_INT, 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);
|
||||||
|
|
||||||
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new RenderBuffer(&m_DepthBuffer, GL_DEPTH_ATTACHMENT)));
|
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_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)));
|
||||||
m_FinalPassFrameBuffer.Generate();
|
m_FinalPassFrameBuffer.Generate();
|
||||||
|
GLERROR("FBO generation");
|
||||||
|
|
||||||
|
glGenRenderbuffers(1, &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));
|
||||||
|
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);
|
||||||
|
//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);
|
||||||
|
//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);
|
||||||
|
|
||||||
|
m_FinalPassFrameBufferLowRes.AddResource(std::shared_ptr<BufferResource>(new RenderBuffer(&m_DepthBufferLowRes, GL_DEPTH_STENCIL_ATTACHMENT)));
|
||||||
|
//m_FinalPassFrameBufferLowRes.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_StencilTexture, GL_STENCIL_ATTACHMENT)));
|
||||||
|
m_FinalPassFrameBufferLowRes.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SceneTextureLowRes, GL_COLOR_ATTACHMENT0)));
|
||||||
|
m_FinalPassFrameBufferLowRes.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_BloomTextureLowRes, GL_COLOR_ATTACHMENT1)));
|
||||||
|
m_FinalPassFrameBufferLowRes.Generate();
|
||||||
|
GLERROR("FBO2 generation");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawFinalPass::InitializeShaderPrograms()
|
void DrawFinalPass::InitializeShaderPrograms()
|
||||||
@@ -44,6 +67,7 @@ void DrawFinalPass::InitializeShaderPrograms()
|
|||||||
m_ForwardPlusProgram->BindFragDataLocation(0, "sceneColor");
|
m_ForwardPlusProgram->BindFragDataLocation(0, "sceneColor");
|
||||||
m_ForwardPlusProgram->BindFragDataLocation(1, "bloomColor");
|
m_ForwardPlusProgram->BindFragDataLocation(1, "bloomColor");
|
||||||
m_ForwardPlusProgram->Link();
|
m_ForwardPlusProgram->Link();
|
||||||
|
GLERROR("Creating forward+ program");
|
||||||
|
|
||||||
m_ExplosionEffectProgram = ResourceManager::Load<ShaderProgram>("#ExplosionEffectProgram");
|
m_ExplosionEffectProgram = ResourceManager::Load<ShaderProgram>("#ExplosionEffectProgram");
|
||||||
m_ExplosionEffectProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardPlus.vert.glsl")));
|
m_ExplosionEffectProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardPlus.vert.glsl")));
|
||||||
@@ -53,30 +77,117 @@ void DrawFinalPass::InitializeShaderPrograms()
|
|||||||
m_ExplosionEffectProgram->BindFragDataLocation(0, "sceneColor");
|
m_ExplosionEffectProgram->BindFragDataLocation(0, "sceneColor");
|
||||||
m_ExplosionEffectProgram->BindFragDataLocation(1, "bloomColor");
|
m_ExplosionEffectProgram->BindFragDataLocation(1, "bloomColor");
|
||||||
m_ExplosionEffectProgram->Link();
|
m_ExplosionEffectProgram->Link();
|
||||||
|
GLERROR("Creating explosion program");
|
||||||
|
|
||||||
|
m_ShieldToStencilProgram = ResourceManager::Load<ShaderProgram>("#ShieldToStencilProgram");
|
||||||
|
m_ShieldToStencilProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ShieldStencil.vert.glsl")));
|
||||||
|
m_ShieldToStencilProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ShieldStencil.frag.glsl")));
|
||||||
|
m_ShieldToStencilProgram->Compile();
|
||||||
|
m_ShieldToStencilProgram->Link();
|
||||||
|
GLERROR("Creating Shield program");
|
||||||
|
|
||||||
|
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 FragmentShader("Shaders/FillDepthBuffer.frag.glsl")));
|
||||||
|
m_FillDepthBufferProgram->Compile();
|
||||||
|
m_FillDepthBufferProgram->Link();
|
||||||
|
GLERROR("Creating DepthFill program");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawFinalPass::Draw(RenderScene& scene)
|
void DrawFinalPass::Draw(RenderScene& scene)
|
||||||
{
|
{
|
||||||
GLERROR("DrawFinalPass::Draw: 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);
|
||||||
}
|
}
|
||||||
|
//TODO: Do we need check for this or will it be per scene always?
|
||||||
|
glClearStencil(0x00);
|
||||||
|
glClear(GL_STENCIL_BUFFER_BIT);
|
||||||
|
|
||||||
DrawModelRenderQueues(scene.OpaqueObjects, scene);
|
//Fill depth buffer
|
||||||
GLERROR("DrawFinalPass::Draw: OpaqueObjects");
|
|
||||||
DrawModelRenderQueues(scene.TransparentObjects, scene);
|
|
||||||
GLERROR("DrawFinalPass::Draw: TransparentObjects");
|
|
||||||
|
|
||||||
GLERROR("DrawFinalPass::Draw: END");
|
|
||||||
|
state->StencilMask(0x00);
|
||||||
|
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
|
||||||
|
GLERROR("OpaqueObjects");
|
||||||
|
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
|
||||||
|
GLERROR("TransparentObjects");
|
||||||
|
|
||||||
|
//DrawStencilState* stencilState = new DrawStencilState(m_FinalPassFrameBuffer.GetHandle());
|
||||||
|
//Draw shields to stencil pass
|
||||||
|
state->StencilFunc(GL_ALWAYS, 1, 0xFF);
|
||||||
|
state->StencilMask(0xFF);
|
||||||
|
DrawShieldToStencilBuffer(scene.Jobs.ShieldObjects, scene);
|
||||||
|
GLERROR("StencilPass");
|
||||||
|
|
||||||
|
//Draw Opaque shielded objects
|
||||||
|
state->StencilFunc(GL_NOTEQUAL, 1, 0xFF);
|
||||||
|
state->StencilMask(0x00);
|
||||||
|
DrawShieldedModelRenderQueue(scene.Jobs.OpaqueShieldedObjects, scene);
|
||||||
|
GLERROR("Shielded Opaque object");
|
||||||
|
|
||||||
|
//Draw Transparen Shielded objects
|
||||||
|
DrawShieldedModelRenderQueue(scene.Jobs.TransparentShieldedObjects, scene);
|
||||||
|
GLERROR("Shielded Transparent objects");
|
||||||
|
|
||||||
|
GLERROR("END");
|
||||||
delete state;
|
delete state;
|
||||||
|
|
||||||
|
|
||||||
|
DrawFinalPassState* stateLowRes = new DrawFinalPassState(m_FinalPassFrameBufferLowRes.GetHandle());
|
||||||
|
//Draw the lowres texture that will be shown behind the shield.
|
||||||
|
stateLowRes->Enable(GL_SCISSOR_TEST);
|
||||||
|
stateLowRes->Enable(GL_DEPTH_TEST);
|
||||||
|
//TODO: Viewports and scissor should be in state
|
||||||
|
glViewport(0, 0, m_Renderer->GetViewportSize().Width/m_ShieldPixelRate, m_Renderer->GetViewportSize().Height/m_ShieldPixelRate);
|
||||||
|
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
|
||||||
|
glClearStencil(0x00);
|
||||||
|
glClear(GL_STENCIL_BUFFER_BIT);
|
||||||
|
|
||||||
|
//TODO: This should not be here...
|
||||||
|
stateLowRes->StencilFunc(GL_ALWAYS, 1, 0xFF);
|
||||||
|
stateLowRes->StencilMask(0x00);
|
||||||
|
DrawToDepthBuffer(scene.Jobs.OpaqueObjects, scene);
|
||||||
|
DrawToDepthBuffer(scene.Jobs.TransparentObjects, scene);
|
||||||
|
|
||||||
|
//Draw shields to stencil pass
|
||||||
|
stateLowRes->StencilFunc(GL_ALWAYS, 1, 0xFF);
|
||||||
|
stateLowRes->StencilMask(0xFF);
|
||||||
|
stateLowRes->Enable(GL_DEPTH_TEST);
|
||||||
|
DrawShieldToStencilBuffer(scene.Jobs.ShieldObjects, scene);
|
||||||
|
GLERROR("StencilPass");
|
||||||
|
|
||||||
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
stateLowRes->Enable(GL_DEPTH_TEST);
|
||||||
|
stateLowRes->StencilFunc(GL_LEQUAL, 1, 0xFF);
|
||||||
|
stateLowRes->StencilMask(0x00);
|
||||||
|
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
|
||||||
|
GLERROR("OpaqueObjects");
|
||||||
|
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
|
||||||
|
GLERROR("TransparentObjects");
|
||||||
|
glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
delete stateLowRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DrawFinalPass::ClearBuffer()
|
void DrawFinalPass::ClearBuffer()
|
||||||
{
|
{
|
||||||
|
m_FinalPassFrameBufferLowRes.Bind();
|
||||||
|
glViewport(0, 0, m_Renderer->GetViewportSize().Width/m_ShieldPixelRate, m_Renderer->GetViewportSize().Height/m_ShieldPixelRate);
|
||||||
|
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
glDisable(GL_SCISSOR_TEST);
|
||||||
|
m_FinalPassFrameBufferLowRes.Unbind();
|
||||||
|
|
||||||
m_FinalPassFrameBuffer.Bind();
|
m_FinalPassFrameBuffer.Bind();
|
||||||
|
glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
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);
|
||||||
m_FinalPassFrameBuffer.Unbind();
|
m_FinalPassFrameBuffer.Unbind();
|
||||||
@@ -96,36 +207,66 @@ void DrawFinalPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum fil
|
|||||||
|
|
||||||
void DrawFinalPass::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const
|
void DrawFinalPass::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const
|
||||||
{
|
{
|
||||||
|
//GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGBA, GL_UNSIGNED_INT, 4);
|
||||||
|
|
||||||
|
//glGenTextures(1, texture);
|
||||||
|
//glBindTexture(GL_TEXTURE_2D, *texture);
|
||||||
|
//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, dimensions.x, dimensions.y, GL_UNSIGNED_BYTE, NULL);
|
||||||
|
//glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
|
|
||||||
glGenTextures(1, texture);
|
glGenTextures(1, texture);
|
||||||
glBindTexture(GL_TEXTURE_2D, *texture);
|
glBindTexture(GL_TEXTURE_2D, *texture);
|
||||||
glTexStorage2D(GL_TEXTURE_2D, numMipMaps, GL_RGBA8, dimensions.x, dimensions.y);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dimensions.x, dimensions.y, 0, format, type, nullptr);//TODO: Renderer: Fix the precision and Resolution
|
||||||
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_S, wrapping);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, 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);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); //TODO: THIS SHIS IS BROKEN WHY YOU NO LINEAR MIPMAP? SHITTY FUCK
|
||||||
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
|
GLERROR("MipMap Texture initialization failed");
|
||||||
|
|
||||||
|
//glGenTextures(1, texture);
|
||||||
|
//glBindTexture(GL_TEXTURE_2D, *texture);
|
||||||
|
//glTexStorage2D(GL_TEXTURE_2D, numMipMaps, GL_RGBA8, dimensions.x, dimensions.y);
|
||||||
|
//glTexImage2D(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");
|
GLERROR("MipMap Texture initialization failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& job, RenderScene& scene)
|
void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
|
||||||
{
|
{
|
||||||
GLuint forwardHandle = m_ForwardPlusProgram->GetHandle();
|
GLuint forwardHandle = m_ForwardPlusProgram->GetHandle();
|
||||||
|
GLERROR("forwardHandle");
|
||||||
GLuint explosionHandle = m_ExplosionEffectProgram->GetHandle();
|
GLuint explosionHandle = m_ExplosionEffectProgram->GetHandle();
|
||||||
|
GLERROR("explosionHandle");
|
||||||
|
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO());
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO());
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO());
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO());
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO());
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO());
|
||||||
|
|
||||||
for(auto &job : job)
|
for(auto &job : jobs)
|
||||||
{
|
{
|
||||||
auto explosionEffectJob = std::dynamic_pointer_cast<ExplosionEffectJob>(job);
|
auto explosionEffectJob = std::dynamic_pointer_cast<ExplosionEffectJob>(job);
|
||||||
if(explosionEffectJob) {
|
if(explosionEffectJob) {
|
||||||
//Bind program
|
//Bind program
|
||||||
|
if(GLERROR("Prebind")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
m_ExplosionEffectProgram->Bind();
|
m_ExplosionEffectProgram->Bind();
|
||||||
|
if(GLERROR("BindProgram")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
glDisable(GL_CULL_FACE);
|
||||||
|
|
||||||
//Bind uniforms
|
//Bind uniforms
|
||||||
BindExplosionUniforms(explosionHandle, explosionEffectJob, scene);
|
BindExplosionUniforms(explosionHandle, explosionEffectJob, scene);
|
||||||
|
if(GLERROR("BindExplosionUniforms")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (explosionEffectJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
if (explosionEffectJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||||
|
|
||||||
@@ -134,13 +275,23 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(GLERROR("Animation")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//bind textures
|
//bind textures
|
||||||
BindExplosionTextures(explosionEffectJob);
|
BindExplosionTextures(explosionEffectJob);
|
||||||
|
if(GLERROR("BindExplosionTextures")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
//draw
|
//draw
|
||||||
glBindVertexArray(explosionEffectJob->Model->VAO);
|
glBindVertexArray(explosionEffectJob->Model->VAO);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, explosionEffectJob->Model->ElementBuffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, explosionEffectJob->Model->ElementBuffer);
|
||||||
glDrawElements(GL_TRIANGLES, explosionEffectJob->EndIndex - explosionEffectJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(explosionEffectJob->StartIndex*sizeof(unsigned int)));
|
glDrawElements(GL_TRIANGLES, explosionEffectJob->EndIndex - explosionEffectJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(explosionEffectJob->StartIndex*sizeof(unsigned int)));
|
||||||
|
glEnable(GL_CULL_FACE);
|
||||||
|
if(GLERROR("explosion effect end")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
@@ -167,45 +318,207 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
glBindVertexArray(modelJob->Model->VAO);
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex*sizeof(unsigned int)));
|
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex*sizeof(unsigned int)));
|
||||||
GLERROR("DrawFinalPass::Model: END");
|
if(GLERROR("models end")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
glActiveTexture(GL_TEXTURE1);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_BloomTexture);
|
||||||
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DrawFinalPass::DrawShieldToStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
|
||||||
|
{
|
||||||
|
m_ShieldToStencilProgram->Bind();
|
||||||
|
GLuint shaderHandle = m_ShieldToStencilProgram->GetHandle();
|
||||||
|
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
|
||||||
|
for (auto &job : jobs) {
|
||||||
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
|
if (modelJob) {
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||||
|
|
||||||
|
|
||||||
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
|
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex*sizeof(unsigned int)));
|
||||||
|
if (GLERROR("models end")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawFinalPass::DrawShieldedModelRenderQueue(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
|
||||||
|
{
|
||||||
|
GLuint forwardHandle = m_ForwardPlusProgram->GetHandle();
|
||||||
|
GLERROR("forwardHandle");
|
||||||
|
GLuint explosionHandle = m_ExplosionEffectProgram->GetHandle();
|
||||||
|
GLERROR("explosionHandle");
|
||||||
|
|
||||||
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO());
|
||||||
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO());
|
||||||
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO());
|
||||||
|
|
||||||
|
for (auto &job : jobs) {
|
||||||
|
auto explosionEffectJob = std::dynamic_pointer_cast<ExplosionEffectJob>(job);
|
||||||
|
if (explosionEffectJob) {
|
||||||
|
//Bind program
|
||||||
|
if (GLERROR("Prebind")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
m_ExplosionEffectProgram->Bind();
|
||||||
|
if (GLERROR("BindProgram")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
glDisable(GL_CULL_FACE);
|
||||||
|
|
||||||
|
//Bind uniforms
|
||||||
|
BindExplosionUniforms(explosionHandle, explosionEffectJob, scene);
|
||||||
|
if (GLERROR("BindExplosionUniforms")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (explosionEffectJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||||
|
|
||||||
|
if (explosionEffectJob->Animation != nullptr) {
|
||||||
|
std::vector<glm::mat4> frameBones = explosionEffectJob->Skeleton->GetFrameBones(*explosionEffectJob->Animation, explosionEffectJob->AnimationTime);
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (GLERROR("Animation")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//bind textures
|
||||||
|
BindExplosionTextures(explosionEffectJob);
|
||||||
|
if (GLERROR("BindExplosionTextures")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//draw
|
||||||
|
glBindVertexArray(explosionEffectJob->Model->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, explosionEffectJob->Model->ElementBuffer);
|
||||||
|
glDrawElements(GL_TRIANGLES, explosionEffectJob->EndIndex - explosionEffectJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(explosionEffectJob->StartIndex*sizeof(unsigned int)));
|
||||||
|
glEnable(GL_CULL_FACE);
|
||||||
|
if (GLERROR("explosion effect end")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
|
if (modelJob) {
|
||||||
|
//bind forward program
|
||||||
|
m_ForwardPlusProgram->Bind();
|
||||||
|
glUniform2f(glGetUniformLocation(forwardHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
|
||||||
|
//bind uniforms
|
||||||
|
BindModelUniforms(forwardHandle, modelJob, scene);
|
||||||
|
|
||||||
|
//bind textures
|
||||||
|
BindModelTextures(modelJob);
|
||||||
|
|
||||||
|
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||||
|
|
||||||
|
if (modelJob->Animation != nullptr) {
|
||||||
|
std::vector<glm::mat4> frameBones = modelJob->Skeleton->GetFrameBones(*modelJob->Animation, modelJob->AnimationTime);
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//draw
|
||||||
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
|
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex*sizeof(unsigned int)));
|
||||||
|
if (GLERROR("models end")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DrawFinalPass::DrawToDepthBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
|
||||||
|
{
|
||||||
|
m_FillDepthBufferProgram->Bind();
|
||||||
|
GLuint shaderHandle = m_FillDepthBufferProgram->GetHandle();
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
|
||||||
|
for (auto &job : jobs) {
|
||||||
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
|
|
||||||
|
//bind uniforms
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||||
|
|
||||||
|
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||||
|
|
||||||
|
if (modelJob->Animation != nullptr) {
|
||||||
|
std::vector<glm::mat4> frameBones = modelJob->Skeleton->GetFrameBones(*modelJob->Animation, modelJob->AnimationTime);
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//draw
|
||||||
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
|
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex*sizeof(unsigned int)));
|
||||||
|
if (GLERROR("models end")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene)
|
void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene)
|
||||||
{
|
{
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix));
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
|
||||||
glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height);
|
glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height);
|
||||||
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix));
|
|
||||||
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color));
|
|
||||||
glUniform3fv(glGetUniformLocation(shaderHandle, "ExplosionOrigin"), 1, glm::value_ptr(job->ExplosionOrigin));
|
glUniform3fv(glGetUniformLocation(shaderHandle, "ExplosionOrigin"), 1, glm::value_ptr(job->ExplosionOrigin));
|
||||||
glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), job->TimeSinceDeath);
|
glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), job->TimeSinceDeath);
|
||||||
glUniform1f(glGetUniformLocation(shaderHandle, "ExplosionDuration"), job->ExplosionDuration);
|
glUniform1f(glGetUniformLocation(shaderHandle, "ExplosionDuration"), job->ExplosionDuration);
|
||||||
glUniform4fv(glGetUniformLocation(shaderHandle, "EndColor"), 1, glm::value_ptr(job->EndColor));
|
glUniform4fv(glGetUniformLocation(shaderHandle, "EndColor"), 1, glm::value_ptr(job->EndColor));
|
||||||
glUniform1i(glGetUniformLocation(shaderHandle, "Randomness"), job->Randomness);
|
glUniform1i(glGetUniformLocation(shaderHandle, "Randomness"), job->Randomness);
|
||||||
|
glUniform1fv(glGetUniformLocation(shaderHandle, "RandomNumbers"), 50, job->RandomNumbers.data());
|
||||||
glUniform1f(glGetUniformLocation(shaderHandle, "RandomnessScalar"), job->RandomnessScalar);
|
glUniform1f(glGetUniformLocation(shaderHandle, "RandomnessScalar"), job->RandomnessScalar);
|
||||||
glUniform2fv(glGetUniformLocation(shaderHandle, "Velocity"), 1, glm::value_ptr(job->Velocity));
|
glUniform2fv(glGetUniformLocation(shaderHandle, "Velocity"), 1, glm::value_ptr(job->Velocity));
|
||||||
glUniform1i(glGetUniformLocation(shaderHandle, "ColorByDistance"), job->ColorByDistance);
|
glUniform1i(glGetUniformLocation(shaderHandle, "ColorByDistance"), job->ColorByDistance);
|
||||||
glUniform1i(glGetUniformLocation(shaderHandle, "ExponentialAccelaration"), job->ExponentialAccelaration);
|
glUniform1i(glGetUniformLocation(shaderHandle, "ExponentialAccelaration"), job->ExponentialAccelaration);
|
||||||
glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(job->DiffuseColor));
|
|
||||||
glUniform1fv(glGetUniformLocation(shaderHandle, "RandomNumbers"), 50, job->RandomNumbers.data());
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene)
|
|
||||||
{
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
|
||||||
glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height);
|
|
||||||
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix));
|
|
||||||
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color));
|
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color));
|
||||||
glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(job->DiffuseColor));
|
glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(job->DiffuseColor));
|
||||||
glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(job->FillColor));
|
glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(job->FillColor));
|
||||||
glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), job->FillPercentage);
|
glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), job->FillPercentage);
|
||||||
|
glUniform4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("END");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene)
|
||||||
|
{
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
|
||||||
|
glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height);
|
||||||
|
|
||||||
|
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color));
|
||||||
|
glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(job->DiffuseColor));
|
||||||
|
glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(job->FillColor));
|
||||||
|
glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), job->FillPercentage);
|
||||||
|
glUniform4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
|
||||||
|
GLERROR("END");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -217,7 +530,22 @@ void DrawFinalPass::BindExplosionTextures(std::shared_ptr<ExplosionEffectJob>& j
|
|||||||
} else {
|
} else {
|
||||||
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
|
if (job->NormalTexture != nullptr) {
|
||||||
|
glBindTexture(GL_TEXTURE_2D, job->NormalTexture->m_Texture);
|
||||||
|
} else {
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_NeutralNormalTexture->m_Texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE2);
|
||||||
|
if (job->SpecularTexture != nullptr) {
|
||||||
|
glBindTexture(GL_TEXTURE_2D, job->SpecularTexture->m_Texture);
|
||||||
|
} else {
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_GreyTexture->m_Texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE3);
|
||||||
if (job->IncandescenceTexture != nullptr) {
|
if (job->IncandescenceTexture != nullptr) {
|
||||||
glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture->m_Texture);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "Rendering/DrawFinalPassState.h"
|
#include "Rendering/DrawFinalPassState.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DrawFinalPassState::DrawFinalPassState(GLuint frameBuffer)
|
DrawFinalPassState::DrawFinalPassState(GLuint frameBuffer)
|
||||||
{
|
{
|
||||||
BindFramebuffer(frameBuffer);
|
BindFramebuffer(frameBuffer);
|
||||||
@@ -8,6 +9,10 @@ DrawFinalPassState::DrawFinalPassState(GLuint frameBuffer)
|
|||||||
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);
|
||||||
Enable(GL_CULL_FACE);
|
Enable(GL_CULL_FACE);
|
||||||
|
Enable(GL_STENCIL_TEST);
|
||||||
|
StencilFunc(GL_NOTEQUAL, 1, 0xFF);
|
||||||
|
StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
||||||
|
StencilMask(0xFF);
|
||||||
ClearColor(glm::vec4(0.f, 0.f, 0.f, 0.f));
|
ClearColor(glm::vec4(0.f, 0.f, 0.f, 0.f));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,3 +20,20 @@ DrawFinalPassState::~DrawFinalPassState()
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DrawStencilState::DrawStencilState(GLuint frameBuffer)
|
||||||
|
{
|
||||||
|
BindFramebuffer(frameBuffer);
|
||||||
|
Enable(GL_STENCIL_TEST);
|
||||||
|
StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
||||||
|
StencilFunc(GL_ALWAYS, 1, 0xFF);
|
||||||
|
StencilMask(0xFF);
|
||||||
|
Enable(GL_DEPTH_TEST);
|
||||||
|
ClearColor(glm::vec4(0.f));
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawStencilState::~DrawStencilState()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,10 +39,13 @@ void FrameBuffer::AddResource(std::shared_ptr<BufferResource> resource)
|
|||||||
|
|
||||||
void FrameBuffer::Generate()
|
void FrameBuffer::Generate()
|
||||||
{
|
{
|
||||||
|
GLERROR("PRE");
|
||||||
|
|
||||||
std::vector<GLenum> attachments;
|
std::vector<GLenum> attachments;
|
||||||
|
|
||||||
glGenFramebuffers(1, &m_BufferHandle);
|
glGenFramebuffers(1, &m_BufferHandle);
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_BufferHandle);
|
glBindFramebuffer(GL_FRAMEBUFFER, m_BufferHandle);
|
||||||
|
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) {
|
||||||
@@ -54,29 +57,32 @@ void FrameBuffer::Generate()
|
|||||||
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");
|
||||||
if ( (*it)->m_Attachment != GL_COLOR_ATTACHMENT0 ||
|
|
||||||
(*it)->m_Attachment != GL_COLOR_ATTACHMENT1 ||
|
|
||||||
(*it)->m_Attachment != GL_DEPTH_ATTACHMENT ||
|
|
||||||
(*it)->m_Attachment != GL_STENCIL_ATTACHMENT) //TODO: Viktor: Fixa detta
|
|
||||||
{
|
|
||||||
LOG_ERROR("RenderBuffer Attachment not valid.");
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
GLERROR("2");
|
||||||
|
|
||||||
if ((*it)->m_Attachment != GL_DEPTH_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("3");
|
||||||
|
|
||||||
|
|
||||||
GLenum* bufferTextures = &attachments[0];
|
GLenum* bufferTextures = &attachments[0];
|
||||||
glDrawBuffers(attachments.size(), bufferTextures);
|
glDrawBuffers(attachments.size(), bufferTextures);
|
||||||
|
if(GLERROR("4")) {
|
||||||
|
printf("hello");
|
||||||
|
}
|
||||||
|
|
||||||
if (GLenum frameBufferStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
if (GLenum frameBufferStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
||||||
LOG_ERROR("FrameBuffer incomplete: 0x%x\n", frameBufferStatus);
|
GLERROR("Framebuffer incomplete");
|
||||||
|
//LOG_ERROR("FrameBuffer incomplete: 0x%x\n", frameBufferStatus);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
GLERROR("END");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameBuffer::Bind()
|
void FrameBuffer::Bind()
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ LightCullingPass::~LightCullingPass()
|
|||||||
|
|
||||||
void LightCullingPass::GenerateNewFrustum(RenderScene& scene)
|
void LightCullingPass::GenerateNewFrustum(RenderScene& scene)
|
||||||
{
|
{
|
||||||
if (scene.PointLightJobs.size() == 0)
|
if (scene.Jobs.PointLight.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GLERROR("CalculateFrustum Error: Pre");
|
GLERROR("CalculateFrustum Error: Pre");
|
||||||
@@ -83,7 +83,7 @@ void LightCullingPass::FillLightList(RenderScene& scene)
|
|||||||
{
|
{
|
||||||
m_LightSources.clear();
|
m_LightSources.clear();
|
||||||
|
|
||||||
for(auto &job : scene.PointLightJobs) {
|
for(auto &job : scene.Jobs.PointLight) {
|
||||||
auto pointLightjob = std::dynamic_pointer_cast<PointLightJob>(job);
|
auto pointLightjob = std::dynamic_pointer_cast<PointLightJob>(job);
|
||||||
if (pointLightjob) {
|
if (pointLightjob) {
|
||||||
LightSource p;
|
LightSource p;
|
||||||
@@ -97,7 +97,7 @@ void LightCullingPass::FillLightList(RenderScene& scene)
|
|||||||
m_LightSources.push_back(p);
|
m_LightSources.push_back(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(auto &job : scene.DirectionalLightJobs) {
|
for(auto &job : scene.Jobs.DirectionalLight) {
|
||||||
auto directionalLightJob = std::dynamic_pointer_cast<DirectionalLightJob>(job);
|
auto directionalLightJob = std::dynamic_pointer_cast<DirectionalLightJob>(job);
|
||||||
if(directionalLightJob) {
|
if(directionalLightJob) {
|
||||||
LightSource p;
|
LightSource p;
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
}
|
}
|
||||||
m_Camera = scene.Camera;
|
m_Camera = scene.Camera;
|
||||||
|
|
||||||
for (auto &job : scene.OpaqueObjects) {
|
for (auto &job : scene.Jobs.OpaqueObjects) {
|
||||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
|
|
||||||
if (modelJob) {
|
if (modelJob) {
|
||||||
@@ -75,9 +75,9 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]);
|
m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]);
|
||||||
if (m_ColorCounter[0] > 255) {
|
if (m_ColorCounter[0] > 255) {
|
||||||
m_ColorCounter[0] = 0;
|
m_ColorCounter[0] = 0;
|
||||||
m_ColorCounter[1] += 5;
|
m_ColorCounter[1] += 1;
|
||||||
} else {
|
} else {
|
||||||
m_ColorCounter[0] += 50;
|
m_ColorCounter[0] += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &job : scene.TransparentObjects) {
|
for (auto &job : scene.Jobs.TransparentObjects) {
|
||||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
|
|
||||||
if (modelJob) {
|
if (modelJob) {
|
||||||
@@ -121,9 +121,101 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]);
|
m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]);
|
||||||
if (m_ColorCounter[0] > 255) {
|
if (m_ColorCounter[0] > 255) {
|
||||||
m_ColorCounter[0] = 0;
|
m_ColorCounter[0] = 0;
|
||||||
m_ColorCounter[1] += 5;
|
m_ColorCounter[1] += 1;
|
||||||
} else {
|
} else {
|
||||||
m_ColorCounter[0] += 50;
|
m_ColorCounter[0] += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_PickingColorsToEntity[glm::ivec2(pickColor[0], pickColor[1])] = pickInfo;
|
||||||
|
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2fv(glGetUniformLocation(shaderHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||||
|
|
||||||
|
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||||
|
|
||||||
|
if (modelJob->Animation != nullptr) {
|
||||||
|
std::vector<glm::mat4> frameBones = modelJob->Skeleton->GetFrameBones(*modelJob->Animation, modelJob->AnimationTime);
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
|
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex * sizeof(unsigned int)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto &job : scene.Jobs.OpaqueShieldedObjects) {
|
||||||
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
|
|
||||||
|
if (modelJob) {
|
||||||
|
int pickColor[2] = { m_ColorCounter[0], m_ColorCounter[1] };
|
||||||
|
|
||||||
|
PickingInfo pickInfo;
|
||||||
|
pickInfo.Entity = modelJob->Entity;
|
||||||
|
pickInfo.World = modelJob->World;
|
||||||
|
pickInfo.Camera = scene.Camera;
|
||||||
|
|
||||||
|
auto color = m_EntityColors.find(std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera));
|
||||||
|
if (color != m_EntityColors.end()) {
|
||||||
|
pickColor[0] = color->second[0];
|
||||||
|
pickColor[1] = color->second[1];
|
||||||
|
} else {
|
||||||
|
m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]);
|
||||||
|
if (m_ColorCounter[0] > 255) {
|
||||||
|
m_ColorCounter[0] = 0;
|
||||||
|
m_ColorCounter[1] += 1;
|
||||||
|
} else {
|
||||||
|
m_ColorCounter[0] += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_PickingColorsToEntity[glm::ivec2(pickColor[0], pickColor[1])] = pickInfo;
|
||||||
|
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2fv(glGetUniformLocation(shaderHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||||
|
|
||||||
|
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||||
|
|
||||||
|
if (modelJob->Animation != nullptr) {
|
||||||
|
std::vector<glm::mat4> frameBones = modelJob->Skeleton->GetFrameBones(*modelJob->Animation, modelJob->AnimationTime);
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
|
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex * sizeof(unsigned int)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto &job : scene.Jobs.TransparentShieldedObjects) {
|
||||||
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
|
|
||||||
|
if (modelJob) {
|
||||||
|
int pickColor[2] = { m_ColorCounter[0], m_ColorCounter[1] };
|
||||||
|
|
||||||
|
PickingInfo pickInfo;
|
||||||
|
pickInfo.Entity = modelJob->Entity;
|
||||||
|
pickInfo.World = modelJob->World;
|
||||||
|
pickInfo.Camera = scene.Camera;
|
||||||
|
|
||||||
|
auto color = m_EntityColors.find(std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera));
|
||||||
|
if (color != m_EntityColors.end()) {
|
||||||
|
pickColor[0] = color->second[0];
|
||||||
|
pickColor[1] = color->second[1];
|
||||||
|
} else {
|
||||||
|
m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]);
|
||||||
|
if (m_ColorCounter[0] > 255) {
|
||||||
|
m_ColorCounter[0] = 0;
|
||||||
|
m_ColorCounter[1] += 1;
|
||||||
|
} else {
|
||||||
|
m_ColorCounter[0] += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,10 @@ bool RenderState::Enable(GLenum cap)
|
|||||||
//LOG_WARNING("Trying to enable somthing that is already enabled.");
|
//LOG_WARNING("Trying to enable somthing that is already enabled.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ResetFunctions.push_back(std::bind(glDisable, cap));
|
m_ResetFunctions.push_back(std::bind(glDisable, cap));
|
||||||
glEnable(cap);
|
glEnable(cap);
|
||||||
return !GLERROR("RenderState::Enable");
|
return !GLERROR("Enable");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderState::Disable(GLenum cap)
|
bool RenderState::Disable(GLenum cap)
|
||||||
@@ -16,9 +17,10 @@ bool RenderState::Disable(GLenum cap)
|
|||||||
if (!glIsEnabled(cap)) {
|
if (!glIsEnabled(cap)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ResetFunctions.push_back(std::bind(glEnable, cap));
|
m_ResetFunctions.push_back(std::bind(glEnable, cap));
|
||||||
glDisable(cap);
|
glDisable(cap);
|
||||||
return !GLERROR("RenderState::Disable");
|
return !GLERROR("Disable");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderState::CullFace(GLenum mode)
|
bool RenderState::CullFace(GLenum mode)
|
||||||
@@ -32,7 +34,7 @@ bool RenderState::CullFace(GLenum mode)
|
|||||||
glGetIntegerv(GL_CULL_FACE_MODE, &original);
|
glGetIntegerv(GL_CULL_FACE_MODE, &original);
|
||||||
m_ResetFunctions.push_back(std::bind(glCullFace, original));
|
m_ResetFunctions.push_back(std::bind(glCullFace, original));
|
||||||
glCullFace(mode);
|
glCullFace(mode);
|
||||||
return !GLERROR("RenderState::CullFace");
|
return !GLERROR("CullFace");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderState::ClearColor(glm::vec4 color)
|
bool RenderState::ClearColor(glm::vec4 color)
|
||||||
@@ -41,7 +43,7 @@ bool RenderState::ClearColor(glm::vec4 color)
|
|||||||
glGetFloatv(GL_COLOR_CLEAR_VALUE, &original[0]);
|
glGetFloatv(GL_COLOR_CLEAR_VALUE, &original[0]);
|
||||||
m_ResetFunctions.push_back(std::bind(glClearColor, original[0], original[1], original[2], original[3]));
|
m_ResetFunctions.push_back(std::bind(glClearColor, original[0], original[1], original[2], original[3]));
|
||||||
glClearColor(color.r, color.g, color.b, color.a);
|
glClearColor(color.r, color.g, color.b, color.a);
|
||||||
return !GLERROR("RenderState::ClearColor");
|
return !GLERROR("ClearColor");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderState::BindFramebuffer(GLint framebuffer)
|
bool RenderState::BindFramebuffer(GLint framebuffer)
|
||||||
@@ -55,7 +57,7 @@ bool RenderState::BindFramebuffer(GLint framebuffer)
|
|||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, originalDraw);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, originalDraw);
|
||||||
});
|
});
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
|
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
|
||||||
return !GLERROR("RenderState::BindBuffer");
|
return !GLERROR("BindBuffer");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -67,7 +69,7 @@ bool RenderState::BlendEquation(GLenum mode)
|
|||||||
glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &originalAlpha);
|
glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &originalAlpha);
|
||||||
m_ResetFunctions.push_back(std::bind(glBlendEquationSeparate, originalRGB, originalAlpha));
|
m_ResetFunctions.push_back(std::bind(glBlendEquationSeparate, originalRGB, originalAlpha));
|
||||||
glBlendEquation(mode);
|
glBlendEquation(mode);
|
||||||
return !GLERROR("RenderState::BlendEquation");
|
return !GLERROR("BlendEquation");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderState::BlendFunc(GLenum sfactor, GLenum dfactor)
|
bool RenderState::BlendFunc(GLenum sfactor, GLenum dfactor)
|
||||||
@@ -82,7 +84,46 @@ bool RenderState::BlendFunc(GLenum sfactor, GLenum dfactor)
|
|||||||
glGetIntegerv(GL_BLEND_DST_ALPHA, &originalDestAlpha);
|
glGetIntegerv(GL_BLEND_DST_ALPHA, &originalDestAlpha);
|
||||||
m_ResetFunctions.push_back(std::bind(glBlendFuncSeparate, originalSrcRGB, originalSrcAlpha, originalDestRGB, originalDestAlpha));
|
m_ResetFunctions.push_back(std::bind(glBlendFuncSeparate, originalSrcRGB, originalSrcAlpha, originalDestRGB, originalDestAlpha));
|
||||||
glBlendFunc(sfactor, dfactor);
|
glBlendFunc(sfactor, dfactor);
|
||||||
return !GLERROR("RenderState::BlendFunc");
|
return !GLERROR("BlendFunc");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool RenderState::StencilOp(GLenum sfail, GLenum dpfail, GLenum dppass)
|
||||||
|
{
|
||||||
|
GLint originalSFail;
|
||||||
|
glGetIntegerv(GL_STENCIL_FAIL, &originalSFail);
|
||||||
|
GLint originalDPFail;
|
||||||
|
glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, &originalDPFail);
|
||||||
|
GLint originalDPPass;
|
||||||
|
glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, &originalDPPass);
|
||||||
|
m_ResetFunctions.push_back(std::bind(glStencilOp, originalSFail, originalDPFail, originalDPPass));
|
||||||
|
glStencilOp(sfail, dpfail, dppass);
|
||||||
|
return !GLERROR("StencilOp");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool RenderState::StencilFunc(GLenum func, GLint ref, GLuint mask)
|
||||||
|
{
|
||||||
|
GLint originalFunc;
|
||||||
|
glGetIntegerv(GL_STENCIL_FUNC, &originalFunc);
|
||||||
|
GLint originalRef;
|
||||||
|
glGetIntegerv(GL_STENCIL_REF, &originalRef);
|
||||||
|
GLint originalMask;
|
||||||
|
glGetIntegerv(GL_STENCIL_VALUE_MASK, &originalMask);
|
||||||
|
m_ResetFunctions.push_back(std::bind(glStencilFunc, originalFunc, originalRef, originalMask));
|
||||||
|
glStencilFunc(func, ref, mask);
|
||||||
|
return !GLERROR("StencilFunc");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool RenderState::StencilMask(GLuint mask)
|
||||||
|
{
|
||||||
|
GLint originalMask;
|
||||||
|
glGetIntegerv(GL_STENCIL_WRITEMASK, &originalMask);
|
||||||
|
m_ResetFunctions.push_back(std::bind(glStencilMask, mask));
|
||||||
|
glStencilMask(mask);
|
||||||
|
return !GLERROR("StencilMask");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderState::DepthMask(GLboolean flag)
|
bool RenderState::DepthMask(GLboolean flag)
|
||||||
@@ -91,12 +132,12 @@ bool RenderState::DepthMask(GLboolean flag)
|
|||||||
glGetBooleanv(GL_DEPTH_WRITEMASK, &original);
|
glGetBooleanv(GL_DEPTH_WRITEMASK, &original);
|
||||||
m_ResetFunctions.push_back(std::bind(glDepthMask, original));
|
m_ResetFunctions.push_back(std::bind(glDepthMask, original));
|
||||||
glDepthMask(flag);
|
glDepthMask(flag);
|
||||||
return !GLERROR("RenderState::DepthMask");
|
return !GLERROR("DepthMask");
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderState::~RenderState()
|
RenderState::~RenderState()
|
||||||
{
|
{
|
||||||
for (auto& f : m_ResetFunctions) {
|
for (auto& f : boost::adaptors::reverse(m_ResetFunctions)) {
|
||||||
f();
|
f();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user