Skip to content

Commit

Permalink
Merge branch 'dev' into feat/floor
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler-Lentz committed Jun 3, 2024
2 parents 09a397a + 57f7874 commit 68447d9
Show file tree
Hide file tree
Showing 71 changed files with 1,371 additions and 181 deletions.
Binary file modified assets/.DS_Store
Binary file not shown.
Binary file added assets/imgs/arrowtrap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/compasses/compass_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/imgs/compasses/compass_120.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/imgs/compasses/compass_150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/compasses/compass_180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/imgs/compasses/compass_210.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/imgs/compasses/compass_240.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/compasses/compass_270.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/imgs/compasses/compass_30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/imgs/compasses/compass_300.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/imgs/compasses/compass_330.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/imgs/compasses/compass_60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/imgs/compasses/compass_90.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/imgs/floorspiketrap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/imgs/lightning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/imgs/spiketrap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/imgs/sungod.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/imgs/teleporter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sounds/server_sfx/itemdrop.wav
Binary file not shown.
Binary file added assets/sounds/server_sfx/itempickup.wav
Binary file not shown.
Binary file added assets/sounds/server_sfx/potion.wav
Binary file not shown.
Binary file added assets/sounds/server_sfx/spell.wav
Binary file not shown.
Binary file added assets/sounds/server_sfx/teleport.wav
Binary file not shown.
46 changes: 23 additions & 23 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"game": {
"maze": {
"directory": "maps",
"procedural": true,
"maze_file": "test/itemRoom.maze"
}
},
"network": {
"server_ip": "localhost",
"server_port": 2355
},
"server": {
"lobby_name": "Hope you're doing well!1",
"lobby_broadcast": true,
"max_players": 5,
"disable_dm": false
},
"client": {
"default_name": "Conan O'Brien",
"lobby_discovery": true,
"fullscreen": true,
"draw_bboxes": false,
"fps_counter": true
"game": {
"maze": {
"directory": "maps",
"procedural": false,
"maze_file": "test/itemRoom.maze"
}
},
"network": {
"server_ip": "localhost",
"server_port": 2355
},
"server": {
"lobby_name": "Hope you're doing well!1",
"lobby_broadcast": true,
"max_players": 1,
"disable_dm": true
},
"client": {
"default_name": "Conan O'Brien",
"lobby_discovery": true,
"fullscreen": true,
"draw_bboxes": false,
"fps_counter": true
}
}
44 changes: 44 additions & 0 deletions include/client/animation.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#pragma once

#include <vector>
#include <map>
#include <glm/glm.hpp>
#include <assimp/scene.h>
#include <functional>
#include "client/bone.hpp"
#include "client/model.hpp"
#include "client/util.hpp"

struct AssimpNodeData {
glm::mat4 transformation;
std::string name;
int numChildren;
std::vector<AssimpNodeData> children;
};

class Animation {
public:
Animation() = default;

Animation(const std::string& animationPath, Model* model);

~Animation() {}

Bone* findBone(const std::string& name);

inline float getTicksPerSecond() { return m_ticksPerSecond; }
inline float getDuration() { return m_duration;}
inline const AssimpNodeData& getRootNode() { return m_rootNode; }
inline const std::map<std::string,BoneInfo>& getBoneIDMap() { return m_boneInfoMap; }

private:
void readMissingBones(const aiAnimation* animation, Model& model);

void readHierarchyData(AssimpNodeData& dest, const aiNode* src);

float m_duration;
int m_ticksPerSecond;
std::vector<Bone> m_bones;
AssimpNodeData m_rootNode;
std::map<std::string, BoneInfo> m_boneInfoMap;
};
41 changes: 41 additions & 0 deletions include/client/animationmanager.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#pragma once

#include <glm/glm.hpp>
#include <map>
#include <vector>
#include <unordered_map>
#include <utility>

#include <assimp/scene.h>
#include <assimp/Importer.hpp>
#include "client/animation.hpp"
#include "client/bone.hpp"
#include "shared/game/sharedobject.hpp"

class AnimationManager
{
public:
AnimationManager(Animation* animation);

void updateAnimation(float dt);

void playAnimation(Animation* pAnimation);

void calculateBoneTransform(const AssimpNodeData* node, glm::mat4 parentTransform);

void addAnimation(Animation* anim, ObjectType objType, AnimState animState);

void setAnimation(EntityID id, ObjectType objType, AnimState animState);

std::vector<glm::mat4> getFinalBoneMatrices() { return m_finalBoneMatrices; }

private:
std::vector<glm::mat4> m_finalBoneMatrices;
std::unordered_map<EntityID, std::pair<float, Animation*>> entityAnimMap;
std::unordered_map<ObjectType, std::unordered_map<AnimState, Animation*>> objAnimMap;
Animation* m_currentAnimation;
EntityID currEntity;
float m_currentTime;
float m_deltaTime;

};
69 changes: 69 additions & 0 deletions include/client/bone.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#pragma once

/* Container for bone data */

#include <vector>
#include <assimp/scene.h>
#include <list>
#include <glm/glm.hpp>

#define GLM_ENABLE_EXPERIMENTAL
#include <glm/gtx/quaternion.hpp>
#include "client/util.hpp"

struct keyPosition
{
glm::vec3 position;
float timeStamp;
};

struct keyRotation
{
glm::quat orientation;
float timeStamp;
};

struct keyScale
{
glm::vec3 scale;
float timeStamp;
};

class Bone
{
public:
Bone(const std::string& name, int ID, const aiNodeAnim* channel);

void update(float animationTime);

glm::mat4 getLocalTransform() { return m_localTransform; }
std::string getBoneName() const { return m_name; }
int getBoneID() { return m_ID; }

int getPositionIndex(float animationTime);

int getRotationIndex(float animationTime);

int getScaleIndex(float animationTime);

private:

float getScaleFactor(float lastTimeStamp, float nextTimeStamp, float animationTime);

glm::mat4 interpolatePosition(float animationTime);

glm::mat4 interpolateRotation(float animationTime);

glm::mat4 interpolateScaling(float animationTime);

std::vector<keyPosition> m_positions;
std::vector<keyRotation> m_rotations;
std::vector<keyScale> m_scales;
int m_numPositions;
int m_numRotations;
int m_numScalings;

glm::mat4 m_localTransform;
std::string m_name;
int m_ID;
};
6 changes: 6 additions & 0 deletions include/client/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#include "client/camera.hpp"
#include "client/audio/audiomanager.hpp"
#include "client/constants.hpp"
#include "client/animation.hpp"
#include "client/animationmanager.hpp"
#include "client/bone.hpp"

#include "shared/game/sharedgamestate.hpp"
#include "shared/game/sharedobject.hpp"
Expand Down Expand Up @@ -164,6 +167,7 @@ class Client {
bool connect(std::string ip_addr);

AudioManager* getAudioManager();
AnimationManager* getAnimManager() { return animManager; }

void setWorldPos();

Expand Down Expand Up @@ -220,6 +224,7 @@ class Client {
/* Shader objects for various */
std::shared_ptr<Shader> deferred_geometry_shader;
std::shared_ptr<Shader> deferred_lighting_shader;
std::shared_ptr<Shader> dm_deferred_lighting_shader;
std::shared_ptr<Shader> deferred_light_box_shader;

/* Character models and lighting objects, might need to move to different classes later */
Expand Down Expand Up @@ -278,6 +283,7 @@ class Client {
RadioButtonState roleSelection;

AudioManager* audioManager;
AnimationManager* animManager;

/* Camera object representing player's current position & orientation */
std::unique_ptr<Camera> cam;
Expand Down
1 change: 1 addition & 0 deletions include/client/gui/font/font.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@ float getScaleFactor(Size size);
*/
float getRelativePixels(float pixels);

float getRelativePixelsHorizontal(float pixels);

}
5 changes: 5 additions & 0 deletions include/client/gui/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ class GUI {
* @brief Wipes all of the captured keyboard input from the internal state.
*/
void clearCapturedKeyboardInput();
/**
* @brief Displays controls for the player
*/
void displayControl();
/**
* @brief Returns all of the captured keyboard input without clearing it.
*
Expand Down Expand Up @@ -292,6 +296,7 @@ class GUI {
Client* client;

GameConfig config;
bool controlDisplayed;

std::vector<std::string> recentEvents;

Expand Down
23 changes: 16 additions & 7 deletions include/client/gui/img/img.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,20 @@ enum class ImgID {
ManaTickEmpty,
ManaTickFull,
Needle,
Compass,
ItemBG,
DMTrapBG,
EventBG,
DMEventBG,
Compass0,
Compass90,
Compass180,
Compass270,
Compass0, Compass30, Compass60,
Compass90, Compass120, Compass150,
Compass180, Compass210, Compass240,
Compass270, Compass300, Compass330,
FloorSpikeTrap,
Sungod,
Teleporter,
Lightning,
ArrowTrap,
SpikeTrap,
Blank,
};
#define GET_ALL_IMG_IDS() \
Expand All @@ -62,9 +67,13 @@ enum class ImgID {
ImgID::LeftHotbar, ImgID::RightHotbar, ImgID::MiddleHotbar, ImgID::Blank, ImgID::Title, \
ImgID::MiddleSelected, ImgID::HealthBar, ImgID::HealthTickEmpty, ImgID::HealthTickFull, \
ImgID::ManaBar, ImgID::ManaTickEmpty, ImgID::ManaTickFull, ImgID::ItemBG, \
ImgID::DMTrapBG, ImgID::Needle, ImgID::Compass, ImgID::Compass0, \
ImgID::Compass90, ImgID::Compass180, ImgID::Compass270, ImgID::EventBG, ImgID::DMEventBG, \
ImgID::DMTrapBG, ImgID::Needle, ImgID::EventBG, ImgID::DMEventBG, \
ImgID::Compass0, ImgID::Compass30, ImgID::Compass60, ImgID::Compass90, \
ImgID::Compass120, ImgID::Compass150, ImgID::Compass180, ImgID::Compass210, \
ImgID::Compass240, ImgID::Compass270, ImgID::Compass300, ImgID::Compass330, \
ImgID::DMLeftHotbar, ImgID::DMRightHotbar, ImgID::DMMiddleHotbar, ImgID::DMMiddleSelected, \
ImgID::FloorSpikeTrap, ImgID::Sungod, ImgID::Teleporter, ImgID::Lightning, \
ImgID::ArrowTrap, ImgID::SpikeTrap, \
}

/**
Expand Down
29 changes: 28 additions & 1 deletion include/client/model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <vector>
#include <string>
#include <map>
#include <memory>
#include <optional>
#include <set>
Expand All @@ -16,6 +17,9 @@
#include "client/renderable.hpp"
#include "client/shader.hpp"
#include "client/util.hpp"
#include "client/bone.hpp"

#define MAX_BONE_INFLUENCE 4

/**
* Stores position, normal vector, and coordinates
Expand All @@ -25,6 +29,8 @@ struct Vertex {
glm::vec3 position;
glm::vec3 normal;
glm::vec2 textureCoords;
int m_boneIDs[MAX_BONE_INFLUENCE]; /* Bone indices which influence the vertex */
float m_weights[MAX_BONE_INFLUENCE]; /* Weights for each bone */
};

class Texture {
Expand Down Expand Up @@ -60,6 +66,14 @@ struct Material {
float shininess;
};

struct BoneInfo {
/*id is index in finalBoneMatrices*/
int id;

/*offset matrix transforms vertex from model space to bone space*/
glm::mat4 offset;
};

/**
* Mesh holds the data needed to render a mesh (collection of triangles).
*
Expand Down Expand Up @@ -113,7 +127,7 @@ class Model : public Renderable {
*
* @param Filepath to model file.
*/
explicit Model(const std::string& filepath);
explicit Model(const std::string& filepath, bool flip_uvs);

/**
* Draws all the meshes of a given model
Expand Down Expand Up @@ -239,13 +253,26 @@ class Model : public Renderable {

void overrideSolidColor(std::optional<glm::vec3> color);


auto& getBoneInfoMap() { return m_boneInfoMap; }
int& getBoneCount() { return m_boneCounter; }


private:
std::vector<Mesh> meshes;
Bbox bbox;
glm::vec3 dimensions;

std::map<std::string, BoneInfo> m_boneInfoMap;
int m_boneCounter = 0;


void processNode(aiNode* node, const aiScene* scene);
Mesh processMesh(aiMesh* mesh, const aiScene* scene);
void setDefaultVertexBoneData(Vertex& vertex);
void setVertexBoneData(Vertex& vertex, int boneID, float weight);
void extractBoneWeight(std::vector<Vertex>& vertices, aiMesh* mesh, const aiScene* scene);

std::vector<Texture> loadMaterialTextures(aiMaterial* mat, const aiTextureType& type);


Expand Down
Loading

0 comments on commit 68447d9

Please sign in to comment.