Merge branch 'master' of github.com:sippeangelo/Return-to-the-Return-of-Return-Fire-2-Returngeance

Conflicts:
	vs11/Returngeance/Returngeance.vcxproj.filters
This commit is contained in:
Stiffly
2014-04-17 00:11:53 +02:00
10 changed files with 158 additions and 17 deletions
+3
View File
@@ -1,7 +1,10 @@
#ifndef Components_ParticleEmitter_h__
#define Components_ParticleEmitter_h__
#include "System.h"
#include "Component.h"
#include "Components/Transform.h"
#include "Components/ParticleEmitter.h"
#include "Color.h"
#include <vector>
+31 -4
View File
@@ -40,11 +40,38 @@ void GameWorld::Initialize()
physics->Mass = 10;
}
for(int i = 0; i < 10; i++)
{
auto TankTest = CreateEntity();
auto transform = AddComponent<Components::Transform>(TankTest, "Transform");
transform->Position = glm::vec3(1.5f, 0.7f, 5.f);
auto model = AddComponent<Components::Model>(TankTest, "Model");
model->ModelFile = "Models/Placeholders/tank/Chassi.obj";
}
for(int i = 0; i < 83; i++)
{
auto light = CreateEntity();
auto transform = AddComponent<Components::Transform>(light, "Transform");
transform->Position = glm::vec3((float)(2*i)*glm::sin((float)i), 3, (float)(2*i)*glm::cos((float)i));
auto pointLight = AddComponent<Components::PointLight>(light, "PointLight");
pointLight->Specular = glm::vec3(0.1f, 0.1f, 0.1f);
pointLight->Diffuse = glm::vec3(0.05f, 0.36f, 1.f);
pointLight->constantAttenuation = 0.03f;
pointLight->linearAttenuation = 0.009f;
pointLight->quadraticAttenuation = 0.07f;
pointLight->spotExponent = 0.0f;
auto model = AddComponent<Components::Model>(light, "Model");
model->ModelFile = "Models/Placeholders/PhysicsTest/PointLight.obj";
}
for(int i = 0; i < 500; i++)
{
auto ball = CreateEntity();
auto transform = AddComponent<Components::Transform>(ball, "Transform");
transform->Position = glm::vec3(0, 5 + i*2, 0);
transform->Position = glm::vec3(i/5.f, 5 + i*2, i/5.f);
transform->Scale = glm::vec3(1.0f, 1.0f, 1.0f);
transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f));
auto model = AddComponent<Components::Model>(ball, "Model");
@@ -84,7 +111,7 @@ void GameWorld::RegisterSystems()
//m_SystemFactory.Register("LevelGenerationSystem", [this]() { return new Systems::LevelGenerationSystem(this); });
m_SystemFactory.Register("InputSystem", [this]() { return new Systems::InputSystem(this, m_Renderer); });
//m_SystemFactory.Register("CollisionSystem", [this]() { return new Systems::CollisionSystem(this); });
////m_SystemFactory.Register("ParticleSystem", [this]() { return new Systems::ParticleSystem(this); });
m_SystemFactory.Register("ParticleSystem", [this]() { return new Systems::ParticleSystem(this); });
//m_SystemFactory.Register("PlayerSystem", [this]() { return new Systems::PlayerSystem(this); });
m_SystemFactory.Register("FreeSteeringSystem", [this]() { return new Systems::FreeSteeringSystem(this); });
m_SystemFactory.Register("SoundSystem", [this]() { return new Systems::SoundSystem(this); });
@@ -98,7 +125,7 @@ void GameWorld::AddSystems()
//AddSystem("LevelGenerationSystem");
AddSystem("InputSystem");
//AddSystem("CollisionSystem");
//AddSystem("ParticleSystem");
AddSystem("ParticleSystem");
//AddSystem("PlayerSystem");
AddSystem("FreeSteeringSystem");
AddSystem("SoundSystem");
+1 -1
View File
@@ -8,7 +8,7 @@
//#include "Systems/CollisionSystem.h"
#include "Systems/InputSystem.h"
//#include "Systems/LevelGenerationSystem.h"
//#include "Systems/ParticleSystem.h"
#include "Systems/ParticleSystem.h"
//#include "Systems/PlayerSystem.h"
#include "Systems/FreeSteeringSystem.h"
#include "Systems/RenderSystem.h"
+20
View File
@@ -0,0 +1,20 @@
#version 430
in vec2 TexCoord0;
in vec3 Normal0;
in vec3 WorldPos0;
layout (location = 0) out vec3 WorldPosOut;
layout (location = 1) out vec3 DiffuseOut;
layout (location = 2) out vec3 NormalOut;
layout (location = 3) out vec3 TexCoordOut;
uniform sampler2D gColorMap;
void main()
{
WorldPosOut = WorldPos0;
DiffuseOut = texture(gColorMap, TexCoord0).xyz;
NormalOut = normalize(Normal0);
TexCoordOut = vec3(TexCoord0, 0.0);
}
+20
View File
@@ -0,0 +1,20 @@
#version 430
layout (location = 0) in vec3 Position;
layout (location = 1) in vec2 TexCoord;
layout (location = 2) in vec3 Normal;
uniform mat4 gWVP;
uniform mat4 gWorld;
out vec2 TexCoord0;
out vec3 Normal0;
out vec3 WorldPos0;
void main()
{
gl_Position = gWVP * vec4(Position, 1.0);
TexCoord0 = TexCoord;
Normal0 = (gWorld * vec4(Normal, 0.0)).xyz;
WorldPos0 = (gWorld * vec4(Position, 1.0)).xyz;
}
+4 -7
View File
@@ -1,5 +1,6 @@
#include "ParticleSystem.h"
#include "PrecompiledHeader.h"
#include "ParticleSystem.h"
#include "World.h"
void Systems::ParticleSystem::Update(double dt)
@@ -13,13 +14,10 @@ void Systems::ParticleSystem::UpdateEntity(double dt, EntityID entity, EntityID
if(!transformComponent)
return;
transformComponent->Position.y --;
timeLived[entity] += dt;
auto emitterComponent = m_World->GetComponent<Components::ParticleEmitter>(entity, "ParticleEmitter");
}
@@ -35,7 +33,6 @@ void Systems::ParticleSystem::SpawnParticles()
auto particle = m_World->CreateEntity();
auto transform = m_World->AddComponent<Components::Transform>(particle, "Transform");
transform->Position = glm::vec3(0);
particles.push_back(particle);
}
}
+3 -4
View File
@@ -13,16 +13,15 @@ namespace Systems
class ParticleSystem : public System
{
public:
ParticleSystem(World* world);
ParticleSystem(World* world)
:System(world) { };
void RegisterComponents(ComponentFactory* cf) override;
void Update(double dt) override;
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
void Draw(double dt);
private:
void SpawnParticles();
};
+1 -1
View File
@@ -41,7 +41,7 @@ Systems::PhysicsSystem::PhysicsSystem(World* world) : System(world)
worldInfo.m_broadPhaseBorderBehaviour = hkpWorldCinfo::BROADPHASE_BORDER_FIX_ENTITY; // just fix the entity if the object falls off too far
// You must specify the size of the broad phase - objects should not be simulated outside this region
worldInfo.setBroadPhaseWorldSize(1000.0f);
worldInfo.setBroadPhaseWorldSize(10000.0f);
m_PhysicsWorld = new hkpWorld(worldInfo);
}
// Register all collision agents, even though only box - box will be used in this particular example.
+40
View File
@@ -0,0 +1,40 @@
#include "PrecompiledHeader.h"
#include "gBuffer.h"
bool GBuffer::Init(unsigned int WindowWidth, unsigned int WindowHeight)
{
// Create the FBO
glGenFramebuffers(1, &m_fbo);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo);
// Create the gbuffer textures
glGenTextures(ARRAY_SIZE_IN_ELEMENTS(m_textures), m_textures);
glGenTextures(1, &m_depthTexture);
for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_textures) ; i++) {
glBindTexture(GL_TEXTURE_2D, m_textures[i]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, WindowWidth, WindowHeight, 0, GL_RGB, GL_FLOAT, NULL);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, m_textures[i], 0);
}
// depth
glBindTexture(GL_TEXTURE_2D, m_depthTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32F, WindowWidth, WindowHeight, 0, GL_DEPTH_COMPONENT, GL_FLOAT,
NULL);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_depthTexture, 0);
GLenum DrawBuffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
glDrawBuffers(ARRAY_SIZE_IN_ELEMENTS(DrawBuffers), DrawBuffers);
GLenum Status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (Status != GL_FRAMEBUFFER_COMPLETE) {
printf("FB error, status: 0x%x\n", Status);
return false;
}
// restore default FBO
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
return true;
}
+35
View File
@@ -0,0 +1,35 @@
#ifndef gBuffer_h__
#define gBuffer_h__
#include <stdio.h>
class GBuffer
{
public:
enum GBUFFER_TEXTURE_TYPE {
GBUFFER_TEXTURE_TYPE_POSITION,
GBUFFER_TEXTURE_TYPE_DIFFUSE,
GBUFFER_TEXTURE_TYPE_NORMAL,
GBUFFER_TEXTURE_TYPE_TEXCOORD,
GBUFFER_NUM_TEXTURES
};
GBuffer();
~GBuffer();
bool Init(unsigned int WindowWidth, unsigned int WindowHeight);
void BindForWriting();
void BindForReading();
private:
GLuint m_fbo;
GLuint m_textures[GBUFFER_NUM_TEXTURES];
GLuint m_depthTexture;
};
#endif //gBuffer_h__