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