diff --git a/OpenGLEngine/OpenGLEngine/AddTorqueFromCameraComponent.h b/OpenGLEngine/OpenGLEngine/AddTorqueFromCameraComponent.h new file mode 100644 index 0000000..1da6028 --- /dev/null +++ b/OpenGLEngine/OpenGLEngine/AddTorqueFromCameraComponent.h @@ -0,0 +1,15 @@ +#pragma once +#include "ECSConfig.h" + +namespace Reality +{ + struct AddTorqueFromCameraComponent + { + AddTorqueFromCameraComponent(float _torqueScale = 10.0f) + : torqueScale(_torqueScale) + { + + } + float torqueScale; + }; +} diff --git a/OpenGLEngine/OpenGLEngine/AddTorqueFromCameraSystem.cpp b/OpenGLEngine/OpenGLEngine/AddTorqueFromCameraSystem.cpp new file mode 100644 index 0000000..be862b6 --- /dev/null +++ b/OpenGLEngine/OpenGLEngine/AddTorqueFromCameraSystem.cpp @@ -0,0 +1,35 @@ +#include "AddTorqueFromCameraSystem.h" +#include "LifeTimeComponent.h" + +namespace Reality +{ + AddTorqueFromCameraSystem::AddTorqueFromCameraSystem() + { + requireComponent(); + requireComponent(); + requireComponent(); + } + + void AddTorqueFromCameraSystem::Update(float deltaTime) + { + if (!pressed && glfwGetKey(getWorld().data.renderUtil->window->glfwWindow, GLFW_KEY_E) == GLFW_PRESS) + { + for (auto e : getEntities()) + { + auto& transform = e.getComponent(); + auto& forceAndTorqueAcc = e.getComponent(); + auto& addTorqueComp = e.getComponent(); + + Camera& cam = getWorld().data.renderUtil->camera; + + Vector3 torque = glm::cross(cam.Position - transform.GetPosition(), cam.Front * addTorqueComp.torqueScale); + forceAndTorqueAcc.AddTorque(torque); + } + pressed = true; + } + else if(glfwGetKey(getWorld().data.renderUtil->window->glfwWindow, GLFW_KEY_E) == GLFW_RELEASE) + { + pressed = false; + } + } +} diff --git a/OpenGLEngine/OpenGLEngine/AddTorqueFromCameraSystem.h b/OpenGLEngine/OpenGLEngine/AddTorqueFromCameraSystem.h new file mode 100644 index 0000000..b6a638f --- /dev/null +++ b/OpenGLEngine/OpenGLEngine/AddTorqueFromCameraSystem.h @@ -0,0 +1,17 @@ +#pragma once +#include "ECSConfig.h" +#include "TransformComponentV2.h" +#include "ForceAndTorqueAccumulatorComponent.h" +#include "AddTorqueFromCameraComponent.h" + +namespace Reality +{ + class AddTorqueFromCameraSystem : public ECSSystem + { + public: + AddTorqueFromCameraSystem(); + void Update(float deltaTime); + private: + bool pressed = false; + }; +} diff --git a/OpenGLEngine/OpenGLEngine/AeroComponent.h b/OpenGLEngine/OpenGLEngine/AeroComponent.h deleted file mode 100644 index aa005a9..0000000 --- a/OpenGLEngine/OpenGLEngine/AeroComponent.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once -#include "ECSConfig.h" - -namespace Reality -{ - struct AeroComponent - { - AeroComponent(ECSEntity _target = ECSEntity(), Mat3 _aerodynamicTensor = Mat3(1.0f), Vector3 _relativePoint = Vector3(0, 0, 0)) - :target(_target), aerodynamicTensor(_aerodynamicTensor), relativePoint(_relativePoint) - { - - } - Mat3 aerodynamicTensor; - ECSEntity target; - Vector3 relativePoint; - }; -} diff --git a/OpenGLEngine/OpenGLEngine/AeroControlComponent.h b/OpenGLEngine/OpenGLEngine/AeroControlComponent.h index a918690..4de2a53 100644 --- a/OpenGLEngine/OpenGLEngine/AeroControlComponent.h +++ b/OpenGLEngine/OpenGLEngine/AeroControlComponent.h @@ -1,19 +1,26 @@ #pragma once #include "ECSConfig.h" -#include namespace Reality { struct AeroControlComponent { - AeroControlComponent(std::vector _positiveKeys = { GLFW_KEY_UP }, std::vector _negetiveKeys = { GLFW_KEY_DOWN }, float _rate = 1) - :positiveKeys(_positiveKeys), negetiveKeys(_negetiveKeys), rate(_rate) + AeroControlComponent(Vector3 _aeroPlusOne = Vector3(0, 0, 0), Vector3 _aeroMinusOne = Vector3(0, 0, 0), + const std::vector& _positiveKeys = {}, const std::vector& _negetiveKeys = {}, + float _controlSpeed = 1) + :aeroPlusOne(_aeroPlusOne), + aeroMinusOne(_aeroMinusOne), + positiveKeys(_positiveKeys), + negetiveKeys(_negetiveKeys), + controlSpeed(_controlSpeed) { } - + Vector3 aeroPlusOne; + Vector3 aeroMinusOne; std::vector positiveKeys; std::vector negetiveKeys; - float rate; + float controlSetting = 0; + float controlSpeed; }; } diff --git a/OpenGLEngine/OpenGLEngine/AeroControlSystem.cpp b/OpenGLEngine/OpenGLEngine/AeroControlSystem.cpp index 98b7cab..85f643d 100644 --- a/OpenGLEngine/OpenGLEngine/AeroControlSystem.cpp +++ b/OpenGLEngine/OpenGLEngine/AeroControlSystem.cpp @@ -4,43 +4,54 @@ namespace Reality { AeroControlSystem::AeroControlSystem() { - requireComponent(); + requireComponent(); requireComponent(); } void AeroControlSystem::Update(float deltaTime) { - pKey = false; - nKey = false; for (auto e : getEntities()) { - auto& aero = e.getComponent(); + auto& surface = e.getComponent(); auto& control = e.getComponent(); - for (auto key : control.positiveKeys) + bool reset = true; + + for (int key : control.positiveKeys) { if (glfwGetKey(getWorld().data.renderUtil->window->glfwWindow, key) == GLFW_PRESS) { - aero.controlSetting += control.rate * deltaTime; - pKey = true; + control.controlSetting += control.controlSpeed * deltaTime; + reset = false; } } - - for (auto key : control.negetiveKeys) + + if (control.controlSetting > 1) + { + control.controlSetting = 1; + } + + for (int key : control.negetiveKeys) { if (glfwGetKey(getWorld().data.renderUtil->window->glfwWindow, key) == GLFW_PRESS) { - aero.controlSetting -= control.rate * deltaTime; - nKey = true; + control.controlSetting -= control.controlSpeed * deltaTime; + reset = false; } } - if (!pKey && !nKey) + if (control.controlSetting < -1) + { + control.controlSetting = -1; + } + + if (reset) { - aero.controlSetting = 0; + control.controlSetting = 0; } - aero.controlSetting = glm::clamp(aero.controlSetting, -1.0f, 1.0f); + float t = (control.controlSetting + 1) * 0.5f; + surface.aerodynamicForce = t * control.aeroMinusOne + (1 - t) * control.aeroPlusOne; } } } diff --git a/OpenGLEngine/OpenGLEngine/AeroControlSystem.h b/OpenGLEngine/OpenGLEngine/AeroControlSystem.h index 27b8ec1..1d2b69c 100644 --- a/OpenGLEngine/OpenGLEngine/AeroControlSystem.h +++ b/OpenGLEngine/OpenGLEngine/AeroControlSystem.h @@ -1,6 +1,6 @@ #pragma once #include "ECSConfig.h" -#include "AeroMinMaxComponent.h" +#include "AeroSurfaceComponent.h" #include "AeroControlComponent.h" namespace Reality @@ -10,8 +10,5 @@ namespace Reality public: AeroControlSystem(); void Update(float deltaTime); - private: - bool pKey = false; - bool nKey = false; }; } diff --git a/OpenGLEngine/OpenGLEngine/AeroMinMaxComponent.h b/OpenGLEngine/OpenGLEngine/AeroMinMaxComponent.h deleted file mode 100644 index 3d6abf6..0000000 --- a/OpenGLEngine/OpenGLEngine/AeroMinMaxComponent.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include "ECSConfig.h" - -namespace Reality -{ - struct AeroMinMaxComponent - { - AeroMinMaxComponent(Mat3 _minTensor = Mat3(1.0f), Mat3 _baseTensor = Mat3(1.0f), Mat3 _maxTensor = Mat3(1.0f), float _controlSetting = 0.0f) - :minTensor(_minTensor), baseTensor(_baseTensor), maxTensor(_maxTensor), controlSetting(_controlSetting) - { - - } - Mat3 minTensor; - Mat3 baseTensor; - Mat3 maxTensor; - float controlSetting; - }; -} diff --git a/OpenGLEngine/OpenGLEngine/AeroSurfaceComponent.h b/OpenGLEngine/OpenGLEngine/AeroSurfaceComponent.h new file mode 100644 index 0000000..d4b1c04 --- /dev/null +++ b/OpenGLEngine/OpenGLEngine/AeroSurfaceComponent.h @@ -0,0 +1,20 @@ +#pragma once +#include "ECSConfig.h" + +namespace Reality +{ + struct AeroSurfaceComponent + { + AeroSurfaceComponent(ECSEntity _targetEntity = ECSEntity(), Vector3 _aerodynamicForce = Vector3(0, 0, 0), + Vector3 _localOffset = Vector3(0, 0, 0)) + :targetEntity(_targetEntity), + aerodynamicForce(_aerodynamicForce), + localOffset(_localOffset) + { + + } + ECSEntity targetEntity; + Vector3 aerodynamicForce; + Vector3 localOffset; + }; +} diff --git a/OpenGLEngine/OpenGLEngine/AeroSurfaceSystem.cpp b/OpenGLEngine/OpenGLEngine/AeroSurfaceSystem.cpp new file mode 100644 index 0000000..326b028 --- /dev/null +++ b/OpenGLEngine/OpenGLEngine/AeroSurfaceSystem.cpp @@ -0,0 +1,48 @@ +#include "AeroSurfaceSystem.h" +#include "RigidbodyComponent.h" +#include "ForceAndTorqueAccumulatorComponent.h" + +namespace Reality +{ + AeroSurfaceSystem::AeroSurfaceSystem() + { + requireComponent(); + requireComponent(); + } + + void AeroSurfaceSystem::Update(float deltaTime) + { + for (auto e : getEntities()) + { + auto& surfaceTransform = e.getComponent(); + auto& aero = e.getComponent(); + + if (aero.targetEntity.hasComponent() && + aero.targetEntity.hasComponent() && + aero.targetEntity.hasComponent()) + { + auto& targetTransform = aero.targetEntity.getComponent(); + auto& rigidbody = aero.targetEntity.getComponent(); + auto& forceAndTorque = aero.targetEntity.getComponent(); + + // HACK: For lack of scene graph + Vector3 worldSurfacePosition = targetTransform.LocalToWorldPosition(aero.localOffset); + surfaceTransform.SetPosition(worldSurfacePosition); + surfaceTransform.SetOrientation(targetTransform.GetOrientation()); + getWorld().data.renderUtil->DrawCube(surfaceTransform.GetPosition(), + Vector3(1, 1, 1), + surfaceTransform.GetOrientation()); + + Vector3 force = CalculateWorldAerodynamicForce(aero.aerodynamicForce, targetTransform); + forceAndTorque.AddForceAtPoint(force, + surfaceTransform.GetPosition(), + targetTransform.GetPosition()); + } + } + } + + const Vector3 & AeroSurfaceSystem::CalculateWorldAerodynamicForce(const Vector3& localAeroForce, TransformComponentV2& transform) + { + return transform.LocalToWorldDirection(localAeroForce); + } +} diff --git a/OpenGLEngine/OpenGLEngine/AeroSurfaceSystem.h b/OpenGLEngine/OpenGLEngine/AeroSurfaceSystem.h new file mode 100644 index 0000000..b186ab1 --- /dev/null +++ b/OpenGLEngine/OpenGLEngine/AeroSurfaceSystem.h @@ -0,0 +1,18 @@ +#pragma once +#include "ECSConfig.h" +#include "TransformComponentV2.h" +#include "AeroSurfaceComponent.h" + +namespace Reality +{ + class AeroSurfaceSystem : public ECSSystem + { + public: + AeroSurfaceSystem(); + void Update(float deltaTime); + Vector3 windVelocity = Vector3(0, 0, 0); + private: + const Vector3& CalculateWorldAerodynamicForce(const Vector3& localAeroForce, + TransformComponentV2& transform); + }; +} diff --git a/OpenGLEngine/OpenGLEngine/AeroSystem.cpp b/OpenGLEngine/OpenGLEngine/AeroSystem.cpp deleted file mode 100644 index 8b68db7..0000000 --- a/OpenGLEngine/OpenGLEngine/AeroSystem.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "AeroSystem.h" -#include "RigidBodyComponent.h" -#include "TransformComponentV2.h" - -namespace Reality -{ - AeroSystem::AeroSystem() - { - requireComponent(); - } - - void AeroSystem::UpdateForceFromTensor(ECSWorld& world, AeroComponent& aero, RigidBodyComponent& body, TransformComponentV2& transform) - { - // Calculate total velocity (windspeed and body's velocity). - Vector3 velocity = body.velocity; - velocity += windspeed; - - // Calculate the velocity in body coordinates - Vector3 bodyVel = transform.WorldToLocalDirection(velocity); - - // Calculate the force in body coordinates - Vector3 bodyForce = aero.aerodynamicTensor * bodyVel / 1.0f; - Vector3 force = transform.LocalToWorldDirection(bodyForce); - - // Apply the force - Vector3 forcePoint = transform.LocalToWorldPosition(aero.relativePoint); - body.AddForceAtPoint(force, forcePoint, transform.GetPosition()); - - //world.data.renderUtil->DrawLine(transform.GetPosition(), forcePoint + force * 1000.0f, Color::Purple); - world.data.renderUtil->DrawLine(forcePoint, forcePoint + force * 1000.0f, Color::Purple); - } - - void AeroSystem::Update(float deltaTime) - { - for (auto e : getEntities()) - { - auto& aero = e.getComponent(); - if (aero.target.hasComponent() && aero.target.hasComponent()) - { - auto& rigidbody = aero.target.getComponent(); - auto& transform = aero.target.getComponent(); - UpdateForceFromTensor(getWorld(), aero, rigidbody, transform); - } - } - } -} diff --git a/OpenGLEngine/OpenGLEngine/AeroSystem.h b/OpenGLEngine/OpenGLEngine/AeroSystem.h deleted file mode 100644 index 63ccebd..0000000 --- a/OpenGLEngine/OpenGLEngine/AeroSystem.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include "ECSConfig.h" -#include "AeroComponent.h" - -namespace Reality -{ - struct RigidBodyComponent; - struct TransformComponentV2; - class AeroSystem : public ECSSystem - { - public: - AeroSystem(); - void Update(float deltaTime); - Vector3 windspeed = Vector3(0, 0, 0); - private: - void UpdateForceFromTensor(ECSWorld& world, AeroComponent& aero, RigidBodyComponent& body, TransformComponentV2& transform); - }; -} diff --git a/OpenGLEngine/OpenGLEngine/BoxColliderComponent.h b/OpenGLEngine/OpenGLEngine/BoxColliderComponent.h deleted file mode 100644 index 7ef0bf3..0000000 --- a/OpenGLEngine/OpenGLEngine/BoxColliderComponent.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once -#include "ECSConfig.h" -#include - -namespace Reality -{ - struct BoxColliderComponent - { - BoxColliderComponent(ECSEntity _body = ECSEntity(), Vector3 _size = Vector3(0, 0, 0), Vector3 _offset = Vector3(0, 0, 0), Vector3 _eulerAngles = Vector3(0, 0, 0)) - : body(_body), size(_size), offset(_offset), rp3dId(-1) - { - SetRotation(_eulerAngles); - } - ECSEntity body; - Vector3 offset; - Vector3 size; - Quaternion orientation; - // Euler angles in degrees - inline void SetRotation(Vector3 eulerAngles) - { - glm::vec3 rotationInRads = glm::vec3(glm::radians(eulerAngles.x), - glm::radians(eulerAngles.y), glm::radians(eulerAngles.z)); - orientation = glm::quat(rotationInRads); - } - int rp3dId; - }; -} diff --git a/OpenGLEngine/OpenGLEngine/BoxColliderSystem.cpp b/OpenGLEngine/OpenGLEngine/BoxColliderSystem.cpp deleted file mode 100644 index 898ccc4..0000000 --- a/OpenGLEngine/OpenGLEngine/BoxColliderSystem.cpp +++ /dev/null @@ -1,95 +0,0 @@ -#include "BoxColliderSystem.h" -#include "RigidBodyComponent.h" -#include "RigidBodySystem.h" - -namespace Reality -{ - BoxColliderSystem::BoxColliderSystem(rp3d::CollisionWorld& _rp3dWorld) - :rp3dWorld(_rp3dWorld) - { - requireComponent(); - } - - void BoxColliderSystem::Update(float deltaTime) - { - std::vector rp3dShapesTemp; - std::vector aliveIds; - aliveIds.resize(rp3dShapes.size()); - int id = 0; - - for (auto e : getEntities()) - { - auto &boxCollider = e.getComponent(); - - if (boxCollider.body.isAlive() && boxCollider.body.hasComponent()) - { - auto &body = boxCollider.body.getComponent(); - - // Update RP3D Ids - // Calculate local rp3d transform - rp3d::Vector3 initPosition(boxCollider.offset.x, - boxCollider.offset.y, - boxCollider.offset.z); - rp3d::Quaternion initOrientation = rp3d::Quaternion(boxCollider.orientation.x, boxCollider.orientation.y, boxCollider.orientation.z, boxCollider.orientation.w); - rp3d::Transform rp3dtransform(initPosition, initOrientation); - - auto rp3dBody = getWorld().getSystemManager().getSystem().rp3dBodies[body.rp3dId]; - // If new rigidbody, create an entry - if (boxCollider.rp3dId < 0) - { - rp3d::BoxShape* shape = new rp3d::BoxShape(rp3d::Vector3(boxCollider.size.x, boxCollider.size.y, boxCollider.size.z) * 0.5f); - // Add the collision shape to the rigid body - - rp3d::ProxyShape * proxyShape = rp3dBody->addCollisionShape(shape, rp3dtransform); - proxyShape->setUserData(&boxCollider); - rp3dShapesTemp.push_back(proxyShape); - body.inertiaTensor[0][0] += (1.0f / 12.0f) * (pow(2 * boxCollider.size.y, 2) + pow(2 * boxCollider.size.z, 2)) / body.inverseMass; - body.inertiaTensor[1][1] += (1.0f / 12.0f) * (pow(2 * boxCollider.size.z, 2) + pow(2 * boxCollider.size.x, 2)) / body.inverseMass; - body.inertiaTensor[2][2] += (1.0f / 12.0f) * (pow(2 * boxCollider.size.x, 2) + pow(2 * boxCollider.size.y, 2)) / body.inverseMass; - boxCollider.rp3dId = id; - } - else if (boxCollider.body.isAlive()) - { - rp3d::ProxyShape * shape = rp3dShapes[boxCollider.rp3dId]; - shape->setLocalToBodyTransform(rp3dtransform); - aliveIds[boxCollider.rp3dId] = 1; - rp3dShapesTemp.push_back(shape); - boxCollider.rp3dId = id; - } - id++; - - if (boxCollider.body.hasComponent()) - { - auto& bodyTransform = boxCollider.body.getComponent(); - getWorld().data.renderUtil->DrawCube(bodyTransform.GetUnScaledTransformationMatrix() * Vector4(boxCollider.offset, 1.0f), boxCollider.size, bodyTransform.GetOrientation() * boxCollider.orientation); - } - } - else - { - // No need to kill it, the death of RB already killed it - aliveIds[boxCollider.rp3dId] = 1; - e.kill(); - } - - } - - for (int i = 0; i < aliveIds.size(); i++) - { - if (aliveIds[i] == 0) - { - if (rp3dShapes[i]) - { - auto shape = rp3dShapes[i]->getCollisionShapePublic(); - - if (rp3dShapes[i]->getBody() && rp3dShapes[i]->getBody()->getProxyShapesList()) - { - rp3dShapes[i]->getBody()->removeCollisionShape(rp3dShapes[i]); - } - delete shape; - } - } - } - - rp3dShapes = rp3dShapesTemp; - } -} diff --git a/OpenGLEngine/OpenGLEngine/BoxColliderSystem.h b/OpenGLEngine/OpenGLEngine/BoxColliderSystem.h deleted file mode 100644 index 189e426..0000000 --- a/OpenGLEngine/OpenGLEngine/BoxColliderSystem.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once -#include "ECSConfig.h" -#include "BoxColliderComponent.h" -#include "TransformComponentV2.h" -#include -namespace Reality -{ - class BoxColliderSystem : public ECSSystem - { - public: - BoxColliderSystem(rp3d::CollisionWorld& _rp3dWorld); - void Update(float deltaTime); - private: - rp3d::CollisionWorld& rp3dWorld; - std::vector rp3dShapes; - }; -} diff --git a/OpenGLEngine/OpenGLEngine/BuoyancyComponent.h b/OpenGLEngine/OpenGLEngine/BuoyancyComponent.h new file mode 100644 index 0000000..947a411 --- /dev/null +++ b/OpenGLEngine/OpenGLEngine/BuoyancyComponent.h @@ -0,0 +1,29 @@ +#pragma once +#include "ECSConfig.h" + +namespace Reality +{ + struct BuoyancyComponent + { + BuoyancyComponent(ECSEntity _target = ECSEntity(), Vector3 _localOffset = Vector3(0, 0, 0), const std::vector& _horizontalKeys = {}, float _componentLength = 6, + float _waterHeight = 0.0f, float _liquidDenisty = 10.0f, Vector3 _netForce = Vector3(0, 0, 0)) + : + target(_target), + offset(_localOffset), + componentLength(_componentLength), + waterHeight(_waterHeight), + liquidDensity(_liquidDenisty), + currentDensity(_liquidDenisty), + HorizontalKeys(_horizontalKeys) { + } + + ECSEntity target; + float componentLength; + float liquidDensity; + float currentDensity; + float waterHeight; + Vector3 offset; + Vector3 netForce; + std::vector HorizontalKeys; + }; +} diff --git a/OpenGLEngine/OpenGLEngine/BuoyancySystem.cpp b/OpenGLEngine/OpenGLEngine/BuoyancySystem.cpp new file mode 100644 index 0000000..2fe4fc4 --- /dev/null +++ b/OpenGLEngine/OpenGLEngine/BuoyancySystem.cpp @@ -0,0 +1,80 @@ +#include "BuoyancySystem.h" +#include "ForceAndTorqueAccumulatorComponent.h" +#include "RigidbodyComponent.h" +#include "ThrusterComponent.h" +#include "LifeTimeComponent.h" + +namespace Reality +{ + BuoyancySystem::BuoyancySystem() + { + requireComponent(); + requireComponent(); + } + + void BuoyancySystem::Update(float deltaTime) + { + + for (auto e : getEntities()) + { + auto& buoyancy = e.getComponent(); + auto& transform = e.getComponent(); + auto& boatRigidbody = buoyancy.target.getComponent(); + auto& boatTran = buoyancy.target.getComponent(); + auto& forceAcc = buoyancy.target.getComponent(); + + timer += deltaTime; + if (timer > 1000) timer = 0.0f; + + Vector3 newPosition = boatTran.LocalToWorldPosition(buoyancy.offset); + transform.SetPosition(newPosition); + transform.SetOrientation(boatTran.GetOrientation()); + + float volume = pow(buoyancy.componentLength, 3); + float depth = transform.GetPosition().y - buoyancy.componentLength / 2; + Vector3 tForce = Vector3(0); + + for (int key : buoyancy.HorizontalKeys) { + if (glfwGetKey(getWorld().data.renderUtil->window->glfwWindow, key) == GLFW_PRESS) { + if (buoyancy.currentDensity > buoyancy.liquidDensity) + buoyancy.currentDensity -= buoyancy.liquidDensity * 0.01; + else + buoyancy.currentDensity = buoyancy.liquidDensity; + } + else { + if (buoyancy.currentDensity < buoyancy.liquidDensity) + buoyancy.currentDensity += buoyancy.liquidDensity * 0.01; + else + buoyancy.currentDensity = buoyancy.liquidDensity; + } + } + + if (depth <= buoyancy.waterHeight - buoyancy.componentLength && depth + buoyancy.componentLength > -cubeSideLength + buoyancy.waterHeight) { + if (buoyancy.offset.z > 0) { + float densityOffset = 0.2 * sin(timer) + 1; + tForce.y += deltaTime * buoyancy.currentDensity * densityOffset * volume; + } + else { + tForce.y += deltaTime * buoyancy.currentDensity * volume; + } + buoyancy.netForce = buoyancy.netForce + (deltaTime * 10 * (tForce - buoyancy.netForce)); + } + + else if (depth + buoyancy.componentLength > -cubeSideLength + buoyancy.waterHeight) { + if (buoyancy.offset.z > 0) { + float densityOffset = 0.2 * sin(timer) + 1; + tForce.y += deltaTime * buoyancy.currentDensity * densityOffset * (buoyancy.waterHeight - depth) * buoyancy.componentLength * buoyancy.componentLength; + } + else { + tForce.y += deltaTime * buoyancy.currentDensity * (buoyancy.waterHeight - depth) * buoyancy.componentLength * buoyancy.componentLength; + } + buoyancy.netForce = buoyancy.netForce + (deltaTime * 10 * (tForce - buoyancy.netForce)); + } + + forceAcc.AddForceAtPoint(tForce, transform.GetPosition(), boatTran.GetPosition()); + + getWorld().data.renderUtil->DrawCube(Vector3(0.0f, buoyancy.waterHeight - 20, 0.0f), Vector3(cubeSideLength, 20, cubeSideLength), Vector3(0), Color::Blue); + } + + } +} diff --git a/OpenGLEngine/OpenGLEngine/BuoyancySystem.h b/OpenGLEngine/OpenGLEngine/BuoyancySystem.h new file mode 100644 index 0000000..41d41b0 --- /dev/null +++ b/OpenGLEngine/OpenGLEngine/BuoyancySystem.h @@ -0,0 +1,16 @@ +#pragma once +#include "ECSConfig.h" +#include "BuoyancyComponent.h" +#include "TransformComponentV2.h" + +namespace Reality +{ + class BuoyancySystem : public ECSSystem + { + public: + BuoyancySystem(); + void Update(float deltaTime); + float cubeSideLength = 3000; + float timer = 0.0f; + }; +} diff --git a/OpenGLEngine/OpenGLEngine/CameraLookComponent.h b/OpenGLEngine/OpenGLEngine/CameraLookComponent.h deleted file mode 100644 index 80c44a4..0000000 --- a/OpenGLEngine/OpenGLEngine/CameraLookComponent.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#include "ECSConfig.h" - -namespace Reality -{ - struct CameraLookComponent - { - CameraLookComponent() - { - - } - }; -} diff --git a/OpenGLEngine/OpenGLEngine/CameraLookSystem.cpp b/OpenGLEngine/OpenGLEngine/CameraLookSystem.cpp deleted file mode 100644 index 420c611..0000000 --- a/OpenGLEngine/OpenGLEngine/CameraLookSystem.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "CameraLookSystem.h" -#include "MouseMoveEvent.h" - -namespace Reality -{ - CameraLookSystem::CameraLookSystem() - { - requireComponent(); - } - - void CameraLookSystem::Update(float deltaTime) - { - for (auto e : getEntities()) - { - Camera& camera = getWorld().data.renderUtil->camera; - auto mouseMoveEvents = getWorld().getEventManager().getEvents(); - for (auto event : mouseMoveEvents) - { - camera.ProcessMouseMovement(event.deltaX, event.deltaY); - } - } - } -} diff --git a/OpenGLEngine/OpenGLEngine/ContactEvent.h b/OpenGLEngine/OpenGLEngine/ContactEvent.h deleted file mode 100644 index c8ef717..0000000 --- a/OpenGLEngine/OpenGLEngine/ContactEvent.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once -#include "ECSConfig.h" -#include "RigidBodyComponent.h" - -namespace Reality -{ - struct ContactEvent - { - ContactEvent(ECSEntity _bodyA = ECSEntity(), ECSEntity _bodyB = ECSEntity(), Vector3 _normal = Vector3(0, 0 , 0), float _penetrationDepth = 0, Vector3 _localPointOnShape1 = Vector3(0, 0, 0), Vector3 _localPointOnShape2 = Vector3(0, 0, 0), Vector3 _worldPoint1 = Vector3(0, 0, 0), Vector3 _worldPoint2 = Vector3(0, 0, 0), float _restitution = 1.0f) - :entityA(_bodyA), entityB(_bodyB), normal(_normal), penetrationDepth(_penetrationDepth), localPointOnShape1(_localPointOnShape1), localPointOnShape2(_localPointOnShape2), worldPoint1(_worldPoint1), worldPoint2(_worldPoint2), restitution(_restitution) - { - - } - - ECSEntity entityA; - - ECSEntity entityB; - - /// Normalized normal vector of the contact (from body1 toward body2) in world space - Vector3 normal; - - /// Penetration depth - float penetrationDepth; - - /// Contact point on proxy shape 1 in local-space of proxy shape 1 - Vector3 localPointOnShape1; - - /// Contact point on proxy shape 2 in local-space of proxy shape 2 - Vector3 localPointOnShape2; - - /// Contact point on proxy shape 1 in world-space - Vector3 worldPoint1; - - /// Contact point on proxy shape 2 in world-space - Vector3 worldPoint2; - - /// Coefficient Of restitution - float restitution; - }; -} diff --git a/OpenGLEngine/OpenGLEngine/ContactGenerationSystem.cpp b/OpenGLEngine/OpenGLEngine/ContactGenerationSystem.cpp deleted file mode 100644 index 3ecb9f3..0000000 --- a/OpenGLEngine/OpenGLEngine/ContactGenerationSystem.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "ContactGenerationSystem.h" - -namespace Reality -{ - ContactGenerationSystem::ContactGenerationSystem(rp3d::CollisionWorld& _rp3dWorld) : rp3dWorld(_rp3dWorld) - { - - } - - void ContactGenerationSystem::Update(float deltaTime) - { - if (contactReciever == nullptr) - { - contactReciever = new ContactInfoReciever(getWorld()); - } - rp3dWorld.testCollision(contactReciever); - } - - ContactGenerationSystem::~ContactGenerationSystem() - { - delete contactReciever; - } -} diff --git a/OpenGLEngine/OpenGLEngine/ContactGenerationSystem.h b/OpenGLEngine/OpenGLEngine/ContactGenerationSystem.h deleted file mode 100644 index 14c2b24..0000000 --- a/OpenGLEngine/OpenGLEngine/ContactGenerationSystem.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include "ECSConfig.h" -#include "ContactInfoReciever.h" -#include - -namespace Reality -{ - class ContactGenerationSystem : public ECSSystem - { - public: - ContactGenerationSystem(rp3d::CollisionWorld& _rp3dWorld); - void Update(float deltaTime); - ~ContactGenerationSystem(); - private: - rp3d::CollisionWorld& rp3dWorld; - ContactInfoReciever* contactReciever = nullptr; - }; -} diff --git a/OpenGLEngine/OpenGLEngine/ContactInfoReciever.h b/OpenGLEngine/OpenGLEngine/ContactInfoReciever.h deleted file mode 100644 index f472fdd..0000000 --- a/OpenGLEngine/OpenGLEngine/ContactInfoReciever.h +++ /dev/null @@ -1,66 +0,0 @@ -#pragma once -#include "ECSConfig.h" -#include "ContactEvent.h" -#include "RigidBodyData.h" -#include -#include -#include -namespace Reality -{ - class ContactInfoReciever : public rp3d::CollisionCallback - { - public: - ContactInfoReciever(ECSWorld& _world) : world(_world) {} - ECSWorld& world; - void notifyContact(const CollisionCallbackInfo& collisionCallbackInfo) - { - rp3d::ContactManifoldListElement * listElem = collisionCallbackInfo.contactManifoldElements; - // For each contact manifold - for (; listElem != nullptr; listElem = listElem->getNext()) { - rp3d::ContactManifold * manifold = listElem->getContactManifold(); - // Get the contact point - rp3d::ContactPoint * point = manifold->getContactPoints(); - // For each contact point of the manifold - for (int i = 0; i < manifold->getNbContactPoints(); i++) { - // Get the world - space contact point on body 1 - rp3d::Vector3 pos1 = point->getLocalPointOnShape1(); - // Get the world - space contact point on body 1 - rp3d::Vector3 pos2 = point->getLocalPointOnShape2(); - // Get the world - space contact normal - rp3d::Vector3 normal = point->getNormal(); - normal.normalize(); - // Get the penetration - rp3d::decimal penetration = point->getPenetrationDepth(); - // Get Body 1 - rp3d::CollisionBody* body1 = manifold->getBody1(); - assert(body1); - RigidBodyData* bodyA = (RigidBodyData*)(manifold->getBody1()->getUserData()); - // Get Body 2 - rp3d::CollisionBody* body2 = manifold->getBody2(); - assert(body2); - RigidBodyData* bodyB = (RigidBodyData*)(manifold->getBody2()->getUserData()); - // Get Collider 1 - rp3d::ProxyShape* shape1 = manifold->getShape1(); - assert(shape1); - // Get Collider 2 - rp3d::ProxyShape* shape2 = manifold->getShape2(); - assert(shape2); - // Get World Point 1 - rp3d::Vector3 worldPos1 = shape1->getLocalToWorldTransform() * pos1; - // Get World Point 2 - rp3d::Vector3 worldPos2 = shape2->getLocalToWorldTransform() * pos2; - // Create a contact event - world.getEventManager().emitEvent(bodyA->entity, bodyB->entity, - Vector3(normal.x, normal.y, normal.z), - penetration, - Vector3(pos1.x, pos1.y, pos1.z), - Vector3(pos2.x, pos2.y, pos2.z), - Vector3(worldPos1.x, worldPos1.y, worldPos1.z), - Vector3(worldPos2.x, worldPos2.y, worldPos2.z)); - // Go to the next point in the list - point = point->getNext(); - } - } - } - }; -} diff --git a/OpenGLEngine/OpenGLEngine/ContactResolutionSystem.cpp b/OpenGLEngine/OpenGLEngine/ContactResolutionSystem.cpp deleted file mode 100644 index 5999763..0000000 --- a/OpenGLEngine/OpenGLEngine/ContactResolutionSystem.cpp +++ /dev/null @@ -1,225 +0,0 @@ -#include "ContactResolutionSystem.h" -#include "TransformComponentV2.h" -#include "RigidBodyComponent.h" -#include - -namespace Reality -{ - - ContactResolutionSystem::ContactResolutionSystem(rp3d::CollisionWorld& _rp3dWorld) : rp3dWorld(_rp3dWorld) - { - } - - void ContactResolutionSystem::Update(float deltaTime) - { - auto contactEvents = getWorld().getEventManager().getEvents(); - for (auto& contact : contactEvents) - { - ResolvePenetration(contact); - ResolveVelocity(contact); - } - getWorld().data.renderUtil->RenderText("Num Contacts = " + to_string(contactEvents.size()), 1920 * 0.5f - 100, 1080 * 0.5f, 0.5f, Color::Red); - } - void ContactResolutionSystem::ResolvePenetration(ContactEvent & contact) - { - // Get Rigidbodies involved - auto& rbA = contact.entityA.getComponent(); - auto& rbB = contact.entityB.getComponent(); - auto& transformA = contact.entityA.getComponent(); - auto& transformB = contact.entityB.getComponent(); - - // Calculate contact point as avg - Vector3 contactPoint = (contact.worldPoint1 + contact.worldPoint2) * 0.5f; - - // Relative Positions - Vector3 relativePositionA = contact.worldPoint1 - transformA.GetPosition(); - Vector3 relativePositionB = contact.worldPoint2 - transformB.GetPosition(); - contact.normal *= -1; - // World Inertia Tensors - Mat3 worldInvInertiaTensorA = rbA.worldInverseInertiaTensor(transformA.GetRotationMatrix()); - Mat3 worldInvInertiaTensorB = rbB.worldInverseInertiaTensor(transformB.GetRotationMatrix()); - - float totalInertia = 0; - - Vector3 angularInertiaWorldA = glm::cross(relativePositionA, contact.normal); - angularInertiaWorldA = worldInvInertiaTensorA * angularInertiaWorldA; - angularInertiaWorldA = glm::cross(angularInertiaWorldA, relativePositionA); - - float angularInertiaA = glm::dot(angularInertiaWorldA, contact.normal); - float linearInertiaA = rbA.inverseMass; - totalInertia += angularInertiaA + linearInertiaA; - - Vector3 angularInertiaWorldB = glm::cross(relativePositionB, contact.normal); - angularInertiaWorldB = worldInvInertiaTensorB * angularInertiaWorldB; - angularInertiaWorldB = glm::cross(angularInertiaWorldB, relativePositionB); - - float angularInertiaB = glm::dot(angularInertiaWorldB, contact.normal); - float linearInertiaB = rbB.inverseMass; - totalInertia += angularInertiaB + linearInertiaB; - - // Total Moves - float inverseInertia = 1 / totalInertia; - float linearMoveA = contact.penetrationDepth * linearInertiaA * inverseInertia; - float linearMoveB = -contact.penetrationDepth * linearInertiaB * inverseInertia; - float angularMoveA = contact.penetrationDepth * angularInertiaA * inverseInertia; - float angularMoveB = -contact.penetrationDepth * angularInertiaB * inverseInertia; - - float limitA = angularLimitConstant * glm::length(relativePositionA); - if (abs(angularMoveA) > limitA) - { - float totalMoveA = linearMoveA + angularMoveA; - // Set the new angular move, with the same sign as before. - if (angularMoveA >= 0) - { - angularMoveA = limitA; - } else - { - angularMoveA = -limitA; - } - // Make the linear move take the extra slack. - linearMoveA = totalMoveA - angularMoveA; - } - - float limitB = angularLimitConstant * glm::length(relativePositionB); - if (abs(angularMoveB) > limitB) - { - float totalMoveB = linearMoveB + angularMoveB; - // Set the new angular move, with the same sign as before. - if (angularMoveB >= 0) - { - angularMoveB = limitB; - } - else - { - angularMoveB = -limitB; - } - // Make the linear move take the extra slack. - linearMoveB = totalMoveB - angularMoveB; - } - - // Update Linear Moves - transformA.SetPosition(transformA.GetPosition() + contact.normal * linearMoveA); - transformB.SetPosition(transformB.GetPosition() + contact.normal * linearMoveB); - - // Update Rotational Moves - // A - Vector3 impulsiveTorqueA = glm::cross(relativePositionA, contact.normal); - Vector3 impulsePerMoveA = worldInvInertiaTensorA * impulsiveTorqueA; - - Vector3 rotationPerMoveA = impulsePerMoveA * (1 / angularInertiaA); - Vector3 rotationA = rotationPerMoveA * angularMoveA; - - glm::quat rotationQuatA = glm::quat(0, rotationA.x, rotationA.y, rotationA.z); - transformA.SetOrientation(glm::normalize(transformA.GetOrientation() + 0.5f * rotationQuatA * transformA.GetOrientation())); - - // B - Vector3 impulsiveTorqueB = glm::cross(relativePositionB, contact.normal); - Vector3 impulsePerMoveB = worldInvInertiaTensorB * impulsiveTorqueB; - - Vector3 rotationPerMoveB = impulsePerMoveB * (1 / angularInertiaB); - Vector3 rotationB = rotationPerMoveB * angularMoveB; - - glm::quat rotationQuatB = glm::quat(0, rotationB.x, rotationB.y, rotationB.z); - transformB.SetOrientation(glm::normalize(transformB.GetOrientation() + 0.5f * rotationQuatB * transformB.GetOrientation())); - contact.normal *= -1; - - } - void ContactResolutionSystem::ResolveVelocity(ContactEvent & contact) - { - // Get Rigidbodies involved - auto& rbA = contact.entityA.getComponent(); - auto& rbB = contact.entityB.getComponent(); - auto& transformA = contact.entityA.getComponent(); - auto& transformB = contact.entityB.getComponent(); - - // Calculate contact point as avg - Vector3 contactPoint = (contact.worldPoint1 + contact.worldPoint2) * 0.5f; - - // Calculate contact point basis - Vector3 contactY; - Vector3 contactZ; - Mat3 contactLocalToWorld = Mat3(1.0f); - CalculateContactBasis(contact.normal, contactLocalToWorld, contactY, contactZ); - getWorld().data.renderUtil->DrawLine(contactPoint, contactPoint + 5.0f * contact.normal, Color::Red); - getWorld().data.renderUtil->DrawLine(contactPoint, contactPoint + 5.0f * contactY, Color::Green); - getWorld().data.renderUtil->DrawLine(contactPoint, contactPoint + 5.0f * contactZ, Color::Blue); - - // Relative Positions - Vector3 relativePositionA = contact.worldPoint1 - transformA.GetPosition(); - Vector3 relativePositionB = contact.worldPoint2 - transformB.GetPosition(); - - // World Inertia Tensors - Mat3 worldInvInertiaTensorA = rbA.worldInverseInertiaTensor(transformA.GetRotationMatrix()); - Mat3 worldInvInertiaTensorB = rbB.worldInverseInertiaTensor(transformB.GetRotationMatrix()); - - // Calculate velocity Per Unit Impulse - // Body A - Vector3 torquePerUnitImpulseA = glm::cross(relativePositionA, contact.normal); - Vector3 rotationPerUnitImpulseA = worldInvInertiaTensorA * torquePerUnitImpulseA; - Vector3 deltaVelWorldA = glm::cross(rotationPerUnitImpulseA, relativePositionA); - - float deltaVel = glm::dot(deltaVelWorldA, contact.normal); - deltaVel += rbA.inverseMass; - - // Body B - Vector3 torquePerUnitImpulseB = glm::cross(relativePositionB, contact.normal); - Vector3 rotationPerUnitImpulseB = worldInvInertiaTensorB * torquePerUnitImpulseB; - Vector3 deltaVelWorldB = glm::cross(rotationPerUnitImpulseB, relativePositionB); - - deltaVel += glm::dot(deltaVelWorldB, contact.normal); - deltaVel += rbB.inverseMass; - - // Closing Velocity - Vector3 velocityA = glm::cross(rbA.angularVelocity, relativePositionA); - velocityA += rbA.velocity; - - Vector3 velocityB = glm::cross(rbB.angularVelocity, relativePositionB); - velocityB += rbB.velocity; - - Vector3 closingVelocityWorld = velocityA - velocityB; - Vector3 closingVelocityLocal = glm::transpose(contactLocalToWorld) * closingVelocityWorld; - - if (closingVelocityLocal.x < 0) - { - return; - } - // Delta Velocity and impulse - float desiredDeltaVelocityLocal = -closingVelocityLocal.x * (1 + 0.4f); - Vector3 impulseContact = Vector3(desiredDeltaVelocityLocal / deltaVel, 0, 0); - Vector3 impulseA = contactLocalToWorld * impulseContact; - Vector3 impulseB = -impulseA; - - // Calculate Velocity Change - // A - Vector3 velocityChangeA = impulseA * rbA.inverseMass; - Vector3 rotationalTorqueA = glm::cross(relativePositionA, impulseA); - Vector3 angularVelocityChangeA = worldInvInertiaTensorA * rotationalTorqueA; - rbA.velocity += velocityChangeA; - rbA.angularVelocity += angularVelocityChangeA; - // B - Vector3 velocityChangeB = impulseB * rbB.inverseMass; - Vector3 rotationalTorqueB = glm::cross(relativePositionB, impulseB); - Vector3 angularVelocityChangeB = worldInvInertiaTensorB * rotationalTorqueB; - rbB.velocity += velocityChangeB; - rbB.angularVelocity += angularVelocityChangeB; - - // Debug Drawing - getWorld().data.renderUtil->DrawSphere(contact.worldPoint1, 0.4f, Color::Red); - getWorld().data.renderUtil->DrawSphere(contact.worldPoint2, 0.4f, Color::Blue); - getWorld().data.renderUtil->DrawLine(contact.worldPoint1, contact.worldPoint2, Color::Beige); - } - void ContactResolutionSystem::CalculateContactBasis(Vector3 contactNormal, Mat3 & transformationMat, Vector3 & y, Vector3 & z) - { - Vector3 possibleYAxis = Vector3(0, 1.0f, 0); - if (glm::length(glm::cross(possibleYAxis, contactNormal)) <= 0.01f) - { - possibleYAxis = Vector3(0, 0, 1.0f); - } - z = glm::normalize(glm::cross(contactNormal, possibleYAxis)); - y = glm::normalize(glm::cross(z, contactNormal)); - - transformationMat = Mat3(contactNormal.x, contactNormal.y, contactNormal.z, - y.x, y.y, y.z, - z.x, z.y, z.z); - } -} diff --git a/OpenGLEngine/OpenGLEngine/ContactResolutionSystem.h b/OpenGLEngine/OpenGLEngine/ContactResolutionSystem.h deleted file mode 100644 index 2b70f08..0000000 --- a/OpenGLEngine/OpenGLEngine/ContactResolutionSystem.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include "ECSConfig.h" -#include "ContactEvent.h" -#include - -namespace Reality -{ - class ContactResolutionSystem : public ECSSystem - { - public: - ContactResolutionSystem(rp3d::CollisionWorld& _rp3dWorld); - void Update(float deltaTime); - rp3d::CollisionWorld& rp3dWorld; - float angularLimitConstant = 0.2f; - private: - void ResolvePenetration(ContactEvent& contact); - void ResolveVelocity(ContactEvent& contact); - void CalculateContactBasis(Vector3 contactNormal, Mat3& transformationMat, Vector3& y, Vector3& z); - }; -} \ No newline at end of file diff --git a/OpenGLEngine/OpenGLEngine/DragComponent.h b/OpenGLEngine/OpenGLEngine/DragComponent.h new file mode 100644 index 0000000..0f91467 --- /dev/null +++ b/OpenGLEngine/OpenGLEngine/DragComponent.h @@ -0,0 +1,16 @@ +#pragma once +#include "ECSConfig.h" + +namespace Reality +{ + struct DragComponent + { + DragComponent(float _linearDrag = 0.7f, float _angularDrag = 0.7f) + :linearDrag(_linearDrag), angularDrag(_angularDrag) + { + + } + float linearDrag; + float angularDrag; + }; +} diff --git a/OpenGLEngine/OpenGLEngine/DragSystem.cpp b/OpenGLEngine/OpenGLEngine/DragSystem.cpp new file mode 100644 index 0000000..8b51198 --- /dev/null +++ b/OpenGLEngine/OpenGLEngine/DragSystem.cpp @@ -0,0 +1,22 @@ +#include "DragSystem.h" + +namespace Reality +{ + DragSystem::DragSystem() + { + requireComponent(); + requireComponent(); + } + + void DragSystem::Update(float deltaTime) + { + for (auto e : getEntities()) + { + auto& rigidbody = e.getComponent(); + auto& drag = e.getComponent(); + + rigidbody.velocity *= pow(1.0f - drag.linearDrag, deltaTime); + rigidbody.angularVelocity *= pow(1.0f - drag.angularDrag, deltaTime); + } + } +} diff --git a/OpenGLEngine/OpenGLEngine/DragSystem.h b/OpenGLEngine/OpenGLEngine/DragSystem.h new file mode 100644 index 0000000..5636485 --- /dev/null +++ b/OpenGLEngine/OpenGLEngine/DragSystem.h @@ -0,0 +1,14 @@ +#pragma once +#include "ECSConfig.h" +#include "RigidbodyComponent.h" +#include "DragComponent.h" + +namespace Reality +{ + class DragSystem : public ECSSystem + { + public: + DragSystem(); + void Update(float deltaTime); + }; +} diff --git a/OpenGLEngine/OpenGLEngine/FlighSimulatorComponent.h b/OpenGLEngine/OpenGLEngine/FlighSimulatorComponent.h deleted file mode 100644 index 6d4420c..0000000 --- a/OpenGLEngine/OpenGLEngine/FlighSimulatorComponent.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include "ECSConfig.h" - -namespace Reality -{ - struct FlighSimulatorComponent - { - FlighSimulatorComponent(Vector3 _propulsion = Vector3(0.0f ,0.0f, 1000.0f)) - :propulsion(_propulsion) - { - - } - Vector3 propulsion; - }; -} diff --git a/OpenGLEngine/OpenGLEngine/FlightSimulatorSystem.cpp b/OpenGLEngine/OpenGLEngine/FlightSimulatorSystem.cpp deleted file mode 100644 index a2ff9d5..0000000 --- a/OpenGLEngine/OpenGLEngine/FlightSimulatorSystem.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "FlightSimulatorSystem.h" -#include "LifeTimeComponent.h" - -namespace Reality -{ - FlightSimulatorSystem::FlightSimulatorSystem() - { - requireComponent(); - requireComponent(); - requireComponent(); - } - - void FlightSimulatorSystem::Update(float deltaTime) - { - timer += deltaTime; - for (auto e : getEntities()) - { - auto& rigidbody = e.getComponent(); - auto& transform = e.getComponent(); - auto& flight = e.getComponent(); - - rigidbody.AddForce(transform.LocalToWorldDirection(flight.propulsion)); - //rigidbody.AddForce(Vector3(0, -10, 0)); - - // smoke - if (timer > 0.1f) - { - /*for (int i = 0; i < 3; i++) - { - auto e = getWorld().createEntity(); - e.addComponent(transform.GetPosition() + Vector3(RANDOM_FLOAT(-5.0f, 5.0f), RANDOM_FLOAT(-5.0f, 5.0f), RANDOM_FLOAT(-5.0f, 5.0f)) - transform.Forward() * 15.0f); - e.addComponent(7.0f); - }*/ - auto e = getWorld().createEntity(); - e.addComponent(transform.GetPosition() - transform.Forward() * 15.0f); - e.addComponent(7.0f); - timer = 0; - } - } - - if (getEntities().size() > 0) - { - float width = getWorld().data.renderUtil->window->width; - float height = getWorld().data.renderUtil->window->height; - - getWorld().data.renderUtil->RenderText("W , S - Pitch Controls", width / 2 - 100.0f, 60.0f, 0.4f, Color::Orange); - getWorld().data.renderUtil->RenderText("A , D - Yaw Controls", width / 2 - 100.0f, 35.0f, 0.4f, Color::Orange); - getWorld().data.renderUtil->RenderText("Q , E - Roll Controls", width / 2 - 100.0f, 10.0f, 0.4f, Color::Orange); - } - - } -} diff --git a/OpenGLEngine/OpenGLEngine/ForceAndTorqueAccumulatorComponent.h b/OpenGLEngine/OpenGLEngine/ForceAndTorqueAccumulatorComponent.h new file mode 100644 index 0000000..7d9f67b --- /dev/null +++ b/OpenGLEngine/OpenGLEngine/ForceAndTorqueAccumulatorComponent.h @@ -0,0 +1,58 @@ +#pragma once +#include "ECSConfig.h" + +namespace Reality +{ + struct ForceAndTorqueAccumulatorComponent + { + ForceAndTorqueAccumulatorComponent(float _mass = 1.0f, float _inertia = 1.0f) + : inverseMass(1.0f / _mass), forceAccumulator(Vector3(0, 0, 0)), + inertiaTensor(Mat3(_inertia)), torqueAccumulator(Vector3(0, 0, 0)) + { + + } + float inverseMass; + Mat3 inertiaTensor; + + inline void AddForce(const Vector3& force) + { + forceAccumulator += force; + } + inline void ResetForceAccumulator() + { + forceAccumulator = Vector3(0, 0, 0); + } + inline const Vector3& GetAccumulatedForce() + { + return forceAccumulator; + } + + inline void AddTorque(const Vector3& torque) + { + torqueAccumulator += torque; + } + inline void ResetTorqueAccumulator() + { + torqueAccumulator = Vector3(0, 0, 0); + } + inline const Vector3& GetAccumulatedTorque() + { + return torqueAccumulator; + } + + inline void AddForceAtPoint(const Vector3& force, const Vector3& point, const Vector3& origin) + { + AddForce(force); + AddTorque(glm::cross(point - origin, force)); + } + + inline const Mat3& GetWorldInverseInertiaTensor(const Mat3& localToWorldRotation) + { + return localToWorldRotation * inertiaTensor * glm::inverse(localToWorldRotation); + } + + private: + Vector3 forceAccumulator; + Vector3 torqueAccumulator; + }; +} diff --git a/OpenGLEngine/OpenGLEngine/ForceAndTorqueAccumulatorSystem.cpp b/OpenGLEngine/OpenGLEngine/ForceAndTorqueAccumulatorSystem.cpp index 3b91bdb..8f1cf94 100644 --- a/OpenGLEngine/OpenGLEngine/ForceAndTorqueAccumulatorSystem.cpp +++ b/OpenGLEngine/OpenGLEngine/ForceAndTorqueAccumulatorSystem.cpp @@ -5,23 +5,24 @@ namespace Reality ForceAndTorqueAccumulatorSystem::ForceAndTorqueAccumulatorSystem() { requireComponent(); - requireComponent(); + requireComponent(); + requireComponent(); } void ForceAndTorqueAccumulatorSystem::Update(float deltaTime) { for (auto e : getEntities()) { - auto &rigidbody = e.getComponent(); - auto &transform = e.getComponent(); + auto& transform = e.getComponent(); + auto& rigidbody = e.getComponent(); + auto& forceAndTorqueAcc = e.getComponent(); - rigidbody.accelaration = rigidbody.GetForce() * rigidbody.inverseMass; - rigidbody.ResetForceAccumulator(); + rigidbody.acceleration = forceAndTorqueAcc.GetAccumulatedForce() * forceAndTorqueAcc.inverseMass; + forceAndTorqueAcc.ResetForceAccumulator(); - Mat3 rotMat = transform.GetRotationMatrix(); - rigidbody.angularAccelaration = rigidbody.worldInverseInertiaTensor(rotMat) - * rigidbody.GetTorque(); - rigidbody.ResetTorqueAccumulator(); + Mat3 worldInvInertia = forceAndTorqueAcc.GetWorldInverseInertiaTensor(transform.GetRotationMatrix()); + rigidbody.angularAcceleration = worldInvInertia * forceAndTorqueAcc.GetAccumulatedTorque(); + forceAndTorqueAcc.ResetTorqueAccumulator(); } } } diff --git a/OpenGLEngine/OpenGLEngine/ForceAndTorqueAccumulatorSystem.h b/OpenGLEngine/OpenGLEngine/ForceAndTorqueAccumulatorSystem.h index d4f0221..cea9f11 100644 --- a/OpenGLEngine/OpenGLEngine/ForceAndTorqueAccumulatorSystem.h +++ b/OpenGLEngine/OpenGLEngine/ForceAndTorqueAccumulatorSystem.h @@ -1,6 +1,7 @@ #pragma once #include "ECSConfig.h" -#include "RigidBodyComponent.h" +#include "RigidbodyComponent.h" +#include "ForceAndTorqueAccumulatorComponent.h" #include "TransformComponentV2.h" namespace Reality diff --git a/OpenGLEngine/OpenGLEngine/GravityForceGeneratorSystem.cpp b/OpenGLEngine/OpenGLEngine/GravityForceGeneratorSystem.cpp deleted file mode 100644 index c1df543..0000000 --- a/OpenGLEngine/OpenGLEngine/GravityForceGeneratorSystem.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "GravityForceGeneratorSystem.h" - - -namespace Reality -{ - GravityForceGeneratorSystem::GravityForceGeneratorSystem() - { - requireComponent(); - } - - - void GravityForceGeneratorSystem::Update(float deltaTime) - { - for (auto e : getEntities()) - { - auto &particle = e.getComponent(); - particle.AddForce(gravity * particle.gravityScale / particle.inverseMass); - } - - } -} diff --git a/OpenGLEngine/OpenGLEngine/GravityForceGeneratorSystem.h b/OpenGLEngine/OpenGLEngine/GravityForceGeneratorSystem.h deleted file mode 100644 index c9a720f..0000000 --- a/OpenGLEngine/OpenGLEngine/GravityForceGeneratorSystem.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include "ECSConfig.h" -#include "ParticleComponent.h" - -namespace Reality -{ - class GravityForceGeneratorSystem : public ECSSystem - { - public: - Vector3 gravity = Vector3(0, -9.8f, 0); - GravityForceGeneratorSystem(); - void Update(float deltaTime); - }; -} - diff --git a/OpenGLEngine/OpenGLEngine/InfiniteSpawnComponent.h b/OpenGLEngine/OpenGLEngine/InfiniteSpawnComponent.h deleted file mode 100644 index 8a81892..0000000 --- a/OpenGLEngine/OpenGLEngine/InfiniteSpawnComponent.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include "ECSConfig.h" - -namespace Reality -{ - struct InfiniteSpawnComponent - { - InfiniteSpawnComponent(float _height = 0) - : height(_height) - { - - } - float height; - }; -} diff --git a/OpenGLEngine/OpenGLEngine/InfiniteSpawnSystem.cpp b/OpenGLEngine/OpenGLEngine/InfiniteSpawnSystem.cpp deleted file mode 100644 index ae10ce8..0000000 --- a/OpenGLEngine/OpenGLEngine/InfiniteSpawnSystem.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "InfiniteSpawnSystem.h" -#include "SpawnTargetEvent.h" - -namespace Reality -{ - InfiniteSpawnSystem::InfiniteSpawnSystem() - { - requireComponent(); - requireComponent(); - } - - void InfiniteSpawnSystem::Update(float deltaTime) - { - auto targetEvents = getWorld().getEventManager().getEvents(); - - if (targetEvents.size() > 0) - { - Vector3 target = targetEvents[0].targetPos; - - for (auto e : getEntities()) - { - auto& spawn = e.getComponent(); - auto& transform = e.getComponent(); - - if (abs(target.z - transform.GetPosition().z) > 2050.0f) - { - transform.SetPosition(transform.GetPosition() + (target.z > transform.GetPosition().z ? 4050.0f : -4050.0f) * Vector3(0, 0, 1)); - spawn.height = RANDOM_FLOAT(100.0f, 500.0f); - } - getWorld().data.renderUtil->DrawCube(transform.GetPosition() + spawn.height * 0.5f * Vector3(0, 1, 0), Vector3(50.0f, spawn.height, 50.0f)); - } - } - } -} diff --git a/OpenGLEngine/OpenGLEngine/InfiniteSpawnSystem.h b/OpenGLEngine/OpenGLEngine/InfiniteSpawnSystem.h deleted file mode 100644 index cb95b34..0000000 --- a/OpenGLEngine/OpenGLEngine/InfiniteSpawnSystem.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include "ECSConfig.h" -#include "InfiniteSpawnComponent.h" -#include "TransformComponentV2.h" - -namespace Reality -{ - class InfiniteSpawnSystem : public ECSSystem - { - public: - InfiniteSpawnSystem(); - void Update(float deltaTime); - }; -} diff --git a/OpenGLEngine/OpenGLEngine/InfiniteSpawnTargetComponent.h b/OpenGLEngine/OpenGLEngine/InfiniteSpawnTargetComponent.h deleted file mode 100644 index 317a9ad..0000000 --- a/OpenGLEngine/OpenGLEngine/InfiniteSpawnTargetComponent.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#include "ECSConfig.h" - -namespace Reality -{ - struct InfiniteSpawnTargetComponent - { - InfiniteSpawnTargetComponent() - { - - } - }; -} diff --git a/OpenGLEngine/OpenGLEngine/InfiniteSpawnTargetSystem.cpp b/OpenGLEngine/OpenGLEngine/InfiniteSpawnTargetSystem.cpp deleted file mode 100644 index 5434839..0000000 --- a/OpenGLEngine/OpenGLEngine/InfiniteSpawnTargetSystem.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "InfiniteSpawnTargetSystem.h" -#include "SpawnTargetEvent.h" - -namespace Reality -{ - InfiniteSpawnTargetSystem::InfiniteSpawnTargetSystem() - { - requireComponent(); - requireComponent(); - } - - void InfiniteSpawnTargetSystem::Update(float deltaTime) - { - for (auto e : getEntities()) - { - auto& transform = e.getComponent(); - getWorld().getEventManager().emitEvent(transform.GetPosition()); - } - } -} diff --git a/OpenGLEngine/OpenGLEngine/InfiniteSpawnTargetSystem.h b/OpenGLEngine/OpenGLEngine/InfiniteSpawnTargetSystem.h deleted file mode 100644 index 7694392..0000000 --- a/OpenGLEngine/OpenGLEngine/InfiniteSpawnTargetSystem.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include "ECSConfig.h" -#include "InfiniteSpawnTargetComponent.h" -#include "TransformComponentV2.h" - -namespace Reality -{ - class InfiniteSpawnTargetSystem : public ECSSystem - { - public: - InfiniteSpawnTargetSystem(); - void Update(float deltaTime); - }; -} diff --git a/OpenGLEngine/OpenGLEngine/LifeTimeComponent.h b/OpenGLEngine/OpenGLEngine/LifeTimeComponent.h index 0173690..94ed8c2 100644 --- a/OpenGLEngine/OpenGLEngine/LifeTimeComponent.h +++ b/OpenGLEngine/OpenGLEngine/LifeTimeComponent.h @@ -5,14 +5,13 @@ namespace Reality { struct LifeTimeComponent { - LifeTimeComponent(float _maxTime = 10) - :maxTime(_maxTime), timer(0), startSize(RANDOM_FLOAT(1.0f, 3.0f)), size(0) + LifeTimeComponent(float _maxTime = 5, Color _color = Color::Green) + :maxTime(_maxTime), timer(0), color(_color) { } float maxTime; float timer; - float startSize; - float size; + Color color; }; } diff --git a/OpenGLEngine/OpenGLEngine/LifeTimeSystem.cpp b/OpenGLEngine/OpenGLEngine/LifeTimeSystem.cpp index b188084..afe6b1a 100644 --- a/OpenGLEngine/OpenGLEngine/LifeTimeSystem.cpp +++ b/OpenGLEngine/OpenGLEngine/LifeTimeSystem.cpp @@ -4,21 +4,21 @@ namespace Reality { LifeTimeSystem::LifeTimeSystem() { - requireComponent(); requireComponent(); + requireComponent(); } void LifeTimeSystem::Update(float deltaTime) { for (auto e : getEntities()) { - auto& life = e.getComponent(); auto& transform = e.getComponent(); + auto& lifeTime = e.getComponent(); + + getWorld().data.renderUtil->DrawSphere(transform.GetPosition(), 1.0f, lifeTime.color); - life.timer += deltaTime; - life.size = life.startSize + 10.0f * pow(life.timer, 0.5f); - getWorld().data.renderUtil->DrawSphere(transform.GetPosition(), life.size, Color::Yellow); - if (life.timer > life.maxTime) + lifeTime.timer += deltaTime; + if (lifeTime.timer >= lifeTime.maxTime) { e.kill(); } diff --git a/OpenGLEngine/OpenGLEngine/LifeTimeSystem.h b/OpenGLEngine/OpenGLEngine/LifeTimeSystem.h index 17b76fb..db8725c 100644 --- a/OpenGLEngine/OpenGLEngine/LifeTimeSystem.h +++ b/OpenGLEngine/OpenGLEngine/LifeTimeSystem.h @@ -1,7 +1,7 @@ #pragma once #include "ECSConfig.h" -#include "LifeTimeComponent.h" #include "TransformComponentV2.h" +#include "LifeTimeComponent.h" namespace Reality { diff --git a/OpenGLEngine/OpenGLEngine/Main.cpp b/OpenGLEngine/OpenGLEngine/Main.cpp index 91a5161..22df195 100644 --- a/OpenGLEngine/OpenGLEngine/Main.cpp +++ b/OpenGLEngine/OpenGLEngine/Main.cpp @@ -3,6 +3,7 @@ #include "RenderingSystem.h" #include "RenderingSystemV2.h" #include "InputEventSystem.h" +<<<<<<< Updated upstream #include "RotateSystem.h" #include "ParticleSystem.h" #include "ParticleSpawnerSystem.h" @@ -23,6 +24,33 @@ #include "BoxColliderSystem.h" #include "MoveInBoundsSystem.h" #include "FPSControlSystem.h" +======= +#include "FPSControlSystem.h" +#include "FollowCameraSystem.h" +#include "RotateSystem.h" +#include "RotateSystemV2.h" +#include "LifeTimeSystem.h" +#include "FireworksSystem.h" +#include "GravityForceSystem.h" +#include "DragForceSystem.h" +#include "FixedSpringSystem.h" +#include "PairedSpringSystem.h" +#include "ParticleSphereSystem.h" +#include "CableSystem.h" +#include "RodSystem.h" +#include "ParticleContactResolutionSystem.h" +#include "ResetPenetrationDeltaMoveSystem.h" +#include "ForceAccumulatorSystem.h" +#include "ParticleSystem.h" +#include "RigidbodySystem.h" +#include "ForceAndTorqueAccumulatorSystem.h" +#include "DragSystem.h" +#include "AddTorqueFromCameraSystem.h" +#include "AeroControlSystem.h" +#include "AeroSurfaceSystem.h" +#include "ThrusterSystem.h" +#include "BuoyancySystem.h" +>>>>>>> Stashed changes #include "DynamicDirectionalLightSystem.h" #include "DynamicPointLightSystem.h" #include "DynamicSpotLightSystem.h" @@ -45,6 +73,7 @@ using namespace Reality; void LoadShaders(ECSWorld& world); void LoadModels(ECSWorld& world); +<<<<<<< Updated upstream void MakeABunchaObjects(ECSWorld& world); void MakeABunchaSprings(ECSWorld& world); void MakeABunchaSpheres(ECSWorld& world); @@ -54,6 +83,11 @@ void MakeFlight(ECSWorld& world); void TestContacts(ECSWorld& world); void TestCollision(ECSWorld& world); void SetupLights(ECSWorld& world); +======= +void SetupLights(ECSWorld& world); +void MakeAFlightSimulator(ECSWorld& world); +void Boat(ECSWorld& world); +>>>>>>> Stashed changes int main() { @@ -62,8 +96,13 @@ int main() // Init and Load world.data.InitRendering(); //LoadAssets(world); +<<<<<<< Updated upstream world.data.renderUtil->camera.Position = Vector3(0, 15.0f, 100.0f); +======= + + world.data.renderUtil->camera.Position = Vector3(0, 0.0f, 50.0f); +>>>>>>> Stashed changes world.data.renderUtil->SetFOV(60); // Create entities @@ -77,6 +116,7 @@ int main() //wall.addComponent("Resources/Models/Sponza-master/sponza.obj"); SetupLights(world); +<<<<<<< Updated upstream //MakeABunchaObjects(world); //MakeABunchaSpheres(world); //MakeABunchaSprings(world); @@ -85,12 +125,17 @@ int main() //MakeFlight(world); //TestContacts(world); TestCollision(world); +======= + //MakeAFlightSimulator(world); + Boat(world); +>>>>>>> Stashed changes // Create Systems world.getSystemManager().addSystem(); world.getSystemManager().addSystem(); world.getSystemManager().addSystem(); world.getSystemManager().addSystem(); +<<<<<<< Updated upstream world.getSystemManager().addSystem(); world.getSystemManager().addSystem(); world.getSystemManager().addSystem(); @@ -99,9 +144,24 @@ int main() world.getSystemManager().addSystem(); world.getSystemManager().addSystem(); world.getSystemManager().addSystem(); +======= + world.getSystemManager().addSystem(); + world.getSystemManager().addSystem(); + world.getSystemManager().addSystem(); + world.getSystemManager().addSystem(); + world.getSystemManager().addSystem(); + world.getSystemManager().addSystem(); + world.getSystemManager().addSystem(); + world.getSystemManager().addSystem(); + world.getSystemManager().addSystem(); + world.getSystemManager().addSystem(); + world.getSystemManager().addSystem(); + world.getSystemManager().addSystem(); +>>>>>>> Stashed changes world.getSystemManager().addSystem(); world.getSystemManager().addSystem(); world.getSystemManager().addSystem(); +<<<<<<< Updated upstream world.getSystemManager().addSystem(); world.getSystemManager().addSystem(); world.getSystemManager().addSystem(); @@ -114,6 +174,17 @@ int main() world.getSystemManager().addSystem(); world.getSystemManager().addSystem(); world.getSystemManager().addSystem(); +======= + world.getSystemManager().addSystem(); + world.getSystemManager().addSystem(); + world.getSystemManager().addSystem(); + world.getSystemManager().addSystem(); + world.getSystemManager().addSystem(); + world.getSystemManager().addSystem(); + world.getSystemManager().addSystem(); + world.getSystemManager().addSystem(); + world.getSystemManager().addSystem(); +>>>>>>> Stashed changes world.getSystemManager().addSystem(); world.getSystemManager().addSystem(); world.getSystemManager().addSystem(); @@ -159,7 +230,7 @@ int main() { shadersLoaded = world.data.assetLoader->ShadersLoaded(); } - if(shadersLoaded && !modelsLoadStarted) + if (shadersLoaded && !modelsLoadStarted) { LoadModels(world); modelsLoadStarted = true; @@ -171,7 +242,9 @@ int main() // Game Logic Update world.getSystemManager().getSystem().Update(deltaTime); + world.getSystemManager().getSystem().Update(deltaTime); world.getSystemManager().getSystem().Update(deltaTime); +<<<<<<< Updated upstream world.getSystemManager().getSystem().Update(deltaTime); world.getSystemManager().getSystem().Update(deltaTime); @@ -184,10 +257,21 @@ int main() world.getSystemManager().getSystem().Update(deltaTime); world.getSystemManager().getSystem().Update(deltaTime); world.getSystemManager().getSystem().Update(deltaTime); +======= + world.getSystemManager().getSystem().Update(deltaTime); + world.getSystemManager().getSystem().Update(deltaTime); + world.getSystemManager().getSystem().Update(deltaTime); + world.getSystemManager().getSystem().Update(deltaTime); + world.getSystemManager().getSystem().Update(deltaTime); + world.getSystemManager().getSystem().Update(deltaTime); + world.getSystemManager().getSystem().Update(deltaTime); + world.getSystemManager().getSystem().Update(deltaTime); +>>>>>>> Stashed changes // Update Transform world.getSystemManager().getSystem().Update(deltaTime); // Physics +<<<<<<< Updated upstream float fixedDeltaTime = glfwGetKey(world.data.renderUtil->window->glfwWindow, GLFW_KEY_SPACE) == GLFW_PRESS ? 1 / 60.0f : 0; //float fixedDeltaTime = 1 / 60.0f; world.getSystemManager().getSystem().Update(fixedDeltaTime); @@ -208,10 +292,41 @@ int main() world.getSystemManager().getSystem().Update(fixedDeltaTime); world.getSystemManager().getSystem().Update(fixedDeltaTime); world.getSystemManager().getSystem().Update(fixedDeltaTime); +======= + //float fixedDeltaTime = glfwGetKey(world.data.renderUtil->window->glfwWindow, GLFW_KEY_SPACE) == GLFW_PRESS ? 1 / 60.0f : 0; + float fixedDeltaTime = 1 / 60.0f; + // Force Generator + /// Particle + world.getSystemManager().getSystem().Update(fixedDeltaTime); + world.getSystemManager().getSystem().Update(fixedDeltaTime); + world.getSystemManager().getSystem().Update(fixedDeltaTime); + world.getSystemManager().getSystem().Update(fixedDeltaTime); + /// Rigidbody + world.getSystemManager().getSystem().Update(fixedDeltaTime); + world.getSystemManager().getSystem().Update(fixedDeltaTime); + world.getSystemManager().getSystem().Update(fixedDeltaTime); + world.getSystemManager().getSystem().Update(fixedDeltaTime); + + // Force Accumulator + /// Particle + world.getSystemManager().getSystem().Update(fixedDeltaTime); + /// Rigidbody + world.getSystemManager().getSystem().Update(fixedDeltaTime); + + // Contact Resolution +>>>>>>> Stashed changes world.getSystemManager().getSystem().Update(fixedDeltaTime); +<<<<<<< Updated upstream world.getSystemManager().getSystem().Update(fixedDeltaTime); world.getSystemManager().getSystem().Update(fixedDeltaTime); +======= + // Integrator + /// Particle + world.getSystemManager().getSystem().Update(fixedDeltaTime); + /// Rigidbody + world.getSystemManager().getSystem().Update(fixedDeltaTime); +>>>>>>> Stashed changes // Rendering Update world.getSystemManager().getSystem().Update(deltaTime); @@ -237,11 +352,11 @@ int main() std::string renderString = logic < 10 ? " " + std::to_string(render) : std::to_string(render); int debug = (int)round(debugDelta * 100.0f / deltaTime); std::string debugString = logic < 10 ? " " + std::to_string(debug) : std::to_string(debug); - + world.data.renderUtil->RenderText("Logic : " + logicString + "%" + //+ " | Physics : " + std::to_string((int)round(physicsDelta * 100.0f / deltaTime)) + "%" + - + " | Rendering : " + renderString + "%" + - + " | Debug : " + debugString + "%" + +" | Rendering : " + renderString + "%" + + +" | Debug : " + debugString + "%" , 1680.0f, 1040.0f, 0.25f, Color(0, 1, 1, 1)); } if (DEBUG_LOG_LEVEL > 2) @@ -276,16 +391,21 @@ void LoadShaders(ECSWorld& world) void LoadModels(ECSWorld& world) { world.data.assetLoader->StartModelLoading({ +<<<<<<< Updated upstream //ModelData("Resources/Models/snowy-mountain-terrain/SnowyMountainMesh.obj"), //ModelData("Resources/Models/Sponza-master/sponza.obj"), //ModelData("Resources/Models/nanosuit/nanosuit.obj"),*/ ModelData("Resources/Models/supermarine-spitfire/spitfire.fbx", {{"spitfire_d.png"}}) +======= + ModelData("Resources/Models/Boat.fbx") +>>>>>>> Stashed changes }); } -void MakeABunchaObjects(ECSWorld& world) +void MakeAFlightSimulator(ECSWorld & world) { +<<<<<<< Updated upstream auto e = world.createEntity(); e.addComponent(Vector3(4, 10.0f, 48), Vector3(0.10f, 0.1f, 0.1f), Vector3(-90, 180, 0)); // Add mesh @@ -571,13 +691,108 @@ void TestCollision(ECSWorld& world) auto objectCol2 = world.createEntity(); objectCol2.addComponent(object2, Vector3(10, 10, 10)); } +======= + auto ground = world.createEntity(); + ground.addComponent(Vector3(0, -1000, 0), Vector3(10, 10, 10), Vector3(0, 90, 0)); + ground.addComponent("Resources/Models/Sponza-master/sponza.obj"); + + auto flight = world.createEntity(); + flight.addComponent(Vector3(0, 0, -50), Vector3(0.1f, 0.1f, 0.1f), Vector3(0, 180, 0)); + flight.addComponent("Resources/Models/supermarine-spitfire/spitfire.fbx", Vector3(-90, 0, 0), Vector3(0, -50, 0)); + flight.addComponent(); + flight.addComponent(); + flight.addComponent(0.3, 0.5); + flight.addComponent(); + + auto engine = world.createEntity(); + engine.addComponent(flight); + + auto leftWing = world.createEntity(); + leftWing.addComponent(); + leftWing.addComponent(flight, Vector3(0, 0, 0), Vector3(100, 50, -50)); + std::vector leftWingPositiveKeys = { GLFW_KEY_S, GLFW_KEY_Q }; + std::vector leftWingNegetiveKeys = { GLFW_KEY_W, GLFW_KEY_E }; + leftWing.addComponent( + Vector3(0, 0.1f, 0), + Vector3(0, -0.1f, 0), + leftWingPositiveKeys, leftWingNegetiveKeys); + + auto rightWing = world.createEntity(); + rightWing.addComponent(); + rightWing.addComponent(flight, Vector3(0, 0, 0), Vector3(-100, 50, -50)); + std::vector rightWingPositiveKeys = { GLFW_KEY_S, GLFW_KEY_E }; + std::vector rightWingNegetiveKeys = { GLFW_KEY_W, GLFW_KEY_Q }; + rightWing.addComponent( + Vector3(0, 0.1f, 0), + Vector3(0, -0.1f, 0), + rightWingPositiveKeys, rightWingNegetiveKeys); + + auto rudder = world.createEntity(); + rudder.addComponent(); + rudder.addComponent(flight, Vector3(0, 0, 0), Vector3(0, 0, -150)); + std::vector rudderWingPositiveKeys = { GLFW_KEY_D }; + std::vector rudderWingNegetiveKeys = { GLFW_KEY_A }; + rudder.addComponent( + Vector3(-0.04f, 0, 0), + Vector3(0.04f, 0, 0), + rudderWingPositiveKeys, rudderWingNegetiveKeys); +} + +void Boat(ECSWorld & world) +{ + auto boat = world.createEntity(); + boat.addComponent(Vector3(0, 0, 0), Vector3(0.13f, 0.13f, 0.13f), Vector3(0, 0, 0)); + boat.addComponent("Resources/Models/Boat.fbx", Vector3(-90, 90, 0)); + boat.addComponent(); + boat.addComponent(7.0f, 1.0f); + boat.addComponent(); + boat.addComponent(); + boat.addComponent(); + + auto engine = world.createEntity(); + std::vector thrustPositiveKeys = { GLFW_KEY_W }; + std::vector thrustNegetiveKeys = { GLFW_KEY_S }; + engine.addComponent(boat, thrustPositiveKeys, thrustNegetiveKeys); + + auto frontLeft = world.createEntity(); + frontLeft.addComponent(); + auto frontRight = world.createEntity(); + frontRight.addComponent(); + auto backLeft = world.createEntity(); + backLeft.addComponent(); + auto backRight = world.createEntity(); + backRight.addComponent(); + + std::vector PositiveKeys = { GLFW_KEY_A }; + std::vector NegativeKeys = { GLFW_KEY_D }; + + frontLeft.addComponent(boat, Vector3(-140.0f, -4, 140.0f), PositiveKeys); + frontRight.addComponent(boat, Vector3(140.0f, -4, 140.0f), NegativeKeys); + backLeft.addComponent(boat, Vector3(-140.0f, 4, -140.0f), PositiveKeys); + backRight.addComponent(boat, Vector3(140.0f, 4, -140.0f), NegativeKeys); + + auto rudder = world.createEntity(); + rudder.addComponent(); + rudder.addComponent(boat, Vector3(0, 0, 0), Vector3(0, 0, -150)); + std::vector rudderWingPositiveKeys = { GLFW_KEY_D }; + std::vector rudderWingNegetiveKeys = { GLFW_KEY_A }; + rudder.addComponent( + Vector3(-0.04f, 0, 0), + Vector3(0.04f, 0, 0), + rudderWingPositiveKeys, rudderWingNegetiveKeys); + +>>>>>>> Stashed changes } void SetupLights(ECSWorld& world) { auto l = world.createEntity(); l.addComponent(Vector3(0, 0, 0), Vector3(0, 0, 0), Vector3(90, 0, 0)); +<<<<<<< Updated upstream l.addComponent(Color(0.00, 0.0, 0), Color::White, Color::Orange); +======= + l.addComponent(Color(1, 1, 1), Color(0.0, 0.1, 0.1), Color(0.0, 0.1, 0.1)); +>>>>>>> Stashed changes // Lanterns auto pl1 = world.createEntity(); @@ -606,8 +821,12 @@ void SetupLights(ECSWorld& world) hook.addComponent(5, 1, pl2); hook = world.createEntity(); hook.addComponent(Vector3(-14.5f, 14 - 1, 49.0f + 1)); +<<<<<<< Updated upstream hook.addComponent(5, 1, pl2); +======= + +>>>>>>> Stashed changes auto pl3 = world.createEntity(); pl3.addComponent(Vector3(22, 14, -62.0f)); pl3.addComponent(100.0f, Color(0, 0.1f, 0), Color(0.0f, 1.0f, 0.0f), Color(0.0f, 1.0f, 0.0f)); @@ -627,14 +846,22 @@ void SetupLights(ECSWorld& world) pl4.addComponent(100.0f, Color(0.1, 0.05, 0), Color(1.0f, 0.55f, 0.0f), Color(1.0f, 0.55f, 0.0f)); pl4.addComponent(); hook = world.createEntity(); +<<<<<<< Updated upstream hook.addComponent(Vector3(-14.5f - 1, 14, -61.5f -1)); hook.addComponent(5, 1, pl4); +======= + hook.addComponent(Vector3(-14.5f - 1, 14, -61.5f - 1)); +>>>>>>> Stashed changes hook = world.createEntity(); hook.addComponent(Vector3(-14.5f - 0.25f, 14 - 0.5f, -61.5f + 1)); hook.addComponent(5, 1, pl4); hook = world.createEntity(); +<<<<<<< Updated upstream hook.addComponent(Vector3(-14.5f + 0.5f, 14+ 1, -61.5f + 1)); hook.addComponent(5, 1, pl4); +======= + hook.addComponent(Vector3(-14.5f + 0.5f, 14 + 1, -61.5f + 1)); +>>>>>>> Stashed changes // Spears std::vector cols = { Color(1,0,0), Color(0,1,0), Color(0,0,1), Color(0.7f,0.55f,0) }; diff --git a/OpenGLEngine/OpenGLEngine/MeshComponent.h b/OpenGLEngine/OpenGLEngine/MeshComponent.h index f76b4e7..b473b9e 100644 --- a/OpenGLEngine/OpenGLEngine/MeshComponent.h +++ b/OpenGLEngine/OpenGLEngine/MeshComponent.h @@ -11,9 +11,20 @@ namespace Reality Vector3 offset; Vector3 rotation; // Constructor - ModelComponent(std::string const _model = "", Vector3 _offset = Vector3(0, 0, 0), Vector3 _rotation = Vector3(0, 0, 0)) : mesh(_model), offset(_offset), rotation(_rotation) + ModelComponent(std::string const _model = "", Vector3 _rotation = Vector3(0, 0, 0), Vector3 _offset = Vector3(0, 0, 0)) : mesh(_model), offset(_offset), rotation(_rotation) { modelId = -1; + Vector3 rotInRads = Vector3(glm::radians(_rotation.x), glm::radians(_rotation.y), glm::radians(_rotation.z)); + modelOffsetTransformation = Mat4(Quaternion(rotInRads)); + modelOffsetTransformation = glm::translate(Mat4(1.0f), _offset) * modelOffsetTransformation; } + + const Mat4& GetModelOffsetTransformation() + { + return modelOffsetTransformation; + } + + private: + Mat4 modelOffsetTransformation; }; } diff --git a/OpenGLEngine/OpenGLEngine/OpenGLEngine.vcxproj b/OpenGLEngine/OpenGLEngine/OpenGLEngine.vcxproj index dbb8b45..ec9cf9d 100644 --- a/OpenGLEngine/OpenGLEngine/OpenGLEngine.vcxproj +++ b/OpenGLEngine/OpenGLEngine/OpenGLEngine.vcxproj @@ -121,21 +121,37 @@ +<<<<<<< Updated upstream +======= + + + + +>>>>>>> Stashed changes +<<<<<<< Updated upstream +======= + +>>>>>>> Stashed changes +<<<<<<< Updated upstream +======= + + +>>>>>>> Stashed changes @@ -148,6 +164,10 @@ + + + + @@ -169,8 +189,17 @@ +<<<<<<< Updated upstream +======= + + +>>>>>>> Stashed changes + + + + @@ -218,12 +247,30 @@ +<<<<<<< Updated upstream +======= + + + + + + + + + + + + + + + +>>>>>>> Stashed changes @@ -232,16 +279,34 @@ +<<<<<<< Updated upstream +======= + + + + + + + +>>>>>>> Stashed changes +<<<<<<< Updated upstream +======= + + + + + +>>>>>>> Stashed changes @@ -253,16 +318,30 @@ +<<<<<<< Updated upstream +======= + + + + + +>>>>>>> Stashed changes +<<<<<<< Updated upstream +======= + + + +>>>>>>> Stashed changes @@ -282,7 +361,16 @@ +<<<<<<< Updated upstream +======= + + + + + + +>>>>>>> Stashed changes @@ -290,6 +378,7 @@ +<<<<<<< Updated upstream @@ -299,6 +388,12 @@ +======= + + + + +>>>>>>> Stashed changes @@ -339,9 +434,15 @@ +<<<<<<< Updated upstream +======= + + + +>>>>>>> Stashed changes @@ -350,8 +451,22 @@ +<<<<<<< Updated upstream +======= + + + + + + + + + + + +>>>>>>> Stashed changes @@ -425,16 +540,41 @@ +<<<<<<< Updated upstream +======= + + + + + + +>>>>>>> Stashed changes +<<<<<<< Updated upstream +======= + + + + + + + + + + + + + +>>>>>>> Stashed changes @@ -442,6 +582,7 @@ +<<<<<<< Updated upstream @@ -456,6 +597,34 @@ +======= + + + + + + + + + + + + + + + + + + + + + + + + + + +>>>>>>> Stashed changes diff --git a/OpenGLEngine/OpenGLEngine/OpenGLEngine.vcxproj.filters b/OpenGLEngine/OpenGLEngine/OpenGLEngine.vcxproj.filters index 0199877..11e9ff5 100644 --- a/OpenGLEngine/OpenGLEngine/OpenGLEngine.vcxproj.filters +++ b/OpenGLEngine/OpenGLEngine/OpenGLEngine.vcxproj.filters @@ -49,6 +49,36 @@ {3f5a8043-c367-47f5-bbe1-005323d21b00} +<<<<<<< Updated upstream +======= + + {3b57134f-d90e-46bd-8888-c0777df6a173} + + + {2a1ab3ed-c9b4-469a-8efb-a6ad96814ca1} + + + {a47e3b81-90db-42eb-a5f1-e5a072f9b973} + + + {05f83a53-3654-4ae0-99f7-3b5b0131942b} + + + {4c54bdb5-bf1a-46eb-97aa-4ad2f029416e} + + + {26df7371-0611-42cd-b6e5-2556995c23d7} + + + {8f440b87-7f9c-4d7f-993c-ec5fa08dde39} + + + {8d7d692e-fedf-4e75-9661-f2eb1dd346c1} + + + {fee04adf-2290-4e0b-9dd6-1b2c67f5a98f} + +>>>>>>> Stashed changes @@ -195,8 +225,46 @@ Physics\Particles +<<<<<<< Updated upstream Physics\Particles +======= + + Rendering + + + TestCS + + + TestCS + + + Physics\Rigidbody + + + Physics\Rigidbody + + + Physics\Rigidbody + + + TestCS + + + TestCS\FlightSimulator + + + TestCS\FlightSimulator + + + TestCS\FlightSimulator + + + TestCS\FlightSimulator + + + Physics\Rigidbody +>>>>>>> Stashed changes Physics\Rigidbody @@ -461,11 +529,85 @@ Physics\Particles +<<<<<<< Updated upstream Physics\Particles Physics\Particles +======= + + ComponentsCore + + + Rendering + + + TestCS + + + TestCS + + + TestCS + + + TestCS + + + Physics\Rigidbody + + + Physics\Rigidbody + + + Physics\Rigidbody + + + Physics\Rigidbody + + + Physics\Rigidbody + + + Physics\Rigidbody + + + TestCS + + + TestCS + + + TestCS\FlightSimulator + + + TestCS\FlightSimulator + + + TestCS\FlightSimulator + + + TestCS\FlightSimulator + + + TestCS\FlightSimulator + + + TestCS\FlightSimulator + + + TestCS\FlightSimulator + + + TestCS\FlightSimulator + + + Physics\Rigidbody + + + Physics\Rigidbody +>>>>>>> Stashed changes Physics\Rigidbody diff --git a/OpenGLEngine/OpenGLEngine/PairedSpringForceGeneratorSystem.cpp b/OpenGLEngine/OpenGLEngine/PairedSpringForceGeneratorSystem.cpp deleted file mode 100644 index 532d8eb..0000000 --- a/OpenGLEngine/OpenGLEngine/PairedSpringForceGeneratorSystem.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "PairedSpringForceGeneratorSystem.h" -#include "TransformComponent.h" -#include "ParticleComponent.h" - -namespace Reality -{ - PairedSpringForceGeneratorSystem::PairedSpringForceGeneratorSystem() - { - requireComponent(); - } - - - void PairedSpringForceGeneratorSystem::Update(float deltaTime) - { - for (auto e : getEntities()) - { - auto &spring = e.getComponent(); - - if (spring.entityA.hasComponent() && - spring.entityB.hasComponent()) - { - //auto &particle = spring.entity.getComponent(); - auto &entityTransformA = spring.entityA.getComponent(); - auto &entityTransformB = spring.entityB.getComponent(); - - Vector3 relativePosition = entityTransformA.position - entityTransformB.position; - float length = glm::length(relativePosition); - float x = length - spring.restLength; - Vector3 direction = glm::normalize(relativePosition); - - if (spring.entityA.hasComponent()) - { - spring.entityA.getComponent().AddForce(-spring.springConstant * x * direction); - } - - if (spring.entityB.hasComponent()) - { - spring.entityB.getComponent().AddForce(spring.springConstant * x * direction); - } - - float g = 1.0f / (1.0f + pow(abs(x), 0.5f)); - float r = (1 - g); - Color color = Color(r, g, 0, 1); - - float deltaLength = length / 10.0f; - for (int i = 0; i < 10; i++) - { - getWorld().data.renderUtil->DrawCube( - entityTransformB.position + (float)i * deltaLength * direction, - Vector3(0.1f, 0.1f, 0.1f) * min((spring.springConstant / 10.0f), 5.0f), Vector3(0,0,0), color); - } - - getWorld().data.renderUtil->DrawLine( - entityTransformB.position, entityTransformB.position + length * direction, color); - } - } - - } -} - diff --git a/OpenGLEngine/OpenGLEngine/PairedSpringForceGeneratorSystem.h b/OpenGLEngine/OpenGLEngine/PairedSpringForceGeneratorSystem.h deleted file mode 100644 index 5adbcab..0000000 --- a/OpenGLEngine/OpenGLEngine/PairedSpringForceGeneratorSystem.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include "ECSConfig.h" -#include "PairedSpringComponent.h" - -namespace Reality -{ - class PairedSpringForceGeneratorSystem : public ECSSystem - { - public: - PairedSpringForceGeneratorSystem(); - void Update(float deltaTime); - }; -} - diff --git a/OpenGLEngine/OpenGLEngine/ParticleContactResolutionSystem.cpp b/OpenGLEngine/OpenGLEngine/ParticleContactResolutionSystem.cpp index 42c892a..5e548ed 100644 --- a/OpenGLEngine/OpenGLEngine/ParticleContactResolutionSystem.cpp +++ b/OpenGLEngine/OpenGLEngine/ParticleContactResolutionSystem.cpp @@ -1,6 +1,10 @@ #include "ParticleContactResolutionSystem.h" #include "ParticleComponent.h" #include "TransformComponent.h" +<<<<<<< Updated upstream +======= +#include "PenetrationDeltaMoveComponent.h" +>>>>>>> Stashed changes namespace Reality { @@ -11,19 +15,38 @@ namespace Reality float ParticleContactResolutionSystem::CalculateSeparatingVelocity(ParticleContactComponent& contact) { +<<<<<<< Updated upstream Vector3 velocityA = contact.entityA.hasComponent() ? contact.entityA.getComponent().velocity : Vector3(0, 0, 0); Vector3 velocityB = contact.entityB.hasComponent() ? contact.entityB.getComponent().velocity : Vector3(0, 0, 0); Vector3 relativeVel = velocityA - velocityB; return glm::dot(relativeVel, contact.normal); +======= + Vector3 velocityA = contact.entityA.hasComponent() ? + contact.entityA.getComponent().velocity : Vector3(0, 0, 0); + + Vector3 velocityB = contact.entityB.hasComponent() ? + contact.entityB.getComponent().velocity : Vector3(0, 0, 0); + + Vector3 separationVelocity = velocityA - velocityB; + + return glm::dot(separationVelocity, contact.normal); +>>>>>>> Stashed changes } void ParticleContactResolutionSystem::ResolveVelocity(ParticleContactComponent& contact, float deltaTime) { float separatingVelocity = CalculateSeparatingVelocity(contact); +<<<<<<< Updated upstream if (separatingVelocity > 0) { return; +======= + if (contact.entityB.hasComponent()) + { + Vector3 deltaMove = contact.entityB.getComponent().deltaMove; + actualPenetration += glm::dot(deltaMove, contact.normal); +>>>>>>> Stashed changes } bool isAvalid = contact.entityA.hasComponent(); @@ -40,11 +63,20 @@ namespace Reality { accCausedVelocity += contact.entityA.getComponent().accelaration; } +<<<<<<< Updated upstream if (isBvalid) { accCausedVelocity -= contact.entityB.getComponent().accelaration; } float accCausedSepVelocity = glm::dot(accCausedVelocity, contact.normal) * deltaTime; +======= + if (contact.entityB.hasComponent()) + { + relativeAccelaration -= contact.entityB.getComponent().acceleration; + } + + float accCausedSepVelocity = glm::dot(relativeAccelaration, contact.normal) * deltaTime; +>>>>>>> Stashed changes // If we have a closing velocity due to accelaration build up, // remove it from new separating velocity @@ -57,9 +89,21 @@ namespace Reality } } +<<<<<<< Updated upstream float deltaVelocity = newSeparatingVelocity - separatingVelocity; float totalInverseMass = invM1 + invM2; +======= + float deltaVelocity = finalVelocity - initialVelocity; + + float invMA = contact.entityA.hasComponent() ? + contact.entityA.getComponent().inverseMass : 0; + + float invMB = contact.entityB.hasComponent() ? + contact.entityB.getComponent().inverseMass : 0; + + float totalInverseMass = invMA + invMB; +>>>>>>> Stashed changes if (totalInverseMass <= 0) { @@ -70,6 +114,7 @@ namespace Reality Vector3 impulsePerIMass = contact.normal * impulse; +<<<<<<< Updated upstream if (isAvalid) { contact.entityA.getComponent().velocity += impulsePerIMass * invM1; @@ -77,6 +122,11 @@ namespace Reality if (isBvalid) { contact.entityB.getComponent().velocity -= impulsePerIMass * invM2; +======= + if (contact.entityB.hasComponent()) + { + contact.entityB.getComponent().velocity -= impulsePerIMass * invMB; +>>>>>>> Stashed changes } } @@ -92,6 +142,7 @@ namespace Reality float invM1 = isAvalid ? contact.entityA.getComponent().inverseMass : 0; float invM2 = isBvalid ? contact.entityB.getComponent().inverseMass : 0; +<<<<<<< Updated upstream float totalInverseMass = invM1 + invM2; if (totalInverseMass <= 0) @@ -105,6 +156,10 @@ namespace Reality { contact.entityA.getComponent().position -= movePerMass * invM1; } +======= + float invMassB = contact.entityB.hasComponent() ? + contact.entityB.getComponent().inverseMass : 0; +>>>>>>> Stashed changes if (isBvalid) { @@ -126,6 +181,7 @@ namespace Reality float deltaPenetration = glm::dot(deltaMove, contact.normal); contact.penetration -= deltaPenetration; } +<<<<<<< Updated upstream if (bestContact.entityB == contact.entityB || bestContact.entityA == contact.entityB) { float mult = bestContact.entityA == contact.entityB ? -1 : 1; @@ -181,6 +237,18 @@ namespace Reality } +======= + + if (contact.entityB.hasComponent()) + { + Vector3 deltaMove = movePerUnitIMass * invMassB; + contact.entityB.getComponent().position -= movePerUnitIMass * invMassB; + if (contact.entityB.hasComponent()) + { + contact.entityB.getComponent().deltaMove -= deltaMove; + } + } +>>>>>>> Stashed changes } } diff --git a/OpenGLEngine/OpenGLEngine/ParticleSphereSystem.cpp b/OpenGLEngine/OpenGLEngine/ParticleSphereSystem.cpp new file mode 100644 index 0000000..bd2cc30 --- /dev/null +++ b/OpenGLEngine/OpenGLEngine/ParticleSphereSystem.cpp @@ -0,0 +1,145 @@ +#include "ParticleSphereSystem.h" +#include "ParticleContactEvent.h" + +namespace Reality +{ + ParticleSphereSystem::ParticleSphereSystem() + { + requireComponent(); + requireComponent(); + } + + void ParticleSphereSystem::Update(float deltaTime) + { + if (!createBox) + { + boundingBox = getWorld().createEntity(); + createBox = true; + } + + // Draw Bounding Box + if (getEntities().size() > 0) + { + getWorld().data.renderUtil->DrawCube( + Vector3(0, 0, 0), + Vector3(20, 20, 20), + Vector3(0, 0, 0), + Color::Purple + ); + } + + for (int i = 0; i < getEntities().size(); i++) + { + auto e = getEntities()[i]; + auto& transform = e.getComponent(); + auto& sphere = e.getComponent(); + + // Draw Debug Sphere + if (DEBUG_LOG_LEVEL > 0) + { + getWorld().data.renderUtil->DrawSphere( + transform.position, + sphere.radius, + Color::Orange + ); + } + + // Collision Check with X + if (abs(transform.position.x) + sphere.radius >= 10) + { + Vector3 normal = Vector3(transform.position.x > 0 ? -1 : 1, 0, 0); + float penetration = abs(transform.position.x) + sphere.radius - 10; + + getWorld().getEventManager().emitEvent( + e, + boundingBox, + 0.8f, + normal, + penetration); + + getWorld().data.renderUtil->DrawLine( + transform.position - normal * sphere.radius, + transform.position - normal * (sphere.radius - penetration), + Color::Red); + } + + // Collision Check with Y + if (abs(transform.position.y) + sphere.radius >= 10) + { + Vector3 normal = Vector3(0, transform.position.y > 0 ? -1 : 1, 0); + float penetration = abs(transform.position.y) + sphere.radius - 10; + + getWorld().getEventManager().emitEvent( + e, + boundingBox, + 0.8f, + normal, + penetration); + + getWorld().data.renderUtil->DrawLine( + transform.position - normal * sphere.radius, + transform.position - normal * (sphere.radius - penetration), + Color::Red); + } + + // Collision Check with Z + if (abs(transform.position.z) + sphere.radius >= 10) + { + Vector3 normal = Vector3(0, 0, transform.position.z > 0 ? -1 : 1); + float penetration = abs(transform.position.z) + sphere.radius - 10; + + getWorld().getEventManager().emitEvent( + e, + boundingBox, + 0.8f, + normal, + penetration); + + getWorld().data.renderUtil->DrawLine( + transform.position - normal * sphere.radius, + transform.position - normal * (sphere.radius - penetration), + Color::Red); + } + + // Collision with other spheres + if (i < getEntities().size() - 1) + { + for (int j = i + 1; j < getEntities().size(); j++) + { + CheckCollision(e, getEntities()[j]); + } + } + } + } + void ParticleSphereSystem::CheckCollision(ECSEntity sphereEntityA, ECSEntity sphereEntityB) + { + auto& transformA = sphereEntityA.getComponent(); + auto& sphereA = sphereEntityA.getComponent(); + + auto& transformB = sphereEntityB.getComponent(); + auto& sphereB = sphereEntityB.getComponent(); + + Vector3 relativePos = transformA.position - transformB.position; + float distance = glm::length(relativePos); + + if (distance < sphereA.radius + sphereB.radius) + { + Vector3 normal = glm::normalize(relativePos); + float penetration = sphereA.radius + sphereB.radius - distance; + + getWorld().getEventManager().emitEvent( + sphereEntityA, + sphereEntityB, + 0.8f, + normal, + penetration + ); + + getWorld().data.renderUtil->DrawLine( + transformA.position - normal * sphereA.radius, + transformB.position + normal * sphereB.radius, + Color::Red + ); + } + } +} diff --git a/OpenGLEngine/OpenGLEngine/RenderUtil.cpp b/OpenGLEngine/OpenGLEngine/RenderUtil.cpp index cfadec7..2bd8400 100644 --- a/OpenGLEngine/OpenGLEngine/RenderUtil.cpp +++ b/OpenGLEngine/OpenGLEngine/RenderUtil.cpp @@ -576,6 +576,10 @@ namespace Reality glm::vec3 position = (start + end) * 0.5f; float scale = glm::length(start - end); glm::vec3 axis = glm::cross(glm::vec3(1, 0, 0), end - start); + if (glm::length(axis) < 0.001f) + { + axis = glm::vec3(1, 0, 0); + } axis = glm::normalize(axis); float proj = glm::dot(end - start, glm::vec3(1, 0, 0)); glm::mat4 model = glm::mat4(1.0f); diff --git a/OpenGLEngine/OpenGLEngine/RenderingSystem.cpp b/OpenGLEngine/OpenGLEngine/RenderingSystem.cpp index b11bd6d..0f4663a 100644 --- a/OpenGLEngine/OpenGLEngine/RenderingSystem.cpp +++ b/OpenGLEngine/OpenGLEngine/RenderingSystem.cpp @@ -25,7 +25,7 @@ namespace Reality } for (auto e : getEntities()) { - const auto transform = e.getComponent(); + auto &transform = e.getComponent(); auto &mesh = e.getComponent(); if (getWorld().data.assetLoader->ModelsLoaded()) @@ -41,10 +41,18 @@ namespace Reality getWorld().data.renderUtil->DrawModel(mesh.modelId, transform.position, transform.scale, transform.eulerAngles, drawModes[drawMode]); } - // Draw - //getWorld().data.renderUtil->DrawCube(transform.position, Vector3(10,10,10), transform.eulerAngles); - //getWorld().data.renderUtil->DrawCube(transform.position + Vector3(0, transform.scale.y , 0) * 7.5f, transform.scale * 15.0f, transform.eulerAngles); - //getWorld().data.renderUtil->DrawLine(transform.position - Vector3(1, 1, 1), transform.position + Vector3(1, 1, 1)); + if (DEBUG_LOG_LEVEL > 0) + { + // X + getWorld().data.renderUtil->DrawLine(transform.position, + transform.position + transform.Right() * 10.0f, Color::Red); + // Y + getWorld().data.renderUtil->DrawLine(transform.position, + transform.position + transform.Up() * 10.0f, Color::Green); + // Z + getWorld().data.renderUtil->DrawLine(transform.position, + transform.position + transform.Forward() * 10.0f, Color::Blue); + } } } } diff --git a/OpenGLEngine/OpenGLEngine/RenderingSystemV2.cpp b/OpenGLEngine/OpenGLEngine/RenderingSystemV2.cpp index aa2dbef..a31ab95 100644 --- a/OpenGLEngine/OpenGLEngine/RenderingSystemV2.cpp +++ b/OpenGLEngine/OpenGLEngine/RenderingSystemV2.cpp @@ -1,4 +1,7 @@ #include "RenderingSystemV2.h" +#include "Shader.h" +#include "Camera.h" +#include namespace Reality { @@ -10,31 +13,46 @@ namespace Reality void RenderingSystemV2::Update(float deltaTime) { + if (glfwGetKey(getWorld().data.renderUtil->window->glfwWindow, GLFW_KEY_F1) == GLFW_PRESS && !drawModeChanged) + { + drawMode++; + drawMode = drawMode % 2; + drawModeChanged = true; + } + else if (glfwGetKey(getWorld().data.renderUtil->window->glfwWindow, GLFW_KEY_F1) == GLFW_RELEASE) + { + drawModeChanged = false; + } for (auto e : getEntities()) { - auto& transform = e.getComponent(); - auto &model = e.getComponent(); + auto &transform = e.getComponent(); + auto &mesh = e.getComponent(); if (getWorld().data.assetLoader->ModelsLoaded()) { getWorld().data.assetLoader->SetLight(getWorld().data.renderUtil->camera.Position); } - if (model.modelId < 0) + if (mesh.modelId < 0) { - model.modelId = getWorld().data.assetLoader->GetModelId(model.mesh); + mesh.modelId = getWorld().data.assetLoader->GetModelId(mesh.mesh); } - if (model.modelId >= 0) + if (mesh.modelId >= 0) + { + getWorld().data.renderUtil->DrawModel(mesh.modelId, transform.GetTransformationMatrix() * mesh.GetModelOffsetTransformation(), drawModes[drawMode]); + } + + if (DEBUG_LOG_LEVEL > 0) { - //Mat4 modelMat = glm::translate(glm::mat4(1.0f), model.offset.x * transform.Right() + model.offset.y * transform.Up() + model.offset.z * transform.Forward()) * transform.transformationMatrix; - //Mat4 modelMat = glm::translate(transform.transformationMatrix, model.offset.x * transform.Right() + model.offset.y * transform.Up() + model.offset.z * transform.Forward()); - glm::vec3 rotationOffsetInRads = glm::vec3(glm::radians(model.rotation.x), glm::radians(model.rotation.y), glm::radians(model.rotation.z)); - glm::mat4 rotationOffsetMat = glm::toMat4(glm::quat(rotationOffsetInRads)); - Mat4 modelMat = transform.GetTransformationMatrix() * glm::translate(glm::mat4(1.0f), model.offset) * rotationOffsetMat; - getWorld().data.renderUtil->DrawModel(model.modelId, modelMat); + // X + getWorld().data.renderUtil->DrawLine(transform.GetPosition(), + transform.GetPosition() + transform.Right() * 10.0f, Color::Red); + // Y + getWorld().data.renderUtil->DrawLine(transform.GetPosition(), + transform.GetPosition() + transform.Up() * 10.0f, Color::Green); + // Z + getWorld().data.renderUtil->DrawLine(transform.GetPosition(), + transform.GetPosition() + transform.Forward() * 10.0f, Color::Blue); } - getWorld().data.renderUtil->DrawLine(transform.GetPosition(), transform.GetPosition() + transform.Right() * 10.0f, Color::Red); - getWorld().data.renderUtil->DrawLine(transform.GetPosition(), transform.GetPosition() + transform.Up() * 10.0f, Color::Green); - getWorld().data.renderUtil->DrawLine(transform.GetPosition(), transform.GetPosition() + transform.Forward() * 10.0f, Color::Blue); } } } diff --git a/OpenGLEngine/OpenGLEngine/RenderingSystemV2.h b/OpenGLEngine/OpenGLEngine/RenderingSystemV2.h index b2a18e5..610bfbe 100644 --- a/OpenGLEngine/OpenGLEngine/RenderingSystemV2.h +++ b/OpenGLEngine/OpenGLEngine/RenderingSystemV2.h @@ -2,6 +2,10 @@ #include "ECSConfig.h" #include "TransformComponentV2.h" #include "MeshComponent.h" + +class Shader; +class Camera; + namespace Reality { class RenderingSystemV2 : public ECSSystem @@ -9,5 +13,9 @@ namespace Reality public: RenderingSystemV2(); void Update(float deltaTime); + private: + unsigned int drawMode = 0; + unsigned int drawModes[2] = { GL_FILL, GL_LINE }; + bool drawModeChanged = false; }; } diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Boat.FBX b/OpenGLEngine/OpenGLEngine/Resources/Models/Boat.FBX new file mode 100644 index 0000000..38348b4 Binary files /dev/null and b/OpenGLEngine/OpenGLEngine/Resources/Models/Boat.FBX differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/README.md b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/README.md deleted file mode 100644 index 16922a0..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/README.md +++ /dev/null @@ -1,7 +0,0 @@ -Sponza -=================== - -A fixed version of the sponza obj model. -The original model was created by Frank Meinl. -More info: -http://graphics.cs.williams.edu/data/meshes/crytek-sponza-copyright.html \ No newline at end of file diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/sponza.mtl b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/sponza.mtl deleted file mode 100644 index cefdb90..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/sponza.mtl +++ /dev/null @@ -1,306 +0,0 @@ -# Blender MTL File: 'None' -# Material Count: 25 - -newmtl Material__25 -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 0.000000 -illum 2 -map_Kd textures/lion.tga -map_Disp textures/lion_ddn.tga -map_Ka textures/lion.tga - -newmtl Material__298 -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 0.000000 -illum 2 -map_Kd textures/background.tga -map_Disp textures/background_ddn.tga -map_Ka textures/background.tga - -newmtl Material__47 -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 0.000000 -illum 2 - - -newmtl Material__57 -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 1.000000 -illum 2 -map_Kd textures/vase_plant.tga -map_d textures/vase_plant_mask.tga -map_Ka textures/vase_plant.tga - -newmtl arch -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 0.000000 -illum 2 -map_Kd textures/sponza_arch_diff.tga -map_Ka textures/sponza_arch_diff.tga -map_Disp textures/sponza_arch_ddn.tga - -newmtl bricks -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 0.000000 -illum 2 -map_Kd textures/spnza_bricks_a_diff.tga -map_Disp textures/spnza_bricks_a_ddn.tga -map_Ka textures/spnza_bricks_a_diff.tga - -newmtl ceiling -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 0.000000 -illum 2 -map_Kd textures/sponza_ceiling_a_diff.tga -map_Ka textures/sponza_ceiling_a_diff.tga -map_Disp textures/sponza_ceiling_a_ddn.tga - -newmtl chain -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 1.000000 -illum 2 -map_Kd textures/chain_texture.tga -map_d textures/chain_texture_mask.tga -map_Disp textures/chain_texture_ddn.tga -map_Ka textures/chain_texture.tga - -newmtl column_a -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 0.000000 -illum 2 -map_Kd textures/sponza_column_a_diff.tga -map_Disp textures/sponza_column_a_ddn.tga -map_Ka textures/sponza_column_a_diff.tga - -newmtl column_b -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 0.000000 -illum 2 -map_Kd textures/sponza_column_b_diff.tga -map_Disp textures/sponza_column_b_ddn.tga -map_Ka textures/sponza_column_b_diff.tga - -newmtl column_c -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 0.000000 -illum 2 -map_Kd textures/sponza_column_c_diff.tga -map_Disp textures/sponza_column_c_ddn.tga -map_Ka textures/sponza_column_c_diff.tga - -newmtl details -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 0.000000 -illum 2 -map_Kd textures/sponza_details_diff.tga -map_Ka textures/sponza_details_diff.tga -map_Disp textures/sponza_details_ddn.tga - -newmtl fabric_a -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 0.000000 -illum 2 -map_Kd textures/sponza_fabric_diff.tga -map_Ka textures/sponza_fabric_diff.tga -map_Disp textures/sponza_fabric_ddn.tga - -newmtl fabric_c -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 0.000000 -illum 2 -map_Kd textures/sponza_curtain_diff.tga -map_Ka textures/sponza_curtain_diff.tga -map_Disp textures/sponza_curtain_ddn.tga - - -newmtl fabric_d -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 0.000000 -illum 2 -map_Kd textures/sponza_fabric_blue_diff.tga -map_Ka textures/sponza_fabric_blue_diff.tga -map_Disp textures/sponza_fabric_ddn.tga - - -newmtl fabric_e -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 0.000000 -illum 2 -map_Kd textures/sponza_fabric_green_diff.tga -map_Ka textures/sponza_fabric_green_diff.tga -map_Disp textures/sponza_fabric_ddn.tga - - -newmtl fabric_f -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 0.000000 -illum 2 -map_Kd textures/sponza_curtain_green_diff.tga -map_Ka textures/sponza_curtain_green_diff.tga -map_Disp textures/sponza_curtain_ddn.tga - -newmtl fabric_g -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 0.000000 -illum 2 -map_Kd textures/sponza_curtain_blue_diff.tga -map_Ka textures/sponza_curtain_blue_diff.tga -map_Disp textures/sponza_curtain_ddn.tga - - -newmtl flagpole -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 0.000000 -illum 2 -map_Kd textures/sponza_flagpole_diff.tga -map_Ka textures/sponza_flagpole_diff.tga -map_Disp textures/sponza_flagpole_ddn.tga - -newmtl floor -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 0.000000 -illum 2 -map_Kd textures/sponza_floor_a_diff.tga -map_Ka textures/sponza_floor_a_diff.tga -map_Disp textures/sponza_floor_a_ddn.tga - -newmtl leaf -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 1.000000 -illum 2 -map_Kd textures/sponza_thorn_diff.tga -map_d textures/sponza_thorn_mask.tga -map_Disp textures/sponza_thorn_ddn.tga -map_Ka textures/sponza_thorn_diff.tga - -newmtl roof -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 0.000000 -illum 2 -map_Kd textures/sponza_roof_diff.tga -map_Ka textures/sponza_roof_diff.tga -map_Ka textures/sponza_roof_ddn.tga - -newmtl vase -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 0.000000 -illum 2 -map_Kd textures/vase_dif.tga -map_Ka textures/vase_dif.tga -map_Disp textures/vase_ddn.tga - -newmtl vase_hanging -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 0.000000 -illum 2 -map_Kd textures/vase_hanging.tga -map_Ka textures/vase_hanging.tga -map_Disp textures/vase_hanging_ddn.tga - -newmtl vase_round -Ns 7.843137 -Ka 0.000000 0.000000 0.000000 -Kd 0.470400 0.470400 0.470400 -Ks 0.000000 0.000000 0.000000 -Ni 1.000000 -d 0.000000 -illum 2 -map_Kd textures/vase_round.tga -map_Disp textures/vase_round_ddn.tga -map_Ka textures/vase_round.tga diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/Thumbs.db b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/Thumbs.db deleted file mode 100644 index 70b4ac6..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/Thumbs.db and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/background.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/background.tga deleted file mode 100644 index 19da1d3..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/background.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/background_ddn.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/background_ddn.tga deleted file mode 100644 index 3839936..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/background_ddn.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/chain_texture.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/chain_texture.tga deleted file mode 100644 index 297274b..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/chain_texture.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/chain_texture_ddn.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/chain_texture_ddn.tga deleted file mode 100644 index c597acb..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/chain_texture_ddn.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/lion.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/lion.tga deleted file mode 100644 index 6888e9e..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/lion.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/lion2_ddn.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/lion2_ddn.tga deleted file mode 100644 index 8ab961f..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/lion2_ddn.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/lion_ddn.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/lion_ddn.tga deleted file mode 100644 index 16a1c78..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/lion_ddn.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/spnza_bricks_a_ddn.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/spnza_bricks_a_ddn.tga deleted file mode 100644 index 31dcfc2..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/spnza_bricks_a_ddn.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/spnza_bricks_a_diff.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/spnza_bricks_a_diff.tga deleted file mode 100644 index 2124b32..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/spnza_bricks_a_diff.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_arch_ddn.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_arch_ddn.tga deleted file mode 100644 index 09851c6..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_arch_ddn.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_arch_diff.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_arch_diff.tga deleted file mode 100644 index 01c425e..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_arch_diff.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_ceiling_a_ddn.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_ceiling_a_ddn.tga deleted file mode 100644 index 5d7a0a4..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_ceiling_a_ddn.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_ceiling_a_diff.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_ceiling_a_diff.tga deleted file mode 100644 index 16cfc25..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_ceiling_a_diff.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_column_a_ddn.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_column_a_ddn.tga deleted file mode 100644 index 5a99322..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_column_a_ddn.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_column_a_diff.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_column_a_diff.tga deleted file mode 100644 index ba10c95..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_column_a_diff.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_column_b_ddn.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_column_b_ddn.tga deleted file mode 100644 index c716b38..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_column_b_ddn.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_column_b_diff.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_column_b_diff.tga deleted file mode 100644 index 8478671..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_column_b_diff.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_column_c_ddn.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_column_c_ddn.tga deleted file mode 100644 index 0c384e7..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_column_c_ddn.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_column_c_diff.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_column_c_diff.tga deleted file mode 100644 index 61ea0c0..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_column_c_diff.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_curtain_blue_diff.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_curtain_blue_diff.tga deleted file mode 100644 index 6cd4c52..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_curtain_blue_diff.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_curtain_ddn.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_curtain_ddn.tga deleted file mode 100644 index 16b8f4e..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_curtain_ddn.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_curtain_diff.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_curtain_diff.tga deleted file mode 100644 index af23d3e..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_curtain_diff.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_curtain_green_diff.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_curtain_green_diff.tga deleted file mode 100644 index d8f9a28..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_curtain_green_diff.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_details_ddn.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_details_ddn.tga deleted file mode 100644 index 3448ef9..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_details_ddn.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_details_diff.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_details_diff.tga deleted file mode 100644 index 31b67d8..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_details_diff.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_fabric_blue_diff.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_fabric_blue_diff.tga deleted file mode 100644 index 7a37c26..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_fabric_blue_diff.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_fabric_ddn.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_fabric_ddn.tga deleted file mode 100644 index 7628952..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_fabric_ddn.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_fabric_diff.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_fabric_diff.tga deleted file mode 100644 index c9f933a..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_fabric_diff.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_fabric_green_diff.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_fabric_green_diff.tga deleted file mode 100644 index 7693da3..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_fabric_green_diff.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_flagpole_ddn.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_flagpole_ddn.tga deleted file mode 100644 index c6d202f..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_flagpole_ddn.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_flagpole_diff.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_flagpole_diff.tga deleted file mode 100644 index 8600a6b..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_flagpole_diff.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_floor_a_ddn.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_floor_a_ddn.tga deleted file mode 100644 index 4ef1409..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_floor_a_ddn.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_floor_a_diff.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_floor_a_diff.tga deleted file mode 100644 index e9587e3..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_floor_a_diff.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_roof_ddn.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_roof_ddn.tga deleted file mode 100644 index 72b1cbe..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_roof_ddn.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_roof_diff.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_roof_diff.tga deleted file mode 100644 index a8fd321..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_roof_diff.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_thorn_ddn.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_thorn_ddn.tga deleted file mode 100644 index 2fee918..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_thorn_ddn.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_thorn_diff.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_thorn_diff.tga deleted file mode 100644 index da77e00..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/sponza_thorn_diff.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/vase_ddn.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/vase_ddn.tga deleted file mode 100644 index 2f78759..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/vase_ddn.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/vase_dif.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/vase_dif.tga deleted file mode 100644 index c147b37..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/vase_dif.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/vase_hanging.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/vase_hanging.tga deleted file mode 100644 index 8954561..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/vase_hanging.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/vase_hanging_ddn.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/vase_hanging_ddn.tga deleted file mode 100644 index 451250a..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/vase_hanging_ddn.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/vase_plant.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/vase_plant.tga deleted file mode 100644 index 6ddbe2f..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/vase_plant.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/vase_round.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/vase_round.tga deleted file mode 100644 index 6f83f61..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/vase_round.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/vase_round_ddn.tga b/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/vase_round_ddn.tga deleted file mode 100644 index dddc76a..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/Sponza-master/textures/vase_round_ddn.tga and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Books.png b/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Books.png deleted file mode 100644 index 286806d..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Books.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d22e32193a310227721e83e86c446477b5728a0af2db77ed118d4799b4773d37 -size 199086 diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Clock.png b/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Clock.png deleted file mode 100644 index ae63e27..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Clock.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:425ec9a600cf2aad0f93e9552e29f9bb5b75618e12e0d56ab52f89b6fd73a12f -size 28576 diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Dask1.png b/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Dask1.png deleted file mode 100644 index bb68b39..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Dask1.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:735a8786a1261607a9103a3dda1dc2f9c9dbf4d2716c7df43e37f56c48569f37 -size 14260 diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Dask2.png b/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Dask2.png deleted file mode 100644 index 87c9948..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Dask2.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ed820be94883d94958a6eed83c97f725a380975e352cdebf3cad42eb52a436b4 -size 58209 diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Floare.png b/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Floare.png deleted file mode 100644 index 1c8b590..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Floare.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fad4811acf24fa25d868c9d563bd73263f43ea8252c5d76d64f639a9d06f1a7d -size 161752 diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Gak.png b/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Gak.png deleted file mode 100644 index f073ef1..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Gak.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:37674e373d54f4ec927a19a019daa12e7ee3a09a78f011f4c3b3f5e42c9ad619 -size 216820 diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Mel.png b/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Mel.png deleted file mode 100644 index fae5ef5..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Mel.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ccd3cc22dab4e0254c4757b5bbaf3cef9a2b6e05fab8f31b5e73af15a7015f51 -size 4213 diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Sky Anime Landscape [Scenery - Background] 53.jpg b/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Sky Anime Landscape [Scenery - Background] 53.jpg deleted file mode 100644 index 43f8699..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Sky Anime Landscape [Scenery - Background] 53.jpg +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a40a5bd72ab6f78c853b3170a530a96dc884616c4c10fe4f9506823c1fdc2fb6 -size 55679 diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/St1.png b/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/St1.png deleted file mode 100644 index a6a3f3d..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/St1.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a252fcff6ce27ff3da23c29801e24f8fd43f25eabfe619d8877bf3b4663f0400 -size 132558 diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/St3.png b/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/St3.png deleted file mode 100644 index f35b502..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/St3.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4ea969a7c5322738472dafb5e70374f161637cf1ae8aa3c3f886a77efea7de8a -size 594281 diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Stor.png b/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Stor.png deleted file mode 100644 index a9c3428..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/Stor.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b33813f29bdad914286a94238370538335ff9f20cf8f5f4ab8d794741267709c -size 69533 diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/anime school.mtl b/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/anime school.mtl deleted file mode 100644 index 2329ef0..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/anime school.mtl +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2d67c7e9715fefb01c2ea07a2e647fda5ca500c9e71c236de7d425b4873ec0c8 -size 3893 diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/foto1.png b/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/foto1.png deleted file mode 100644 index 27faf48..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/foto1.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ca4a83f03963ea3a9bbd1370b6bbe531fae9d1d1b7aa645dd2e43b8b170fb336 -size 58564 diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/foto2.png b/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/foto2.png deleted file mode 100644 index 854aac1..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/foto2.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5c86a9f1075b946a076295a5eacfc39a89bd66cb6f36d53ef1609816dc5ba818 -size 27614 diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/lamp.png b/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/lamp.png deleted file mode 100644 index 10554ee..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/lamp.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cc7c8e46cd41cef3cbb1cb62357d691080193cf4d199a595ec6c52ad74baedf4 -size 37469 diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/st2.png b/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/st2.png deleted file mode 100644 index 08bac87..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/st2.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:aceeba9b256f167a63e56cf7f97ed78a567a35db120d7cf487fcecfd8df8eafc -size 213397 diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/sten.png b/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/sten.png deleted file mode 100644 index 715eb72..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/animeclassroom/sten.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:15b0fc71018e0581b5579180e7c707ff152af1f4fc6adb58bc3488ccf5ff03a3 -size 58225 diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/bagan-khayiminga-temple-interior/source/{960D1B3D-BFCA-44C3-ABDC-D98809662125}.zip b/OpenGLEngine/OpenGLEngine/Resources/Models/bagan-khayiminga-temple-interior/source/{960D1B3D-BFCA-44C3-ABDC-D98809662125}.zip deleted file mode 100644 index ff89dd3..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/bagan-khayiminga-temple-interior/source/{960D1B3D-BFCA-44C3-ABDC-D98809662125}.zip +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6e6309a0161f3dbec937c27f49147354ed45e78ad425e452f4724be4ea2a4d7c -size 15844052 diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/bagan-khayiminga-temple-interior/tex_u1_v1.jpg b/OpenGLEngine/OpenGLEngine/Resources/Models/bagan-khayiminga-temple-interior/tex_u1_v1.jpg deleted file mode 100644 index 9ac0919..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/bagan-khayiminga-temple-interior/tex_u1_v1.jpg +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a9a75ea4b72147ccd3b16c856f06992bb7991ffe0ce213b75ef9f9dd176b1bb3 -size 13857317 diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/bagan-khayiminga-temple-interior/textures/tex_u1_v1.jpeg b/OpenGLEngine/OpenGLEngine/Resources/Models/bagan-khayiminga-temple-interior/textures/tex_u1_v1.jpeg deleted file mode 100644 index ce59f3a..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/bagan-khayiminga-temple-interior/textures/tex_u1_v1.jpeg +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9cc884f2c317bb1f9966a2d45955deda6330abd6609550f0ef9da6ae71af9957 -size 13769281 diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/LICENSE.txt b/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/LICENSE.txt deleted file mode 100644 index 5132909..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/LICENSE.txt +++ /dev/null @@ -1,6 +0,0 @@ -Original Nanosuit model by ForrestPL: -http://tf3dm.com/3d-model/crysis-2-nanosuit-2-97837.html - -Slightly modified for use in the LearnOpenGL.com tutorials (by Joey de Vries) - -For personal use only \ No newline at end of file diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/arm_dif.png b/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/arm_dif.png deleted file mode 100644 index 4afa5a4..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/arm_dif.png and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/arm_showroom_ddn.png b/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/arm_showroom_ddn.png deleted file mode 100644 index f1e7cea..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/arm_showroom_ddn.png and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/arm_showroom_spec.png b/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/arm_showroom_spec.png deleted file mode 100644 index 10bc141..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/arm_showroom_spec.png and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/body_dif.png b/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/body_dif.png deleted file mode 100644 index 22f5c0e..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/body_dif.png and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/body_showroom_ddn.png b/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/body_showroom_ddn.png deleted file mode 100644 index b8be545..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/body_showroom_ddn.png and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/body_showroom_spec.png b/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/body_showroom_spec.png deleted file mode 100644 index 8af4d1a..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/body_showroom_spec.png and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/glass_ddn.png b/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/glass_ddn.png deleted file mode 100644 index 7c71616..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/glass_ddn.png and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/glass_dif.png b/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/glass_dif.png deleted file mode 100644 index a2566cd..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/glass_dif.png and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/hand_dif.png b/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/hand_dif.png deleted file mode 100644 index 14fe073..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/hand_dif.png and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/hand_showroom_ddn.png b/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/hand_showroom_ddn.png deleted file mode 100644 index 5d203c4..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/hand_showroom_ddn.png and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/hand_showroom_spec.png b/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/hand_showroom_spec.png deleted file mode 100644 index f5f56d7..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/hand_showroom_spec.png and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/helmet_diff.png b/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/helmet_diff.png deleted file mode 100644 index 209615b..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/helmet_diff.png and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/helmet_showroom_ddn.png b/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/helmet_showroom_ddn.png deleted file mode 100644 index 2d4e20e..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/helmet_showroom_ddn.png and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/helmet_showroom_spec.png b/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/helmet_showroom_spec.png deleted file mode 100644 index a2e36c8..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/helmet_showroom_spec.png and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/leg_dif.png b/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/leg_dif.png deleted file mode 100644 index 6b84baf..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/leg_dif.png and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/leg_showroom_ddn.png b/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/leg_showroom_ddn.png deleted file mode 100644 index 2822fae..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/leg_showroom_ddn.png and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/leg_showroom_spec.png b/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/leg_showroom_spec.png deleted file mode 100644 index 49a95e7..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/leg_showroom_spec.png and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/nanosuit.blend b/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/nanosuit.blend deleted file mode 100644 index 2c4651d..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/nanosuit.blend and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/nanosuit.mtl b/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/nanosuit.mtl deleted file mode 100644 index c73e458..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/nanosuit/nanosuit.mtl +++ /dev/null @@ -1,79 +0,0 @@ -# Blender MTL File: 'nanosuit.blend' -# Material Count: 6 -newmtl Arm -Ns 96.078431 -Ka 0.000000 0.000000 0.000000 -Kd 0.640000 0.640000 0.640000 -Ks 0.500000 0.500000 0.500000 -Ni 1.000000 -d 1.000000 -illum 2 -map_Kd arm_dif.png -map_Bump arm_showroom_ddn.png -map_Ks arm_showroom_spec.png - - -newmtl Body -Ns 96.078431 -Ka 0.000000 0.000000 0.000000 -Kd 0.640000 0.640000 0.640000 -Ks 0.500000 0.500000 0.500000 -Ni 1.000000 -d 1.000000 -illum 2 -map_Kd body_dif.png -map_Bump body_showroom_ddn.png -map_Ks body_showroom_spec.png - - -newmtl Glass -Ns 96.078431 -Ka 0.000000 0.000000 0.000000 -Kd 0.640000 0.640000 0.640000 -Ks 0.500000 0.500000 0.500000 -Ni 1.000000 -d 1.000000 -illum 2 -map_Kd glass_dif.png -map_Bump glass_ddn.png - - -newmtl Hand -Ns 96.078431 -Ka 0.000000 0.000000 0.000000 -Kd 0.640000 0.640000 0.640000 -Ks 0.500000 0.500000 0.500000 -Ni 1.000000 -d 1.000000 -illum 2 -map_Kd hand_dif.png -map_Bump hand_showroom_ddn.png -map_Ks hand_showroom_spec.png - - -newmtl Helmet -Ns 96.078431 -Ka 0.000000 0.000000 0.000000 -Kd 0.640000 0.640000 0.640000 -Ks 0.500000 0.500000 0.500000 -Ni 1.000000 -d 1.000000 -illum 2 -map_Kd helmet_diff.png -map_Bump helmet_showroom_ddn.png -map_Ks helmet_showroom_spec.png - - -newmtl Leg -Ns 96.078431 -Ka 0.000000 0.000000 0.000000 -Kd 0.640000 0.640000 0.640000 -Ks 0.500000 0.500000 0.500000 -Ni 1.000000 -d 1.000000 -illum 2 -map_Kd leg_dif.png -map_Bump leg_showroom_ddn.png -map_Ks leg_showroom_spec.png - - diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/ribbon-ball/tex_u1_v1.jpg b/OpenGLEngine/OpenGLEngine/Resources/Models/ribbon-ball/tex_u1_v1.jpg deleted file mode 100644 index 7d2ac8e..0000000 --- a/OpenGLEngine/OpenGLEngine/Resources/Models/ribbon-ball/tex_u1_v1.jpg +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:81ddfacbe9e2880f23a133480bbfa19d180f1b4d58d2b2d31c275eddbc2d332c -size 5307859 diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire.zip b/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire.zip deleted file mode 100644 index ca156c4..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire.zip and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire/source/spitfire.rar b/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire/source/spitfire.rar deleted file mode 100644 index e5448d8..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire/source/spitfire.rar and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire/spitfire.FBX b/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire/spitfire.FBX deleted file mode 100644 index 4344991..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire/spitfire.FBX and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire/spitfire_ao.png b/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire/spitfire_ao.png deleted file mode 100644 index e38b9c7..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire/spitfire_ao.png and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire/spitfire_d.png b/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire/spitfire_d.png deleted file mode 100644 index 247d496..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire/spitfire_d.png and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire/spitfire_m.png b/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire/spitfire_m.png deleted file mode 100644 index 93a4b91..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire/spitfire_m.png and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire/spitfire_n.png b/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire/spitfire_n.png deleted file mode 100644 index ca2b67a..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire/spitfire_n.png and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire/spitfire_r.png b/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire/spitfire_r.png deleted file mode 100644 index 1910648..0000000 Binary files a/OpenGLEngine/OpenGLEngine/Resources/Models/supermarine-spitfire/spitfire_r.png and /dev/null differ diff --git a/OpenGLEngine/OpenGLEngine/RigidBodyComponent.h b/OpenGLEngine/OpenGLEngine/RigidBodyComponent.h index f391a16..b2b56d5 100644 --- a/OpenGLEngine/OpenGLEngine/RigidBodyComponent.h +++ b/OpenGLEngine/OpenGLEngine/RigidBodyComponent.h @@ -3,74 +3,17 @@ namespace Reality { - struct RigidBodyComponent + struct RigidbodyComponent { - RigidBodyComponent(float mass = 1.0f, float _linearDamping = 0.4f, float _angularDamping = 0.3f, Vector3 _velocity = Vector3(0, 0, 0), Vector3 _angularVelocity = Vector3(0, 0, 0), float _gravityScale = 1) - : inverseMass(1.0f / mass), velocity(_velocity), angularVelocity(_angularVelocity), linearDamping(_linearDamping), angularDamping(_angularDamping), gravityScale(_gravityScale), rp3dId(-1) + RigidbodyComponent(Vector3 _velocity = Vector3(0, 0, 0), Vector3 _angularVelocity = Vector3(0, 0, 0)) + :velocity(_velocity), acceleration(Vector3(0, 0, 0)), + angularVelocity(_angularVelocity), angularAcceleration(Vector3(0, 0, 0)) { - inertiaTensor = glm::mat3(0.0f); - inertiaTensor[0][0] = 0.001f; - inertiaTensor[1][1] = 0.001f; - inertiaTensor[2][2] = 0.001f; - accelaration = Vector3(0, 0, 0); - angularAccelaration = Vector3(0, 0, 0); - forceAccumulator = Vector3(0, 0, 0); - torqueAccumulator = Vector3(0, 0, 0); + } - float inverseMass; + Vector3 acceleration; Vector3 velocity; + Vector3 angularAcceleration; Vector3 angularVelocity; - Vector3 accelaration; - Vector3 angularAccelaration; - Mat3 inertiaTensor; - float gravityScale; - float linearDamping; - float angularDamping; - int rp3dId; - - Mat3 worldInverseInertiaTensor(Mat3 localToWorld) - { - Mat3 worldInertiaTensor = localToWorld * inertiaTensor * glm::inverse(localToWorld); - return glm::inverse(worldInertiaTensor); - } - - - // Forces - inline void AddForce(Vector3 force) - { - forceAccumulator += force; - } - inline Vector3 GetForce() - { - return forceAccumulator; - } - inline void ResetForceAccumulator() - { - forceAccumulator = Vector3(0, 0, 0); - } - - // Torque and force - inline void AddForceAtPoint(Vector3 force, Vector3 point, Vector3 origin) - { - AddForce(force); - AddTorque(glm::cross(point - origin, force)); - } - - // Torque - inline void AddTorque(Vector3 torque) - { - torqueAccumulator += torque; - } - inline Vector3 GetTorque() - { - return torqueAccumulator; - } - inline void ResetTorqueAccumulator() - { - torqueAccumulator = Vector3(0, 0, 0); - } - private: - Vector3 forceAccumulator; - Vector3 torqueAccumulator; }; } diff --git a/OpenGLEngine/OpenGLEngine/RigidBodyData.h b/OpenGLEngine/OpenGLEngine/RigidBodyData.h deleted file mode 100644 index d02cd64..0000000 --- a/OpenGLEngine/OpenGLEngine/RigidBodyData.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include "ECSConfig.h" - -namespace Reality -{ - struct RigidBodyData - { - RigidBodyData(ECSEntity _entity) - :entity(_entity) - { - - } - ECSEntity entity; - }; -} diff --git a/OpenGLEngine/OpenGLEngine/RigidBodySystem.cpp b/OpenGLEngine/OpenGLEngine/RigidBodySystem.cpp index aa20197..b8b36d3 100644 --- a/OpenGLEngine/OpenGLEngine/RigidBodySystem.cpp +++ b/OpenGLEngine/OpenGLEngine/RigidBodySystem.cpp @@ -1,77 +1,26 @@ -#include "RigidBodySystem.h" -#include "RigidBodyData.h" +#include "RigidbodySystem.h" namespace Reality { - RigidBodySystem::RigidBodySystem(rp3d::CollisionWorld& _rp3dWorld) - :rp3dWorld(_rp3dWorld) + RigidbodySystem::RigidbodySystem() { requireComponent(); - requireComponent(); + requireComponent(); } - void RigidBodySystem::Update(float deltaTime) + void RigidbodySystem::Update(float deltaTime) { - std::vector rp3dBodiesTemp; - std::vector aliveIds; - aliveIds.resize(rp3dBodies.size()); - int id = 0; - for (auto e : getEntities()) { - auto &rigidbody = e.getComponent(); - auto &transform = e.getComponent(); - - // Update RP3D Ids - // Calculate rp3d transform - rp3d::Vector3 initPosition(transform.GetPosition().x, - transform.GetPosition().y, - transform.GetPosition().z); - Quaternion quat = transform.GetOrientation(); - rp3d::Quaternion initOrientation = rp3d::Quaternion( - quat.x, quat.y, quat.z, quat.w); - rp3d::Transform rp3dtransform(initPosition, initOrientation); - // If new rigidbody, create an entry - if (rigidbody.rp3dId < 0) - { - rp3d::CollisionBody * body = rp3dWorld.createCollisionBody(rp3dtransform); - RigidBodyData* data = new RigidBodyData(e); - body->setUserData(data); - rp3dBodiesTemp.push_back(body); - rigidbody.rp3dId = id; - } - else - { - rp3d::CollisionBody * body = rp3dBodies[rigidbody.rp3dId]; - body->setTransform(rp3dtransform); - aliveIds[rigidbody.rp3dId] = 1; - rp3dBodiesTemp.push_back(body); - rigidbody.rp3dId = id; - } - id++; - - // Update velocity from accelarartion - rigidbody.velocity += rigidbody.accelaration * deltaTime; - rigidbody.angularVelocity += rigidbody.angularAccelaration * deltaTime; + auto& transform = e.getComponent(); + auto& rigidbody = e.getComponent(); - // Damping - rigidbody.velocity *= pow(1.0f - rigidbody.linearDamping, deltaTime); - rigidbody.angularVelocity *= pow(1.0f - rigidbody.angularDamping, deltaTime); - + rigidbody.velocity += rigidbody.acceleration * deltaTime; transform.SetPosition(transform.GetPosition() + rigidbody.velocity * deltaTime); - glm::quat angularVelocityQuat = glm::quat(0, rigidbody.angularVelocity.x, rigidbody.angularVelocity.y, rigidbody.angularVelocity.z); - getWorld().data.renderUtil->DrawLine(transform.GetPosition(), transform.GetPosition() + rigidbody.angularVelocity, Color::Blue); - transform.SetOrientation(glm::normalize(transform.GetOrientation() + 0.5f * angularVelocityQuat * transform.GetOrientation() * deltaTime)); - } - for (int i = 0; i < aliveIds.size(); i++) - { - if (aliveIds[i] == 0) - { - rp3dWorld.destroyCollisionBody(rp3dBodies[i]); - } + rigidbody.angularVelocity += rigidbody.angularAcceleration * deltaTime; + Quaternion deltaRot = Quaternion(0, rigidbody.angularVelocity * deltaTime); + transform.SetOrientation(glm::normalize(transform.GetOrientation() + 0.5f * deltaRot * transform.GetOrientation())); } - - rp3dBodies = rp3dBodiesTemp; } } diff --git a/OpenGLEngine/OpenGLEngine/RigidBodySystem.h b/OpenGLEngine/OpenGLEngine/RigidBodySystem.h index 88b8e03..7d3800c 100644 --- a/OpenGLEngine/OpenGLEngine/RigidBodySystem.h +++ b/OpenGLEngine/OpenGLEngine/RigidBodySystem.h @@ -1,17 +1,14 @@ #pragma once #include "ECSConfig.h" -#include "RigidBodyComponent.h" #include "TransformComponentV2.h" -#include +#include "RigidbodyComponent.h" namespace Reality { - class RigidBodySystem : public ECSSystem + class RigidbodySystem : public ECSSystem { public: - RigidBodySystem(rp3d::CollisionWorld& _rp3dWorld); + RigidbodySystem(); void Update(float deltaTime); - rp3d::CollisionWorld& rp3dWorld; - std::vector rp3dBodies; }; } diff --git a/OpenGLEngine/OpenGLEngine/RigidbodyGravityForceGeneratorSystem.cpp b/OpenGLEngine/OpenGLEngine/RigidbodyGravityForceGeneratorSystem.cpp deleted file mode 100644 index bf6fcef..0000000 --- a/OpenGLEngine/OpenGLEngine/RigidbodyGravityForceGeneratorSystem.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "RigidbodyGravityForceGeneratorSystem.h" - -namespace Reality -{ - RigidbodyGravityForceGeneratorSystem::RigidbodyGravityForceGeneratorSystem() - { - requireComponent(); - } - - void RigidbodyGravityForceGeneratorSystem::Update(float deltaTime) - { - for (auto e : getEntities()) - { - auto &body = e.getComponent(); - if (body.inverseMass > 0) - { - body.AddForce(gravity * body.gravityScale / body.inverseMass); - } - } - } -} diff --git a/OpenGLEngine/OpenGLEngine/RigidbodyGravityForceGeneratorSystem.h b/OpenGLEngine/OpenGLEngine/RigidbodyGravityForceGeneratorSystem.h deleted file mode 100644 index e1ea768..0000000 --- a/OpenGLEngine/OpenGLEngine/RigidbodyGravityForceGeneratorSystem.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include "ECSConfig.h" -#include "RigidBodyComponent.h" - -namespace Reality -{ - class RigidbodyGravityForceGeneratorSystem : public ECSSystem - { - public: - Vector3 gravity = Vector3(0.0f, -9.8f, 0.0f); - RigidbodyGravityForceGeneratorSystem(); - void Update(float deltaTime); - }; -} diff --git a/OpenGLEngine/OpenGLEngine/RotateComponentV2.h b/OpenGLEngine/OpenGLEngine/RotateComponentV2.h new file mode 100644 index 0000000..b5f34d8 --- /dev/null +++ b/OpenGLEngine/OpenGLEngine/RotateComponentV2.h @@ -0,0 +1,15 @@ +#pragma once +#include "ECSConfig.h" + +namespace Reality +{ + struct RotateComponentV2 + { + RotateComponentV2(Vector3 _rotationVelocity = Vector3(0, 0, 0)) + : rotationVelocity(_rotationVelocity) + { + + } + Vector3 rotationVelocity; + }; +} diff --git a/OpenGLEngine/OpenGLEngine/RotateSystem.cpp b/OpenGLEngine/OpenGLEngine/RotateSystem.cpp index 6bd16a0..5455ee5 100644 --- a/OpenGLEngine/OpenGLEngine/RotateSystem.cpp +++ b/OpenGLEngine/OpenGLEngine/RotateSystem.cpp @@ -1,4 +1,6 @@ #include "RotateSystem.h" +#include "LifeTimeComponent.h" +#include "TransformComponentV2.h" RotateSystem::RotateSystem() { @@ -10,11 +12,43 @@ void RotateSystem::Update(float deltaTime) { for (auto e : getEntities()) { +<<<<<<< Updated upstream auto &rotate = e.getComponent(); auto &transform = e.getComponent(); transform.eulerAngles.x += rotate.xRot * deltaTime; transform.eulerAngles.y += rotate.yRot * deltaTime; transform.eulerAngles.z += rotate.zRot * deltaTime; +======= + timer += deltaTime; + for (auto e : getEntities()) + { + auto& transform = e.getComponent(); + auto& rotate = e.getComponent(); + + transform.eulerAngles += rotate.rotationVelocity * deltaTime; + + if (timer >= 0.1f) + { + auto e1 = getWorld().createEntity(); + e1.addComponent(transform.position + transform.Up() * 10.0f); + e1.addComponent(); + + auto e2 = getWorld().createEntity(); + e2.addComponent(transform.position + transform.Right() * 10.0f); + e2.addComponent(5, Color::Red); + + auto e3 = getWorld().createEntity(); + e3.addComponent(transform.position + transform.Forward() * 10.0f); + e3.addComponent(5, Color::Blue); + } + } + if (timer >= 0.1f) + { + timer = 0; + } + + //getWorld().data.renderUtil->RenderText("Euler Angles", 350, 200, 1, Color::Orange); +>>>>>>> Stashed changes } } diff --git a/OpenGLEngine/OpenGLEngine/RotateSystem.h b/OpenGLEngine/OpenGLEngine/RotateSystem.h index 1a9cc29..6dc3f85 100644 --- a/OpenGLEngine/OpenGLEngine/RotateSystem.h +++ b/OpenGLEngine/OpenGLEngine/RotateSystem.h @@ -6,8 +6,20 @@ using namespace Reality; class RotateSystem : public ECSSystem { +<<<<<<< Updated upstream public: RotateSystem(); void Update(float deltaTime); }; +======= + class RotateSystem : public ECSSystem + { + public: + RotateSystem(); + void Update(float deltaTime); + private: + float timer = 0; + }; +} +>>>>>>> Stashed changes diff --git a/OpenGLEngine/OpenGLEngine/RotateSystemV2.cpp b/OpenGLEngine/OpenGLEngine/RotateSystemV2.cpp new file mode 100644 index 0000000..b3d64fe --- /dev/null +++ b/OpenGLEngine/OpenGLEngine/RotateSystemV2.cpp @@ -0,0 +1,51 @@ +#include "RotateSystemV2.h" +#include +#include "LifeTimeComponent.h" + +namespace Reality +{ + RotateSystemV2::RotateSystemV2() + { + requireComponent(); + requireComponent(); + } + + void RotateSystemV2::Update(float deltaTime) + { + timer += deltaTime; + for (auto e : getEntities()) + { + auto& transform = e.getComponent(); + auto& rotate = e.getComponent(); + + Vector3 axis = glm::normalize(rotate.rotationVelocity); + float angle = glm::radians(glm::length(rotate.rotationVelocity)) * deltaTime; + + Quaternion deltaQuat = glm::angleAxis(angle, axis); + Quaternion newRot = glm::normalize(deltaQuat * transform.GetOrientation()); + + transform.SetOrientation(newRot); + + if (timer >= 0.1f) + { + auto e1 = getWorld().createEntity(); + e1.addComponent(transform.GetPosition() + transform.Up() * 10.0f); + e1.addComponent(); + + auto e2 = getWorld().createEntity(); + e2.addComponent(transform.GetPosition() + transform.Right() * 10.0f); + e2.addComponent(5, Color::Red); + + auto e3 = getWorld().createEntity(); + e3.addComponent(transform.GetPosition() + transform.Forward() * 10.0f); + e3.addComponent(5, Color::Blue); + } + } + if (timer >= 0.1f) + { + timer = 0; + } + + //getWorld().data.renderUtil->RenderText("Quaternions", 1300, 200, 1, Color::Orange); + } +} diff --git a/OpenGLEngine/OpenGLEngine/FlightSimulatorSystem.h b/OpenGLEngine/OpenGLEngine/RotateSystemV2.h similarity index 54% rename from OpenGLEngine/OpenGLEngine/FlightSimulatorSystem.h rename to OpenGLEngine/OpenGLEngine/RotateSystemV2.h index 67dcc5c..9b594bf 100644 --- a/OpenGLEngine/OpenGLEngine/FlightSimulatorSystem.h +++ b/OpenGLEngine/OpenGLEngine/RotateSystemV2.h @@ -1,15 +1,14 @@ #pragma once #include "ECSConfig.h" -#include "FlighSimulatorComponent.h" -#include "RigidBodyComponent.h" #include "TransformComponentV2.h" +#include "RotateComponentV2.h" namespace Reality { - class FlightSimulatorSystem : public ECSSystem + class RotateSystemV2 : public ECSSystem { public: - FlightSimulatorSystem(); + RotateSystemV2(); void Update(float deltaTime); private: float timer = 0; diff --git a/OpenGLEngine/OpenGLEngine/SetAerodynamicTensorSystem.cpp b/OpenGLEngine/OpenGLEngine/SetAerodynamicTensorSystem.cpp deleted file mode 100644 index 6ba18d7..0000000 --- a/OpenGLEngine/OpenGLEngine/SetAerodynamicTensorSystem.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "SetAerodynamicTensorSystem.h" - -namespace Reality -{ - SetAerodynamicTensorSystem::SetAerodynamicTensorSystem() - { - requireComponent(); - requireComponent(); - } - - void SetAerodynamicTensorSystem::Update(float deltaTime) - { - for (auto e : getEntities()) - { - auto& aero = e.getComponent(); - auto& minMax = e.getComponent(); - - /*if (minMax.controlSetting <= -1.0f) - { - aero.aerodynamicTensor = minMax.minTensor; - } - else if (minMax.controlSetting >= 1.0f) - { - aero.aerodynamicTensor = minMax.maxTensor; - }*/ - if (minMax.controlSetting <= 0) - { - aero.aerodynamicTensor = -minMax.controlSetting * minMax.minTensor + (minMax.controlSetting + 1) * minMax.baseTensor; - } - else if (minMax.controlSetting > 0) - { - aero.aerodynamicTensor = (1-minMax.controlSetting) * minMax.baseTensor + minMax.controlSetting * minMax.maxTensor; - } - /*else - { - aero.aerodynamicTensor = minMax.baseTensor; - }*/ - - - } - } -} diff --git a/OpenGLEngine/OpenGLEngine/SetAerodynamicTensorSystem.h b/OpenGLEngine/OpenGLEngine/SetAerodynamicTensorSystem.h deleted file mode 100644 index ad467f0..0000000 --- a/OpenGLEngine/OpenGLEngine/SetAerodynamicTensorSystem.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include "ECSConfig.h" -#include "AeroComponent.h" -#include "AeroMinMaxComponent.h" - -namespace Reality -{ - class SetAerodynamicTensorSystem : public ECSSystem - { - public: - SetAerodynamicTensorSystem(); - void Update(float deltaTime); - }; -} diff --git a/OpenGLEngine/OpenGLEngine/SphereColliderComponent.h b/OpenGLEngine/OpenGLEngine/SphereColliderComponent.h deleted file mode 100644 index 3d5e9cd..0000000 --- a/OpenGLEngine/OpenGLEngine/SphereColliderComponent.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include "ECSConfig.h" - -namespace Reality -{ - struct SphereColliderComponent - { - SphereColliderComponent(ECSEntity _body = ECSEntity(), float _radius = 1.0f, Vector3 _offset = Vector3(0, 0, 0)) - : body(_body), offset(_offset), radius(_radius), rp3dId(-1) - {} - ECSEntity body; - Vector3 offset; - float radius; - int rp3dId; - }; -} diff --git a/OpenGLEngine/OpenGLEngine/SphereColliderSystem.cpp b/OpenGLEngine/OpenGLEngine/SphereColliderSystem.cpp deleted file mode 100644 index 46c752f..0000000 --- a/OpenGLEngine/OpenGLEngine/SphereColliderSystem.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include "SphereColliderSystem.h" -#include "RigidBodyComponent.h" -#include "RigidBodySystem.h" - -namespace Reality -{ - SphereColliderSystem::SphereColliderSystem(rp3d::CollisionWorld& _rp3dWorld) - :rp3dWorld(_rp3dWorld) - { - requireComponent(); - } - - void SphereColliderSystem::Update(float deltaTime) - { - std::vector rp3dShapesTemp; - std::vector aliveIds; - aliveIds.resize(rp3dShapes.size()); - int id = 0; - - for (auto e : getEntities()) - { - auto &sphereCollider = e.getComponent(); - - if (sphereCollider.body.isAlive() && sphereCollider.body.hasComponent()) - { - auto &body = sphereCollider.body.getComponent(); - - // Update RP3D Ids - // Calculate local rp3d transform - rp3d::Vector3 initPosition(sphereCollider.offset.x, - sphereCollider.offset.y, - sphereCollider.offset.z); - rp3d::Quaternion initOrientation = rp3d::Quaternion::identity(); - rp3d::Transform rp3dtransform(initPosition, initOrientation); - - auto rp3dBody = getWorld().getSystemManager().getSystem().rp3dBodies[body.rp3dId]; - // If new rigidbody, create an entry - if (sphereCollider.rp3dId < 0) - { - rp3d::decimal radius = rp3d::decimal(sphereCollider.radius); - rp3d::SphereShape* shape = new rp3d::SphereShape(radius); - // Add the collision shape to the rigid body - - rp3d::ProxyShape * proxyShape = rp3dBody->addCollisionShape(shape, rp3dtransform); - proxyShape->setUserData(&sphereCollider); - rp3dShapesTemp.push_back(proxyShape); - sphereCollider.rp3dId = id; - } - else if (sphereCollider.body.isAlive()) - { - rp3d::ProxyShape * shape = rp3dShapes[sphereCollider.rp3dId]; - shape->setLocalToBodyTransform(rp3dtransform); - aliveIds[sphereCollider.rp3dId] = 1; - rp3dShapesTemp.push_back(shape); - sphereCollider.rp3dId = id; - } - id++; - - if (sphereCollider.body.hasComponent()) - { - getWorld().data.renderUtil->DrawSphere(sphereCollider.body.getComponent().GetUnScaledTransformationMatrix() * Vector4(sphereCollider.offset, 1.0f), sphereCollider.radius); - } - } - else - { - // No need to kill it, the death of RB already killed it - aliveIds[sphereCollider.rp3dId] = 1; - e.kill(); - } - } - - for (int i = 0; i < aliveIds.size(); i++) - { - if (aliveIds[i] == 0) - { - if (rp3dShapes[i]) - { - auto shape = rp3dShapes[i]->getCollisionShapePublic(); - - if (rp3dShapes[i]->getBody() && rp3dShapes[i]->getBody()->getProxyShapesList()) - { - rp3dShapes[i]->getBody()->removeCollisionShape(rp3dShapes[i]); - } - delete shape; - } - } - } - - rp3dShapes = rp3dShapesTemp; - } -} diff --git a/OpenGLEngine/OpenGLEngine/SphereColliderSystem.h b/OpenGLEngine/OpenGLEngine/SphereColliderSystem.h deleted file mode 100644 index 9be8223..0000000 --- a/OpenGLEngine/OpenGLEngine/SphereColliderSystem.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include "ECSConfig.h" -#include "SphereColliderComponent.h" -#include "TransformComponentV2.h" -#include - -namespace Reality -{ - class SphereColliderSystem : public ECSSystem - { - public: - SphereColliderSystem(rp3d::CollisionWorld& _rp3dWorld); - void Update(float deltaTime); - private: - rp3d::CollisionWorld& rp3dWorld; - std::vector rp3dShapes; - }; -} diff --git a/OpenGLEngine/OpenGLEngine/ThrusterComponent.h b/OpenGLEngine/OpenGLEngine/ThrusterComponent.h new file mode 100644 index 0000000..a6f6b9d --- /dev/null +++ b/OpenGLEngine/OpenGLEngine/ThrusterComponent.h @@ -0,0 +1,29 @@ +#pragma once +#include "ECSConfig.h" + +namespace Reality +{ + struct ThrusterComponent + { + ThrusterComponent(ECSEntity _targetEntity = ECSEntity(), + const std::vector& _positiveKeys = {}, + const std::vector& _negetiveKeys = {}, + Vector3 _localThrustDirection = Vector3(0, 0, 1), + float _thrust = 200 + ) + :targetEntity(_targetEntity), + localThrustDirection(_localThrustDirection), + thrust(_thrust), + positiveKeys(_positiveKeys), + negetiveKeys(_negetiveKeys) + { + + } + ECSEntity targetEntity; + Vector3 localThrustDirection; + float thrust; + float timer = 0; + std::vector positiveKeys; + std::vector negetiveKeys; + }; +} diff --git a/OpenGLEngine/OpenGLEngine/ThrusterSystem.cpp b/OpenGLEngine/OpenGLEngine/ThrusterSystem.cpp new file mode 100644 index 0000000..82e9917 --- /dev/null +++ b/OpenGLEngine/OpenGLEngine/ThrusterSystem.cpp @@ -0,0 +1,50 @@ +#include "ThrusterSystem.h" +#include "TransformComponentV2.h" +#include "ForceAndTorqueAccumulatorComponent.h" +#include "LifeTimeComponent.h" + +namespace Reality +{ + ThrusterSystem::ThrusterSystem() + { + requireComponent(); + } + + void ThrusterSystem::Update(float deltaTime) + { + for (auto e : getEntities()) + { + auto& thruster = e.getComponent(); + + for (int key : thruster.positiveKeys) { + if (glfwGetKey(getWorld().data.renderUtil->window->glfwWindow, key) == GLFW_PRESS) + thruster.thrust += deltaTime * 50; + } + + for (int key : thruster.negetiveKeys) { + if (glfwGetKey(getWorld().data.renderUtil->window->glfwWindow, key) == GLFW_PRESS) + thruster.thrust -= deltaTime * 50; + } + + if (thruster.targetEntity.hasComponent() && + thruster.targetEntity.hasComponent()) + { + auto& transform = thruster.targetEntity.getComponent(); + auto& forceAndTorque = thruster.targetEntity.getComponent(); + + Vector3 worldThrustDirection = transform.LocalToWorldDirection(thruster.localThrustDirection); + forceAndTorque.AddForce(worldThrustDirection * thruster.thrust); + + thruster.timer += deltaTime; + + if (thruster.timer > 0.3f) + { + auto smokeTrail = getWorld().createEntity(); + smokeTrail.addComponent(transform.GetPosition() - worldThrustDirection * 10.0f); + smokeTrail.addComponent(); + thruster.timer = 0; + } + } + } + } +} diff --git a/OpenGLEngine/OpenGLEngine/CameraLookSystem.h b/OpenGLEngine/OpenGLEngine/ThrusterSystem.h similarity index 52% rename from OpenGLEngine/OpenGLEngine/CameraLookSystem.h rename to OpenGLEngine/OpenGLEngine/ThrusterSystem.h index 8d17a1c..d32164d 100644 --- a/OpenGLEngine/OpenGLEngine/CameraLookSystem.h +++ b/OpenGLEngine/OpenGLEngine/ThrusterSystem.h @@ -1,13 +1,13 @@ #pragma once #include "ECSConfig.h" -#include "CameraLookComponent.h" +#include "ThrusterComponent.h" namespace Reality { - class CameraLookSystem : public ECSSystem + class ThrusterSystem : public ECSSystem { public: - CameraLookSystem(); + ThrusterSystem(); void Update(float deltaTime); }; } diff --git a/OpenGLEngine/OpenGLEngine/TransformComponent.h b/OpenGLEngine/OpenGLEngine/TransformComponent.h index cfa71b5..a5bb70f 100644 --- a/OpenGLEngine/OpenGLEngine/TransformComponent.h +++ b/OpenGLEngine/OpenGLEngine/TransformComponent.h @@ -12,11 +12,26 @@ namespace Reality Vector3 position; Vector3 scale; Vector3 eulerAngles; - Quaternion orientation; - Mat4 scaleMatrix; - Mat4 rotationMatrix; - Mat4 translationMatrix; - Mat4 unScaledTransformationMatrix; - Mat4 transformationMatrix; + + inline const Vector3& Right() + { + Vector3 radAngle = Vector3(glm::radians(eulerAngles.x), + glm::radians(eulerAngles.y), glm::radians(eulerAngles.z)); + return glm::quat(radAngle) * Vector3(1, 0, 0); + } + + inline const Vector3& Up() + { + Vector3 radAngle = Vector3(glm::radians(eulerAngles.x), + glm::radians(eulerAngles.y), glm::radians(eulerAngles.z)); + return glm::quat(radAngle) * Vector3(0, 1, 0); + } + + inline const Vector3& Forward() + { + Vector3 radAngle = Vector3(glm::radians(eulerAngles.x), + glm::radians(eulerAngles.y), glm::radians(eulerAngles.z)); + return glm::quat(radAngle) * Vector3(0, 0, 1); + } }; } \ No newline at end of file diff --git a/OpenGLEngine/OpenGLEngine/TransformComponentV2.h b/OpenGLEngine/OpenGLEngine/TransformComponentV2.h index 27575d5..b3bfc0e 100644 --- a/OpenGLEngine/OpenGLEngine/TransformComponentV2.h +++ b/OpenGLEngine/OpenGLEngine/TransformComponentV2.h @@ -6,10 +6,10 @@ namespace Reality { struct TransformComponentV2 { - TransformComponentV2(Vector3 _position = Vector3(0, 0, 0), Vector3 _scale = Vector3(1, 1, 1), Vector3 _eulerAngles = Vector3(0.0f, 0.0f, 0.0f)) : + TransformComponentV2(Vector3 _position = Vector3(0, 0, 0), Vector3 _scale = Vector3(1, 1, 1), Vector3 _eulerAngles = Vector3(0, 0, 0)) : position(_position), scale(_scale) { - SetRotation(_eulerAngles); + SetEulerAngles(_eulerAngles); } private: Vector3 position; @@ -24,22 +24,25 @@ namespace Reality inline void UpdateMatrices() { - scaleMatrix = glm::scale(glm::mat4(1.0f), scale); - translationMatrix = glm::translate(glm::mat4(1.0f), position); + scaleMatrix = glm::scale(Mat4(1.0f), scale); rotationMatrix = glm::toMat4(orientation); + translationMatrix = glm::translate(Mat4(1.0f), position); unScaledTransformationMatrix = translationMatrix * rotationMatrix; transformationMatrix = unScaledTransformationMatrix * scaleMatrix; dirty = false; } + public: - public: inline void SetPosition(const Vector3& _position) { position = _position; dirty = true; } - inline Vector3 GetPosition() { return position; } + inline const Vector3& GetPosition() + { + return position; + } inline void SetScale(const Vector3& _scale) { @@ -47,43 +50,36 @@ namespace Reality dirty = true; } - inline Vector3 GetScale() { return scale; } - - inline void SetOrientation(const Quaternion& _orientation) + inline const Vector3& GetScale() { - orientation = _orientation; - dirty = true; + return scale; } - inline Quaternion GetOrientation() { return orientation; } - - // Euler angles in degrees - inline void SetRotation(Vector3 eulerAngles) + inline void SetOrientation(const Quaternion& _orientation) { - glm::vec3 rotationInRads = glm::vec3(glm::radians(eulerAngles.x), - glm::radians(eulerAngles.y), glm::radians(eulerAngles.z)); - orientation = glm::quat(rotationInRads); + orientation = _orientation; dirty = true; } - inline Vector3 GetRotation() { return glm::eulerAngles(orientation); } - - inline Vector3 Up() + inline const Quaternion& GetOrientation() { - return orientation * Vector3(0.0f, 1.0f, 0.0f); + return orientation; } - inline Vector3 Right() + inline void SetEulerAngles(const Vector3& _eulerAngles) { - return orientation * Vector3(1.0f, 0.0f, 0.0f); + Vector3 radAngle = Vector3(glm::radians(_eulerAngles.x), + glm::radians(_eulerAngles.y), glm::radians(_eulerAngles.z)); + orientation = glm::quat(radAngle); + dirty = true; } - inline Vector3 Forward() + inline const Vector3& GetEulerAngles() { - return orientation * Vector3(0.0f, 0.0f, 1.0f); + return glm::eulerAngles(orientation); } - inline Mat4 GetScaleMatrix() + inline const Mat4& GetScaleMatrix() { if (dirty) { @@ -92,7 +88,7 @@ namespace Reality return scaleMatrix; } - inline Mat4 GetRotationMatrix() + inline const Mat4& GetRotationMatrix() { if (dirty) { @@ -101,16 +97,16 @@ namespace Reality return rotationMatrix; } - inline Mat4 GetTranslationMatrix() + inline const Mat4& GetTranslationMatrix() { if (dirty) { UpdateMatrices(); } - return transformationMatrix; + return translationMatrix; } - inline Mat4 GetUnScaledTransformationMatrix() + inline const Mat4& GetUnScaledTransformationMatrix() { if (dirty) { @@ -119,7 +115,7 @@ namespace Reality return unScaledTransformationMatrix; } - inline Mat4 GetTransformationMatrix() + inline const Mat4& GetTransformationMatrix() { if (dirty) { @@ -128,30 +124,48 @@ namespace Reality return transformationMatrix; } - inline Vector3 WorldToLocalPosition(Vector3 _position) + inline const Vector3& Right() { - return glm::inverse(GetTransformationMatrix()) * Vector4(_position, 1); + return orientation * Vector3(1, 0, 0); + } + + inline const Vector3& Up() + { + return orientation * Vector3(0, 1, 0); + } + inline const Vector3& Forward() + { + return orientation * Vector3(0, 0, 1); } - inline Vector3 LocalToWorldPosition(Vector3 _position) + inline const Vector3& LocalToWorldDirection(const Vector3& _localDirection) { - return GetTransformationMatrix() * Vector4(_position, 1); + return orientation * _localDirection; } - //TODO : Check - inline Vector3 WorldToLocalDirection(Vector3 direction) + inline const Vector3& WorldToLocalDirection(const Vector3& _worldDirection) { if (glm::length(orientation) > 0) { - return glm::inverse(orientation) * direction; + return glm::inverse(orientation) * _worldDirection; } return Vector3(0, 0, 0); } - inline Vector3 LocalToWorldDirection(Vector3 direction) + + inline const Vector3& LocalToWorldPosition(const Vector3& _localPosition) + { + return GetTransformationMatrix() * Vector4(_localPosition, 1.0f); + } + + inline const Vector3& WorldToLocalPosition(const Vector3& _worldPosition) { - return orientation * direction; + if (abs(glm::determinant(GetTransformationMatrix())) > 0) + { + return glm::inverse(GetTransformationMatrix()) * Vector4(_worldPosition, 1.0f); + } + return Vector3(0, 0, 0); } }; } diff --git a/OpenGLEngine/OpenGLEngine/UpdateTransformMatricesSystem.cpp b/OpenGLEngine/OpenGLEngine/UpdateTransformMatricesSystem.cpp deleted file mode 100644 index a17a6ce..0000000 --- a/OpenGLEngine/OpenGLEngine/UpdateTransformMatricesSystem.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "UpdateTransformMatricesSystem.h" - -namespace Reality -{ - UpdateTransformMatricesSystem::UpdateTransformMatricesSystem() - { - requireComponent(); - } - - void UpdateTransformMatricesSystem::Update(float deltaTime) - { - for (auto e : getEntities()) - { - auto& transform = e.getComponent(); - //transform.scaleMatrix = glm::scale(glm::mat4(1.0f), transform.scale); - //transform.translationMatrix = glm::translate(glm::mat4(1.0f), transform.position); - //transform.rotationMatrix = glm::toMat4(transform.orientation); - //transform.unScaledTransformationMatrix = transform.translationMatrix * transform.rotationMatrix; - //transform.transformationMatrix = transform.unScaledTransformationMatrix * transform.scaleMatrix; - } - } -} diff --git a/OpenGLEngine/OpenGLEngine/UpdateTransformMatricesSystem.h b/OpenGLEngine/OpenGLEngine/UpdateTransformMatricesSystem.h deleted file mode 100644 index bcda6dc..0000000 --- a/OpenGLEngine/OpenGLEngine/UpdateTransformMatricesSystem.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#include "ECSConfig.h" -#include "TransformComponentV2.h" - -namespace Reality -{ - class UpdateTransformMatricesSystem : public ECSSystem - { - public: - UpdateTransformMatricesSystem(); - void Update(float deltaTime); - }; -} diff --git a/README.md b/README.md index 4b12e89..736220e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # Reality-Game-Engine -An OpenGL based game engine with custom rigidbody physics +An Fork of Reality Game Engine for teaching purposes. + +![](https://i.imgur.com/44IeKeI.gif)