Skip to content

Commit

Permalink
Dynamic library export
Browse files Browse the repository at this point in the history
  • Loading branch information
KaganBaldiran committed Apr 28, 2024
1 parent 447c258 commit 64a71fa
Show file tree
Hide file tree
Showing 65 changed files with 2,108 additions and 1,276 deletions.
198 changes: 103 additions & 95 deletions Fusion_Frame_Engine/Application.cpp

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions Fusion_Frame_Engine/Application.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#pragma once
#include <glew.h>
#include <glfw3.h>

#define TARGET_FPS 144
#define ENGINE_DEBUG

#ifndef ENGINE_DEBUG
#define ENGINE_RELEASE
#endif

struct GLFWwindow;

class Application
{
public:
Expand Down
5 changes: 5 additions & 0 deletions Fusion_Frame_Engine/FusionCore/Animation.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#include "Animation.hpp"
#include <glew.h>
#include <glfw3.h>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>

FUSIONCORE::Animation::Animation(const char* AnimationPath, Model* model)
{
Expand Down
13 changes: 6 additions & 7 deletions Fusion_Frame_Engine/FusionCore/Animation.hpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
#pragma once
#include <glew.h>
#include <glfw3.h>
#include "../FusionUtility/Log.h"
#include "../FusionUtility/VectorMath.h"
#include <vector>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include "Bone.hpp"
#include "Model.hpp"
#include "../FusionUtility/FusionDLLExport.h"

struct aiAnimation;
struct aiNode;

namespace FUSIONCORE
{
struct BoneNodeData
struct FUSIONFRAME_EXPORT BoneNodeData
{
glm::mat4 transformation;
std::string name;
int childrenCount;
std::vector<BoneNodeData> children;
};

class Animation
class FUSIONFRAME_EXPORT Animation
{
public:
Animation(const char* AnimationPath, Model* model);
Expand Down
2 changes: 2 additions & 0 deletions Fusion_Frame_Engine/FusionCore/Animator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "Animator.hpp"
#include <glew.h>
#include <glfw3.h>

namespace FUSIONCORE
{
Expand Down
7 changes: 4 additions & 3 deletions Fusion_Frame_Engine/FusionCore/Animator.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#pragma once
#include "Animation.hpp"
#include "../FusionUtility/FusionDLLExport.h"

#define MAX_BONE_COUNT 100

namespace FUSIONCORE
{
extern std::unique_ptr<UBO> AnimationUniformBufferObject;
FUSIONFRAME_EXPORT_FUNCTION std::unique_ptr<UBO> AnimationUniformBufferObject;

void InitializeAnimationUniformBuffer();
FUSIONFRAME_EXPORT_FUNCTION void InitializeAnimationUniformBuffer();

class Animator
class FUSIONFRAME_EXPORT Animator
{
public:
Animator(Animation* Animation);
Expand Down
52 changes: 52 additions & 0 deletions Fusion_Frame_Engine/FusionCore/Bone.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#include "Bone.hpp"
#include "../FusionUtility/glm/gtx/quaternion.hpp"
#include <glew.h>
#include <glfw3.h>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>

float FUSIONCORE::Bone::GetScaleFactor(float lastTimeStamp, float nextTimeStamp, float AnimationTime)
{
Expand Down Expand Up @@ -52,6 +57,53 @@ glm::mat4 FUSIONCORE::Bone::InterpolateScaling(float AnimationTime)
return glm::scale(glm::mat4(1.0f) , FinalScale);
}

FUSIONCORE::Bone::Bone(const std::string& name, int ID, aiNodeAnim* channel) : Name(name), ID(ID), LocalTransform(1.0f)
{
NumberOfPositions = channel->mNumPositionKeys;

for (size_t i = 0; i < NumberOfPositions; i++)
{
aiVector3D aiPosition = channel->mPositionKeys[i].mValue;
float timeStamp = channel->mPositionKeys[i].mTime;
KeyPosition data;
data.Position.x = aiPosition.x;
data.Position.y = aiPosition.y;
data.Position.z = aiPosition.z;

data.timeStamp = timeStamp;
Positions.push_back(data);
}

NumberOfRotations = channel->mNumRotationKeys;

for (size_t i = 0; i < NumberOfRotations; i++)
{
aiQuaternion Orientation = channel->mRotationKeys[i].mValue;
float timeStamp = channel->mRotationKeys[i].mTime;

KeyRotation data;
data.Orientation = glm::quat(Orientation.w, Orientation.x, Orientation.y, Orientation.z);
data.timeStamp = timeStamp;
Rotations.push_back(data);
}

NumberOfScalings = channel->mNumScalingKeys;

for (size_t i = 0; i < NumberOfScalings; i++)
{
aiVector3D scale = channel->mScalingKeys[i].mValue;
float timeStamp = channel->mScalingKeys[i].mTime;

KeyScale data;
data.Scale.x = scale.x;
data.Scale.y = scale.y;
data.Scale.z = scale.z;

data.timeStamp = timeStamp;
Scales.push_back(data);
}
}

void FUSIONCORE::Bone::Update(float AnimationTime)
{
glm::mat4 translation = InterpolatePosition(AnimationTime);
Expand Down
66 changes: 9 additions & 57 deletions Fusion_Frame_Engine/FusionCore/Bone.hpp
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
#pragma once
#include <glew.h>
#include <glfw3.h>
#include "../FusionUtility/Log.h"
#include "../FusionUtility/VectorMath.h"
#include <vector>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include "../FusionUtility/FusionDLLExport.h"

//Forward declaration
struct aiNodeAnim;

namespace FUSIONCORE
{
struct KeyPosition
struct FUSIONFRAME_EXPORT KeyPosition
{
glm::vec3 Position;
float timeStamp;
};

struct KeyRotation
struct FUSIONFRAME_EXPORT KeyRotation
{
glm::quat Orientation;
float timeStamp;
};

struct KeyScale
struct FUSIONFRAME_EXPORT KeyScale
{
glm::vec3 Scale;
float timeStamp;
};

class Bone
class FUSIONFRAME_EXPORT Bone
{
private:
std::vector<KeyPosition> Positions;
Expand All @@ -48,56 +47,9 @@ namespace FUSIONCORE
glm::mat4 InterpolateRotation(float AnimationTime);
glm::mat4 InterpolateScaling(float AnimationTime);


public:

Bone(const std::string& name, int ID, aiNodeAnim* channel) : Name(name), ID(ID), LocalTransform(1.0f)
{
NumberOfPositions = channel->mNumPositionKeys;

for (size_t i = 0; i < NumberOfPositions; i++)
{
aiVector3D aiPosition = channel->mPositionKeys[i].mValue;
float timeStamp = channel->mPositionKeys[i].mTime;
KeyPosition data;
data.Position.x = aiPosition.x;
data.Position.y = aiPosition.y;
data.Position.z = aiPosition.z;

data.timeStamp = timeStamp;
Positions.push_back(data);
}

NumberOfRotations = channel->mNumRotationKeys;

for (size_t i = 0; i < NumberOfRotations; i++)
{
aiQuaternion Orientation = channel->mRotationKeys[i].mValue;
float timeStamp = channel->mRotationKeys[i].mTime;

KeyRotation data;
data.Orientation = glm::quat(Orientation.w, Orientation.x, Orientation.y, Orientation.z);
data.timeStamp = timeStamp;
Rotations.push_back(data);
}

NumberOfScalings = channel->mNumScalingKeys;

for (size_t i = 0; i < NumberOfScalings; i++)
{
aiVector3D scale = channel->mScalingKeys[i].mValue;
float timeStamp = channel->mScalingKeys[i].mTime;

KeyScale data;
data.Scale.x = scale.x;
data.Scale.y = scale.y;
data.Scale.z = scale.z;

data.timeStamp = timeStamp;
Scales.push_back(data);
}
}

Bone(const std::string& name, int ID, aiNodeAnim* channel);
void Update(float AnimationTime);

glm::mat4 GetLocalTransformation() { return this->LocalTransform; };
Expand Down
2 changes: 2 additions & 0 deletions Fusion_Frame_Engine/FusionCore/Buffer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "Buffer.h"
#include <glew.h>
#include <glfw3.h>

FUSIONCORE::Buffer::Buffer()
{
Expand Down
48 changes: 23 additions & 25 deletions Fusion_Frame_Engine/FusionCore/Buffer.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#pragma once
#include <glew.h>
#include <glfw3.h>
#include "../FusionUtility/FusionDLLExport.h"
#include "../FusionUtility/VectorMath.h"

namespace FUSIONCORE
{
class Buffer
class FUSIONFRAME_EXPORT Buffer
{
public:
Buffer();
Expand All @@ -20,8 +20,7 @@ namespace FUSIONCORE
GLuint vao, vbo;
};


class Buffer3D : public Buffer
class FUSIONFRAME_EXPORT Buffer3D : public Buffer
{
public:

Expand All @@ -36,8 +35,7 @@ namespace FUSIONCORE

};


class VBO
class FUSIONFRAME_EXPORT VBO
{
public:
VBO();
Expand All @@ -51,7 +49,7 @@ namespace FUSIONCORE
bool IsChanged;
};

class VAO
class FUSIONFRAME_EXPORT VAO
{
public:

Expand All @@ -63,7 +61,7 @@ namespace FUSIONCORE
GLuint vao;
};

class UBO
class FUSIONFRAME_EXPORT UBO
{
public:
UBO();
Expand All @@ -77,7 +75,7 @@ namespace FUSIONCORE
GLuint ubo;
};

class EBO
class FUSIONFRAME_EXPORT EBO
{
public:

Expand All @@ -92,7 +90,7 @@ namespace FUSIONCORE

};

class SSBO
class FUSIONFRAME_EXPORT SSBO
{
public:
void BindSSBO(unsigned int BindingPoint);
Expand All @@ -107,22 +105,22 @@ namespace FUSIONCORE
GLuint ssbo;
};

struct DrawArraysIndirectCommand {
struct FUSIONFRAME_EXPORT DrawArraysIndirectCommand {
GLuint Count;
GLuint InstanceCount;
GLuint First;
GLuint BaseInstance;
};

struct DrawElementsIndirectCommand {
GLuint Count; // Number of elements to render
GLuint InstanceCount; // Number of instances
GLuint FirstIndex; // The base index within the index buffer to start drawing from
GLuint BaseVertex; // Offset to add to each index before fetching the vertex data
GLuint BaseInstance; // Instance ID of the first instance to draw
struct FUSIONFRAME_EXPORT DrawElementsIndirectCommand {
GLuint Count;
GLuint InstanceCount;
GLuint FirstIndex;
GLuint BaseVertex;
GLuint BaseInstance;
};

class IndirectCommandBuffer
class FUSIONFRAME_EXPORT IndirectCommandBuffer
{
public:
IndirectCommandBuffer();
Expand All @@ -133,10 +131,10 @@ namespace FUSIONCORE
GLuint icb;
};

void BindVBONull();
void BindVAONull();
void BindEBONull();
void BindUBONull();
void BindSSBONull();
void BindIndirectCommandBufferNull();
FUSIONFRAME_EXPORT_FUNCTION void BindVBONull();
FUSIONFRAME_EXPORT_FUNCTION void BindVAONull();
FUSIONFRAME_EXPORT_FUNCTION void BindEBONull();
FUSIONFRAME_EXPORT_FUNCTION void BindUBONull();
FUSIONFRAME_EXPORT_FUNCTION void BindSSBONull();
FUSIONFRAME_EXPORT_FUNCTION void BindIndirectCommandBufferNull();
}
Loading

0 comments on commit 64a71fa

Please sign in to comment.