Added new sample dolphin.
This commit is contained in:
Executable
+65
@@ -0,0 +1,65 @@
|
||||
EE_BIN = driver.elf
|
||||
|
||||
EE_OBJS = \
|
||||
../../engine/models/math/matrix.o \
|
||||
../../engine/models/math/plane.o \
|
||||
../../engine/models/math/point.o \
|
||||
../../engine/models/math/vector3.o \
|
||||
../../engine/models/mesh_frame.o \
|
||||
../../engine/models/mesh_material.o \
|
||||
../../engine/models/mesh.o \
|
||||
../../engine/models/mesh_texture.o \
|
||||
../../engine/modules/audio.o \
|
||||
../../engine/modules/camera_base.o \
|
||||
../../engine/modules/file_service.o \
|
||||
../../engine/modules/gif_sender.o \
|
||||
../../engine/modules/light.o \
|
||||
../../engine/modules/pad.o \
|
||||
../../engine/modules/renderer.o \
|
||||
../../engine/modules/texture_repository.o \
|
||||
../../engine/modules/timer.o \
|
||||
../../engine/modules/vif_sender.o \
|
||||
../../engine/utils/math.o \
|
||||
../../engine/utils/string.o \
|
||||
../../engine/loaders/bmp_loader.o \
|
||||
../../engine/loaders/dff_loader.o \
|
||||
../../engine/loaders/md2_loader.o \
|
||||
../../engine/loaders/obj_loader.o \
|
||||
../../engine/vu1_progs/draw3D.o \
|
||||
../../engine/engine.o \
|
||||
camera.o \
|
||||
objects/player.o \
|
||||
driver.o \
|
||||
main.o
|
||||
|
||||
EE_LIBS = -ldraw -lgraph -lmath3d -lpacket -ldma -lpacket2 -lpad -laudsrv -lc -lstdc++
|
||||
EE_INCS := -I./../../engine/include $(EE_INCS)
|
||||
EE_DVP = dvp-as
|
||||
EE_VCL = vcl
|
||||
|
||||
all: $(EE_BIN)
|
||||
$(EE_STRIP) --strip-all $(EE_BIN)
|
||||
mv $(EE_BIN) bin/$(EE_BIN)
|
||||
rm $(EE_OBJS)
|
||||
|
||||
# https://github.com/microsoft/wsl/issues/2468#issuecomment-374904520
|
||||
#%.vsm: %.vcl # sudo service binfmt-support start
|
||||
# $(EE_VCL) $< >> $@
|
||||
|
||||
%.o: %.vsm
|
||||
$(EE_DVP) $< -o $@
|
||||
|
||||
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 $(PS2SDK)/samples/Makefile.pref
|
||||
include $(PS2SDK)/samples/Makefile.eeglobal
|
||||
Executable
+67
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Michał Mostowik <mostek3pl@gmail.com>
|
||||
*/
|
||||
|
||||
#include "camera.hpp"
|
||||
|
||||
#include <utils/math.hpp>
|
||||
|
||||
const float CAMERA_Y = 15.0F;
|
||||
|
||||
|
||||
Camera::Camera(ScreenSettings *t_screen) : CameraBase(t_screen, &position, &up)
|
||||
{
|
||||
verticalLevel = 80.0F;
|
||||
up.x = 0.0F;
|
||||
up.y = 1.0F;
|
||||
up.z = 0.0F;
|
||||
}
|
||||
|
||||
Camera::~Camera() {}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Michał Mostowik <mostek3pl@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>
|
||||
|
||||
class Camera : public CameraBase
|
||||
{
|
||||
|
||||
public:
|
||||
Vector3 position,up, 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
|
||||
Executable
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Michał Mostowik <mostek3pl@gmail.com>
|
||||
*/
|
||||
|
||||
#include "driver.hpp"
|
||||
#include "utils/math.hpp"
|
||||
|
||||
Driver::Driver(Engine *t_engine) : engine(t_engine), camera(&engine->screen)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Driver::~Driver() {}
|
||||
|
||||
void Driver::onInit()
|
||||
{
|
||||
engine->renderer->setCameraDefinitions(&camera.worldView, &camera.position, camera.planes);
|
||||
|
||||
texRepo = engine->renderer->getTextureRepository();
|
||||
|
||||
engine->renderer->disableVSync();
|
||||
|
||||
island.loadDff("sunnyisl/", "sunnyisl", 1.0F, false);
|
||||
island.rotation.x = -1.6F;
|
||||
island.position.set(0.0F, 10.0F, 20.0F);
|
||||
island.shouldBeBackfaceCulled = true;
|
||||
island.shouldBeFrustumCulled = false;
|
||||
|
||||
texRepo->addByMesh("dolphin/",player.mesh);
|
||||
texRepo->addByMesh("sunnyisl/",island);
|
||||
|
||||
bulb.intensity=55;
|
||||
bulb.position.set(5.0F,10.0F,10.0f);
|
||||
}
|
||||
|
||||
void Driver::onUpdate()
|
||||
{
|
||||
player.update(engine->pad);
|
||||
camera.update(engine->pad,player.mesh);
|
||||
engine->renderer->draw(island);
|
||||
engine->renderer->draw(player.mesh);
|
||||
}
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Michał Mostowik <mostek3pl@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _DRIVER_
|
||||
#define _DRIVER_
|
||||
|
||||
#include <tamtypes.h>
|
||||
#include <audsrv.h>
|
||||
#include <game.hpp>
|
||||
#include <engine.hpp>
|
||||
#include <models/light_bulb.hpp>
|
||||
#include <modules/texture_repository.hpp>
|
||||
#include "./camera.hpp"
|
||||
#include "./objects/player.hpp"
|
||||
|
||||
|
||||
class Driver : public Game
|
||||
{
|
||||
|
||||
public:
|
||||
Driver(Engine* t_engine);
|
||||
~Driver();
|
||||
|
||||
void onInit();
|
||||
void onUpdate();
|
||||
|
||||
Engine *engine;
|
||||
private:
|
||||
LightBulb bulb;
|
||||
Player player;
|
||||
Camera camera;
|
||||
Mesh island;
|
||||
TextureRepository *texRepo;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Michał Mostowik <mostek3pl@gmail.com>
|
||||
*/
|
||||
|
||||
#include "driver.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
Engine engine = Engine();
|
||||
Driver game = Driver(&engine);
|
||||
game.engine->init(&game,128);
|
||||
SleepThread();
|
||||
return 0;
|
||||
|
||||
}
|
||||
Executable
+52
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Michał Mostowik <mostek3pl@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>
|
||||
|
||||
Player::Player()
|
||||
{
|
||||
mesh.loadMD2("dolphin/","dolphin",0.05F,true);
|
||||
mesh.shouldBeFrustumCulled = false;
|
||||
mesh.position.set(0.0F,20.0F,-10.0f);
|
||||
mesh.rotation.x = -1.6F;
|
||||
mesh.setAnimSpeed(0.05F);
|
||||
}
|
||||
|
||||
Player::~Player()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Player::update(Pad& t_pad)
|
||||
{
|
||||
velocity=0;
|
||||
if(t_pad.lJoyV <= 100)
|
||||
velocity=1;
|
||||
else if(t_pad.lJoyV >= 200)
|
||||
velocity=-1;
|
||||
|
||||
if(t_pad.lJoyH >= 200)
|
||||
mesh.rotation.z-=0.1;
|
||||
else if(t_pad.lJoyH <= 100)
|
||||
mesh.rotation.z+=0.1;
|
||||
|
||||
if(velocity>0 && mesh.getCurrentAnimationFrame()==0)
|
||||
mesh.playAnimation(0, 14);
|
||||
|
||||
mesh.position.z+=Math::cos(mesh.rotation.z)*velocity;
|
||||
mesh.position.x+=Math::sin(mesh.rotation.z)*velocity;
|
||||
|
||||
}
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Michał Mostowik <mostek3pl@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _PLAYER_
|
||||
#define _PLAYER_
|
||||
|
||||
#include "../camera.hpp"
|
||||
#include <modules/pad.hpp>
|
||||
#include <tamtypes.h>
|
||||
|
||||
class Player
|
||||
{
|
||||
|
||||
public:
|
||||
float gravity, velocity;
|
||||
Mesh mesh;
|
||||
Player();
|
||||
~Player();
|
||||
void update(Pad &t_pad);
|
||||
private:
|
||||
Vector3 playerNextPosition;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user