Merge remote-tracking branch 'origin/master' into WeaponSystem

# Conflicts:
#	include/Engine/Collision/FillFrustumOctreeSystem.h
#	include/Engine/Core/Octree.h
#	include/Engine/Rendering/RenderSystem.h
#	include/Game/Game.h
#	resources/DefaultInput.ini
#	resources/Schema/Components.xsd
#	resources/Schema/Entities/Player.xml
#	resources/Schema/Types/Entity.xsd
#	src/Engine/Rendering/RenderSystem.cpp
#	src/Game/Game.cpp
#	src/Game/Systems/PlayerMovementSystem.cpp
This commit is contained in:
2016-02-10 14:49:03 +01:00
174 changed files with 8445 additions and 1872 deletions
+4 -2
View File
@@ -9,6 +9,7 @@
#include "Rendering/Model.h"
#include "Rendering/EAnimationComplete.h"
#include "Rendering/Skeleton.h"
#include <imgui/imgui.h>
class AnimationSystem : public PureSystem
{
@@ -22,8 +23,9 @@ public:
~AnimationSystem() { }
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& animationComponent, double dt) override;
private:
float angle = 0.f;
bool b_forward = false;
char bone[100];
};
#endif
@@ -0,0 +1,29 @@
#ifndef BoneAttachmentSystem_h__
#define BoneAttachmentSystem_h__
#include "GLM.h"
#include "Common.h"
#include "Core/System.h"
#include "Core/ResourceManager.h"
#include "Rendering/Model.h"
#include "Rendering/Skeleton.h"
//Needs to be a higher orderlevel than AnimationSystem
class BoneAttachmentSystem : public PureSystem
{
public:
BoneAttachmentSystem(SystemParams params)
: System(params)
, PureSystem("BoneAttachment")
{
}
~BoneAttachmentSystem() { }
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& BoneAttachmentComponent, double dt) override;
private:
};
#endif
@@ -17,7 +17,7 @@ public:
void InitializeFrameBuffers();
void InitializeShaderPrograms();
void Draw(GLuint sceneTexture, GLuint bloomTexture, GLfloat gamma, GLfloat exposure);
void Draw(GLuint sceneTexture, GLuint bloomTexture, GLuint sceneTextureLowRes, GLuint bloomTextureLowRes, GLfloat gamma, GLfloat exposure);
private:
const IRenderer* m_Renderer;
+30 -3
View File
@@ -22,21 +22,29 @@ public:
//Return the texture that is used in later stages to apply the bloom effect
GLuint BloomTexture() const { return m_BloomTexture; }
GLuint BloomTextureLowRes() const { return m_BloomTextureLowRes; }
//Return the texture with diffuse and lighting of the scene.
GLuint SceneTexture() const { return m_SceneTexture; }
GLuint SceneTextureLowRes() const { return m_SceneTextureLowRes; }
//Return the framebuffer used in the scene rendering stage.
FrameBuffer* FinalPassFrameBuffer() { return &m_FinalPassFrameBuffer; }
FrameBuffer* FinalPassFrameBufferLowRes() { return &m_FinalPassFrameBufferLowRes; }
private:
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const;
void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& job, RenderScene& scene);
void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
void DrawShieldToStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
void DrawShieldedModelRenderQueue(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
void DrawToDepthBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
void BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene);
void BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene);
void BindExplosionTextures(std::shared_ptr<ExplosionEffectJob>& job);
void BindModelTextures(std::shared_ptr<ModelJob>& job);
void BindExplosionTextures(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job);
void BindModelTextures(GLuint shaderHandle, std::shared_ptr<ModelJob>& job);
Texture* m_WhiteTexture;
Texture* m_BlackTexture;
@@ -44,15 +52,34 @@ private:
Texture* m_GreyTexture;
FrameBuffer m_FinalPassFrameBuffer;
FrameBuffer m_FinalPassFrameBufferLowRes;
GLuint m_BloomTexture;
GLuint m_SceneTexture;
GLuint m_BloomTextureLowRes;
GLuint m_SceneTextureLowRes;
GLuint m_DepthBuffer;
GLuint m_DepthBufferLowRes;
//maqke this component based i guess?
GLuint m_ShieldPixelRate = 16;
const IRenderer* m_Renderer;
const LightCullingPass* m_LightCullingPass;
ShaderProgram* m_ForwardPlusProgram;
ShaderProgram* m_ExplosionEffectProgram;
ShaderProgram* m_ExplosionEffectSplatMapProgram;
ShaderProgram* m_ForwardPlusSplatMapProgram;
ShaderProgram* m_ShieldToStencilProgram;
ShaderProgram* m_FillDepthBufferProgram;
ShaderProgram* m_ForwardPlusSkinnedProgram;
ShaderProgram* m_ExplosionEffectSkinnedProgram;
ShaderProgram* m_ExplosionEffectSplatMapSkinnedProgram;
ShaderProgram* m_ForwardPlusSplatMapSkinnedProgram;
ShaderProgram* m_ShieldToStencilSkinnedProgram;
ShaderProgram* m_FillDepthBufferSkinnedProgram;
};
#endif
@@ -12,4 +12,11 @@ private:
};
class DrawStencilState : public RenderState
{
public:
DrawStencilState(GLuint frameBuffer);
~DrawStencilState();
};
#endif
@@ -15,7 +15,7 @@
struct ExplosionEffectJob : ModelJob
{
ExplosionEffectJob(ComponentWrapper explosionEffectComponent, ::Model* model, Camera* camera, glm::mat4 matrix, ::RawModel::MaterialGroup matGroup, ComponentWrapper modelComponent, ::World* world, glm::vec4 fillColor, float fillPercentage)
ExplosionEffectJob(ComponentWrapper explosionEffectComponent, ::Model* model, Camera* camera, glm::mat4 matrix, ::RawModel::MaterialProperties matGroup, ComponentWrapper modelComponent, ::World* world, glm::vec4 fillColor, float fillPercentage)
: ModelJob(model, camera, matrix, matGroup, modelComponent, world, fillColor, fillPercentage)
{
ExplosionOrigin = (glm::vec3)explosionEffectComponent["ExplosionOrigin"];
+8 -4
View File
@@ -4,6 +4,7 @@
#include "Rendering/RawModelCustom.h"
//#include "Rendering/RawModelAssimp.h"
#include "../OpenGL.h"
#include "Core/AABB.h"
class Model : public ThreadUnsafeResource
{
@@ -14,16 +15,19 @@ private:
public:
~Model();
const std::vector<RawModel::MaterialGroup>& MaterialGroups() const { return m_RawModel->MaterialGroups; }
const std::vector<RawModel::MaterialProperties>& MaterialGroups() const { return m_RawModel->m_Materials; }
const glm::mat4& Matrix() const { return m_RawModel->m_Matrix; }
const std::vector<RawModel::Vertex>& Vertices() const { return m_RawModel->m_Vertices; }
const RawModel::Vertex* Vertices() const { return m_RawModel->Vertices(); }
unsigned int NumberOfVertices() const { return m_RawModel->NumVertices(); }
const AABB& Box() const { return m_Box; }
bool IsSkinned() const { return m_RawModel->IsSkinned(); }
GLuint VAO;
GLuint ElementBuffer;
RawModel* m_RawModel;
private:
AABB m_Box;
GLuint VertexBuffer;
GLuint NormalBuffer;
GLuint TangentNormalsBuffer;
+123 -37
View File
@@ -14,39 +14,98 @@
#include "../Core/World.h"
#include "../Core/Transform.h"
#include "Skeleton.h"
#include "ShaderProgram.h"
struct ModelJob : RenderJob
{
ModelJob(Model* model, Camera* camera, glm::mat4 matrix, ::RawModel::MaterialGroup matGroup, ComponentWrapper modelComponent, World* world, glm::vec4 fillColor, float fillPercentage)
ModelJob(Model* model, Camera* camera, glm::mat4 matrix, ::RawModel::MaterialProperties matProp, ComponentWrapper modelComponent, World* world, glm::vec4 fillColor, float fillPercentage)
: RenderJob()
{
Model = model;
TextureID = (matGroup.Texture) ? matGroup.Texture->ResourceID : 0;
if (modelComponent["DiffuseTexture"]) {
DiffuseTexture = matGroup.Texture.get();
} else {
DiffuseTexture = nullptr;
}
if (modelComponent["NormalMap"]) {
NormalTexture = matGroup.NormalMap.get();
} else {
NormalTexture = nullptr;
}
if (modelComponent["SpecularMap"]) {
SpecularTexture = matGroup.SpecularMap.get();
} else {
SpecularTexture = nullptr;
}
if (modelComponent["GlowMap"]) {
IncandescenceTexture = matGroup.IncandescenceMap.get();
} else {
IncandescenceTexture = nullptr;
}
DiffuseColor = matGroup.DiffuseColor;
SpecularColor = matGroup.SpecularColor;
IncandescenceColor = matGroup.IncandescenceColor;
StartIndex = matGroup.StartIndex;
EndIndex = matGroup.EndIndex;
ModelID = model->ResourceID;
Type = matProp.type;
::RawModel::MaterialBasic* matGroup = matProp.material;
switch(matProp.type){
case ::RawModel::MaterialType::Basic:
if (Model->IsSkinned()) {
ShaderID = ResourceManager::Load<ShaderProgram>("#ForwardPlusSkinnedProgram")->ResourceID;
}
else {
ShaderID = ResourceManager::Load<ShaderProgram>("#ForwardPlusProgram")->ResourceID;
}
TextureID = 0;
break;
case ::RawModel::MaterialType::SingleTextures:
{
if (Model->IsSkinned()) {
ShaderID = ResourceManager::Load<ShaderProgram>("#ForwardPlusSkinnedProgram")->ResourceID;
}
else {
ShaderID = ResourceManager::Load<ShaderProgram>("#ForwardPlusProgram")->ResourceID;
}
::RawModel::MaterialSingleTextures* singleTextures = static_cast<::RawModel::MaterialSingleTextures*>(matProp.material);
TextureID = (singleTextures->ColorMap.Texture) ? singleTextures->ColorMap.Texture->ResourceID : 0;
if (modelComponent["DiffuseTexture"]) {
DiffuseTexture.push_back(&singleTextures->ColorMap);
}
if (modelComponent["NormalMap"]) {
NormalTexture.push_back(&singleTextures->NormalMap);
}
if (modelComponent["SpecularMap"]) {
SpecularTexture.push_back(&singleTextures->SpecularMap);
}
if (modelComponent["GlowMap"]) {
IncandescenceTexture.push_back(&singleTextures->IncandescenceMap);
}
}
break;
case ::RawModel::MaterialType::SplatMapping:
{
if (Model->IsSkinned()) {
ShaderID = ResourceManager::Load<ShaderProgram>("#ForwardPlusSplatMapSkinnedProgram")->ResourceID;
}
else {
ShaderID = ResourceManager::Load<ShaderProgram>("#ForwardPlusSplatMapProgram")->ResourceID;
}
::RawModel::MaterialSplatMapping* SplatTextures = static_cast<::RawModel::MaterialSplatMapping*>(matProp.material);
SplatMap = &SplatTextures->SplatMap;
TextureID = (SplatTextures->ColorMaps[0].Texture) ? SplatTextures->ColorMaps[0].Texture->ResourceID : 0;
if (modelComponent["DiffuseTexture"]) {
for (auto& texture : SplatTextures->ColorMaps) {
DiffuseTexture.push_back(&texture);
}
}
if (modelComponent["NormalMap"]) {
for (auto& texture : SplatTextures->NormalMaps) {
NormalTexture.push_back(&texture);
}
}
if (modelComponent["SpecularMap"]) {
for (auto& texture : SplatTextures->SpecularMaps) {
SpecularTexture.push_back(&texture);
}
}
if (modelComponent["GlowMap"]) {
for (auto& texture : SplatTextures->IncandescenceMaps) {
IncandescenceTexture.push_back(&texture);
}
}
}
break;
}
DiffuseColor = matGroup->DiffuseColor;
SpecularColor = matGroup->SpecularColor;
IncandescenceColor = matGroup->IncandescenceColor;
StartIndex = matGroup->StartIndex;
EndIndex = matGroup->EndIndex;
Matrix = matrix;
Color = modelComponent["Color"];
Entity = modelComponent.EntityID;
@@ -57,29 +116,56 @@ struct ModelJob : RenderJob
FillColor = fillColor;
FillPercentage = fillPercentage;
Skeleton = Model->m_RawModel->m_Skeleton;
if (world->HasComponent(Entity, "Animation") && Skeleton != nullptr) {
auto animationComponent = world->GetComponent(Entity, "Animation");
Animation = model->m_RawModel->m_Skeleton->GetAnimation(animationComponent["Name"]);
AnimationTime = (double)animationComponent["Time"];
if (Skeleton != nullptr) {
if (world->HasComponent(Entity, "Animation")) {
auto animationComponent = world->GetComponent(Entity, "Animation");
for (int i = 1; i <= 3; i++) {
::Skeleton::AnimationData animationData;
animationData.animation = model->m_RawModel->m_Skeleton->GetAnimation(animationComponent["AnimationName" + std::to_string(i)]);
if (animationData.animation == nullptr) {
continue;
}
animationData.time = (double)animationComponent["Time" + std::to_string(i)];
animationData.weight = (double)animationComponent["Weight" + std::to_string(i)];
Animations.push_back(animationData);
}
}
if (world->HasComponent(Entity, "AnimationOffset")) {
auto animationOffsetComponent = world->GetComponent(Entity, "AnimationOffset");
AnimationOffset.animation = model->m_RawModel->m_Skeleton->GetAnimation(animationOffsetComponent["AnimationName"]);
AnimationOffset.time = (double)animationOffsetComponent["Time"];
} else {
AnimationOffset.animation = nullptr;
}
}
};
unsigned int TextureID;
unsigned int ShaderID;
unsigned int ModelID;
::RawModel::MaterialType Type;
EntityID Entity;
glm::mat4 Matrix;
const Texture* DiffuseTexture;
const Texture* NormalTexture;
const Texture* SpecularTexture;
const Texture* IncandescenceTexture;
const ::RawModel::TextureProperties* SplatMap;
std::vector<const ::RawModel::TextureProperties*> DiffuseTexture;
std::vector<const ::RawModel::TextureProperties*> NormalTexture;
std::vector<const ::RawModel::TextureProperties*> SpecularTexture;
std::vector<const ::RawModel::TextureProperties*> IncandescenceTexture;
float Shininess = 0.f;
glm::vec4 Color;
const ::Model* Model = nullptr;
::Skeleton* Skeleton = nullptr;
const ::Skeleton::Animation* Animation = nullptr;
// const ::Skeleton::Animation* Animation = nullptr;
std::vector<::Skeleton::AnimationData> Animations;
::Skeleton::AnimationOffset AnimationOffset;
float AnimationTime = 0.f;
@@ -95,7 +181,7 @@ struct ModelJob : RenderJob
void CalculateHash() override
{
Hash = TextureID;
Hash = TextureID + ModelID << 10 + ShaderID << 20;
}
};
+1
View File
@@ -40,6 +40,7 @@ private:
const IRenderer* m_Renderer;
ShaderProgram* m_PickingProgram;
ShaderProgram* m_PickingSkinnedProgram;
Camera* m_Camera;
struct PickingInfo
+77 -20
View File
@@ -33,18 +33,27 @@ protected:
public:
~RawModelCustom();
struct Vertex
{
glm::vec3 Position;
glm::vec3 Normal;
glm::vec3 Tangent;
glm::vec3 BiNormal;
glm::vec2 TextureCoords;
struct Vertex
{
glm::vec3 Position;
glm::vec3 Normal;
glm::vec3 Tangent;
glm::vec3 BiNormal;
glm::vec2 TextureCoords;
};
struct SkinedVertex : public Vertex {
glm::vec4 BoneIndices;
glm::vec4 BoneWeights;
};
struct MaterialGroup
struct TextureProperties {
std::string TexturePath;
glm::vec2 UVRepeat;
std::shared_ptr<::Texture> Texture;
};
struct MaterialBasic
{
float SpecularExponent;
float ReflectionFactor;
@@ -54,25 +63,69 @@ public:
unsigned int StartIndex;
unsigned int EndIndex;
//float Transparency;
std::string TexturePath;
std::shared_ptr<::Texture> Texture;
std::string NormalMapPath;
std::shared_ptr<::Texture> NormalMap;
std::string SpecularMapPath;
std::shared_ptr<::Texture> SpecularMap;
std::string IncandescenceMapPath;
std::shared_ptr<::Texture> IncandescenceMap;
};
std::vector<MaterialGroup> MaterialGroups;
struct MaterialSplatMapping : public MaterialBasic
{
TextureProperties SplatMap;
std::vector<TextureProperties> ColorMaps;
std::vector<TextureProperties> NormalMaps;
std::vector<TextureProperties> SpecularMaps;
std::vector<TextureProperties> IncandescenceMaps;
};
struct MaterialSingleTextures : public MaterialBasic
{
TextureProperties ColorMap;
TextureProperties NormalMap;
TextureProperties SpecularMap;
TextureProperties IncandescenceMap;
};
enum class MaterialType { Basic = 1, SplatMapping, SingleTextures };
struct MaterialProperties {
MaterialType type;
MaterialBasic* material;
};
const Vertex* Vertices() const {
if (hasSkin) {
return m_SkinedVertices.data();
} else {
return m_Vertices.data();
}
};
unsigned int VertexSize() const {
if (hasSkin) {
return sizeof(SkinedVertex);
}
else {
return sizeof(Vertex);
}
};
unsigned int NumVertices() const {
if (hasSkin) {
return m_SkinedVertices.size();
} else {
return m_Vertices.size();
}
};
bool IsSkinned() const { return hasSkin; };
std::vector<MaterialProperties> m_Materials;
std::vector<Vertex> m_Vertices;
std::vector<unsigned int> m_Indices;
Skeleton* m_Skeleton = nullptr;
glm::mat4 m_Matrix;
private:
bool hasSkin;
std::vector<Vertex> m_Vertices;
std::vector<SkinedVertex> m_SkinedVertices;
void ReadMeshFile(std::string filePath);
void ReadMeshFileHeader(std::size_t& offset, char* fileData);
@@ -83,13 +136,17 @@ private:
void ReadMaterialFile(std::string filePath);
void ReadMaterials(std::size_t& offset, char* fileData, const unsigned int& fileByteSize);
void ReadMaterialSingle(std::size_t& offset, char* fileData, const unsigned int& fileByteSize);
void ReadMaterialBasic(MaterialBasic* Material, std::size_t& offset, char* fileData, const unsigned int& fileByteSize);
void ReadMaterialSingleTexture(MaterialSingleTextures* Material, std::size_t& offset, char* fileData, const unsigned int& fileByteSize);
void ReadMaterialSplatMapping(MaterialSplatMapping* Material, std::size_t& offset, char* fileData, const unsigned int& fileByteSize);
void ReadMaterialTextureProperties(TextureProperties& texture, std::size_t& offset, char* fileData, const unsigned int& fileByteSize);
void ReadAnimationFile(std::string filePath);
void ReadAnimationBindPoses(std::size_t& offset, char* fileData, const unsigned int& fileByteSize);
void ReadAnimationJoint(std::size_t& offset, char* fileData, const unsigned int& fileByteSize);
void ReadAnimationClips(std::size_t& offset, char* fileData, const unsigned int& fileByteSize, unsigned int numberOfClips);
void ReadAnimationClipSingle(std::size_t& offset, char* fileData, const unsigned int& fileByteSize, unsigned int clipIndex);
void ReadAnimationKeyFrame(std::size_t& offset, char* fileData, const unsigned int& fileByteSize, unsigned int numberOfJoints, Skeleton::Animation& animation);
void ReadAnimationKeyFrame(std::size_t& offset, char* fileData, const unsigned int& fileByteSize, std::vector<Skeleton::Animation::Keyframe>& animation);
//void CreateSkeleton(std::vector<std::tuple<std::string, glm::mat4>> &boneInfo, std::map<std::string, int> &boneNameMapping, aiNode* node, int parentID);
};
+18 -10
View File
@@ -19,22 +19,30 @@
struct RenderScene
{
::Camera* Camera = nullptr;
std::list<std::shared_ptr<RenderJob>> OpaqueObjects;
std::list<std::shared_ptr<RenderJob>> TransparentObjects;
std::list<std::shared_ptr<RenderJob>> PointLightJobs;
std::list<std::shared_ptr<RenderJob>> TextJobs;
std::list<std::shared_ptr<RenderJob>> DirectionalLightJobs;
struct Queues {
std::list<std::shared_ptr<RenderJob>> OpaqueObjects;
std::list<std::shared_ptr<RenderJob>> TransparentObjects;
std::list<std::shared_ptr<RenderJob>> OpaqueShieldedObjects;
std::list<std::shared_ptr<RenderJob>> TransparentShieldedObjects;
std::list<std::shared_ptr<RenderJob>> ShieldObjects;
std::list<std::shared_ptr<RenderJob>> PointLight;
std::list<std::shared_ptr<RenderJob>> Text;
std::list<std::shared_ptr<RenderJob>> DirectionalLight;
} Jobs;
Rectangle Viewport;
bool ClearDepth = false;
glm::vec4 AmbientColor;
void Clear()
{
OpaqueObjects.clear();
TransparentObjects.clear();
PointLightJobs.clear();
TextJobs.clear();
DirectionalLightJobs.clear();
Jobs.OpaqueObjects.clear();
Jobs.TransparentObjects.clear();
Jobs.OpaqueShieldedObjects.clear();
Jobs.TransparentShieldedObjects.clear();
Jobs.ShieldObjects.clear();
Jobs.Text.clear();
Jobs.DirectionalLight.clear();
}
};
+4
View File
@@ -2,6 +2,7 @@
#define RenderState_h__
#include <functional>
#include <boost/range/adaptor/reversed.hpp>
#include "../Common.h"
#include "../OpenGL.h"
#include "../GLM.h"
@@ -19,6 +20,9 @@ public:
bool BindFramebuffer(GLint framebuffer);
bool BlendEquation(GLenum mode);
bool BlendFunc(GLenum sfactor, GLenum dfactor);
bool StencilOp(GLenum sfail, GLenum dpfail, GLenum dppass);
bool StencilFunc(GLenum func, GLint ref, GLuint mask);
bool StencilMask(GLuint mask);
bool DepthMask(GLboolean flag);
private:
+5 -3
View File
@@ -16,11 +16,13 @@
#include "PointLightJob.h"
#include "../Core/Transform.h"
#include "../Core/EPlayerSpawned.h"
#include "../Core/Octree.h"
#include "../Collision/EntityAABB.h"
class RenderSystem : public ImpureSystem
{
public:
RenderSystem(SystemParams params, const IRenderer* renderer, RenderFrame* renderFrame);
RenderSystem(SystemParams params, const IRenderer* renderer, RenderFrame* renderFrame, Octree<EntityAABB>* frustumCullOctree);
~RenderSystem();
virtual void Update(double dt) override;
@@ -31,6 +33,7 @@ private:
Camera* m_Camera;
EntityWrapper m_CurrentCamera = EntityWrapper::Invalid;
EntityWrapper m_LocalPlayer = EntityWrapper::Invalid;
Octree<EntityAABB>* m_Octree;
EventRelay<RenderSystem, Events::SetCamera> m_ESetCamera;
bool OnSetCamera(Events::SetCamera &event);
@@ -39,14 +42,13 @@ private:
EventRelay<RenderSystem, Events::PlayerSpawned> m_EPlayerSpawned;
bool OnPlayerSpawned(Events::PlayerSpawned& e);
void fillModels(std::list<std::shared_ptr<RenderJob>>& opaqueJobs, std::list<std::shared_ptr<RenderJob>>& transparentJobs);
void fillModels(RenderScene::Queues &jobs);
void fillText(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
void fillPointLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
void fillDirectionalLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
void fillLight(std::list<std::shared_ptr<RenderJob>>& jobs);
bool isChildOfACamera(EntityWrapper entity);
bool isChildOfCurrentCamera(EntityWrapper entity);
};
#endif
+45 -17
View File
@@ -5,6 +5,7 @@
#include "Common.h"
#include "../GLM.h"
#include <glm/gtx/matrix_decompose.hpp>
#include <imgui/imgui.h>
//struct Bone
//{
@@ -53,22 +54,39 @@ public:
{
struct BoneProperty
{
int ID;
glm::vec3 Position;
glm::quat Rotation;
glm::vec3 Position;
glm::quat Rotation;
glm::vec3 Scale = glm::vec3(1);
};
int Index = 0;
double Time = 0.0;
std::map<int, Keyframe::BoneProperty> BoneProperties;
int Index = 0;
double Time = 0.0;
BoneProperty BoneProperties;
};
std::string Name;
double Duration;
std::vector<Keyframe> Keyframes;
std::string Name;
double Duration;
std::map<int, std::vector<Keyframe>> JointAnimations;
};
struct AnimationData
{
const Animation* animation;
float time;
float weight;
};
struct JointFrameTransform {
glm::vec3 PositionInterp = glm::vec3(0);
glm::quat RotationInterp = glm::quat();
glm::vec3 ScaleInterp = glm::vec3(0);
float Weight;
};
struct AnimationOffset {
const Animation* animation;
float time;
};
Skeleton() { }
~Skeleton();
@@ -82,17 +100,27 @@ public:
int GetBoneID(std::string name);
const Animation* GetAnimation(std::string name);
std::vector<glm::mat4> GetFrameBones(const Animation& animation, double time, bool noRootMotion = false);
void AccumulateBoneTransforms(bool noRootMotion, const Animation::Keyframe& currentFrame, const Animation::Keyframe& nextFrame, float progress, std::map<int, glm::mat4>& boneMatrices, const Bone* bone, glm::mat4 parentMatrix);
void PrintSkeleton();
const Animation* GetAnimation(std::string name);
std::vector<glm::mat4> GetFrameBones(std::vector<AnimationData> animations, bool noRootMotion = false);
std::vector<glm::mat4> GetFrameBones(std::vector<AnimationData> animations, AnimationOffset animationOffset, bool noRootMotion = false);
//void AccumulateBoneTransforms(bool noRootMotion, const Animation* animation, float time, std::map<int, glm::mat4>& boneMatrices, const Bone* bone, glm::mat4 parentMatrix);
void AccumulateBoneTransforms(bool noRootMotion, std::vector<AnimationData> animations, std::map<int, glm::mat4>& boneMatrices, const Bone* bone, glm::mat4 parentMatrix);
void AccumulateBoneTransforms(bool noRootMotion, std::vector<AnimationData> animations, AnimationOffset animationOffset, std::map<int, glm::mat4>& boneMatrices, const Bone* bone, glm::mat4 parentMatrix);
void PrintSkeleton();
void PrintSkeleton(const Bone* parent, int depthCount);
std::map<std::string, Animation> Animations;
private:
std::map<std::string, Bone*> m_BonesByName;
glm::mat4 GetBoneTransform(const Bone* bone, const Animation* animation, float time, glm::mat4 childMatrix);
int GetKeyframe(const Animation& animation, double time);
int GetKeyframe(const Animation& animation, double time);
private:
glm::mat4 GetOffsetTransform(const Bone* bone, AnimationOffset animationOffset);
std::map<std::string, Bone*> m_BonesByName;
float aim = 0.f;
};
#endif