-
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
22 changed files
with
4,227 additions
and
12 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,86 @@ | ||
#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}) | ||
{ | ||
mSoundBuffer.loadFromFile("resources/Sounds/button-click.wav"); | ||
mClickSound.setBuffer(mSoundBuffer); | ||
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); | ||
|
||
mButtonShotTriggerBox.callback( | ||
[this](const Collider& collider) | ||
{ | ||
if (collider.colliderTag() == ColliderTag::GunShot) | ||
{ | ||
if (not isAnimationBeingPlayed) | ||
{ | ||
signalizeButtonClick(); | ||
mOnShotFunction(); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
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) | ||
{ | ||
if (isAnimationBeingPlayed) | ||
{ | ||
if (mAnimationClock.getElapsedTime() > mTimeOfClickAnimation) | ||
{ | ||
isAnimationBeingPlayed = false; | ||
mButtonStand.mesh().setTexture( | ||
{"resources/Models/button_stand/button-stand.png", Texture::Type::Diffuse}); | ||
} | ||
} | ||
} | ||
|
||
void ButtonStand::onClick(std::function<void()> onShotFunction) | ||
{ | ||
mOnShotFunction = std::move(onShotFunction); | ||
} | ||
|
||
void ButtonStand::handleEvent(const sf::Event& event) | ||
{ | ||
// TODO: Meh... I think it is unexpected to check | ||
// whether mouse is clicked :/ | ||
|
||
if (event.type == sf::Event::MouseButtonPressed && event.key.code == sf::Mouse::Left && | ||
not isAnimationBeingPlayed) | ||
{ | ||
hasNewMouseClickOccured = true; | ||
} | ||
} | ||
|
||
void ButtonStand::signalizeButtonClick() | ||
{ | ||
if (hasNewMouseClickOccured) | ||
{ | ||
isAnimationBeingPlayed = true; | ||
mAnimationClock.restart(); | ||
mButtonStand.mesh().setTexture( | ||
{"resources/Models/button_stand/button-stand-clicked.png", Texture::Type::Diffuse}); | ||
hasNewMouseClickOccured = false; | ||
mClickSound.play(); | ||
} | ||
} |
Oops, something went wrong.