From 21073a8a9919409447f9c71787363becbd52d160 Mon Sep 17 00:00:00 2001 From: h4570 Date: Tue, 26 Jul 2022 23:46:57 +0200 Subject: [PATCH] rename --- .../windows-docker/settings.json | 2 +- samples/h4570/run.ps1 | 4 - samples/wellinator/Makefile | 24 --- samples/wellinator/bin/.gitignore | 4 - samples/wellinator/inc/wellinator.hpp | 53 ----- samples/wellinator/obj/.gitignore | 4 - samples/wellinator/res/.gitignore | 4 - samples/wellinator/run.ps1 | 4 - samples/wellinator/src/main.cpp | 20 -- samples/wellinator/src/wellinator.cpp | 196 ------------------ .../h4570 => tutorials/01-hello}/Makefile | 4 +- .../01-hello}/bin/.gitignore | 0 .../01-hello/inc/tutorial_01.hpp | 6 +- .../01-hello}/obj/.gitignore | 0 .../01-hello}/res/.gitignore | 0 tutorials/01-hello/run.ps1 | 4 + .../h4570 => tutorials/01-hello}/src/main.cpp | 4 +- .../01-hello/src/tutorial_01.cpp | 10 +- .../Makefile.tutorials-base | 0 .../windows-pcsx2.ps1 => windows-pcsx2.ps1 | 0 20 files changed, 17 insertions(+), 326 deletions(-) delete mode 100644 samples/h4570/run.ps1 delete mode 100644 samples/wellinator/Makefile delete mode 100644 samples/wellinator/bin/.gitignore delete mode 100644 samples/wellinator/inc/wellinator.hpp delete mode 100644 samples/wellinator/obj/.gitignore delete mode 100644 samples/wellinator/res/.gitignore delete mode 100644 samples/wellinator/run.ps1 delete mode 100644 samples/wellinator/src/main.cpp delete mode 100644 samples/wellinator/src/wellinator.cpp rename {samples/h4570 => tutorials/01-hello}/Makefile (82%) rename {samples/h4570 => tutorials/01-hello}/bin/.gitignore (100%) rename samples/h4570/inc/h4570.hpp => tutorials/01-hello/inc/tutorial_01.hpp (90%) rename {samples/h4570 => tutorials/01-hello}/obj/.gitignore (100%) rename {samples/h4570 => tutorials/01-hello}/res/.gitignore (100%) create mode 100644 tutorials/01-hello/run.ps1 rename {samples/h4570 => tutorials/01-hello}/src/main.cpp (83%) rename samples/h4570/src/h4570.cpp => tutorials/01-hello/src/tutorial_01.cpp (94%) rename samples/Makefile.samples-base => tutorials/Makefile.tutorials-base (100%) rename samples/windows-pcsx2.ps1 => windows-pcsx2.ps1 (100%) diff --git a/.vscode/configurations/windows-docker/settings.json b/.vscode/configurations/windows-docker/settings.json index e47f737..c933a6f 100644 --- a/.vscode/configurations/windows-docker/settings.json +++ b/.vscode/configurations/windows-docker/settings.json @@ -1,5 +1,5 @@ { - "buildDirectory": "samples/cube", + "buildDirectory": "tutorials/01-hello", "C_Cpp.default.intelliSenseMode": "gcc-x86", "files.associations": { "*.vcl": "asm-collection", diff --git a/samples/h4570/run.ps1 b/samples/h4570/run.ps1 deleted file mode 100644 index 58035c6..0000000 --- a/samples/h4570/run.ps1 +++ /dev/null @@ -1,4 +0,0 @@ -$ConfigFile = Join-Path $PSScriptRoot '../windows-pcsx2.ps1' -. $ConfigFile - -RunPCSX2 diff --git a/samples/wellinator/Makefile b/samples/wellinator/Makefile deleted file mode 100644 index 33c7b49..0000000 --- a/samples/wellinator/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TARGET := wellinator.elf -ENGINEDIR := ../../engine - -#The Directories, Source, Includes, Objects, Binary and Resources -SRCDIR := src -INCDIR := inc -BUILDDIR := obj -TARGETDIR := bin -RESDIR := res -SRCEXT := cpp -VSMEXT := vsm -VCLEXT := vcl -VCLPPEXT := vclpp -DEPEXT := d -OBJEXT := o - -#Flags, Libraries and Includes -CFLAGS := -LIB := -LIBDIRS := -INC := -I$(INCDIR) -INCDEP := -I$(INCDIR) - -include ../Makefile.samples-base \ No newline at end of file diff --git a/samples/wellinator/bin/.gitignore b/samples/wellinator/bin/.gitignore deleted file mode 100644 index 44c5ea8..0000000 --- a/samples/wellinator/bin/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# Ignore everything in this directory -* -# Except this file -!.gitignore \ No newline at end of file diff --git a/samples/wellinator/inc/wellinator.hpp b/samples/wellinator/inc/wellinator.hpp deleted file mode 100644 index f6fd373..0000000 --- a/samples/wellinator/inc/wellinator.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/* -# ______ ____ ___ -# | \/ ____| |___| -# | | | \ | | -#----------------------------------------------------------------------- -# Copyright 2020 - 2022, tyra - https://github.com/h4570/tyra -# Licenced under Apache License 2.0 -# Wellington Carvalho -*/ - -#pragma once - -#include -#include -#include "renderer/3d/pipeline/minecraft/minecraft_pipeline.hpp" -#include "renderer/3d/pipeline/static/static_pipeline.hpp" -#include "renderer/3d/pipeline/dynamic/dynamic_pipeline.hpp" - -namespace Tyra { - -class Wellinator : public Game { - public: - Wellinator(Engine* engine); - ~Wellinator(); - - void init(); - void loop(); - - private: - Engine* engine; - - DynamicMesh* warrior; - Sprite* picture; - audsrv_adpcm_t* adpcmSample; - Timer adpcmTimer; - - Vec4 cameraPosition, cameraLookAt; - - MinecraftPipeline mcPip; - StaticPipeline stapip; - DynamicPipeline dynpip; - StaPipOptions* staOptions; - DynPipOptions* dynOptions; - Texture* blocksTex; - - u32 blocksCount; - McpipBlock* blocks; - M4x4* translations; - M4x4* rotations; - M4x4* scales; -}; - -} // namespace Tyra diff --git a/samples/wellinator/obj/.gitignore b/samples/wellinator/obj/.gitignore deleted file mode 100644 index 44c5ea8..0000000 --- a/samples/wellinator/obj/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# Ignore everything in this directory -* -# Except this file -!.gitignore \ No newline at end of file diff --git a/samples/wellinator/res/.gitignore b/samples/wellinator/res/.gitignore deleted file mode 100644 index 44c5ea8..0000000 --- a/samples/wellinator/res/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# Ignore everything in this directory -* -# Except this file -!.gitignore \ No newline at end of file diff --git a/samples/wellinator/run.ps1 b/samples/wellinator/run.ps1 deleted file mode 100644 index 58035c6..0000000 --- a/samples/wellinator/run.ps1 +++ /dev/null @@ -1,4 +0,0 @@ -$ConfigFile = Join-Path $PSScriptRoot '../windows-pcsx2.ps1' -. $ConfigFile - -RunPCSX2 diff --git a/samples/wellinator/src/main.cpp b/samples/wellinator/src/main.cpp deleted file mode 100644 index 1a024d6..0000000 --- a/samples/wellinator/src/main.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* -# ______ ____ ___ -# | \/ ____| |___| -# | | | \ | | -#----------------------------------------------------------------------- -# Copyright 2020, tyra - https://github.com/h4570/tyra -# Licenced under Apache License 2.0 -# Wellington Carvalho -*/ - -#include "engine.hpp" -#include "wellinator.hpp" - -int main() { - Tyra::Engine engine; - Tyra::Wellinator game(&engine); - engine.run(&game); - SleepThread(); - return 0; -} diff --git a/samples/wellinator/src/wellinator.cpp b/samples/wellinator/src/wellinator.cpp deleted file mode 100644 index d8392a7..0000000 --- a/samples/wellinator/src/wellinator.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/* -# ______ ____ ___ -# | \/ ____| |___| -# | | | \ | | -#----------------------------------------------------------------------- -# Copyright 2020, tyra - https://github.com/h4570/tyra -# Licenced under Apache License 2.0 -# Wellington Carvalho -*/ - -#include "wellinator.hpp" -#include "file/file_utils.hpp" -#include "loaders/3d/md2/md2_loader.hpp" -#include "renderer/3d/mesh/dynamic/dynamic_mesh.hpp" - -namespace Tyra { - -Wellinator::Wellinator(Engine* t_engine) { engine = t_engine; } -Wellinator::~Wellinator() {} - -DynamicMesh* getWarrior(Renderer* renderer); -StaPipOptions* getStaPipOptions(); -DynPipOptions* getDynPipOptions(); -void setPipelineOptions(PipelineOptions* options); -Sprite* get2DPicture(Renderer* renderer); - -void Wellinator::init() { - // Song - - engine->audio.loadSong(FileUtils::fromCwd("mafikizolo-loot.wav")); - engine->audio.setSongLoop(true); - engine->audio.setSongVolume(30); - - adpcmSample = engine->audio.loadADPCM(FileUtils::fromCwd("walk.adpcm")); - engine->audio.setADPCMVolume(80, 1); - - engine->renderer.setClearScreenColor(Color(64.0F, 64.0F, 64.0F)); - warrior = getWarrior(&engine->renderer); - - staOptions = getStaPipOptions(); - dynOptions = getDynPipOptions(); - - cameraPosition = Vec4(0.0F, 0.0F, 0.0F, 1.0F); - cameraLookAt = *warrior->getPosition(); - - blocksTex = engine->renderer.core.texture.repository.add( - FileUtils::fromCwd("blocks.png")); - - mcPip.setRenderer(&engine->renderer.core); - dynpip.setRenderer(&engine->renderer.core); - stapip.setRenderer(&engine->renderer.core); - - picture = get2DPicture(&engine->renderer); - - u32 rows = 8; // 64 - u32 columns = 8; // 64 - blocksCount = rows * columns; - float initialCameraZ = -400.0F; - - float offset = 40.0F; - blocks = new McpipBlock[blocksCount]; - translations = new M4x4[blocksCount]; - rotations = new M4x4[blocksCount]; - scales = new M4x4[blocksCount]; - float center = (rows / 2.0F) * offset; - - for (u32 i = 0; i < blocksCount; i++) { - 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); - - u32 randRow = rand() % (rows + 1); - u32 randColumn = rand() % (columns + 1); - - blocks[i].textureOffset = - Vec4(mcPip.getTextureOffset() * randRow, - mcPip.getTextureOffset() * randColumn, 0.0F, 1.0F); - - blocks[i].color = Color(128.0F, 128.0F, 128.0F, 128.0F); - } - - // Vec4 warriorInitPosition = *warrior->getPosition(); - - engine->audio.playSong(); -} - -void Wellinator::loop() { - warrior->animate(); - - if ((engine->pad.getPressed().DpadUp || engine->pad.getPressed().DpadDown || - engine->pad.getPressed().DpadLeft || - engine->pad.getPressed().DpadRight) && - adpcmTimer.getTimeDelta() > 8000) { - adpcmTimer.prime(); - engine->audio.playADPCM(adpcmSample, 1); - } - - engine->renderer.beginFrame(CameraInfo3D(&cameraPosition, &cameraLookAt)); - { - for (u32 i = 0; i < blocksCount; i++) { - rotations[i].rotateX(0.04F); - rotations[i].rotateY(0.01F); - rotations[i].rotateZ(0.01F); - - blocks[i].model = translations[i] * rotations[i] * scales[i]; - } - - engine->renderer.renderer2D.render(picture); - - // Vec4* nextPos = warrior->getPosition(); - - // if (pad.getPressed().DpadUp) nextPos->y += 0.2; - // if (pad.getPressed().DpadDown) nextPos->y -= 0.2; - // if (pad.getPressed().DpadRight) nextPos->x += 0.2; - // if (pad.getPressed().DpadLeft) nextPos->x -= 0.2; - // if (pad.getLeftJoyPad().v > 200) nextPos->z += 0.2; - // if (pad.getLeftJoyPad().v < 100) nextPos->z -= 0.2; - - // warrior->setPosition(*nextPos); - - engine->renderer.renderer3D.usePipeline(&dynpip); - { dynpip.render(warrior, dynOptions); } - - engine->renderer.renderer3D.usePipeline(&mcPip); - { mcPip.render(blocks, blocksCount, blocksTex, false); } - } - engine->renderer.endFrame(); -} - -DynamicMesh* getWarrior(Renderer* renderer) { - MD2Loader loader; - auto* data = loader.load(FileUtils::fromCwd("warrior.md2"), .08F, false); - auto* result = new DynamicMesh(*data); - result->translation.translateZ(-30.0F); - delete data; - renderer->core.texture.repository.addByMesh(result, FileUtils::getCwd(), - "png"); - result->playAnimation(0, result->getFramesCount() - 1); - result->setAnimSpeed(0.15F); - return result; -} - -Sprite* get2DPicture(Renderer* renderer) { - auto* sprite = new Sprite; - - sprite->size.set(128.0F, 128.0F); - sprite->position.set(500.0F, 280.0F); - - renderer->core.texture.repository.add(FileUtils::fromCwd("reward.png")) - ->addLink(sprite->getId()); - - return sprite; -} - -StaPipOptions* getStaPipOptions() { - auto* options = new StaPipOptions(); - setPipelineOptions(options); - return options; -} - -DynPipOptions* getDynPipOptions() { - auto* options = new DynPipOptions(); - setPipelineOptions(options); - return options; -} - -void setPipelineOptions(PipelineOptions* options) { - auto* ambientColor = new Color(32.0F, 32.0F, 32.0F, 32.0F); - auto* directionalColors = new Color[3]; - for (int i = 0; i < 3; i++) directionalColors[i].set(0.0F, 0.0F, 0.0F, 1.0F); - auto* directionalDirections = new Vec4[3]; - for (int i = 0; i < 3; i++) - directionalDirections[i].set(1.0F, 1.0F, 1.0F, 1.0F); - - auto* lightingOptions = new PipelineLightingOptions(); // Memory leak! - lightingOptions->ambientColor = ambientColor; - lightingOptions->directionalColors = directionalColors; - lightingOptions->directionalDirections = directionalDirections; - - options->shadingType = Tyra::TyraShadingGouraud; - options->blendingEnabled = true; - options->antiAliasingEnabled = false; - options->lighting = lightingOptions; - - directionalDirections[0].set(-1.0F, 0.0F, 0.0F); - directionalColors[0].set(0.0F, 96.0F, 0.0F); - - directionalDirections[1].set(1.0F, 0.0F, 0.0F); - directionalColors[1].set(96.0F, 0.0F, 0.0F); -} - -} // namespace Tyra diff --git a/samples/h4570/Makefile b/tutorials/01-hello/Makefile similarity index 82% rename from samples/h4570/Makefile rename to tutorials/01-hello/Makefile index 354610f..0ecc73a 100644 --- a/samples/h4570/Makefile +++ b/tutorials/01-hello/Makefile @@ -1,4 +1,4 @@ -TARGET := h4570.elf +TARGET := tutorial_01.elf ENGINEDIR := ../../engine #The Directories, Source, Includes, Objects, Binary and Resources @@ -21,4 +21,4 @@ LIBDIRS := INC := -I$(INCDIR) INCDEP := -I$(INCDIR) -include ../Makefile.samples-base \ No newline at end of file +include ../Makefile.tutorials-base \ No newline at end of file diff --git a/samples/h4570/bin/.gitignore b/tutorials/01-hello/bin/.gitignore similarity index 100% rename from samples/h4570/bin/.gitignore rename to tutorials/01-hello/bin/.gitignore diff --git a/samples/h4570/inc/h4570.hpp b/tutorials/01-hello/inc/tutorial_01.hpp similarity index 90% rename from samples/h4570/inc/h4570.hpp rename to tutorials/01-hello/inc/tutorial_01.hpp index d0f79cd..640c62a 100644 --- a/samples/h4570/inc/h4570.hpp +++ b/tutorials/01-hello/inc/tutorial_01.hpp @@ -19,10 +19,10 @@ namespace Tyra { -class H4570 : public Game { +class Tutorial01 : public Game { public: - H4570(Engine* engine); - ~H4570(); + Tutorial01(Engine* engine); + ~Tutorial01(); void init(); void loop(); diff --git a/samples/h4570/obj/.gitignore b/tutorials/01-hello/obj/.gitignore similarity index 100% rename from samples/h4570/obj/.gitignore rename to tutorials/01-hello/obj/.gitignore diff --git a/samples/h4570/res/.gitignore b/tutorials/01-hello/res/.gitignore similarity index 100% rename from samples/h4570/res/.gitignore rename to tutorials/01-hello/res/.gitignore diff --git a/tutorials/01-hello/run.ps1 b/tutorials/01-hello/run.ps1 new file mode 100644 index 0000000..74646cc --- /dev/null +++ b/tutorials/01-hello/run.ps1 @@ -0,0 +1,4 @@ +$ConfigFile = Join-Path $PSScriptRoot '../../windows-pcsx2.ps1' +. $ConfigFile + +RunPCSX2 diff --git a/samples/h4570/src/main.cpp b/tutorials/01-hello/src/main.cpp similarity index 83% rename from samples/h4570/src/main.cpp rename to tutorials/01-hello/src/main.cpp index 6f47255..cba965b 100644 --- a/samples/h4570/src/main.cpp +++ b/tutorials/01-hello/src/main.cpp @@ -9,11 +9,11 @@ */ #include "engine.hpp" -#include "h4570.hpp" +#include "tutorial_01.hpp" int main() { Tyra::Engine engine; - Tyra::H4570 game(&engine); + Tyra::Tutorial01 game(&engine); engine.run(&game); SleepThread(); return 0; diff --git a/samples/h4570/src/h4570.cpp b/tutorials/01-hello/src/tutorial_01.cpp similarity index 94% rename from samples/h4570/src/h4570.cpp rename to tutorials/01-hello/src/tutorial_01.cpp index 8888565..9b7776c 100644 --- a/samples/h4570/src/h4570.cpp +++ b/tutorials/01-hello/src/tutorial_01.cpp @@ -8,7 +8,7 @@ # Wellington Carvalho */ -#include "h4570.hpp" +#include "tutorial_01.hpp" #include "file/file_utils.hpp" #include "loaders/3d/md2/md2_loader.hpp" #include "loaders/3d/tyrobj/tyrobj_loader.hpp" @@ -25,8 +25,8 @@ float getRandomFloat(float a, float b) { int getRandomInt(int a, int b) { return (rand() % (b - a + 1)) + a; } -H4570::H4570(Engine* t_engine) { engine = t_engine; } -H4570::~H4570() {} +Tutorial01 ::Tutorial01(Engine* t_engine) { engine = t_engine; } +Tutorial01 ::~Tutorial01() {} StaticMesh* getStaticMesh(Renderer* renderer); DynamicMesh* getWarrior(Renderer* renderer); @@ -37,7 +37,7 @@ DynPipOptions* getDynPipOptions(); void setPipelineOptions(PipelineOptions* options); Sprite* get2DPicture(Renderer* renderer); -void H4570::init() { +void Tutorial01 ::init() { // Song engine->audio.loadSong(FileUtils::fromCwd("mafikizolo-loot.wav")); engine->audio.setSongLoop(true); @@ -127,7 +127,7 @@ void H4570::init() { u32 counter = 0; -void H4570::loop() { +void Tutorial01 ::loop() { if (counter++ > 100) { TYRA_LOG("Free RAM: ", engine->info.getAvailableRAM(), " MB"); TYRA_LOG("FPS: ", engine->info.getFps()); diff --git a/samples/Makefile.samples-base b/tutorials/Makefile.tutorials-base similarity index 100% rename from samples/Makefile.samples-base rename to tutorials/Makefile.tutorials-base diff --git a/samples/windows-pcsx2.ps1 b/windows-pcsx2.ps1 similarity index 100% rename from samples/windows-pcsx2.ps1 rename to windows-pcsx2.ps1