diff --git a/engine/inc/renderer/3d/pipeline/minecraft/programs/as_is/mcpip_clip.hpp b/engine/inc/renderer/3d/pipeline/minecraft/programs/as_is/mcpip_clip.hpp index b3b9d1c..18e68bd 100644 --- a/engine/inc/renderer/3d/pipeline/minecraft/programs/as_is/mcpip_clip.hpp +++ b/engine/inc/renderer/3d/pipeline/minecraft/programs/as_is/mcpip_clip.hpp @@ -48,8 +48,9 @@ class McpipClip { packet2_t* staticPacket; u16 vu1DBufferSize; - std::vector clippedTriangle; - std::vector inputTriangle; + Vec4 inputVerts[3]; + EEClipVertexPtrs inputTriangle[3]; + EEClipVertex clippedTriangle[9]; Vec4 vertexBuffers[2][108]; Vec4 texCoordBuffers[2][108]; diff --git a/engine/inc/renderer/3d/pipeline/shared/pipeline_options.hpp b/engine/inc/renderer/3d/pipeline/shared/pipeline_options.hpp index 214f999..a9f8f26 100644 --- a/engine/inc/renderer/3d/pipeline/shared/pipeline_options.hpp +++ b/engine/inc/renderer/3d/pipeline/shared/pipeline_options.hpp @@ -18,7 +18,12 @@ namespace Tyra { class PipelineOptions { public: - PipelineOptions() { lighting = nullptr; } + PipelineOptions() { + lighting = nullptr; + antiAliasingEnabled = false; + blendingEnabled = true; + shadingType = TyraShadingFlat; + } ~PipelineOptions() {} PipelineFrustumCulling frustumCulling; diff --git a/engine/inc/renderer/3d/pipeline/static/core/stapip_clipper.hpp b/engine/inc/renderer/3d/pipeline/static/core/stapip_clipper.hpp index 28ddd43..eb135d0 100644 --- a/engine/inc/renderer/3d/pipeline/static/core/stapip_clipper.hpp +++ b/engine/inc/renderer/3d/pipeline/static/core/stapip_clipper.hpp @@ -39,6 +39,10 @@ class StaPipClipper { EEClipAlgorithm algorithm; M4x4* mvp; + Vec4 inputVerts[3]; + EEClipVertexPtrs inputTriangle[3]; + EEClipVertex clippedTriangle[9]; + void perspectiveDivide(std::vector* vertices); void moveDataToBuffer(const std::vector& vertices, StaPipQBuffer* buffer); diff --git a/engine/inc/renderer/core/3d/clipper/ee_clip_algorithm.hpp b/engine/inc/renderer/core/3d/clipper/ee_clip_algorithm.hpp index 631a76c..b8398a8 100644 --- a/engine/inc/renderer/core/3d/clipper/ee_clip_algorithm.hpp +++ b/engine/inc/renderer/core/3d/clipper/ee_clip_algorithm.hpp @@ -28,25 +28,25 @@ class EEClipAlgorithm { void init(const RendererSettings& settings); - void clip(std::vector* o_vertices, - const std::vector& vertices, - const EEClipAlgorithmSettings& settings); + u8 clip(EEClipVertex* o_vertices, EEClipVertexPtrs* i_vertices, + const EEClipAlgorithmSettings& settings); static float clipMargin; private: float halfWidth, halfHeight, near, far; - std::vector tempVertices; + EEClipVertex* tempVertices; float getValueByPlane(const EEClipVertex& v, const int& plane); bool isInside(const int& plane, const float& v, const float& w, const float& planeLimitValue); - void clipAgainstPlane(const std::vector& original, - std::vector* clipped, const int& plane, - const float& planeLimitValue, - const EEClipAlgorithmSettings& settings); + /** @return clipped size */ + u8 clipAgainstPlane(EEClipVertex* original, const u8& originalSize, + EEClipVertex* clipped, const int& plane, + const float& planeLimitValue, + const EEClipAlgorithmSettings& settings); }; } // namespace Tyra diff --git a/engine/inc/renderer/core/3d/clipper/ee_clip_vertex.hpp b/engine/inc/renderer/core/3d/clipper/ee_clip_vertex.hpp index b55dc7c..3ee5859 100644 --- a/engine/inc/renderer/core/3d/clipper/ee_clip_vertex.hpp +++ b/engine/inc/renderer/core/3d/clipper/ee_clip_vertex.hpp @@ -18,4 +18,8 @@ struct EEClipVertex { Vec4 position, normal, st, color; }; +struct EEClipVertexPtrs { + Vec4 *position, *normal, *st, *color; +}; + } // namespace Tyra diff --git a/engine/src/loaders/3d/tyrobj/tyrobj_loader.cpp b/engine/src/loaders/3d/tyrobj/tyrobj_loader.cpp index 608403d..a6d7349 100644 --- a/engine/src/loaders/3d/tyrobj/tyrobj_loader.cpp +++ b/engine/src/loaders/3d/tyrobj/tyrobj_loader.cpp @@ -31,7 +31,9 @@ MeshBuilderData* TyrobjLoader::load(const char* fullpath, const u16& count, auto rawFilename = getFilenameWithoutExtension(path); auto extension = getExtensionOfFilename(path); - auto firstFile = rawFilename + "1." + extension; + std::string firstFile = path; + if (count > 1) firstFile = rawFilename + "1." + extension; + FILE* firstFileHandler = fopen(firstFile.c_str(), "rb"); TYRA_ASSERT(firstFileHandler != nullptr, "Failed to load: ", firstFile); auto data = scan(firstFileHandler, count); @@ -46,10 +48,12 @@ MeshBuilderData* TyrobjLoader::load(const char* fullpath, const u16& count, result->manyColorsEnabled = data.colorsCount > 0; for (u16 i = 1; i <= count; i++) { - auto path = rawFilename + std::to_string(i) + "." + extension; - FILE* fileHandler = fopen(path.c_str(), "rb"); - TYRA_ASSERT(fileHandler != nullptr, "Failed to load: ", path); - loadFile(fileHandler, path, i - 1, data, result); + std::string filePath = rawFilename + std::to_string(i) + "." + extension; + if (count == 1) filePath = path; + + FILE* fileHandler = fopen(filePath.c_str(), "rb"); + TYRA_ASSERT(fileHandler != nullptr, "Failed to load: ", filePath); + loadFile(fileHandler, filePath, i - 1, data, result); fclose(fileHandler); } diff --git a/engine/src/renderer/3d/pipeline/minecraft/programs/as_is/mcpip_clip.cpp b/engine/src/renderer/3d/pipeline/minecraft/programs/as_is/mcpip_clip.cpp index a4e1075..287f97d 100644 --- a/engine/src/renderer/3d/pipeline/minecraft/programs/as_is/mcpip_clip.cpp +++ b/engine/src/renderer/3d/pipeline/minecraft/programs/as_is/mcpip_clip.cpp @@ -64,24 +64,20 @@ void McpipClip::addData(McpipBlock* block, const bool& isMulti, for (u32 i = 0; i < blockData->count / 3; i++) { for (u8 j = 0; j < 3; j++) { - EEClipVertex vert = {mvp * blockData->vertices[i * 3 + j], Vec4(), - blockData->textureCoords[i * 3 + j], Vec4()}; - - inputTriangle.push_back(vert); + inputVerts[j] = mvp * blockData->vertices[i * 3 + j]; + inputTriangle[j] = {&inputVerts[j], nullptr, + &blockData->textureCoords[i * 3 + j], nullptr}; } - clippedTriangle.clear(); + u8 clippedSize = + algorithm.clip(clippedTriangle, inputTriangle, algoSettings); - algorithm.clip(&clippedTriangle, inputTriangle, algoSettings); + if (clippedSize == 0) continue; - inputTriangle.clear(); - - if (clippedTriangle.size() == 0) continue; - - auto va = clippedTriangle.at(0); - for (u32 j = 1; j <= clippedTriangle.size() - 2; j++) { - auto vb = clippedTriangle.at(j); - auto vc = clippedTriangle.at((j + 1) % clippedTriangle.size()); + auto va = clippedTriangle[0]; + for (u8 j = 1; j <= clippedSize - 2; j++) { + auto vb = clippedTriangle[j]; + auto vc = clippedTriangle[(j + 1) % clippedSize]; clippedVertices.push_back(va); clippedVertices.push_back(vb); clippedVertices.push_back(vc); diff --git a/engine/src/renderer/3d/pipeline/static/core/bag/packaging/stapip_bag_packages_bbox.cpp b/engine/src/renderer/3d/pipeline/static/core/bag/packaging/stapip_bag_packages_bbox.cpp index c802719..d17c85c 100644 --- a/engine/src/renderer/3d/pipeline/static/core/bag/packaging/stapip_bag_packages_bbox.cpp +++ b/engine/src/renderer/3d/pipeline/static/core/bag/packaging/stapip_bag_packages_bbox.cpp @@ -52,6 +52,11 @@ StaPipBagPackagesBBox::StaPipBagPackagesBBox(Vec4* t_vertices, mainBBox = new RenderBBox(*bboxParts, 0, partsCount); } +StaPipBagPackagesBBox::~StaPipBagPackagesBBox() { + delete bboxParts; + delete mainBBox; +} + const RenderBBox& StaPipBagPackagesBBox::getChildBBox1By3( const u32& index) const { TYRA_ASSERT(index < partsCount, @@ -106,9 +111,4 @@ std::string StaPipBagPackagesBBox::getPrint(const char* name) const { return res.str(); } -StaPipBagPackagesBBox::~StaPipBagPackagesBBox() { - delete bboxParts; - delete mainBBox; -} - } // namespace Tyra diff --git a/engine/src/renderer/3d/pipeline/static/core/stapip_clipper.cpp b/engine/src/renderer/3d/pipeline/static/core/stapip_clipper.cpp index 1bb847c..01fe753 100644 --- a/engine/src/renderer/3d/pipeline/static/core/stapip_clipper.cpp +++ b/engine/src/renderer/3d/pipeline/static/core/stapip_clipper.cpp @@ -34,26 +34,24 @@ void StaPipClipper::clip(StaPipQBuffer* buffer) { std::vector clippedVertices; for (u32 i = 0; i < buffer->size / 3; i++) { - std::vector inputTriangle; for (u8 j = 0; j < 3; j++) { - EEClipVertex vert = { - *mvp * buffer->vertices[i * 3 + j], - buffer->bag->lighting ? buffer->normals[i * 3 + j] : Vec4(), - buffer->bag->texture ? buffer->sts[i * 3 + j] : Vec4(), - buffer->bag->color->many ? buffer->colors[i * 3 + j] : Vec4()}; - - inputTriangle.push_back(vert); + inputVerts[j] = *mvp * buffer->vertices[i * 3 + j]; + inputTriangle[j] = { + &inputVerts[j], + buffer->bag->lighting ? &buffer->normals[i * 3 + j] : nullptr, + buffer->bag->texture ? &buffer->sts[i * 3 + j] : nullptr, + buffer->bag->color->many ? &buffer->colors[i * 3 + j] : nullptr}; } - std::vector clippedTriangle; - algorithm.clip(&clippedTriangle, inputTriangle, algoSettings); + u8 clippedSize = + algorithm.clip(clippedTriangle, inputTriangle, algoSettings); - if (clippedTriangle.size() == 0) continue; + if (clippedSize == 0) continue; - auto va = clippedTriangle.at(0); - for (u32 j = 1; j <= clippedTriangle.size() - 2; j++) { - auto vb = clippedTriangle.at(j); - auto vc = clippedTriangle.at((j + 1) % clippedTriangle.size()); + auto va = clippedTriangle[0]; + for (u8 j = 1; j <= clippedSize - 2; j++) { + auto vb = clippedTriangle[j]; + auto vc = clippedTriangle[(j + 1) % clippedSize]; clippedVertices.push_back(va); clippedVertices.push_back(vb); clippedVertices.push_back(vc); diff --git a/engine/src/renderer/3d/pipeline/static/core/stapip_core.cpp b/engine/src/renderer/3d/pipeline/static/core/stapip_core.cpp index efb179b..64e524f 100644 --- a/engine/src/renderer/3d/pipeline/static/core/stapip_core.cpp +++ b/engine/src/renderer/3d/pipeline/static/core/stapip_core.cpp @@ -91,7 +91,12 @@ void StaPipCore::render(StaPipBag* bag, const bool& frustumCull, frustumCheck = renderBbox->getMainBBox()->clipIsInFrustum( rendererCore->renderer3D.frustumPlanes.getAll(), *bag->info->model); - if (frustumCheck == OUTSIDE_FRUSTUM) return; + if (frustumCheck == OUTSIDE_FRUSTUM) { + if (frustumCull && !bbox) { + delete renderBbox; + } + return; + } } packager.setRenderBBox(renderBbox); @@ -157,7 +162,9 @@ void StaPipCore::render(StaPipBag* bag, const bool& frustumCull, } } - if (frustumCull && !bbox) delete renderBbox; + if (frustumCull && !bbox) { + delete renderBbox; + } if (texBuffers) delete texBuffers; qbufferRenderer.flushBuffers(); diff --git a/engine/src/renderer/core/3d/clipper/ee_clip_algorithm.cpp b/engine/src/renderer/core/3d/clipper/ee_clip_algorithm.cpp index d5ed65d..6eb5c9e 100644 --- a/engine/src/renderer/core/3d/clipper/ee_clip_algorithm.cpp +++ b/engine/src/renderer/core/3d/clipper/ee_clip_algorithm.cpp @@ -12,34 +12,52 @@ namespace Tyra { -EEClipAlgorithm::EEClipAlgorithm() {} +EEClipAlgorithm::EEClipAlgorithm() { tempVertices = new EEClipVertex[9]; } -EEClipAlgorithm::~EEClipAlgorithm() {} +EEClipAlgorithm::~EEClipAlgorithm() { delete[] tempVertices; } float EEClipAlgorithm::clipMargin = -10.0F; void EEClipAlgorithm::init(const RendererSettings& settings) { - halfWidth = settings.getWidth() / 2; - halfHeight = settings.getHeight() / 2; + // halfWidth = settings.getWidth() / 2; + // halfHeight = settings.getHeight() / 2; + halfWidth = 0.5F; + halfHeight = 0.5F; near = settings.getNear() - (-clipMargin); far = -settings.getFar(); } -void EEClipAlgorithm::clip(std::vector* o_vertices, - const std::vector& vertices, - const EEClipAlgorithmSettings& settings) { - tempVertices.clear(); - - for (u32 i = 0; i < vertices.size(); i++) { - o_vertices->push_back(vertices.at(i)); +u8 EEClipAlgorithm::clip(EEClipVertex* o_vertices, EEClipVertexPtrs* i_vertices, + const EEClipAlgorithmSettings& settings) { + for (int i = 0; i < 3; i++) { + o_vertices[i].position = *i_vertices[i].position; + if (settings.lerpColors) o_vertices[i].color = *i_vertices[i].color; + if (settings.lerpNormals) o_vertices[i].normal = *i_vertices[i].normal; + if (settings.lerpTexCoords) o_vertices[i].st = *i_vertices[i].st; } - clipAgainstPlane(*o_vertices, &tempVertices, 1, halfWidth, settings); - clipAgainstPlane(tempVertices, o_vertices, 1, -halfWidth, settings); - clipAgainstPlane(*o_vertices, &tempVertices, 2, halfHeight, settings); - clipAgainstPlane(tempVertices, o_vertices, 2, -halfHeight, settings); - clipAgainstPlane(*o_vertices, &tempVertices, 3, near, settings); - clipAgainstPlane(tempVertices, o_vertices, 4, far, settings); + u8 tempVerticesSize = 0; + u8 outputSize = 0; + + tempVerticesSize = + clipAgainstPlane(o_vertices, 3, tempVertices, 1, halfWidth, settings); + + outputSize = clipAgainstPlane(tempVertices, tempVerticesSize, o_vertices, 1, + -halfWidth, settings); + + tempVerticesSize = clipAgainstPlane(o_vertices, outputSize, tempVertices, 2, + halfHeight, settings); + + outputSize = clipAgainstPlane(tempVertices, tempVerticesSize, o_vertices, 2, + -halfHeight, settings); + + tempVerticesSize = + clipAgainstPlane(o_vertices, outputSize, tempVertices, 3, near, settings); + + outputSize = clipAgainstPlane(tempVertices, tempVerticesSize, o_vertices, 4, + far, settings); + + return outputSize; } float EEClipAlgorithm::getValueByPlane(const EEClipVertex& v, @@ -70,22 +88,23 @@ bool EEClipAlgorithm::isInside(const int& plane, const float& v, const float& w, } } -void EEClipAlgorithm::clipAgainstPlane( - const std::vector& original, - std::vector* clipped, const int& plane, - const float& planeLimitValue, const EEClipAlgorithmSettings& settings) { - clipped->clear(); +u8 EEClipAlgorithm::clipAgainstPlane(EEClipVertex* original, + const u8& originalSize, + EEClipVertex* clipped, const int& plane, + const float& planeLimitValue, + const EEClipAlgorithmSettings& settings) { + int clippedSize = 0; - for (u32 i = 0; i < original.size(); i++) { - auto a = original.at(i); - auto b = original.at((i + 1) % original.size()); + for (u32 i = 0; i < originalSize; i++) { + auto a = original[i]; + auto b = original[(i + 1) % originalSize]; auto apx = getValueByPlane(a, plane); auto bpx = getValueByPlane(b, plane); auto aIsInside = isInside(plane, apx, a.position.w, planeLimitValue); auto bIsInside = isInside(plane, bpx, b.position.w, planeLimitValue); if (aIsInside) { - clipped->push_back(a); + clipped[clippedSize++] = a; } if (aIsInside != bIsInside) { @@ -96,17 +115,22 @@ void EEClipAlgorithm::clipAgainstPlane( ((b.position.w - a.position.w) * planeLimitValue - (bpx - apx)); - EEClipVertex nb = { - Vec4::getByLerp(a.position, b.position, p), - settings.lerpNormals ? Vec4::getByLerp(a.normal, b.normal, p) - : Vec4(), - settings.lerpTexCoords ? Vec4::getByLerp(a.st, b.st, p) : Vec4(), - settings.lerpColors ? Vec4::getByLerp(a.color, b.color, p) : Vec4(), - }; + auto index = clippedSize++; - clipped->push_back(nb); + clipped[index].position = Vec4::getByLerp(a.position, b.position, p); + + if (settings.lerpNormals) + clipped[index].normal = Vec4::getByLerp(a.normal, b.normal, p); + + if (settings.lerpTexCoords) + clipped[index].st = Vec4::getByLerp(a.st, b.st, p); + + if (settings.lerpColors) + clipped[index].color = Vec4::getByLerp(a.color, b.color, p); } } + + return clippedSize; } } // namespace Tyra diff --git a/engine/src/renderer/core/gs/renderer_core_gs.cpp b/engine/src/renderer/core/gs/renderer_core_gs.cpp index 37085d6..de945ea 100644 --- a/engine/src/renderer/core/gs/renderer_core_gs.cpp +++ b/engine/src/renderer/core/gs/renderer_core_gs.cpp @@ -77,7 +77,6 @@ void RendererCoreGS::allocateBuffers() { zBuffer.address = graph_vram_allocate(frameBuffers[0].width, frameBuffers[0].height, zBuffer.zsm, GRAPH_ALIGN_PAGE); - TYRA_LOG("Framebuffers, zBuffer set and allocated!"); graph_set_mode(GRAPH_MODE_INTERLACED, GRAPH_MODE_NTSC, GRAPH_MODE_FRAME, GRAPH_ENABLE); @@ -95,6 +94,8 @@ void RendererCoreGS::allocateBuffers() { spaceOccupiedByZBuffer = spaceOccupiedByFrameBuffers; spaceOccupiedByFrameBuffers *= 2; + + TYRA_LOG("Framebuffers, zBuffer set and allocated!"); } void RendererCoreGS::initDrawingEnvironment() { diff --git a/samples/h4570/inc/h4570.hpp b/samples/h4570/inc/h4570.hpp index 90d06be..d0f79cd 100644 --- a/samples/h4570/inc/h4570.hpp +++ b/samples/h4570/inc/h4570.hpp @@ -30,6 +30,7 @@ class H4570 : public Game { private: Engine* engine; + StaticMesh* skybox; DynamicMesh* cube; StaticMesh* staticMesh; DynamicMesh* warrior; @@ -44,6 +45,7 @@ class H4570 : public Game { MinecraftPipeline mcPip; DynamicPipeline dynpip; StaticPipeline stapip; + StaPipOptions* skyboxOptions; StaPipOptions* staOptions; DynPipOptions* dynOptions; Texture* warriorTex; diff --git a/samples/h4570/src/h4570.cpp b/samples/h4570/src/h4570.cpp index 6905a91..8888565 100644 --- a/samples/h4570/src/h4570.cpp +++ b/samples/h4570/src/h4570.cpp @@ -30,6 +30,7 @@ H4570::~H4570() {} StaticMesh* getStaticMesh(Renderer* renderer); DynamicMesh* getWarrior(Renderer* renderer); +StaticMesh* getSkybox(Renderer* renderer); DynamicMesh* getCube(Renderer* renderer); StaPipOptions* getStaPipOptions(); DynPipOptions* getDynPipOptions(); @@ -48,6 +49,7 @@ void H4570::init() { engine->renderer.setClearScreenColor(Color(64.0F, 64.0F, 64.0F)); staticMesh = getStaticMesh(&engine->renderer); + skybox = getSkybox(&engine->renderer); cube = getCube(&engine->renderer); @@ -55,7 +57,7 @@ void H4570::init() { warriorTex = engine->renderer.core.texture.repository.getBySpriteOrMesh( warrior->getMaterial(0)->getId()); - warriorsCount = 22; + warriorsCount = 12; warriors = new DynamicMesh*[warriorsCount]; for (u8 i = 0; i < warriorsCount; i++) { warriors[i] = new DynamicMesh(*warrior); @@ -71,6 +73,11 @@ void H4570::init() { } staOptions = getStaPipOptions(); + + skyboxOptions = new StaPipOptions(); + skyboxOptions->fullClipChecks = true; + skyboxOptions->frustumCulling = PipelineFrustumCulling_Precise; + dynOptions = getDynPipOptions(); cameraPosition = Vec4(0.0F, 0.0F, 20.0F); @@ -88,9 +95,8 @@ void H4570::init() { u32 rows = 16; // 64 u32 columns = 16; // 64 blocksCount = rows * columns; - float initialCameraZ = -400.0F; - float offset = 40.0F; + float offset = 4.0F; blocks = new McpipBlock[blocksCount]; translations = new M4x4[blocksCount]; rotations = new M4x4[blocksCount]; @@ -101,10 +107,9 @@ void H4570::init() { u32 column = i % columns; u32 row = i / rows; - scales[i].scale(10.0F); translations[i].translateX(row * offset - center); translations[i].translateY(column * offset - center); - translations[i].translateZ(initialCameraZ); + translations[i].translateZ(-50.0F); u32 randRow = rand() % (rows + 1); u32 randColumn = rand() % (columns + 1); @@ -117,7 +122,7 @@ void H4570::init() { } // engine->audio.playSong(); - engine->renderer.setFrameLimit(false); + // engine->renderer.setFrameLimit(false); } u32 counter = 0; @@ -132,6 +137,8 @@ void H4570::loop() { for (u8 i = 0; i < warriorsCount; i++) warriors[i]->animate(); cube->animate(); + skybox->rotation.rotateY(0.02F); + engine->renderer.beginFrame(CameraInfo3D(&cameraPosition, &cameraLookAt)); { for (u32 i = 0; i < blocksCount; i++) { @@ -142,25 +149,28 @@ void H4570::loop() { blocks[i].model = translations[i] * rotations[i] * scales[i]; } - engine->renderer.renderer2D.render(picture); + // engine->renderer.renderer2D.render(picture); engine->renderer.renderer3D.usePipeline(&stapip); - { stapip.render(staticMesh, staOptions); } - - engine->renderer.renderer3D.usePipeline(&dynpip); { - dynpip.render(cube); - Threading::switchThread(); - for (u8 i = 0; i < warriorsCount; i++) { - dynpip.render(warriors[i], dynOptions); - if (i == 5) Threading::switchThread(); - if (i == 10) Threading::switchThread(); - if (i == 15) Threading::switchThread(); - } + // stapip.render(staticMesh, staOptions); + stapip.render(skybox, skyboxOptions); } - engine->renderer.renderer3D.usePipeline(&mcPip); - { mcPip.render(blocks, blocksCount, blocksTex); } + // engine->renderer.renderer3D.usePipeline(&dynpip); + // { + // dynpip.render(cube); + // Threading::switchThread(); + // for (u8 i = 0; i < warriorsCount; i++) { + // dynpip.render(warriors[i], dynOptions); + // if (i == 5) Threading::switchThread(); + // if (i == 10) Threading::switchThread(); + // if (i == 15) Threading::switchThread(); + // } + // } + + // engine->renderer.renderer3D.usePipeline(&mcPip); + // { mcPip.render(blocks, blocksCount, blocksTex); } } engine->renderer.endFrame(); } @@ -178,6 +188,20 @@ StaticMesh* getStaticMesh(Renderer* renderer) { return result; } +StaticMesh* getSkybox(Renderer* renderer) { + TyrobjLoader loader; + auto* data = + loader.load(FileUtils::fromCwd("skybox/skybox.tyrobj"), 1, 50.0F, true); + auto* result = new StaticMesh(*data); + result->translation.translateZ(-30.0F); + delete data; + + renderer->core.texture.repository.addByMesh( + result, FileUtils::fromCwd("skybox/"), "png"); + + return result; +} + DynamicMesh* getWarrior(Renderer* renderer) { MD2Loader loader; auto* data = loader.load(FileUtils::fromCwd("warrior.md2"), .08F, false);