rename
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"buildDirectory": "samples/cube",
|
||||
"buildDirectory": "tutorials/01-hello",
|
||||
"C_Cpp.default.intelliSenseMode": "gcc-x86",
|
||||
"files.associations": {
|
||||
"*.vcl": "asm-collection",
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
$ConfigFile = Join-Path $PSScriptRoot '../windows-pcsx2.ps1'
|
||||
. $ConfigFile
|
||||
|
||||
RunPCSX2
|
||||
@@ -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
|
||||
@@ -1,4 +0,0 @@
|
||||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file
|
||||
!.gitignore
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020 - 2022, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Wellington Carvalho <wellcoj@gmail.com>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <engine.hpp>
|
||||
#include <game.hpp>
|
||||
#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
|
||||
@@ -1,4 +0,0 @@
|
||||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file
|
||||
!.gitignore
|
||||
@@ -1,4 +0,0 @@
|
||||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file
|
||||
!.gitignore
|
||||
@@ -1,4 +0,0 @@
|
||||
$ConfigFile = Join-Path $PSScriptRoot '../windows-pcsx2.ps1'
|
||||
. $ConfigFile
|
||||
|
||||
RunPCSX2
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Wellington Carvalho <wellcoj@gmail.com>
|
||||
*/
|
||||
|
||||
#include "engine.hpp"
|
||||
#include "wellinator.hpp"
|
||||
|
||||
int main() {
|
||||
Tyra::Engine engine;
|
||||
Tyra::Wellinator game(&engine);
|
||||
engine.run(&game);
|
||||
SleepThread();
|
||||
return 0;
|
||||
}
|
||||
@@ -1,196 +0,0 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Wellington Carvalho <wellcoj@gmail.com>
|
||||
*/
|
||||
|
||||
#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
|
||||
@@ -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
|
||||
include ../Makefile.tutorials-base
|
||||
@@ -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();
|
||||
@@ -0,0 +1,4 @@
|
||||
$ConfigFile = Join-Path $PSScriptRoot '../../windows-pcsx2.ps1'
|
||||
. $ConfigFile
|
||||
|
||||
RunPCSX2
|
||||
@@ -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;
|
||||
@@ -8,7 +8,7 @@
|
||||
# Wellington Carvalho <wellcoj@gmail.com>
|
||||
*/
|
||||
|
||||
#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());
|
||||
Reference in New Issue
Block a user