removed ari sample

This commit is contained in:
h4570
2020-12-02 21:40:40 +01:00
parent d58163d75b
commit a6f8bb9b36
10 changed files with 0 additions and 495 deletions
-3
View File
@@ -1,3 +0,0 @@
.vscode/
bin/**
fonts/**
-33
View File
@@ -1,33 +0,0 @@
EE_BIN = ari.elf
TYRA_DIR = ./../../engine
EE_OBJS = \
camera.o \
objects/player.o \
ari.o \
main.o
EE_LIBS = -ltyra
all: $(EE_BIN)
$(EE_STRIP) --strip-all $(EE_BIN)
mv $(EE_BIN) bin/$(EE_BIN)
rm $(EE_OBJS)
rebuild-engine:
cd $(TYRA_DIR) && make clean && make
clean:
rm -f $(EE_OBJS)
run: $(EE_BIN)
killall -v ps2client || true
ps2client reset
ps2client reset
$(EE_STRIP) --strip-all $(EE_BIN)
mv $(EE_BIN) bin/$(EE_BIN)
rm $(EE_OBJS)
cd bin/ && ps2client execee host:$(EE_BIN)
include $(TYRA_DIR)/Makefile.pref
-19
View File
@@ -1,19 +0,0 @@
## Ari sample
### Description
* .obj (skybox, water)
* .dff (island)
* .md2 (ari)
* mesh cloning (water)
Testing demo. In future there will be Ariana Grande demo.
### Assets
[Download](http://apgcglz.cluster028.hosting.ovh.net/tyra/1.1.0/samples/ari/assets.zip)
### Screenshot
[![Ari screenshot][ari-screenshot]](#)
[ari-screenshot]: http://apgcglz.cluster028.hosting.ovh.net/tyra/1.1.0/samples/ari/ari.gif
-137
View File
@@ -1,137 +0,0 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#include "ari.hpp"
#include "utils/math.hpp"
// ----
// Constructors/Destructors
// ----
const u8 WATER_TILES_COUNT = 64;
Ari::Ari(Engine *t_engine) : engine(t_engine), camera(&engine->screen)
{
waterFloors = new Mesh[WATER_TILES_COUNT];
spirals = new Point[WATER_TILES_COUNT];
}
Ari::~Ari() {}
// ----
// Methods
// ----
void Ari::onInit()
{
engine->renderer->setCameraDefinitions(&camera.worldView, &camera.position, camera.planes);
engine->audio.setSongVolume(40);
// engine->audio.loadSong("MOV-CIRC.WAV");
engine->audio.loadSong("nob-else.wav");
adpcm1 = engine->audio.loadADPCM("ziobro1.adpcm");
adpcm2 = engine->audio.loadADPCM("ziobro2.adpcm");
texRepo = engine->renderer->getTextureRepository();
engine->renderer->disableVSync();
island.loadDff("sunnyisl/", "sunnyisl", 0.1F, false);
island.rotation.x = -1.6F;
island.position.set(0.0F, 10.0F, 20.0F);
island.shouldBeBackfaceCulled = true;
island.shouldBeFrustumCulled = false;
fist.size.set(100.0F, 100.0F);
Texture *fistTex = texRepo->add("2d/", "fist", PNG);
fistTex->addLink(fist.getId());
islandAddons.loadDff("sunnyisl/", "sunnyisl3", 0.1F, false);
islandAddons.shouldBeBackfaceCulled = true;
islandAddons.rotation.x = -1.6F;
islandAddons.position.set(0.0F, 10.0F, 20.0F);
skybox.loadObj("skybox/", "skybox", 100.0F, false);
skybox.shouldBeFrustumCulled = false;
waterFloors[0].loadObj("water/", "water", 5.0F, false);
waterFloors[0].position.set(0.0F, 8.0F, 0.0F);
texRepo->addByMesh("water/", waterFloors[0], BMP);
for (u8 i = 0; i < WATER_TILES_COUNT; i++)
{
spirals[i].x = 1.0F;
spirals[i].y = 2.0F;
}
u32 spiralOffset = (u32)Math::sqrt(WATER_TILES_COUNT);
calcSpiral(spiralOffset, spiralOffset);
for (u8 i = 1; i < WATER_TILES_COUNT; i++)
{
waterFloors[i].loadFrom(waterFloors[0]);
waterFloors[i].position.set(10.0F * spirals[i].x, 8.0F, 10.0F * spirals[i].y);
texRepo->getByMesh(waterFloors[0].getId(), waterFloors[0].getMaterial(0).getId())
->addLink(waterFloors[i].getId(), waterFloors[i].getMaterial(0).getId());
}
texRepo->addByMesh("sunnyisl/", island, BMP);
texRepo->addByMesh("sunnyisl/", islandAddons, BMP);
texRepo->addByMesh("skybox/", skybox, BMP);
texRepo->addByMesh("ari/", player.mesh, BMP);
// engine->audio.playSong();
}
void Ari::initBulb()
{
bulb.intensity = 15;
bulb.position.set(5.0F, 10.0F, 10.0F);
}
void Ari::onUpdate()
{
if (engine->pad.isCrossClicked)
{
// engine->audio.loadSong("nob-else.wav");
engine->audio.playADPCM(adpcm1);
printf("FPS:%f\n", engine->fps);
}
if (engine->pad.isCircleClicked)
engine->audio.playADPCM(adpcm2);
camera.update(engine->pad, player.mesh);
engine->renderer->draw(skybox);
engine->renderer->draw(fist);
engine->renderer->draw(island);
engine->renderer->draw(islandAddons);
engine->renderer->draw(player.mesh);
for (u8 i = 0; i < WATER_TILES_COUNT; i++)
engine->renderer->draw(waterFloors[i]);
}
void Ari::calcSpiral(int X, int Y)
{
int x, y, dx;
x = y = dx = 0;
int dy = -1;
int t = X > Y ? X : Y;
int maxI = t * t;
for (int i = 0; i < maxI; i++)
{
if ((-X / 2 <= x) && (x <= X / 2) && (-Y / 2 <= y) && (y <= Y / 2))
{
spirals[i].x = x;
spirals[i].y = y;
}
if ((x == y) || ((x < 0) && (x == -y)) || ((x > 0) && (x == 1 - y)))
{
t = dx;
dx = -dy;
dy = t;
}
x += dx;
y += dy;
}
}
-50
View File
@@ -1,50 +0,0 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#ifndef _ARI_
#define _ARI_
#include <tamtypes.h>
#include <audsrv.h>
#include <game.hpp>
#include <engine.hpp>
#include "objects/player.hpp"
#include <models/light_bulb.hpp>
#include <models/sprite.hpp>
#include <modules/texture_repository.hpp>
#include "./camera.hpp"
class Ari : public Game
{
public:
Ari(Engine *t_engine);
~Ari();
void onInit();
void onUpdate();
Engine *engine;
private:
void initBulb();
void calcSpiral(int X, int Y);
LightBulb bulb;
Player player;
Mesh island, islandAddons, skybox;
Mesh *waterFloors;
Sprite fist;
audsrv_adpcm_t *adpcm1, *adpcm2;
Point *spirals;
Camera camera;
TextureRepository *texRepo;
};
#endif
-82
View File
@@ -1,82 +0,0 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#include "camera.hpp"
#include <utils/math.hpp>
#include <utils/debug.hpp>
const float CAMERA_Y = 15.0F;
// ----
// Constructors/Destructors
// ----
Camera::Camera(ScreenSettings *t_screen) : CameraBase(t_screen, &position, &up)
{
PRINT_LOG("Initializing camera");
verticalLevel = 80.0F;
up.x = 0.0F;
up.y = 1.0F;
up.z = 0.0F;
PRINT_LOG("Camera initialized!");
}
Camera::~Camera() {}
// ----
// Methods
// ----
void Camera::update(Pad &t_pad, Mesh &t_mesh)
{
rotate(t_pad);
followBy(t_mesh);
Vector3 lookPos = Vector3(t_mesh.position.x, t_mesh.position.y + 10.0F, t_mesh.position.z);
lookAt(lookPos);
}
/** Set camera rotation by pad right joy and update unit circle
* https://en.wikipedia.org/wiki/Unit_circle
* https://www.desmos.com/calculator/3e7iypw4ow
*/
void Camera::rotate(Pad &t_pad)
{
if (t_pad.rJoyH <= 50)
horizontalLevel -= 0.08;
else if (t_pad.rJoyH >= 200)
horizontalLevel += 0.04;
if (t_pad.rJoyV <= 50 && verticalLevel > 25.0F)
verticalLevel -= 0.9F;
else if (t_pad.rJoyV >= 200 && verticalLevel < 80.0F)
verticalLevel += 0.9F;
unitCirclePosition.x = (Math::sin(horizontalLevel) * verticalLevel);
unitCirclePosition.y = CAMERA_Y;
unitCirclePosition.z = (Math::cos(horizontalLevel) * verticalLevel);
}
/** Rotate camera around 3D object */
void Camera::followBy(Mesh &t_mesh)
{
position.x = unitCirclePosition.x + t_mesh.position.x;
position.y = unitCirclePosition.y + t_mesh.position.y;
position.z = unitCirclePosition.z + t_mesh.position.z;
if (position.x > (-0.04F * verticalLevel) &&
position.x < 0.0F &&
position.z > (0.998F * verticalLevel))
{
// TODO
// position.x = 0.0F;
// position.y = 0.0F;
// position.z = 0.0F;
// horizontalLevel = 0.0F;
}
}
-42
View File
@@ -1,42 +0,0 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#ifndef _CAMERA_
#define _CAMERA_
#include <modules/pad.hpp>
#include <models/mesh.hpp>
#include <models/math/vector3.hpp>
#include <models/screen_settings.hpp>
#include <modules/camera_base.hpp>
#include <tamtypes.h>
/** 3D camera which follow by 3D object. Can be rotated via pad */
class Camera : public CameraBase
{
public:
Vector3 up, position, unitCirclePosition;
float horizontalLevel, verticalLevel;
Camera(ScreenSettings *t_screen);
~Camera();
void update(Pad &t_pad, Mesh &t_mesh);
void rotate(Pad &t_pad);
void followBy(Mesh &t_mesh);
protected:
Vector3 *getPosition() { return &position; };
Vector3 *getUp() { return &up; };
ScreenSettings screen;
};
#endif
-20
View File
@@ -1,20 +0,0 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#include "ari.hpp"
int main()
{
Engine engine = Engine();
Ari game = Ari(&engine);
game.engine->init(&game, 128);
SleepThread();
return 0;
}
-44
View File
@@ -1,44 +0,0 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#include "player.hpp"
#include <loaders/obj_loader.hpp>
#include <loaders/bmp_loader.hpp>
#include <modules/gif_sender.hpp>
#include <utils/debug.hpp>
#include <utils/math.hpp>
// ----
// Constructors/Destructors
// ----
Player::Player()
{
PRINT_LOG("Creating player object");
this->gravity = 0.1F;
this->lift = -1.0F;
this->mesh.loadMD2("ari/", "ari", 0.0001F, true);
this->mesh.position.set(0.0F, 10.0F, 0.0F);
this->mesh.shouldBeBackfaceCulled = true;
this->mesh.shouldBeFrustumCulled = false;
this->mesh.shouldBeLighted = true;
this->mesh.setAnimSpeed(0.05F);
this->mesh.playAnimation(0, 1);
PRINT_LOG("Player object created!");
}
Player::~Player()
{
}
// ----
// Methods
// ----
-65
View File
@@ -1,65 +0,0 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#ifndef _PLAYER_
#define _PLAYER_
#include "../camera.hpp"
#include <modules/pad.hpp>
#include <tamtypes.h>
/** Player 3D object class */
class Player
{
public:
float gravity, velocity, lift;
u8 isOnFloor, isCollideFloor, indexOfCurrentFloor;
Mesh mesh;
Player();
~Player();
private:
Vector3 playerNextPosition;
};
// TODO Rysowanie idzie wg tekstur
// 2 Graczy, 1 mesh 2 tekstury
// sharedFrames = objLoader.load("meshes/", "block", 1.0F);
// var addedTextures = texturesRepo.addByMaterialNames("textures/dirt/", sharedFrames);
// var addedTexture = texturesRepo.add("textures/blocks/sand.bmp");
// dirt = new Mesh(sharedFrames);
// sand = new Mesh(sharedFrames);
// addedTextures[0].addUsage(dirt.Id, sharedFrames.getMaterialId(0));
// addedTexture.addUsage(sand.Id, sand.getMaterialId(0));
// 1 gracz, 2 dynamic tekstury
// sharedFrames = objLoader.load("meshes/", "block", 1.0F);
// var addedTexture1 = texturesRepo.add("textures/blocks/sand.bmp");
// var addedTexture2 = texturesRepo.add("textures/blocks/sand_damaged.bmp");
// sand = new Mesh(sharedFrames);
// addedTexture1.removeUsage(sand.Id, sand.getMaterialId(0));
// draw()
// addedTexture2.addUsage(sand.Id, sand.getMaterialId(0));
// 2 różne obj, te same tekstury
// frames1 = objLoader.load("meshes/", "island", 1.0F);
// frames2 = objLoader.load("meshes/", "islandAddons", 1.0F);
// island = new Mesh(frames1);
// islandAddons = new Mesh(frames2);
// var addedTextures1 = texturesRepo.addByMaterialNames("textures/island/",frames1);
// var addedTextures2 = texturesRepo.addByMaterialNames("textures/island/",frames2);
// texturesRepo.remove(addedTextures2[0]); // duplicate
// addedTextures1[0].addUsage(islandAddons.Id, islandAddons.getMaterialId(0));
// Mesh -> position, rotation, color, scale, shouldBeLighted, clut, lod
#endif