-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
4,095 additions
and
12 deletions.
There are no files selected for viewing
3,852 changes: 3,852 additions & 0 deletions
3,852
AimGL/resources/Models/button_stand/button-stand.obj
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "Transform.h" | ||
#include "pch.h" | ||
|
||
#include <Renderer/Graphics/3D/Utils/Rotation3D.h> | ||
|
||
glm::mat4 Transform::matrix() const | ||
{ | ||
return mTransform; | ||
} | ||
|
||
Transform& Transform::translate(const glm::vec3& vec) | ||
{ | ||
glm::translate(mTransform, vec); | ||
return *this; | ||
} | ||
|
||
Transform& Transform::rotate(const Rotation3D& rotation) | ||
{ | ||
mTransform = rotation.rotate(mTransform); | ||
return *this; | ||
} | ||
|
||
Transform& Transform::operator*=(const Transform& rhs) | ||
{ | ||
mTransform *= rhs.mTransform; | ||
return *this; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
#pragma once | ||
|
||
class Rotation3D; | ||
|
||
class Transform | ||
{ | ||
public: | ||
[[nodiscard]] glm::mat4 matrix() const; | ||
Transform& translate(const glm::vec3& vec); | ||
Transform& rotate(const Rotation3D& rotation); | ||
Transform& operator*=(const Transform& rhs); | ||
|
||
|
||
private: | ||
glm::mat4 mTransform{1}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "ButtonStand.h" | ||
#include "pch.h" | ||
|
||
ButtonStand::ButtonStand(ColliderRegister& colliderRegister, const glm::vec3& position) | ||
: mButtonStand("resources/Models/button_stand/button-stand.obj", | ||
{{"resources/Models/button_stand/button-stand.png", Texture::Type::Diffuse}}) | ||
, mColliderRegister(colliderRegister) | ||
, mCollisionBox(mColliderRegister, {0, 0, 0}, mButtonStand.dimensions()) | ||
, mButtonShotTriggerBox( | ||
colliderRegister, {0, 0, 0}, | ||
{mButtonStand.dimensions().x / 2.f, 0.1, mButtonStand.dimensions().z / 2.f}) | ||
{ | ||
mButtonStand.setPosition(position); | ||
mCollisionBox.setPosition(mButtonStand.position() - mButtonStand.dimensions() / 2.f); | ||
|
||
auto shotTriggerBoxPosition = mButtonStand.position(); | ||
shotTriggerBoxPosition.x -= mButtonStand.dimensions().x / 4.f; | ||
shotTriggerBoxPosition.z -= mButtonStand.dimensions().z / 4.f; | ||
shotTriggerBoxPosition.y += (mButtonStand.dimensions().y / 2.f) - 0.1; | ||
mButtonShotTriggerBox.setPosition(shotTriggerBoxPosition); | ||
} | ||
|
||
void ButtonStand::draw(const Renderer& target, const Camera& camera) const | ||
{ | ||
mButtonStand.draw(target, camera); | ||
mCollisionBox.draw(target, camera); | ||
mButtonShotTriggerBox.draw(target, camera); | ||
} | ||
|
||
void ButtonStand::update(const float& deltaTime) | ||
{ | ||
// Nothing I guess? | ||
} | ||
|
||
void ButtonStand::fixedUpdate(const float& deltaTime) | ||
{ | ||
} | ||
|
||
void ButtonStand::handleEvent(const sf::Event& event) | ||
{ | ||
// Nothing I guess? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#pragma once | ||
#include <Renderer/Graphics/3D/Model.h> | ||
#include <World/Physics/Drawable/AABB.h> | ||
|
||
class ColliderRegister; | ||
|
||
class ButtonStand | ||
{ | ||
public: | ||
/** | ||
* \brief Constructor of Button Stand class | ||
* \param colliderRegister Register in which all collisions on the scene should be located | ||
* \param position | ||
*/ | ||
ButtonStand(ColliderRegister& colliderRegister, const glm::vec3& position); | ||
|
||
/** | ||
* \brief Draws a Button Stand to a given target | ||
* \param target The target to which the sprite is drawn | ||
* \param camera TODO: THIS | ||
*/ | ||
void draw(const Renderer& target, const Camera& camera) const; | ||
|
||
/** | ||
* Updates the Button Stand logic dependent, or independent of time, every rendered frame. | ||
* \param deltaTime the time that has passed since the game was last updated. | ||
*/ | ||
void update(const float& deltaTime); | ||
|
||
void fixedUpdate(const float& deltaTime); | ||
|
||
/** | ||
* \brief It takes input (event) from the user and interprets it | ||
* \param event user input | ||
*/ | ||
void handleEvent(const sf::Event& event); | ||
|
||
private: | ||
Model mButtonStand; | ||
sf::SoundBuffer mSoundBuffer; | ||
sf::Sound mClickSound; | ||
ColliderRegister& mColliderRegister; | ||
AABB mCollisionBox; | ||
AABB mButtonShotTriggerBox; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include "Node.h" | ||
#include "pch.h" | ||
|
||
void Node::pinNode(NodePtr node) | ||
{ | ||
node->mParent = this; | ||
mPinnedNodes.emplace_back(std::move(node)); | ||
} | ||
|
||
cpp::result<Node::NodePtr, Node::Result> Node::unpinNode(const Node& node) | ||
{ | ||
auto foundNode = std::find_if(mPinnedNodes.begin(), mPinnedNodes.end(), | ||
[&node](const NodePtr& containerNode) | ||
{ | ||
return containerNode.get() == &node; | ||
}); | ||
if (foundNode == mPinnedNodes.end()) | ||
{ | ||
spdlog::critical("Trying to unpin a node that does not exist in Node container!"); | ||
return cpp::fail(Result::NodeNotFound); | ||
} | ||
|
||
auto nodePtr = std::move(*foundNode); | ||
mPinnedNodes.erase(foundNode); | ||
nodePtr->mParent = nullptr; | ||
return nodePtr; | ||
} | ||
|
||
void Node::draw(const Renderer& target) const | ||
{ | ||
drawThis(target, mTransform); | ||
|
||
for (const auto& pinnedNode: mPinnedNodes) | ||
{ | ||
pinnedNode->draw(target, mTransform); | ||
} | ||
} | ||
|
||
void Node::drawThis(const Renderer& target, const Transform& transform) const | ||
{ | ||
// Should be implemented | ||
} | ||
|
||
void Node::draw(const Renderer& target, Transform transform) const | ||
{ | ||
transform *= mTransform; | ||
drawThis(target, transform); | ||
for (const auto& pinnedNode: mPinnedNodes) | ||
{ | ||
pinnedNode->draw(target, transform); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#pragma once | ||
#include <Utils/Transform.h> | ||
#include <result.hpp> | ||
|
||
class Renderer; | ||
|
||
class Node | ||
{ | ||
public: | ||
enum class Result | ||
{ | ||
NodeNotFound | ||
}; | ||
|
||
using NodePtr = std::unique_ptr<Node>; | ||
virtual ~Node() = default; | ||
|
||
void pinNode(NodePtr node); | ||
cpp::result<NodePtr, Result> unpinNode(const Node& node); | ||
void draw(const Renderer& target) const; | ||
void update(const float& deltaTime); | ||
void handleEvent(const sf::Event& event); | ||
|
||
protected: | ||
virtual void drawThis(const Renderer& target, const Transform& transform) const; | ||
virtual void updateThis(const float& deltaTime); | ||
virtual void handleEventThis(const sf::Event& event); | ||
|
||
private: | ||
void draw(const Renderer& target, Transform transform) const; | ||
|
||
std::list<NodePtr> mPinnedNodes; | ||
Node* mParent{nullptr}; | ||
glm::vec3 mPosition{0, 0, 0}; | ||
Transform mTransform; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,6 @@ | |
// Logging | ||
#include "minitrace.h" | ||
#include "spdlog/spdlog.h" | ||
|
||
// Other | ||
#include <result.hpp> |