Files
MeshShadingDemo/src/MeshShadingDemoGame.cpp
T
2024-07-19 11:43:36 +02:00

149 lines
4.8 KiB
C++

#include "MeshShadingDemoGame.h"
#include "Actor/FlyCam.h"
#include "Asset/AssetRegistry.h"
#include "Component/Transform.h"
#include "System/FlyCamSystem.h"
#include "Component/Path.h"
#include "System/SplineCamSystem.h"
#include "Graphics/StaticMeshVertexData.h"
MeshShadingDemoGame::MeshShadingDemoGame()
{
}
MeshShadingDemoGame::~MeshShadingDemoGame()
{
}
void MeshShadingDemoGame::setupScene(PScene scene, PSystemGraph graph)
{
Array<Vector> lightPoints = {
Vector(13.542, 3.12369, -12.3293),
Vector(20.6668, 3.04548, -20.9486),
Vector(11.5522, 3.09676, -45.9563),
Vector(10.392, 3.0536, -63.238),
Vector(14.8289, 3.01454, -72.0112),
Vector(16.9386, 3.06158, -80.7447),
Vector(17.6772, 3.05903, -89.3406),
Vector(17.4801, 3.03598, -97.9897),
Vector(17.1882, 3.04928, -106.596),
Vector(16.8547, 3.05735, -116.065),
Vector(16.6074, 3.05262, -123.884),
Vector(16.331, 3.03858, -132.499),
Vector(16.0015, 3.07391, -141.126),
Vector(26.1148, 3.05149, -141.591),
Vector(26.4517, 3.06293, -132.945),
Vector(26.7491, 3.06205, -124.321),
Vector(27.0371, 3.11222, -115.731),
Vector(28.7401, 3.063, -98.5291),
Vector(29.0123, 3.09289, -89.8635),
Vector(28.5112, 3.07688, -81.2221),
Vector(26.8285, 3.12346, -72.5381),
Vector(23.7577, 3.07845, -63.8065),
Vector(18.4836, 3.07243, -54.9846),
Vector(11.5667, 3.0757, -46.1511),
Vector(44.4868, 3.169, -11.858),
Vector(50.5335, 3.15588, -21.1511),
Vector(54.2709, 3.18958, -30.2516),
Vector(55.6934, 3.22225, -39.0652),
Vector(55.8267, 3.16783, -47.748),
Vector(55.0125, 3.20429, -56.3455),
Vector(54.0781, 3.20927, -64.9114),
Vector(53.1076, 3.17979, -74.2689),
Vector(52.2437, 3.21515, -82.0613),
Vector(51.3169, 3.19196, -90.6292),
Vector(50.3008, 3.20521, -99.2916),
Vector(60.4217, 3.17473, -100.424),
Vector(61.3612, 3.21026, -91.855),
Vector(62.2923, 3.1473, -83.2846),
Vector(63.2343, 3.18438, -74.7077),
Vector(66.1857, 3.23896, -57.6697),
Vector(67.1304, 3.19608, -49.0803),
Vector(67.2474, 3.17215, -40.4073),
Vector(66.2297, 3.20527, -31.6281),
Vector(63.8036, 3.21531, -22.7063),
Vector(59.241, 3.19388, -13.5084),
Vector(53.0474, 3.21296, -4.20644),
Vector(4.588, 3.085, 4.934),
Vector(7.953, 3.121, -3.686),
Vector(13.556, 3.187, -20.951),
Vector(28.248, 3.119, -12.431),
Vector(21.286, 3.132, -3.812),
Vector(16.584, 3.1152, 4.822),
Vector(14.232, 3.151, 13.474),
Vector(13.178, 3.144, 22.079),
Vector(13.074, 3.176, 30.716),
Vector(13.053, 3.136, 39.339),
Vector(13.062, 3.163, 48.746),
Vector(13.067, 3.097, 56.555),
Vector(13.051, 3.109, 65.204),
Vector(13.073, 3.107, 73.822),
Vector(2.997, 3.1082, 73.903),
Vector(2.951, 3.127, 65.324),
Vector(2.939, 3.117, 56.713),
Vector(2.939, 3.100, 48.078),
Vector(1.819, 3.048, 30.881),
Vector(1.812, 3.076, 22.211),
Vector(2.647, 3.154, 13.573),
};
for (auto p : lightPoints)
{
lights.add(new PointLightActor(scene, p, Vector(251 / 255.f, 207 / 255.f, 107 / 255.f), 3));
}
Path p = Path({
Vector(8.07149, 2.89742, 72.6628),
Vector(6.56899, 3.75079, 50.512),
Vector(5.36649, 3.97833, 33.2987),
Vector(9.95685, 3.66233, 1.15688),
Vector(19.6487, 3.52539, -13.0847),
Vector(26.875, 3.30828, -19.2694),
Vector(34.4412, 3.13038, -11.9002),
Vector(41.6074, 3.17334, -7.07916),
Vector(52.3544, 3.22211, -6.32834),
Vector(59.6433, 2.86301, -16.1626),
Vector(57.3598, 2.50521, -19.7923),
Vector(52.312, 1.85907, -11.5477),
Vector(44.4041, 3.09733, -7.70407),
Vector(31.0161, 3.27204, -16.1626),
Vector(23.3012, 3.2754, -23.0331),
Vector(11.1551, 3.20805, -35.1741),
Vector(3.502, 2.87556, -43.9499),
Vector(10.4903, 3.0962, -52.2983),
Vector(16.7925, 2.39479, -62.9087),
Vector(23.1887, 1.41071, -88.6824),
Vector(24.5556, 1.41071, -95.5271),
});
path = new Entity(scene);
path->attachComponent<Path>(p);
chapel = new StaticMeshActor(scene, AssetRegistry::findMesh("Whitechapel", "Whitechapel"));
//chapel->getTransform().setScale(Vector(0.01, 0.01, 0.01));
//flyCam = new FlyCam(scene);
//flyCam->attachComponent<Component::PointLight>(Vector4(0, 0, 0, 0), Vector4(1, 1, 1, 2));
//flyCam->getCamera().mainCamera = true;
followCam = new PathFollowCam(scene);
followCam->getPathFollow().path = path;
followCam->getCamera().mainCamera = true;
//suburbs = new StaticMeshActor(scene, AssetRegistry::findMesh("suburbs", "city-suburbs"));
//test = new StaticMeshActor(scene, AssetRegistry::findMesh("", "cube"));
//test->getTransform().setScale(Vector(1, 1, 1));
//test->getTransform().setPosition(Vector(0, 0, 100));
light = new DirectionalLightActor(scene, Vector4(0.2, 0.3, 0.2, 0.1), Vector(0.1, -1, 0.2));
graph->addSystem(new FlyCamSystem(scene));
graph->addSystem(new SplineCamSystem(scene));
}
Game* createInstance()
{
return new MeshShadingDemoGame();
}
void destroyInstance(Game* game)
{
delete game;
}