Files
MeshShadingDemo/src/MeshShadingDemoGame.cpp
T

218 lines
7.1 KiB
C++
Raw Normal View History

2025-07-01 20:38:31 +02:00
#include "MeshShadingDemoGame.h"
#include "Actor/FlyCam.h"
#include "Asset/AssetRegistry.h"
#include "Component/Transform.h"
#include "Component/TerrainTile.h"
#include "System/FlyCamSystem.h"
#include "Component/Path.h"
#include "Component/WaterTile.h"
#include "System/SplineCamSystem.h"
#include "Graphics/StaticMeshVertexData.h"
MeshShadingDemoGame::MeshShadingDemoGame()
{
}
MeshShadingDemoGame::~MeshShadingDemoGame()
{
}
void MeshShadingDemoGame::setupScene(PScene scene, PSystemGraph graph)
{
flyCam = new FlyCam(scene);
flyCam->attachComponent<Component::PointLight>(Vector(1, 1, 1), 1.0f, 2.0f);
flyCam->getCamera().mainCamera = true;
followCam = new PathFollowCam(scene);
//followCam->getCamera().mainCamera = true;
/* {
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),
};
Path p = Path({
Vector(-16.9676, 5.7499, -77.5539),
Vector(-3.95049, 3.51678, -60.7428),
Vector(0.954792, 3.47537, -55.1175),
Vector(16.9581, 3.26171, -34.3647),
Vector(25.8841, 3.0817, -24.1843),
Vector(42.8916, 2.71463, -7.55981),
Vector(58.1216, 2.88532, -15.9938),
Vector(67.3108, 3.40471, -48.757),
Vector(73.9232, 3.10779, -144.263),
Vector(81.7667, 3.32603, -172.821),
});
for (auto p : lightPoints)
{
lights.add(new PointLightActor(scene, p, Vector(251 / 255.f, 207 / 255.f, 107 / 255.f), 2));
}
path = new Entity(scene);
path->attachComponent<Path>(p);
chapel = new StaticMeshActor(scene, AssetRegistry::findMesh("Whitechapel", "Whitechapel"));
followCam->getPathFollow().path = path;
}*/
/*
{
Path p = Path({
Vector(-28.8013, 9.58383, -84.0442),
Vector(-27.5597, 9.09855, -57.1531),
Vector(-27.2196, 8.99756, -14.1793),
Vector(-27.5354, 8.11755, 26.1741),
Vector(-28.6125, 7.32383, 67.1864),
Vector(-5.20891, 7.62963, 87.9103),
Vector(18.1879, 8.19607, 113.661),
Vector(18.8014, 5.01105, 149.623),
Vector(18.6341, 4.84045, 183.52),
Vector(21.6458, 4.17056, 190.23),
});
path = new Entity(scene);
path->attachComponent<Path>(p);
for (uint32 y = 0; y < 2; y++)
{
for (uint32 x = 0; x < 2; x++)
{
suburbs.add(new StaticMeshActor(scene, AssetRegistry::findMesh("suburbs", "city-suburbs")));
suburbs.back()->getTransform().setPosition(Vector(x * 143, 0, y * 193));
}
}
followCam->getPathFollow().path = path;
}*/
{
Path p = Path({
Vector(33.3414, 36.8653, 28.819),
Vector(69.6004, 42.7509, 109.65),
Vector(82.0893, 43.8156, 127.942),
Vector(106.724, 42.0612, 154.561),
Vector(168.118, 39.9358, 220.453),
Vector(219.94, 42.453, 273.038),
Vector(244.23, 44.1136, 289.115),
Vector(253.318, 44.4212, 303.567),
Vector(256.505, 44.6277, 324.343),
Vector(282.637, 45.0222, 371.102),
Vector(299.247, 45.3911, 375.493),
Vector(393.234, 37.4515, 364.943),
});
//path = new Entity(scene);
//path->attachComponent<Path>(p);
//followCam->getPathFollow().path = path;
//minecraft = new StaticMeshActor(scene, AssetRegistry::findMesh("minecraft", "minecraft-medieval-city"));
//minecraft->getTransform().setScale(Vector(0.01, 0.01, 0.01));
}
{
Path p = Path({
Vector(89.3805, 153.648, 270.467),
Vector(131.966, 119.247, 116.347),
Vector(72.9846, 95.5085, 18.481),
Vector(23.1404, 96.2972, 31.0632),
Vector(-12.3954, 100.118, -10.2085),
Vector(-11.1341, 104.619, -79.1077),
Vector(-7.61656, 112.695, -102.459),
});
//path = new Entity(scene);
//path->attachComponent<Path>(p);
//followCam->getPathFollow().path = path;
//volvo = new StaticMeshActor(scene, AssetRegistry::findMesh("Volvo", "Volvo"));
}
test = new StaticMeshActor(scene, AssetRegistry::findMesh("rttest", "rttest"));
//test->getTransform().setScale(Vector(0.01, 0.01, 0.01));
/*for (int32 y = -40; y < 40; ++y)
{
for (int32 x = -40; x < 40; ++x)
{
scene->attachComponent<Component::WaterTile>(scene->createEntity(), Component::WaterTile{
.location = IVector2(x, y),
.height = 0,
});
}
}*/
center = new PointLightActor(scene, Vector(0, 0, 0), 10, Vector(1, 1, 1), 10);
xAxis = new PointLightActor(scene, Vector(10, 0, 0), 10, Vector(1, 0, 0), 10);
yAxis = new PointLightActor(scene, Vector(0, 10, 0), 10, Vector(0, 1, 0), 10);
zAxis = new PointLightActor(scene, Vector(0, 0, 10), 10, Vector(0, 0, 1), 10);
light = new DirectionalLightActor(scene, Vector(1, 1, 1), 1, Vector(0.4, -0.4, 0));
graph->addSystem(new FlyCamSystem(scene));
graph->addSystem(new SplineCamSystem(scene));
}
Game* createInstance()
{
return new MeshShadingDemoGame();
}
void destroyInstance(Game* game)
{
delete game;
2024-04-22 12:47:05 +02:00
}