Fixed some things in gameworld and added a new skymap.
This commit is contained in:
+48
-29
@@ -70,26 +70,26 @@ void GameWorld::Initialize()
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
{
|
||||
auto road_base = CreateEntity();
|
||||
auto transform = AddComponent<Components::Transform>(road_base);
|
||||
transform->Position = glm::vec3(0, -50, 0);
|
||||
auto model = AddComponent<Components::Model>(road_base);
|
||||
model->ModelFile = "Models/TerrainFiveIstles/Roads/BaseRoad.obj";
|
||||
auto physics = AddComponent<Components::Physics>(road_base);
|
||||
physics->Mass = 10;
|
||||
physics->Static = true;
|
||||
physics->CollisionLayer = 1;
|
||||
|
||||
auto groundshape = CreateEntity(road_base);
|
||||
auto transformshape = AddComponent<Components::Transform>(groundshape);
|
||||
auto meshShape = AddComponent<Components::MeshShape>(groundshape);
|
||||
meshShape->ResourceName = "Models/TerrainFiveIstles/Roads/BaseRoad.obj";
|
||||
|
||||
|
||||
CommitEntity(groundshape);
|
||||
CommitEntity(road_base);
|
||||
}
|
||||
{
|
||||
auto road_base = CreateEntity();
|
||||
auto transform = AddComponent<Components::Transform>(road_base);
|
||||
transform->Position = glm::vec3(0, -50, 0);
|
||||
auto model = AddComponent<Components::Model>(road_base);
|
||||
model->ModelFile = "Models/TerrainFiveIstles/Roads/BaseRoad.obj";
|
||||
auto physics = AddComponent<Components::Physics>(road_base);
|
||||
physics->Mass = 10;
|
||||
physics->Static = true;
|
||||
physics->CollisionLayer = 1;
|
||||
|
||||
auto groundshape = CreateEntity(road_base);
|
||||
auto transformshape = AddComponent<Components::Transform>(groundshape);
|
||||
auto meshShape = AddComponent<Components::MeshShape>(groundshape);
|
||||
meshShape->ResourceName = "Models/TerrainFiveIstles/Roads/BaseRoad.obj";
|
||||
|
||||
|
||||
CommitEntity(groundshape);
|
||||
CommitEntity(road_base);
|
||||
}
|
||||
|
||||
{
|
||||
auto road_middle = CreateEntity();
|
||||
@@ -143,13 +143,10 @@ void GameWorld::Initialize()
|
||||
auto model = AddComponent<Components::Model>(water);
|
||||
model->ModelFile = "Models/Placeholders/PhysicsTest/Cube.obj";
|
||||
auto blendmap = AddComponent<Components::BlendMap>(water);
|
||||
blendmap->TextureRed = "Textures/Ground/WaterPlain0017_6_S.png";
|
||||
blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png";
|
||||
blendmap->TextureGreen = "Textures/Ground/WaterPlain0017_6_S.jpg";
|
||||
blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png";
|
||||
blendmap->TextureBlue = "Textures/Ground/WaterPlain0017_6_S.png";
|
||||
blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png";
|
||||
blendmap->TextureRepeats = 400.f;
|
||||
blendmap->TextureRed = "Textures/Skybox/Sky34/bottom.jpg";
|
||||
blendmap->TextureGreen = "Textures/Skybox/Sky34/bottom.jpg";
|
||||
blendmap->TextureBlue = "Textures/Skybox/Sky34/bottom.jpg";
|
||||
blendmap->TextureRepeats = 1.f;
|
||||
|
||||
auto physics = AddComponent<Components::Physics>(water);
|
||||
physics->Mass = 10;
|
||||
@@ -327,11 +324,33 @@ void GameWorld::Initialize()
|
||||
{
|
||||
auto tree = CreateEntity();
|
||||
auto transform = AddComponent<Components::Transform>(tree);
|
||||
transform->Position = glm::vec3(0, -15, 0);
|
||||
transform->Position = glm::vec3(0, -10, 0);
|
||||
auto model = AddComponent<Components::Model>(tree);
|
||||
model->ModelFile = "Models/Tree/leafs/Leafs.obj";
|
||||
model->ModelFile = "Models/Tree/Stem/Stem.obj";
|
||||
auto physics = AddComponent<Components::Physics>(tree);
|
||||
physics->Mass = 100.f;
|
||||
physics->Static = false;
|
||||
physics->CalculateCenterOfMass = true;
|
||||
{
|
||||
auto leafs = CreateEntity(tree);
|
||||
auto transform = AddComponent<Components::Transform>(leafs);
|
||||
auto model = AddComponent<Components::Model>(leafs);
|
||||
model->ModelFile = "Models/Tree/Leafs/Leafs.obj";
|
||||
model->Transparent = true;
|
||||
CommitEntity(leafs);
|
||||
}
|
||||
|
||||
{
|
||||
auto shape = CreateEntity(tree);
|
||||
auto transform = AddComponent<Components::Transform>(shape);
|
||||
auto box = AddComponent<Components::BoxShape>(shape);
|
||||
transform->Position = glm::vec3(0.f, 0.f, 2.29552f);
|
||||
box->Width = 0.296f;
|
||||
box->Height = 2.511f;
|
||||
box->Depth = 0.296f;
|
||||
|
||||
CommitEntity(shape);
|
||||
}
|
||||
CommitEntity(tree);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include "Components/Template.h"
|
||||
#include "Components/Transform.h"
|
||||
#include "Components/Viewport.h"
|
||||
#include "Components/BlendMap.h"
|
||||
|
||||
#include "Components/Physics.h"
|
||||
#include "Components/SphereShape.h"
|
||||
|
||||
+9
-9
@@ -14,6 +14,9 @@ struct RenderJob
|
||||
{
|
||||
friend class RenderQueue;
|
||||
|
||||
glm::mat4 ModelMatrix;
|
||||
float Depth;
|
||||
|
||||
protected:
|
||||
uint64_t Hash;
|
||||
|
||||
@@ -37,7 +40,6 @@ struct ModelJob : RenderJob
|
||||
GLuint VAO;
|
||||
unsigned int StartIndex;
|
||||
unsigned int EndIndex;
|
||||
glm::mat4 ModelMatrix;
|
||||
float Transparent;
|
||||
|
||||
void CalculateHash() override
|
||||
@@ -67,7 +69,6 @@ struct SpriteJob : RenderJob
|
||||
|
||||
GLuint Texture;
|
||||
glm::vec4 Color;
|
||||
glm::mat4 ModelMatrix;
|
||||
|
||||
void CalculateHash() override
|
||||
{
|
||||
@@ -82,31 +83,30 @@ public:
|
||||
void Add(T &job)
|
||||
{
|
||||
job.CalculateHash();
|
||||
m_Jobs.push_front(std::shared_ptr<T>(new T(job)));
|
||||
Jobs.push_front(std::shared_ptr<T>(new T(job)));
|
||||
}
|
||||
|
||||
void Sort()
|
||||
{
|
||||
m_Jobs.sort();
|
||||
Jobs.sort();
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
m_Jobs.clear();
|
||||
Jobs.clear();
|
||||
}
|
||||
|
||||
std::forward_list<std::shared_ptr<RenderJob>>::const_iterator begin()
|
||||
{
|
||||
return m_Jobs.begin();
|
||||
return Jobs.begin();
|
||||
}
|
||||
|
||||
std::forward_list<std::shared_ptr<RenderJob>>::const_iterator end()
|
||||
{
|
||||
return m_Jobs.end();
|
||||
return Jobs.end();
|
||||
}
|
||||
|
||||
private:
|
||||
std::forward_list<std::shared_ptr<RenderJob>> m_Jobs;
|
||||
std::forward_list<std::shared_ptr<RenderJob>> Jobs;
|
||||
};
|
||||
|
||||
struct RenderQueuePair
|
||||
|
||||
+16
-3
@@ -18,7 +18,7 @@ Renderer::Renderer(std::shared_ptr<::ResourceManager> resourceManager)
|
||||
CAtt = 1.0f;
|
||||
LAtt = 0.0f;
|
||||
QAtt = 3.0f;
|
||||
m_ShadowMapRes = 2048*2;
|
||||
m_ShadowMapRes = 1;
|
||||
m_SunPosition = glm::vec3(0.f, 1.0f, 0.5f);
|
||||
m_SunTarget = glm::vec3(0, 0, 0);
|
||||
m_SunProjection_height = glm::vec2(-40.f, 40.f);
|
||||
@@ -163,7 +163,7 @@ void Renderer::LoadContent()
|
||||
FrameBufferTextures();
|
||||
|
||||
m_sphereModel = ResourceManager->Load<Model>("Model", "Models/Placeholders/PhysicsTest/Sphere.obj");
|
||||
m_Skybox = std::make_shared<Skybox>("Textures/Skybox/Sky34", "jpg");
|
||||
m_Skybox = std::make_shared<Skybox>("Textures/Skybox/sky36", "jpg");
|
||||
}
|
||||
|
||||
void Renderer::Draw(double dt)
|
||||
@@ -369,6 +369,17 @@ void Renderer::DrawWorld(RenderQueuePair &rq)
|
||||
glDepthMask(GL_TRUE);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
|
||||
//Sort forward rendering items by z value.
|
||||
for(auto job : rq.Forward)
|
||||
{
|
||||
glm::mat4 cameraProjection = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height);
|
||||
glm::mat4 cameraMatrix = cameraProjection * m_Camera->ViewMatrix();
|
||||
|
||||
glm::vec3 spritePos = glm::vec3(cameraMatrix * job->ModelMatrix * glm::vec4(1, 1, 1, 0));
|
||||
job->Depth = spritePos.z;
|
||||
}
|
||||
rq.Forward.Jobs.sort(Renderer::DepthSort);
|
||||
|
||||
//DrawShadowMap(rq.Deferred);
|
||||
|
||||
/*
|
||||
@@ -392,7 +403,7 @@ void Renderer::DrawWorld(RenderQueuePair &rq)
|
||||
|
||||
glCullFace(GL_BACK);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
//DrawSkybox();
|
||||
DrawSkybox();
|
||||
DrawFBOScene(rq.Deferred);
|
||||
|
||||
/*
|
||||
@@ -512,6 +523,8 @@ void Renderer::ForwardRendering(RenderQueue &rq)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job);
|
||||
if (spriteJob)
|
||||
{
|
||||
|
||||
+2
-1
@@ -201,7 +201,8 @@ private:
|
||||
void CreateNormalMapTangent();
|
||||
void ForwardRendering(RenderQueue &rq);
|
||||
|
||||
|
||||
static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j) { return (i->Depth < j->Depth); }
|
||||
|
||||
GLuint CreateQuad();
|
||||
void DrawDebugShadowMap();
|
||||
GLuint CreateAABB();
|
||||
|
||||
@@ -88,7 +88,7 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit
|
||||
Events::ApplyPointImpulse ePointImpulse ;
|
||||
ePointImpulse.Entity = entity;
|
||||
ePointImpulse.Position = absoluteTransform.Position;
|
||||
ePointImpulse.Impulse = glm::normalize(absoluteTransform.Orientation * glm::vec3(0, 0, 1)) * clonePhysicsComponent->Mass * 1670.f;
|
||||
ePointImpulse.Impulse = glm::normalize(absoluteTransform.Orientation * glm::vec3(0, 0, 1)) * clonePhysicsComponent->Mass * 6.f * 1670.f;
|
||||
EventBroker->Publish(ePointImpulse);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user