Subscenes

This commit is contained in:
2023-01-14 22:06:35 -08:00
parent 15e7efb7f3
commit 0558b3bb25
35 changed files with 733 additions and 116 deletions

View File

@ -7,19 +7,27 @@
using namespace Dawn;
PokerVNScene::PokerVNScene(DawnGame *game) : SimpleVNScene(game) {
PokerVNScene::PokerVNScene(DawnGame *game) :
SimpleVNScene(game),
renderTarget(320, 180)
{
}
std::vector<Asset*> PokerVNScene::getRequiredAssets() {
auto assMan = &this->game->assetManager;
std::vector<Asset*> assets, l;
vectorAppend(&assets,SimpleVNScene::getRequiredAssets());
vectorAppend(&assets, &(l = PokerPlayerDisplay::getAssets(assMan)));
std::vector<Asset*> assets;
vectorAppend(&assets, SimpleVNScene::getRequiredAssets());
vectorAppend(&assets, PokerPlayerDisplay::getAssets(assMan));
return assets;
}
void PokerVNScene::vnStage() {
this->renderTarget.setClearColor(COLOR_RED);
this->camera->setRenderTarget(&this->renderTarget);
auto pixelPerfectCamera = this->camera->item->addComponent<PixelPerfectCamera>();
auto pokerGameItem = this->createSceneItem();
this->pokerGame = pokerGameItem->addComponent<PokerGame>();

View File

@ -9,6 +9,7 @@
#include "visualnovel/events/PokerBetLoopEvent.hpp"
#include "visualnovel/events/PokerInitialEvent.hpp"
#include "ui/PokerPlayerDisplay.hpp"
#include "display/TextureRenderTarget.hpp"
namespace Dawn {
class PokerVNScene : public SimpleVNScene {
@ -23,7 +24,10 @@ namespace Dawn {
*/
virtual std::vector<PokerPlayer*> getPokerPlayers() = 0;
public:
TextureRenderTarget renderTarget;
PokerGame *pokerGame;
std::vector<PokerPlayer*> pokerPlayers;
std::map<PokerPlayer*, PokerPlayerDisplay*> pokerPlayerDisplays;

View File

@ -0,0 +1,50 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "scene/Scene.hpp"
#include "game/DawnGame.hpp"
#include "scenes/TestScene.hpp"
namespace Dawn {
class SubsceneTest : public Scene {
public:
Camera *camera;
SceneItem *sceneItem;
TestScene subScene;
SubsceneTest(DawnGame *game) : Scene(game), subScene(game) {
}
std::vector<Asset*> getRequiredAssets() override {
return this->subScene.getRequiredAssets();
}
void stage() override {
this->camera = Camera::create(this);
this->camera->transform->lookAt(glm::vec3(300, 300, 300), glm::vec3(0, 0, 0));
this->subScene.stage();
this->sceneItem = this->createSceneItem();
auto host = this->sceneItem->addComponent<MeshHost>();
auto renderer = this->sceneItem->addComponent<MeshRenderer>();
auto material = this->sceneItem->addComponent<Material>();
material->textureValues[material->getShader()->getParameterByName("u_Text")] = this->subScene.renderTarget.getTexture();
auto renderTargetQuad = this->sceneItem->addComponent<SimpleRenderTargetQuad>();
renderTargetQuad->setRenderTarget(&this->subScene.renderTarget);
auto subSceneController = this->sceneItem->addComponent<SubSceneController>();
subSceneController->setSubScene(&this->subScene);
auto subSceneCameraAlign = this->sceneItem->addComponent<SubSceneCameraAlign>();
subSceneCameraAlign->setRenderTarget(&this->subScene.renderTarget);
subSceneCameraAlign->setCamera(this->camera);
}
};
}