spriteComponent WIP

This commit is contained in:
viktorljung
2016-02-05 16:43:57 +01:00
parent ff26e1235c
commit 8034b42c87
16 changed files with 318 additions and 8 deletions
+2
View File
@@ -33,6 +33,8 @@ public:
glm::mat4 ViewMatrix() const { return m_ViewMatrix; }
void SetViewMatrix(glm::mat4 val);
glm::mat4 BillboardMatrix();
float AspectRatio() const { return m_AspectRatio; }
void SetAspectRatio(float val);
+2
View File
@@ -31,6 +31,7 @@ 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 DrawSprites(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);
@@ -53,6 +54,7 @@ private:
ShaderProgram* m_ForwardPlusProgram;
ShaderProgram* m_ExplosionEffectProgram;
ShaderProgram* m_SpriteProgram;
};
#endif
+4
View File
@@ -15,6 +15,7 @@
#include "PointLightJob.h"
#include "DirectionalLightJob.h"
#include "ExplosionEffectJob.h"
#include "SpriteJob.h"
struct RenderScene
{
@@ -24,6 +25,8 @@ struct RenderScene
std::list<std::shared_ptr<RenderJob>> PointLightJobs;
std::list<std::shared_ptr<RenderJob>> TextJobs;
std::list<std::shared_ptr<RenderJob>> DirectionalLightJobs;
std::list<std::shared_ptr<RenderJob>> SpriteJobs;
Rectangle Viewport;
bool ClearDepth = false;
glm::vec4 AmbientColor;
@@ -35,6 +38,7 @@ struct RenderScene
PointLightJobs.clear();
TextJobs.clear();
DirectionalLightJobs.clear();
SpriteJobs.clear();
}
};
+1
View File
@@ -45,6 +45,7 @@ private:
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);
void fillSprites(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
bool isChildOfACamera(EntityWrapper entity);
bool isChildOfCurrentCamera(EntityWrapper entity);
+75
View File
@@ -0,0 +1,75 @@
#ifndef SpriteJob_h__
#define SpriteJob_h__
#include <cstdint>
#include "../Common.h"
#include "../GLM.h"
#include "../Core/ComponentWrapper.h"
#include "Texture.h"
#include "Model.h"
#include "RenderJob.h"
#include "../Core/ResourceManager.h"
#include "Camera.h"
#include "../Core/World.h"
#include "../Core/Transform.h"
#include "Skeleton.h"
struct SpriteJob : RenderJob
{
SpriteJob(ComponentWrapper cSprite, Camera* camera, glm::mat4 matrix, World* world, glm::vec4 fillColor, float fillPercentage)
: RenderJob()
{
Model = ResourceManager::Load<::Model>("Models/Core/UnitQuad.mesh");
::RawModel::MaterialGroup matGroup = Model->MaterialGroups().front();
TextureID = (matGroup.Texture) ? matGroup.Texture->ResourceID : 0;
if (cSprite["DiffuseTexture"]) {
DiffuseTexture = ResourceManager::Load<Texture>(cSprite["DiffuseTexture"]);
} else {
DiffuseTexture = nullptr;
}
if (cSprite["GlowMap"]) {
IncandescenceTexture = ResourceManager::Load<Texture>(cSprite["GlowMap"]);
} else {
IncandescenceTexture = nullptr;
}
StartIndex = matGroup.StartIndex;
EndIndex = matGroup.EndIndex;
Matrix = matrix;
Color = cSprite["Color"];
Entity = cSprite.EntityID;
glm::vec3 abspos = Transform::AbsolutePosition(world, cSprite.EntityID);
glm::vec3 viewpos = glm::vec3(camera->ViewMatrix() * glm::vec4(abspos, 1));
Depth = viewpos.z;
World = world;
FillColor = fillColor;
FillPercentage = fillPercentage;
};
unsigned int TextureID;
EntityID Entity;
glm::mat4 Matrix;
const Texture* DiffuseTexture;
const Texture* NormalTexture;
const Texture* SpecularTexture;
const Texture* IncandescenceTexture;
float Shininess = 0.f;
glm::vec4 Color;
const ::Model* Model = nullptr;
unsigned int StartIndex = 0;
unsigned int EndIndex = 0;
World* World;
glm::vec4 FillColor = glm::vec4(0);
float FillPercentage = 0.0;
void CalculateHash() override
{
Hash = TextureID;
}
};
#endif