Browse Source

Merge the Scene and SceneLayer classes

master
C. J. Howard 5 years ago
parent
commit
824784af2e
Signed by: cjhoward GPG Key ID: 03E1FABA9C3EC195
6 changed files with 24 additions and 26 deletions
  1. +1
    -1
      src/entity/systems/render-system.cpp
  2. +2
    -2
      src/entity/systems/render-system.hpp
  3. +17
    -18
      src/game.cpp
  4. +2
    -3
      src/game.hpp
  5. +1
    -1
      src/graphics/lighting-render-pass.cpp
  6. +1
    -1
      src/graphics/sky-render-pass.cpp

+ 1
- 1
src/entity/systems/render-system.cpp View File

@ -19,7 +19,7 @@
#include "render-system.hpp"
RenderSystem::RenderSystem(ComponentManager* componentManager, SceneLayer* scene):
RenderSystem::RenderSystem(ComponentManager* componentManager, Scene* scene):
System(componentManager),
cameraGroup(componentManager),
modelGroup(componentManager),

+ 2
- 2
src/entity/systems/render-system.hpp View File

@ -41,7 +41,7 @@ class RenderSystem:
public ModelGroup::Observer
{
public:
RenderSystem(ComponentManager* componentManager, SceneLayer* scene);
RenderSystem(ComponentManager* componentManager, Scene* scene);
virtual ~RenderSystem();
virtual void update(float t, float dt);
@ -49,7 +49,7 @@ public:
private:
CameraGroup cameraGroup;
ModelGroup modelGroup;
SceneLayer* scene;
Scene* scene;
virtual void memberRegistered(const CameraGroup::Member* member);
virtual void memberUnregistered(const CameraGroup::Member* member);

+ 17
- 18
src/game.cpp View File

@ -266,8 +266,6 @@ void Game::setup()
screenshotQueued = false;
// Create scene
scene = new Scene(&stepInterpolator);
// Load model resources
try
@ -860,8 +858,6 @@ void Game::setup()
// Setup scene
{
defaultLayer = scene->addLayer();
// Setup lighting pass
lightingPass = new LightingRenderPass(resourceManager);
lightingPass->setRenderTarget(&defaultRenderTarget);
@ -897,12 +893,12 @@ void Game::setup()
camera.lookAt(Vector3(0.0f, 4.0f, 2.0f), Vector3(0.0f, 0.0f, 0.0f), Vector3(0.0f, 1.0f, 0.0f));
camera.setCompositor(&defaultCompositor);
camera.setCompositeIndex(1);
defaultLayer->addObject(&camera);
worldScene->addObject(&camera);
// Setup sun
sunlight.setDirection(Vector3(0, -1, 0));
setTimeOfDay(11.0f);
defaultLayer->addObject(&sunlight);
worldScene->addObject(&sunlight);
// Setup sunlight camera
sunlightCamera.setOrthographic(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f);
@ -910,13 +906,12 @@ void Game::setup()
sunlightCamera.setCompositeIndex(0);
sunlightCamera.setCullingEnabled(true);
sunlightCamera.setCullingMask(&camera.getViewFrustum());
defaultLayer->addObject(&sunlightCamera);
worldScene->addObject(&sunlightCamera);
}
// Setup UI scene
uiLayer = scene->addLayer();
uiLayer->addObject(uiBatch);
uiLayer->addObject(&uiCamera);
uiScene->addObject(uiBatch);
uiScene->addObject(&uiCamera);
// Setup UI camera
uiCamera.lookAt(Vector3(0), Vector3(0, 0, -1), Vector3(0, 1, 0));
@ -937,8 +932,8 @@ void Game::setup()
lens = new Lens(lensModel, &animator);
lens->setOrbitCam(orbitCam);
defaultLayer->addObject(lens->getModelInstance());
defaultLayer->addObject(lens->getSpotlight());
worldScene->addObject(lens->getModelInstance());
worldScene->addObject(lens->getSpotlight());
lens->setSunDirection(-sunlightCamera.getForward());
ModelInstance* modelInstance = lens->getModelInstance();
@ -952,12 +947,12 @@ void Game::setup()
// Forceps
forceps = new Forceps(forcepsModel, &animator);
forceps->setOrbitCam(orbitCam);
defaultLayer->addObject(forceps->getModelInstance());
worldScene->addObject(forceps->getModelInstance());
// Brush
brush = new Brush(brushModel, &animator);
brush->setOrbitCam(orbitCam);
defaultLayer->addObject(brush->getModelInstance());
worldScene->addObject(brush->getModelInstance());
//
@ -973,7 +968,7 @@ void Game::setup()
soundSystem = new SoundSystem(componentManager);
collisionSystem = new CollisionSystem(componentManager);
cameraSystem = new CameraSystem(componentManager);
renderSystem = new RenderSystem(componentManager, defaultLayer);
renderSystem = new RenderSystem(componentManager, worldScene);
toolSystem = new ToolSystem(componentManager);
toolSystem->setPickingCamera(&camera);
toolSystem->setPickingViewport(Vector4(0, 0, w, h));
@ -987,7 +982,7 @@ void Game::setup()
particleSystem->setDirection(Vector3(0, 1, 0));
lens->setParticleSystem(particleSystem);
particleSystem->getBillboardBatch()->setAlignment(&camera, BillboardAlignmentMode::SPHERICAL);
defaultLayer->addObject(particleSystem->getBillboardBatch());
worldScene->addObject(particleSystem->getBillboardBatch());
// Initialize system manager
@ -1115,7 +1110,8 @@ void Game::render()
particleSystem->getBillboardBatch()->batch();
// Render scene
renderer.render(*scene);
renderer.render(*worldScene);
renderer.render(*uiScene);
// Swap window framebuffers
window->swapBuffers();
@ -1209,8 +1205,11 @@ void Game::setupWindow()
void Game::setupGraphics()
{
glEnable(GL_MULTISAMPLE);
// Create scenes
worldScene = new Scene(&stepInterpolator);
uiScene = new Scene(&stepInterpolator);
}
void Game::setupUI()

+ 2
- 3
src/game.hpp View File

@ -337,9 +337,8 @@ public:
RenderTarget silhouetteRenderTarget;
// Scene
Scene* scene;
SceneLayer* defaultLayer;
SceneLayer* uiLayer;
Scene* worldScene;
Scene* uiScene;
DirectionalLight sunlight;
Camera camera;
Camera sunlightCamera;

+ 1
- 1
src/graphics/lighting-render-pass.cpp View File

@ -104,7 +104,7 @@ void LightingRenderPass::render(RenderContext* renderContext)
const Vector3& cameraPosition = camera.getTransformTween()->getSubstate().translation;
// Gather lights
const std::list<SceneObject*>* lights = renderContext->layer->getObjects(SceneObjectType::LIGHT);
const std::list<SceneObject*>* lights = renderContext->scene->getObjects(SceneObjectType::LIGHT);
// Gather ambient cubes
AmbientCube* ambientCube = nullptr;

+ 1
- 1
src/graphics/sky-render-pass.cpp View File

@ -100,7 +100,7 @@ void SkyRenderPass::render(RenderContext* renderContext)
const Camera& camera = *(renderContext->camera);
// Get sun light
const std::list<SceneObject*>* lights = renderContext->layer->getObjects(SceneObjectType::LIGHT);
const std::list<SceneObject*>* lights = renderContext->scene->getObjects(SceneObjectType::LIGHT);
DirectionalLight* sun = nullptr;
for (SceneObject* object: *lights)
{

Loading…
Cancel
Save