moved from h4570/tyra
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_ENGINE_
|
||||
#define _TYRA_ENGINE_
|
||||
|
||||
#include <tamtypes.h>
|
||||
#include "game.hpp"
|
||||
#include "models/screen_settings.hpp"
|
||||
#include "models/math/matrix.hpp"
|
||||
#include "modules/renderer.hpp"
|
||||
#include "modules/timer.hpp"
|
||||
#include "modules/pad.hpp"
|
||||
#include "modules/audio.hpp"
|
||||
|
||||
class Engine
|
||||
{
|
||||
|
||||
public:
|
||||
Engine();
|
||||
~Engine();
|
||||
|
||||
void init(Game *t_game, u32 t_gifPacketSize);
|
||||
void setDefaultScreen();
|
||||
void setScreen(ScreenSettings &t_settings);
|
||||
Renderer *renderer;
|
||||
Audio audio;
|
||||
ScreenSettings screen;
|
||||
Pad pad;
|
||||
float fps;
|
||||
|
||||
private:
|
||||
u8 fpsDelayer;
|
||||
Timer timer;
|
||||
u8 isInitialized, isScreenInitialized;
|
||||
void gameLoop();
|
||||
Game *game;
|
||||
s32 mainThreadId;
|
||||
static void wakeup(s32 t_alarmId, u16 t_time, void *t_common);
|
||||
|
||||
// ThreadManager threadManager;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_GAME_
|
||||
#define _TYRA_GAME_
|
||||
|
||||
#include <tamtypes.h>
|
||||
|
||||
class Game
|
||||
{
|
||||
|
||||
public:
|
||||
virtual ~Game(){};
|
||||
virtual void onInit() = 0;
|
||||
virtual void onUpdate() = 0;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_BMP_LOADER_
|
||||
#define _TYRA_BMP_LOADER_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <tamtypes.h>
|
||||
#include "../models/texture.hpp"
|
||||
|
||||
/** Class responsible for loading images in bmp format */
|
||||
class BmpLoader
|
||||
{
|
||||
|
||||
public:
|
||||
BmpLoader();
|
||||
~BmpLoader();
|
||||
|
||||
void load(Texture &o_texture, char *t_subfolder, char *t_name, char *t_extension);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_DFF_LOADER_
|
||||
#define _TYRA_DFF_LOADER_
|
||||
|
||||
#include "../models/dff_model.hpp"
|
||||
#include "./dff_structure.hpp"
|
||||
|
||||
/** Class responsible for loading&parsing .obj 3D files */
|
||||
class DffLoader
|
||||
{
|
||||
|
||||
public:
|
||||
DffLoader();
|
||||
~DffLoader();
|
||||
|
||||
void load(RwClump &o_clump, char *t_fileName, float t_scale);
|
||||
void serialize(RwClump &t_clump, u8 *t_data, float t_scale);
|
||||
|
||||
static u8 readByteFromArrayLE(u8 *t_buffer, u32 &t_ptrPos);
|
||||
static u16 readWordFromArrayLE(u8 *t_buffer, u32 &t_ptrPos);
|
||||
static u32 readDwordFromArrayLE(u8 *t_buffer, u32 &t_ptrPos);
|
||||
static float readFloatFromArrayLE(u8 *t_buffer, u32 &t_ptrPos);
|
||||
static u8 *readData(u8 *t_buffer, u32 &t_ptrPos, u32 t_dataSize);
|
||||
static char *readString(u8 *t_buffer, u32 &t_ptrPos, u32 t_dataSize = 0);
|
||||
|
||||
void readSectionHeader(RwSectionHeader &t_sh, u8 *t_buffer, u32 &t_ptrPos);
|
||||
|
||||
private:
|
||||
// ---
|
||||
void readFrameListData(RwFrameListData &t_frd, u8 *t_buffer, u32 &t_ptrPos);
|
||||
void readClumpData(RwClumpData &t_cd, u8 *t_buffer, u32 &t_ptrPos);
|
||||
void readGeometryListData(RwGeometryListData &t_gld, u8 *t_buffer, u32 &t_ptrPos);
|
||||
void readGeometryExtension(RwGeometryExtension &t_ge, u8 *t_buffer, u32 &t_ptrPos);
|
||||
void readGeometryData(RwGeometryData &t_gd, u8 *t_buffer, u32 &t_ptrPos, float t_scale);
|
||||
void readMaterialListData(RwMaterialListData &t_mld, u8 *t_buffer, u32 &t_ptrPos);
|
||||
void readMaterialData(RwMaterialData &t_md, u8 *t_buffer, u32 &t_ptrPos);
|
||||
void readTextureData(RwTextureData &t_td, u8 *t_buffer, u32 &t_ptrPos);
|
||||
void readStringData(RwString &t_s, u8 *bt_uffer, u32 &t_ptrPos);
|
||||
// ---
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,334 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_DFF_STRUCTURE_
|
||||
#define _TYRA_DFF_STRUCTURE_
|
||||
|
||||
#include <tamtypes.h>
|
||||
#include "../models/math/vector3.hpp"
|
||||
|
||||
enum RwGeometryDataFlags
|
||||
{
|
||||
rwOBJECT_VERTEX_TRISTRIP = 0x01,
|
||||
rwOBJECT_VERTEX_POS = 0x02,
|
||||
rwOBJECT_VERTEX_TEXTURED = 0x04,
|
||||
rwOBJECT_VERTEX_PRELIT = 0x08,
|
||||
rwOBJECT_VERTEX_NORMALS = 0x10,
|
||||
rwOBJECT_VERTEX_LIGHT = 0x20,
|
||||
rwOBJECT_VERTEX_MODULATE_MATERIAL_COLOR = 0x40,
|
||||
rwOBJECT_VERTEX_TEXTURED_2 = 0x80
|
||||
};
|
||||
|
||||
class RwSectionHeader
|
||||
{
|
||||
public:
|
||||
u32 sectionType;
|
||||
u32 sectionSize;
|
||||
u32 versionNumber;
|
||||
};
|
||||
|
||||
class RwFrameListChunk
|
||||
{
|
||||
public:
|
||||
~RwFrameListChunk() { delete[] rotationalMatrix; }
|
||||
float *rotationalMatrix; // [ROT_MAT_DIM]
|
||||
float coordinatesOffsetX;
|
||||
float coordinatesOffsetY;
|
||||
float coordinatesOffsetZ;
|
||||
u32 parentFrame; // 0xFFFFFFFF = NONE
|
||||
u32 unk1;
|
||||
};
|
||||
|
||||
// Section: Frame List
|
||||
class RwFrameListData : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
~RwFrameListData() { delete frameInformation; }
|
||||
static const u32 ROT_MAT_DIM = 9;
|
||||
u32 frameCount;
|
||||
|
||||
RwFrameListChunk *frameInformation; // [frameCount]
|
||||
};
|
||||
|
||||
class RwFrame : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
~RwFrame() { delete[] frameName; }
|
||||
u8 *frameName; // [sectionSize] - should be interpreted as string
|
||||
};
|
||||
|
||||
class RwFrameListExtension : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
RwFrame frame;
|
||||
};
|
||||
|
||||
class RwFrameList : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
RwFrameListData data;
|
||||
~RwFrameList() { delete[] extensions; }
|
||||
RwFrameListExtension *extensions;
|
||||
};
|
||||
// ---
|
||||
|
||||
class RwGeometryDataHeader
|
||||
{
|
||||
public:
|
||||
u16 flags;
|
||||
u16 unk1;
|
||||
u32 triangleCount;
|
||||
u32 vertexCount;
|
||||
u32 morphTargetCount;
|
||||
};
|
||||
|
||||
class RwGeometryDataLightingHeader
|
||||
{ // IF versionNumber = 4099 - according to not complete documentation
|
||||
public:
|
||||
float ambient;
|
||||
float diffuse;
|
||||
float specular;
|
||||
};
|
||||
|
||||
class RwGeometryDataColorInformationChunk
|
||||
{ // if rwOBJECT_VERTEX_PREILIT in flags
|
||||
public:
|
||||
u8 red;
|
||||
u8 green;
|
||||
u8 blue;
|
||||
u8 alpha;
|
||||
};
|
||||
|
||||
class RwGeometryDataTextureMappingInformationChunk
|
||||
{ // if rwOBJECT_VERTEX_TEXTURED in flags
|
||||
public:
|
||||
float u;
|
||||
float v;
|
||||
};
|
||||
|
||||
class RwGeometryDataFaceInformation
|
||||
{
|
||||
public:
|
||||
u16 vertex2; // this
|
||||
u16 vertex1; // is
|
||||
u16 flags; // weird
|
||||
u16 vertex3; // order
|
||||
};
|
||||
|
||||
// Section: Geometry
|
||||
class RwGeometryData : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
~RwGeometryData()
|
||||
{
|
||||
delete colorInformation;
|
||||
delete textureMappingInformation;
|
||||
delete faceInformation;
|
||||
delete vertexInformation;
|
||||
delete normalInformation;
|
||||
}
|
||||
RwGeometryDataHeader dataHeader;
|
||||
|
||||
RwGeometryDataLightingHeader lightingHeader;
|
||||
|
||||
RwGeometryDataColorInformationChunk *colorInformation; // [vertexCount]
|
||||
|
||||
RwGeometryDataTextureMappingInformationChunk *textureMappingInformation; // [vertexCount]
|
||||
|
||||
RwGeometryDataFaceInformation *faceInformation; // [triangleCount]
|
||||
|
||||
class RwGeometryDataNonameInfo
|
||||
{
|
||||
public:
|
||||
float boundingSphereX;
|
||||
float boundingSphereY;
|
||||
float boundingSphereZ;
|
||||
float boundingSphereR;
|
||||
u32 hasPosition;
|
||||
u32 hasNormals;
|
||||
} nonameInfo;
|
||||
|
||||
Vector3 *vertexInformation; // [vertexCount]
|
||||
|
||||
Vector3 *normalInformation; // [vertexCount]
|
||||
};
|
||||
|
||||
class RwMaterialData : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
u32 unk1;
|
||||
u8 R;
|
||||
u8 G;
|
||||
u8 B;
|
||||
u8 A;
|
||||
u32 unk2;
|
||||
u32 textureCount;
|
||||
float unkPosX;
|
||||
float unkPosY;
|
||||
float unkPosZ;
|
||||
};
|
||||
|
||||
class RwTextureData : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
u16 textureFilterModeFlags;
|
||||
u16 unk;
|
||||
};
|
||||
|
||||
class RwString : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
~RwString() { delete[] text; }
|
||||
char *text;
|
||||
};
|
||||
|
||||
class RwTextureExtension : public RwSectionHeader
|
||||
{
|
||||
// May contain Sky Mipmap Val
|
||||
};
|
||||
|
||||
class RwTexture : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
RwTextureData data;
|
||||
RwString textureName;
|
||||
RwString textureAlphaName;
|
||||
RwTextureExtension extension;
|
||||
};
|
||||
|
||||
class RwMaterialExtension : public RwSectionHeader
|
||||
{
|
||||
// meant to be void.. don't ask
|
||||
};
|
||||
|
||||
class RwMaterial : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
~RwMaterial() { delete[] textures; }
|
||||
RwMaterialData data;
|
||||
RwTexture *textures;
|
||||
RwMaterialExtension extension;
|
||||
};
|
||||
|
||||
class RwMaterialListData : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
~RwMaterialListData() { delete[] arrayOfUnks; }
|
||||
u32 materialCount;
|
||||
u32 *arrayOfUnks; // Filled with '-1's, [materialCount] - it wasn't mentioned in docs.
|
||||
};
|
||||
|
||||
class RwMaterialList : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
~RwMaterialList() { delete[] materials; }
|
||||
RwMaterialListData data;
|
||||
RwMaterial *materials;
|
||||
};
|
||||
|
||||
class RwGeometryListVertexInfoChunk
|
||||
{
|
||||
public:
|
||||
u32 vertex1;
|
||||
};
|
||||
|
||||
class RwGeometryListInfoChunk
|
||||
{
|
||||
public:
|
||||
~RwGeometryListInfoChunk() { delete vertexInformation; }
|
||||
u32 faceIndex;
|
||||
u32 materialIndex;
|
||||
|
||||
RwGeometryListVertexInfoChunk *vertexInformation; // [faceIndex]
|
||||
};
|
||||
|
||||
class RwMaterialSplit
|
||||
{
|
||||
public:
|
||||
~RwMaterialSplit() { delete splitInformation; }
|
||||
class Header
|
||||
{
|
||||
public:
|
||||
u32 triangleStrip;
|
||||
u32 splitCount;
|
||||
u32 faceCount;
|
||||
} header;
|
||||
|
||||
RwGeometryListInfoChunk *splitInformation; // [splitCount]
|
||||
};
|
||||
|
||||
class RwGeometryExtension : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
RwMaterialSplit materialSplit;
|
||||
};
|
||||
|
||||
class RwGeometry : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
RwGeometryData data;
|
||||
RwMaterialList materialList;
|
||||
RwGeometryExtension extension;
|
||||
};
|
||||
// ---
|
||||
|
||||
// Section: Geometry List
|
||||
class RwGeometryListData : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
u32 geometryCount;
|
||||
};
|
||||
|
||||
class RwGeometryList : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
~RwGeometryList() { delete[] geometries; }
|
||||
RwGeometryListData data;
|
||||
RwGeometry *geometries;
|
||||
};
|
||||
// ---
|
||||
|
||||
// Section: Atomic
|
||||
class RwAtomicData : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
u32 frameNumber;
|
||||
u32 geometryNumber;
|
||||
u32 unk1;
|
||||
u32 unk2;
|
||||
};
|
||||
|
||||
class RwAtomic : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
RwAtomicData data;
|
||||
};
|
||||
// ---
|
||||
|
||||
// Section: Clump
|
||||
class RwClumpData : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
u32 objectCount;
|
||||
u32 unk1;
|
||||
u32 unk2;
|
||||
};
|
||||
|
||||
class RwClump : public RwSectionHeader
|
||||
{
|
||||
public:
|
||||
RwClumpData data;
|
||||
RwFrameList frameList;
|
||||
RwGeometryList geometryList;
|
||||
RwAtomic atomic; //multiple?? but how many
|
||||
};
|
||||
// ---
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_MD2_LOADER_
|
||||
#define _TYRA_MD2_LOADER_
|
||||
|
||||
#include "../models/md2_model.hpp"
|
||||
#include <stdio.h>
|
||||
|
||||
// magic number "IDP2" or 844121161
|
||||
#define MD2_IDENT (('2' << 24) + ('P' << 16) + ('D' << 8) + 'I')
|
||||
|
||||
// model version
|
||||
#define MD2_VERSION 8
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int ident; // magic number. must be equal to "IDP2"
|
||||
int version; // md2 version. must be equal to 8
|
||||
|
||||
int skinwidth; // width of the texture
|
||||
int skinheight; // height of the texture
|
||||
int framesize; // size of one frame in bytes
|
||||
|
||||
int num_skins; // number of textures
|
||||
int num_xyz; // number of vertices
|
||||
int num_st; // number of texture coordinates
|
||||
int num_tris; // number of triangles
|
||||
int num_glcmds; // number of opengl commands
|
||||
int num_frames; // total number of frames
|
||||
|
||||
int ofs_skins; // offset to skin names (64 bytes each)
|
||||
int ofs_st; // offset to s-t texture coordinates
|
||||
int ofs_tris; // offset to triangles
|
||||
int ofs_frames; // offset to frame data
|
||||
int ofs_glcmds; // offset to opengl commands
|
||||
int ofs_end; // offset to end of file
|
||||
|
||||
} md2_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char v[3]; // compressed vertex (x, y, z) coordinates
|
||||
unsigned char lightnormalindex; // index to a normal vector for the lighting
|
||||
|
||||
} mvertex_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float scale[3]; // scale values
|
||||
float translate[3]; // translation vector
|
||||
char name[16]; // frame name
|
||||
mvertex_t verts[1]; // first vertex of this frame
|
||||
|
||||
} frame_t;
|
||||
|
||||
typedef float vec3_t[3];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
short index_xyz[3]; // indexes to triangle's vertices
|
||||
short index_st[3]; // indexes to vertices' texture coorinates
|
||||
} triangle_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
short s;
|
||||
short t;
|
||||
} texCoord_t;
|
||||
|
||||
/** Class responsible for loading&parsing Quake's II ".md2" 3D files */
|
||||
class MD2Loader
|
||||
{
|
||||
|
||||
public:
|
||||
MD2Loader();
|
||||
~MD2Loader();
|
||||
|
||||
void load(MD2Model *o_result, char *t_fileName, float t_scale);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_OBJ_LOADER_
|
||||
#define _TYRA_OBJ_LOADER_
|
||||
|
||||
#include "../models/obj_model.hpp"
|
||||
#include <stdio.h>
|
||||
|
||||
/** Class responsible for loading&parsing .obj 3D files */
|
||||
class ObjLoader
|
||||
{
|
||||
|
||||
public:
|
||||
ObjLoader();
|
||||
~ObjLoader();
|
||||
|
||||
void load(ObjModel *o_result, char *t_fileName, float t_scale);
|
||||
|
||||
private:
|
||||
void setObjDataQuantities(FILE *t_file, ObjModel *t_result);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_AUDIO_LISTENER_
|
||||
#define _TYRA_AUDIO_LISTENER_
|
||||
|
||||
class AudioListener
|
||||
{
|
||||
|
||||
public:
|
||||
virtual ~AudioListener(){};
|
||||
virtual void onAudioTick() = 0;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_DFF_MODEL_
|
||||
#define _TYRA_DFF_MODEL_
|
||||
|
||||
#include <tamtypes.h>
|
||||
#include <math3d.h>
|
||||
#include "../loaders/dff_structure.hpp"
|
||||
#include "./math/vector3.hpp"
|
||||
|
||||
/** Class which have common types for all 3D objects */
|
||||
class DffModel
|
||||
{
|
||||
|
||||
public:
|
||||
DffModel();
|
||||
~DffModel();
|
||||
|
||||
u32 getDrawData(u32 splitIndex, VECTOR *o_vertices, VECTOR *o_normals, VECTOR *o_coordinates, VECTOR *o_colors, Vector3 &t_cameraPos, float t_scale, u8 t_shouldBeBackfaceCulled);
|
||||
RwClump clump;
|
||||
|
||||
private:
|
||||
void fillNextFace(VECTOR *o_vertices, VECTOR *o_normals, VECTOR *o_coordinates, VECTOR *o_colors, u8 geometry, u32 t_getI, u32 t_setI);
|
||||
u8 isMemoryAllocated;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_LIGHT_BULB_
|
||||
#define _TYRA_LIGHT_BULB_
|
||||
|
||||
#include "math/vector3.hpp"
|
||||
#include <tamtypes.h>
|
||||
|
||||
struct LightBulb
|
||||
{
|
||||
Vector3 position;
|
||||
u16 intensity;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_MATRIX_
|
||||
#define _TYRA_MATRIX_
|
||||
|
||||
#include "vector3.hpp"
|
||||
#include "../screen_settings.hpp"
|
||||
|
||||
/** https://en.wikipedia.org/wiki/Matrix_(mathematics) */
|
||||
class Matrix
|
||||
{
|
||||
|
||||
public:
|
||||
float data[16];
|
||||
|
||||
Matrix(float m11, float m12, float m13, float m14,
|
||||
float m21, float m22, float m23, float m24,
|
||||
float m31, float m32, float m33, float m34,
|
||||
float m41, float m42, float m43, float m44);
|
||||
Matrix(const Matrix &v);
|
||||
Matrix operator*(Matrix &v);
|
||||
Matrix();
|
||||
~Matrix();
|
||||
|
||||
void lookAt(Vector3 &t_up, Vector3 &t_position, Vector3 &t_target);
|
||||
void identity();
|
||||
void makeZRotation(float t_radians);
|
||||
void translate(float t_x, float t_y, float t_z);
|
||||
void setPerspective(ScreenSettings &screen);
|
||||
void print();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_PLANE_
|
||||
#define _TYRA_PLANE_
|
||||
|
||||
#include "vector3.hpp"
|
||||
|
||||
/** https://en.wikipedia.org/wiki/Plane_(geometry) */
|
||||
class Plane
|
||||
{
|
||||
|
||||
public:
|
||||
Vector3 normal;
|
||||
float distance;
|
||||
|
||||
Plane();
|
||||
Plane(Vector3 &a, Vector3 &b, Vector3 &c);
|
||||
~Plane();
|
||||
|
||||
void update(Vector3 &a, Vector3 &b, Vector3 &c);
|
||||
inline float distanceTo(Vector3 &t_vec) { return this->distance + this->normal.innerProduct(t_vec); }
|
||||
void print();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_POINT_
|
||||
#define _TYRA_POINT_
|
||||
|
||||
/** https://en.wikipedia.org/wiki/Point_(geometry) */
|
||||
class Point
|
||||
{
|
||||
|
||||
public:
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
};
|
||||
float xy[2] __attribute__((__aligned__(16)));
|
||||
};
|
||||
|
||||
Point(float x, float y);
|
||||
Point();
|
||||
~Point();
|
||||
|
||||
void set(float x, float y);
|
||||
void print();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_VECTOR3_
|
||||
#define _TYRA_VECTOR3_
|
||||
|
||||
#include <tamtypes.h>
|
||||
|
||||
class Math; // Forward definition
|
||||
|
||||
/** https://en.wikipedia.org/wiki/Vector_(mathematics_and_physics) */
|
||||
class Vector3
|
||||
{
|
||||
|
||||
public:
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
};
|
||||
float xyz[3] __attribute__((__aligned__(16)));
|
||||
};
|
||||
|
||||
Vector3(float x, float y, float z);
|
||||
Vector3(const Vector3 &v);
|
||||
Vector3();
|
||||
~Vector3();
|
||||
|
||||
Vector3 operator+(Vector3 v);
|
||||
Vector3 operator-(const Vector3 &v);
|
||||
Vector3 operator*(Vector3 &v);
|
||||
Vector3 operator*(float t);
|
||||
Vector3 operator/(float t);
|
||||
Vector3 operator-(void);
|
||||
|
||||
static u8 shouldBeBackfaceCulled(const Vector3 *t_cameraPos, const Vector3 *v0, const Vector3 *v1, const Vector3 *v2);
|
||||
u8 collidesSquare(Vector3 &t_min, Vector3 &t_max);
|
||||
u8 isOnSquare(Vector3 &t_min, Vector3 &t_max);
|
||||
float length();
|
||||
void normalize();
|
||||
void setByLerp(const Vector3 &v1, const Vector3 &v2, const float t_interp);
|
||||
float innerProduct(Vector3 &v);
|
||||
void set(Vector3 &v);
|
||||
void set(float x, float y, float z);
|
||||
void copy(Vector3 &v);
|
||||
float distanceTo(Vector3 &v);
|
||||
void print();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_MD2_MODEL_
|
||||
#define _TYRA_MD2_MODEL_
|
||||
|
||||
#include <tamtypes.h>
|
||||
#include <math3d.h>
|
||||
#include "math/vector3.hpp"
|
||||
#include "math/point.hpp"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 startFrame;
|
||||
u32 endFrame;
|
||||
float speed;
|
||||
float interpolation;
|
||||
u32 animType;
|
||||
u32 currentFrame;
|
||||
u32 nextFrame;
|
||||
} MD2AnimState;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u16 verticeIndexes[3];
|
||||
u16 coordIndexes[3];
|
||||
} MD2Triangle;
|
||||
|
||||
/** Class which have common types for all 3D objects */
|
||||
class MD2Model
|
||||
{
|
||||
|
||||
public:
|
||||
u32 verticesPerFrameCount, framesCount, coordinatesCount, trianglesCount;
|
||||
Vector3 *vertices __attribute__((aligned(16)));
|
||||
Point *coordinates;
|
||||
u32 *normalIndexes;
|
||||
MD2Triangle *triangles;
|
||||
MD2AnimState animState;
|
||||
/** File name without extension */
|
||||
char *filename;
|
||||
MD2Model(char *t_md2File);
|
||||
~MD2Model();
|
||||
u32 getCurrentFrameData(VECTOR *o_vertices, VECTOR *o_normals, VECTOR *o_coordinates, VECTOR *o_colors, Vector3 &t_cameraPos, float t_scale, u8 t_shouldBeBackfaceCulled);
|
||||
void allocateMemory();
|
||||
|
||||
private:
|
||||
Vector3 calcVector;
|
||||
Vector3 calc3Vectors[3];
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_OBJECT3D_
|
||||
#define _TYRA_OBJECT3D_
|
||||
|
||||
#include "math/vector3.hpp"
|
||||
#include "math/plane.hpp"
|
||||
#include "mesh_spec.hpp"
|
||||
#include "obj_model.hpp"
|
||||
#include "dff_model.hpp"
|
||||
#include "md2_model.hpp"
|
||||
#include <tamtypes.h>
|
||||
#include <draw_types.h>
|
||||
|
||||
/** Class which have common types for all 3D objects */
|
||||
class Mesh
|
||||
{
|
||||
|
||||
public:
|
||||
Vector3 position, rotation;
|
||||
u8 shouldBeLighted, shouldBeBackfaceCulled, shouldBeFrustumCulled;
|
||||
|
||||
MeshSpec *spec;
|
||||
MD2Model *md2;
|
||||
ObjModel *obj;
|
||||
DffModel *dff;
|
||||
float scale;
|
||||
color_t color;
|
||||
Vector3 boxVertices[8];
|
||||
|
||||
Mesh();
|
||||
~Mesh();
|
||||
|
||||
void loadObj(char *t_subfolder, char *t_objFile, Vector3 &t_initPos, float t_scale);
|
||||
void setObj(Vector3 &t_initPos, ObjModel *t_objModel, MeshSpec *t_spec);
|
||||
void loadDff(char *t_subfolder, char *t_dffFile, Vector3 &t_initPos, float t_scale);
|
||||
void setDff(Vector3 &t_initPos, DffModel *t_dffModel, MeshSpec *t_spec);
|
||||
void loadMD2(char *t_subfolder, char *t_md2File, Vector3 &t_initPos, float t_scale);
|
||||
void getMinMax(Vector3 *t_min, Vector3 *t_max);
|
||||
void playAnimation(u32 t_startFrame, u32 t_endFrame);
|
||||
u32 getVertexCount();
|
||||
void setAnimSpeed(float t_value);
|
||||
u32 getDrawData(u32 splitIndex, VECTOR *t_vertices, VECTOR *t_normals, VECTOR *t_coordinates, VECTOR *t_colors, Vector3 &t_cameraPos);
|
||||
u8 isInFrustum(Plane *t_frustumPlanes);
|
||||
|
||||
u8 isMd2Loaded, isObjLoaded, isDffLoaded, isSpecInitialized;
|
||||
|
||||
private:
|
||||
void setDefaultWrapSettings(texwrap_t &t_wrapSettings);
|
||||
u32 verticesCount;
|
||||
Vector3 *vertices;
|
||||
void loadTextures(char *t_subfolder, char *t_extension);
|
||||
void computeBoundingBox();
|
||||
void setVerticesReference(u32 t_verticesCount, Vector3 *t_verticesRef);
|
||||
void createSpecIfNotCreated();
|
||||
void setDefaultColor();
|
||||
void getFarthestVertex(Vector3 *o_result, int t_offset);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_OBJECT3D_SPEC_
|
||||
#define _TYRA_OBJECT3D_SPEC_
|
||||
|
||||
#include "math/vector3.hpp"
|
||||
#include "./texture.hpp"
|
||||
#include <tamtypes.h>
|
||||
#include <draw_buffers.h>
|
||||
#include <draw_sampling.h>
|
||||
|
||||
/** Class which contain 3D object specification */
|
||||
class MeshSpec
|
||||
{
|
||||
|
||||
public:
|
||||
texbuffer_t textureBuffer;
|
||||
clutbuffer_t clut;
|
||||
lod_t lod;
|
||||
|
||||
MeshSpec();
|
||||
~MeshSpec();
|
||||
void allocateTextureBuffer(u16 t_width, u16 t_height);
|
||||
void deallocateTextureBuffer();
|
||||
void allocateMemory();
|
||||
void setupLodAndClut();
|
||||
Texture *textures;
|
||||
|
||||
private:
|
||||
u8 isTextureVRAMAllocated;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_OBJ_MODEL_
|
||||
#define _TYRA_OBJ_MODEL_
|
||||
|
||||
#include <tamtypes.h>
|
||||
#include <math3d.h>
|
||||
#include "math/vector3.hpp"
|
||||
|
||||
/** Class which have common types for all 3D objects */
|
||||
class ObjModel
|
||||
{
|
||||
|
||||
public:
|
||||
u32 verticesCount, coordinatesCount, normalsCount, facesCount;
|
||||
Vector3 *vertices __attribute__((aligned(16))),
|
||||
*coordinates __attribute__((aligned(16))),
|
||||
*normals __attribute__((aligned(16)));
|
||||
u32 *verticeFaces, *coordinateFaces, *normalFaces;
|
||||
|
||||
/** File name without extension */
|
||||
char *filename;
|
||||
|
||||
ObjModel(char *t_objFile);
|
||||
~ObjModel();
|
||||
u32 getDrawData(VECTOR *o_vertices, VECTOR *o_normals, VECTOR *o_coordinates, VECTOR *o_colors, Vector3 &t_cameraPos, float t_scale, u8 t_shouldBeBackfaceCulled);
|
||||
void allocateMemory();
|
||||
|
||||
private:
|
||||
void fillNextFace(VECTOR *o_vertices, VECTOR *o_normals, VECTOR *o_coordinates, VECTOR *o_colors, u32 t_getI, u32 t_setI);
|
||||
u8 isMemoryAllocated;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,34 @@
|
||||
|
||||
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_RENDER_DATA_
|
||||
#define _TYRA_RENDER_DATA_
|
||||
|
||||
#include "light_bulb.hpp"
|
||||
#include <draw_primitives.h>
|
||||
#include "math/matrix.hpp"
|
||||
#include "math/plane.hpp"
|
||||
|
||||
struct RenderData
|
||||
{
|
||||
LightBulb *bulbs;
|
||||
u16 bulbsCount;
|
||||
/** Camera (lookAt) */
|
||||
Matrix *worldView;
|
||||
/** Perspective projection */
|
||||
Matrix *perspective;
|
||||
Vector3 *cameraPosition;
|
||||
Plane *frustumPlanes;
|
||||
prim_t *prim;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_SCREEN_SETTINGS_
|
||||
#define _TYRA_SCREEN_SETTINGS_
|
||||
|
||||
struct ScreenSettings
|
||||
{
|
||||
float fov;
|
||||
float width;
|
||||
float height;
|
||||
float aspectRatio;
|
||||
float nearPlaneDist;
|
||||
float farPlaneDist;
|
||||
/** change it to 4096.0F to check out frustum culling! 😎 */
|
||||
float projectionScale;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_TEXTURE_
|
||||
#define _TYRA_TEXTURE_
|
||||
|
||||
#include <tamtypes.h>
|
||||
#include <draw_sampling.h>
|
||||
|
||||
struct Texture
|
||||
{
|
||||
u32 id;
|
||||
unsigned char *data;
|
||||
texwrap_t wrapSettings;
|
||||
char *name;
|
||||
u8 width, height;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_AUDIO_
|
||||
#define _TYRA_AUDIO_
|
||||
|
||||
#include <tamtypes.h>
|
||||
#include <stdio.h>
|
||||
#include <audsrv.h>
|
||||
#include <kernel.h>
|
||||
#include "../models/audio_listener.hpp"
|
||||
|
||||
#define STACK_SIZE 8 * 1024
|
||||
|
||||
/** Class responsible for audio playing */
|
||||
class Audio
|
||||
{
|
||||
|
||||
public:
|
||||
Audio();
|
||||
~Audio();
|
||||
|
||||
u8 isTrackDone;
|
||||
ee_sema_t sema;
|
||||
int fillbufferSema;
|
||||
|
||||
void init(u32 t_listenersAmount);
|
||||
void play();
|
||||
void stop();
|
||||
void loadSong(char *t_filename);
|
||||
void unloadSong();
|
||||
void setVolume(u8 t_volume);
|
||||
void addListener(AudioListener *t_listener);
|
||||
void startThread();
|
||||
|
||||
private:
|
||||
void work();
|
||||
static void audioThread();
|
||||
u8 isInitialized, shouldPlay, songLoaded, isVolumeSet;
|
||||
|
||||
ee_thread_t audioThreadAttr;
|
||||
u8 audioThreadStack[STACK_SIZE] ALIGNED(16);
|
||||
int audioThreadId;
|
||||
|
||||
AudioListener **listeners;
|
||||
u32 listenersAmount;
|
||||
u32 addedListeners;
|
||||
void initSema();
|
||||
void loadModules();
|
||||
void initAUDSRV();
|
||||
|
||||
int ret, played;
|
||||
char chunk[2048];
|
||||
FILE *wav;
|
||||
audsrv_fmt_t format;
|
||||
static int fillbuffer(void *arg);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_CAMERA_BASE_
|
||||
#define _TYRA_CAMERA_BASE_
|
||||
|
||||
#include "../models/math/plane.hpp"
|
||||
#include "../models/math/matrix.hpp"
|
||||
#include "../models/math/vector3.hpp"
|
||||
#include "../models/screen_settings.hpp"
|
||||
|
||||
/** Class responsible for frustum culling */
|
||||
class CameraBase
|
||||
{
|
||||
|
||||
public:
|
||||
CameraBase(ScreenSettings *t_screen, Vector3 *t_position, Vector3 *t_up, Vector3 *t_unitCirclePosition);
|
||||
virtual ~CameraBase(){};
|
||||
|
||||
void setScreen();
|
||||
void updatePlanes(Vector3 t_target);
|
||||
Plane planes[6];
|
||||
Matrix worldView;
|
||||
|
||||
protected:
|
||||
ScreenSettings *screen;
|
||||
|
||||
private:
|
||||
Vector3 *position2, *up2, *unitCirclePosition2;
|
||||
float farPlaneDist, nearPlaneDist, nearHeight, nearWidth, farHeight, farWidth;
|
||||
Vector3 ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_GIF_SENDER_
|
||||
#define _TYRA_GIF_SENDER_
|
||||
|
||||
#include <tamtypes.h>
|
||||
#include <draw_buffers.h>
|
||||
#include <draw_types.h>
|
||||
#include <draw_primitives.h>
|
||||
#include <math3d.h>
|
||||
#include <packet.h>
|
||||
#include "../models/mesh.hpp"
|
||||
#include "../models/math/matrix.hpp"
|
||||
#include "../models/screen_settings.hpp"
|
||||
#include "../models/light_bulb.hpp"
|
||||
#include "../models/render_data.hpp"
|
||||
|
||||
/** Class responsible for sending data packets via GIF (PATH3) */
|
||||
class GifSender
|
||||
{
|
||||
|
||||
public:
|
||||
GifSender(u32 t_packetSize, ScreenSettings *t_screen);
|
||||
~GifSender();
|
||||
|
||||
void initPacket(u8 context);
|
||||
void addObjects(RenderData *t_renderData, Mesh **t_objects3D, u32 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount);
|
||||
void addClear(zbuffer_t *t_zBuffer);
|
||||
void sendPacket();
|
||||
void sendClear(zbuffer_t *t_zBuffer);
|
||||
static void sendTexture(Texture &texture, texbuffer_t *t_texBuffer);
|
||||
|
||||
private:
|
||||
xyz_t *xyz;
|
||||
color_t *rgbaq;
|
||||
texel_t *st;
|
||||
u8 isAnyObjectAdded;
|
||||
ScreenSettings *screen;
|
||||
u64 *dw;
|
||||
qword_t *q, *dmatag;
|
||||
packet_t *packets[2];
|
||||
packet_t *currentPacket;
|
||||
u8 packetsCount;
|
||||
int packetSize;
|
||||
float halfScreenW, halfScreenH;
|
||||
MATRIX localWorld, localScreen, localLight;
|
||||
|
||||
u32 calc3DObject(Matrix t_perspective, Mesh &t_mesh, RenderData *t_renderData, LightBulb *t_bulbs, u16 t_bulbsCount);
|
||||
void convertCalcs(u32 t_vertCount, VECTOR *t_vertices, VECTOR *t_colors, VECTOR *t_sts, u8 t_alpha);
|
||||
void addCurrentCalcs(u32 &t_vertexCount);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_LIGHT_
|
||||
#define _TYRA_LIGHT_
|
||||
|
||||
#include <math3d.h>
|
||||
#include <tamtypes.h>
|
||||
#include "../models/math/vector3.hpp"
|
||||
#include "../models/light_bulb.hpp"
|
||||
|
||||
class Light
|
||||
{
|
||||
|
||||
public:
|
||||
Light();
|
||||
~Light();
|
||||
|
||||
static u16 getLightsCount(u32 t_bulbsCount);
|
||||
static void calculateLight(VECTOR *t_lightDirections, VECTOR *t_lightColors, int *t_lightTypes, LightBulb *t_bulbs, u32 t_bulbsCount, Vector3 t_objPosition);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_PAD_
|
||||
#define _TYRA_PAD_
|
||||
|
||||
#include <tamtypes.h>
|
||||
#include <libpad.h>
|
||||
|
||||
/** Class responsible for player pad */
|
||||
class Pad
|
||||
{
|
||||
|
||||
public:
|
||||
u8 isCrossClicked, isSquareClicked, isTriangleClicked, isCircleClicked;
|
||||
u8 isDpadUpPressed, isDpadDownPressed, isDpadLeftPressed, isDpadRightPressed;
|
||||
u8 lJoyH, lJoyV, rJoyH, rJoyV;
|
||||
|
||||
Pad();
|
||||
~Pad();
|
||||
void update();
|
||||
|
||||
private:
|
||||
char padBuf[256] __attribute__((aligned(64)));
|
||||
char actAlign[6];
|
||||
int actuators, ret, port, slot;
|
||||
padButtonStatus buttons;
|
||||
u32 padData, oldPad, newPad;
|
||||
|
||||
void reset();
|
||||
void loadModules();
|
||||
int waitPadReady();
|
||||
int initPad();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_RENDERER_
|
||||
#define _TYRA_RENDERER_
|
||||
|
||||
#include <draw_buffers.h>
|
||||
#include <draw_primitives.h>
|
||||
#include <packet.h>
|
||||
#include "gif_sender.hpp"
|
||||
#include "vif_sender.hpp"
|
||||
#include "../models/math/plane.hpp"
|
||||
#include "../models/screen_settings.hpp"
|
||||
#include "../models/render_data.hpp"
|
||||
|
||||
/** Class responsible for intializing draw env, textures and buffers */
|
||||
class Renderer
|
||||
{
|
||||
|
||||
public:
|
||||
Renderer(u32 t_packetSize, ScreenSettings *t_screen);
|
||||
~Renderer();
|
||||
|
||||
framebuffer_t frameBuffers[2];
|
||||
u8 context;
|
||||
zbuffer_t zBuffer;
|
||||
prim_t prim;
|
||||
|
||||
/** PATH3 Many + lighting */
|
||||
void drawByPath3(Mesh **t_meshes, u16 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount);
|
||||
/** PATH3 Single + lighting */
|
||||
void drawByPath3(Mesh *t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount);
|
||||
/** PATH3 Many */
|
||||
void drawByPath3(Mesh **t_meshes, u16 t_amount);
|
||||
/** PATH3 Single */
|
||||
void drawByPath3(Mesh *t_mesh);
|
||||
|
||||
/** PATH1 Many + lighting */
|
||||
void draw(Mesh **t_meshes, u16 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount);
|
||||
/** PATH1 Single + lighting */
|
||||
void draw(Mesh *t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount);
|
||||
/** PATH1 Many */
|
||||
void draw(Mesh **t_meshes, u16 t_amount);
|
||||
/** PATH1 Single */
|
||||
void draw(Mesh *t_mesh);
|
||||
|
||||
void setCameraDefinitions(Matrix *t_worldView, Vector3 *t_cameraPos, Plane *t_planes);
|
||||
|
||||
void endFrame(float fps);
|
||||
|
||||
private:
|
||||
void changeTexture(Mesh *t_mesh, u8 t_textureIndex);
|
||||
void flipBuffers();
|
||||
void beginFrameIfNeeded();
|
||||
u8 isFrameEmpty;
|
||||
Matrix perspective;
|
||||
RenderData renderData;
|
||||
|
||||
u32 lastTextureId;
|
||||
GifSender *gifSender;
|
||||
VifSender *vifSender;
|
||||
packet_t *flipPacket;
|
||||
void allocateBuffers(float t_screenW, float t_screenH);
|
||||
void initDrawingEnv(float t_screenW, float t_screenH);
|
||||
void setPrim();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_TIMER_
|
||||
#define _TYRA_TIMER_
|
||||
|
||||
#include <tamtypes.h>
|
||||
|
||||
/** Class responsible for fps counting */
|
||||
class Timer
|
||||
{
|
||||
|
||||
public:
|
||||
Timer();
|
||||
~Timer();
|
||||
|
||||
u32 getTimeDelta();
|
||||
void primeTimer();
|
||||
float getFPS();
|
||||
|
||||
private:
|
||||
u32 lastTime, time, change;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_VIF_SENDER_
|
||||
#define _TYRA_VIF_SENDER_
|
||||
|
||||
#include <tamtypes.h>
|
||||
#include "../models/render_data.hpp"
|
||||
#include "../models/light_bulb.hpp"
|
||||
#include "../models/mesh.hpp"
|
||||
#include "../models/math/matrix.hpp"
|
||||
#include "../models/math/vector3.hpp"
|
||||
#include "vu1.hpp"
|
||||
|
||||
/** Class responsible for sending 3D objects via VIF (PATH 1) */
|
||||
class VifSender
|
||||
{
|
||||
|
||||
public:
|
||||
VifSender();
|
||||
~VifSender();
|
||||
|
||||
// TODO refactor
|
||||
void drawMesh(RenderData *t_renderData, Matrix t_perspective, u32 vertCount2, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, VECTOR *colors, Mesh *t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount);
|
||||
|
||||
private:
|
||||
void drawVertices(Mesh *t_mesh, u32 t_start, u32 t_end, VECTOR *t_vertices, VECTOR *t_colors, VECTOR *t_coordinates, prim_t *t_prim);
|
||||
|
||||
MATRIX localWorld, localScreen;
|
||||
VECTOR position, rotation;
|
||||
u32 vertCount;
|
||||
VU1 vu1;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_VU1_
|
||||
#define _TYRA_VU1_
|
||||
|
||||
#include "../models/math/matrix.hpp"
|
||||
#include <draw_buffers.h>
|
||||
#include <tamtypes.h>
|
||||
#include <draw_primitives.h>
|
||||
#include <packet.h>
|
||||
#include <math3d.h>
|
||||
|
||||
const u32 VIF_BUFFER_SIZE = 48 * 1024;
|
||||
|
||||
typedef struct VU1BuildList
|
||||
{
|
||||
u8 isBuilding;
|
||||
void *offset;
|
||||
void *kickBuffer;
|
||||
u32 dmaSize;
|
||||
u32 dmaSizeAll;
|
||||
u32 dmaDestination;
|
||||
} VU1BuildList;
|
||||
|
||||
/** Class responsible for managing VU1 micro programs */
|
||||
class VU1
|
||||
{
|
||||
|
||||
public:
|
||||
VU1();
|
||||
~VU1();
|
||||
|
||||
static void uploadProgram(int t_dest, u32 *t_start, u32 *t_end);
|
||||
void createList();
|
||||
void sendSingleRefList(int t_destAddress, void *t_data, int t_quadSize);
|
||||
void addListBeginning();
|
||||
void continueList();
|
||||
void addReferenceList(u32 t_offset, void *t_data, u32 t_size, u8 t_useTops);
|
||||
void addFloat(float v);
|
||||
void add32(u32 v);
|
||||
void add64(u64 v);
|
||||
void add128(u64 v1, u64 v2);
|
||||
void addListEnding();
|
||||
void addStartProgram();
|
||||
void addContinueProgram();
|
||||
void sendList();
|
||||
void addDoubleBufferSetting();
|
||||
void addFlush();
|
||||
|
||||
private:
|
||||
u8 isDoubleBufferSet;
|
||||
void checkDataAlignment(void *data);
|
||||
VU1BuildList buildList;
|
||||
char dmaBuffer1[VIF_BUFFER_SIZE] __attribute__((aligned(16)));
|
||||
char dmaBuffer2[VIF_BUFFER_SIZE] __attribute__((aligned(16)));
|
||||
void *currentBuffer;
|
||||
u32 switchBuffer;
|
||||
static u32 countProgramSize(u32 *t_start, u32 *t_end);
|
||||
void checkList();
|
||||
inline s32 AddUnpack(int format, int addr, int num, int usetops = 0, int nosign = 1, int masking = 0)
|
||||
{
|
||||
return (s32)((0x60 << 24) + (format << 24) + (masking << 28) + (usetops << 15) +
|
||||
(nosign << 14) + (num << 16) + addr);
|
||||
}
|
||||
};
|
||||
|
||||
#define DMA_REF_TAG(ADDR, COUNT) ((((unsigned long)ADDR) << 32) | (0x3 << 28) | COUNT)
|
||||
#define DMA_CNT_TAG(COUNT) (((unsigned long)(0x1) << 28) | COUNT)
|
||||
#define DMA_END_TAG(COUNT) (((unsigned long)(0x7) << 28) | COUNT)
|
||||
#define VIF_NOP 0x00
|
||||
#define VIF_STCYL 0x01
|
||||
#define VIF_OFFSET 0x02
|
||||
#define VIF_BASE 0x03
|
||||
#define VIF_FLUSH 0x11
|
||||
#define VIF_MSCAL 0x14
|
||||
#define VIF_MSCNT 0x17
|
||||
#define VIF_MPG 0x4A
|
||||
#define V4_32 0xC
|
||||
#define VIF_UNPACK 0x60
|
||||
#define U128(n) ((u128)(n))
|
||||
#define VIF_UNPACK_V4_32 (VIF_UNPACK | V4_32)
|
||||
#define VIF_CODE(CMD, NUM, IMMEDIATE) ((((unsigned int)(CMD)) << 24) | \
|
||||
(((unsigned int)(NUM)) << 16) | \
|
||||
((unsigned int)(IMMEDIATE)))
|
||||
#define GS_PRIM(PRIM, IIP, TME, FGE, ABE, AA1, FST, CTXT, FIX) U128((FIX << 10) | (CTXT << 9) | (FST << 8) | (AA1 << 7) | (ABE << 6) | (FGE << 5) | (TME << 4) | (IIP << 3) | (PRIM))
|
||||
#define GS_GIFTAG(NLOOP, EOP, PRE, PRIM, FLG, NREG) (((u64)(NREG) << 60) | ((u64)(FLG) << 58) | ((u64)(PRIM) << 47) | ((u64)(PRE) << 46) | (EOP << 15) | (NLOOP << 0))
|
||||
#define VU1_DMA_CHAN_TIMEOUT -1
|
||||
#define GS_GIFTAG_PACKED 0
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,183 @@
|
||||
/*
|
||||
Copyright (C) 1997-2001 Id Software, Inc.
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_ANORMS_
|
||||
#define _TYRA_ANORMS_
|
||||
|
||||
const float ANORMS[162][3] = {
|
||||
{-0.525731f, 0.000000f, 0.850651f},
|
||||
{-0.442863f, 0.238856f, 0.864188f},
|
||||
{-0.295242f, 0.000000f, 0.955423f},
|
||||
{-0.309017f, 0.500000f, 0.809017f},
|
||||
{-0.162460f, 0.262866f, 0.951056f},
|
||||
{0.000000f, 0.000000f, 1.000000f},
|
||||
{0.000000f, 0.850651f, 0.525731f},
|
||||
{-0.147621f, 0.716567f, 0.681718f},
|
||||
{0.147621f, 0.716567f, 0.681718f},
|
||||
{0.000000f, 0.525731f, 0.850651f},
|
||||
{0.309017f, 0.500000f, 0.809017f},
|
||||
{0.525731f, 0.000000f, 0.850651f},
|
||||
{0.295242f, 0.000000f, 0.955423f},
|
||||
{0.442863f, 0.238856f, 0.864188f},
|
||||
{0.162460f, 0.262866f, 0.951056f},
|
||||
{-0.681718f, 0.147621f, 0.716567f},
|
||||
{-0.809017f, 0.309017f, 0.500000f},
|
||||
{-0.587785f, 0.425325f, 0.688191f},
|
||||
{-0.850651f, 0.525731f, 0.000000f},
|
||||
{-0.864188f, 0.442863f, 0.238856f},
|
||||
{-0.716567f, 0.681718f, 0.147621f},
|
||||
{-0.688191f, 0.587785f, 0.425325f},
|
||||
{-0.500000f, 0.809017f, 0.309017f},
|
||||
{-0.238856f, 0.864188f, 0.442863f},
|
||||
{-0.425325f, 0.688191f, 0.587785f},
|
||||
{-0.716567f, 0.681718f, -0.147621f},
|
||||
{-0.500000f, 0.809017f, -0.309017f},
|
||||
{-0.525731f, 0.850651f, 0.000000f},
|
||||
{0.000000f, 0.850651f, -0.525731f},
|
||||
{-0.238856f, 0.864188f, -0.442863f},
|
||||
{0.000000f, 0.955423f, -0.295242f},
|
||||
{-0.262866f, 0.951056f, -0.162460f},
|
||||
{0.000000f, 1.000000f, 0.000000f},
|
||||
{0.000000f, 0.955423f, 0.295242f},
|
||||
{-0.262866f, 0.951056f, 0.162460f},
|
||||
{0.238856f, 0.864188f, 0.442863f},
|
||||
{0.262866f, 0.951056f, 0.162460f},
|
||||
{0.500000f, 0.809017f, 0.309017f},
|
||||
{0.238856f, 0.864188f, -0.442863f},
|
||||
{0.262866f, 0.951056f, -0.162460f},
|
||||
{0.500000f, 0.809017f, -0.309017f},
|
||||
{0.850651f, 0.525731f, 0.000000f},
|
||||
{0.716567f, 0.681718f, 0.147621f},
|
||||
{0.716567f, 0.681718f, -0.147621f},
|
||||
{0.525731f, 0.850651f, 0.000000f},
|
||||
{0.425325f, 0.688191f, 0.587785f},
|
||||
{0.864188f, 0.442863f, 0.238856f},
|
||||
{0.688191f, 0.587785f, 0.425325f},
|
||||
{0.809017f, 0.309017f, 0.500000f},
|
||||
{0.681718f, 0.147621f, 0.716567f},
|
||||
{0.587785f, 0.425325f, 0.688191f},
|
||||
{0.955423f, 0.295242f, 0.000000f},
|
||||
{1.000000f, 0.000000f, 0.000000f},
|
||||
{0.951056f, 0.162460f, 0.262866f},
|
||||
{0.850651f, -0.525731f, 0.000000f},
|
||||
{0.955423f, -0.295242f, 0.000000f},
|
||||
{0.864188f, -0.442863f, 0.238856f},
|
||||
{0.951056f, -0.162460f, 0.262866f},
|
||||
{0.809017f, -0.309017f, 0.500000f},
|
||||
{0.681718f, -0.147621f, 0.716567f},
|
||||
{0.850651f, 0.000000f, 0.525731f},
|
||||
{0.864188f, 0.442863f, -0.238856f},
|
||||
{0.809017f, 0.309017f, -0.500000f},
|
||||
{0.951056f, 0.162460f, -0.262866f},
|
||||
{0.525731f, 0.000000f, -0.850651f},
|
||||
{0.681718f, 0.147621f, -0.716567f},
|
||||
{0.681718f, -0.147621f, -0.716567f},
|
||||
{0.850651f, 0.000000f, -0.525731f},
|
||||
{0.809017f, -0.309017f, -0.500000f},
|
||||
{0.864188f, -0.442863f, -0.238856f},
|
||||
{0.951056f, -0.162460f, -0.262866f},
|
||||
{0.147621f, 0.716567f, -0.681718f},
|
||||
{0.309017f, 0.500000f, -0.809017f},
|
||||
{0.425325f, 0.688191f, -0.587785f},
|
||||
{0.442863f, 0.238856f, -0.864188f},
|
||||
{0.587785f, 0.425325f, -0.688191f},
|
||||
{0.688191f, 0.587785f, -0.425325f},
|
||||
{-0.147621f, 0.716567f, -0.681718f},
|
||||
{-0.309017f, 0.500000f, -0.809017f},
|
||||
{0.000000f, 0.525731f, -0.850651f},
|
||||
{-0.525731f, 0.000000f, -0.850651f},
|
||||
{-0.442863f, 0.238856f, -0.864188f},
|
||||
{-0.295242f, 0.000000f, -0.955423f},
|
||||
{-0.162460f, 0.262866f, -0.951056f},
|
||||
{0.000000f, 0.000000f, -1.000000f},
|
||||
{0.295242f, 0.000000f, -0.955423f},
|
||||
{0.162460f, 0.262866f, -0.951056f},
|
||||
{-0.442863f, -0.238856f, -0.864188f},
|
||||
{-0.309017f, -0.500000f, -0.809017f},
|
||||
{-0.162460f, -0.262866f, -0.951056f},
|
||||
{0.000000f, -0.850651f, -0.525731f},
|
||||
{-0.147621f, -0.716567f, -0.681718f},
|
||||
{0.147621f, -0.716567f, -0.681718f},
|
||||
{0.000000f, -0.525731f, -0.850651f},
|
||||
{0.309017f, -0.500000f, -0.809017f},
|
||||
{0.442863f, -0.238856f, -0.864188f},
|
||||
{0.162460f, -0.262866f, -0.951056f},
|
||||
{0.238856f, -0.864188f, -0.442863f},
|
||||
{0.500000f, -0.809017f, -0.309017f},
|
||||
{0.425325f, -0.688191f, -0.587785f},
|
||||
{0.716567f, -0.681718f, -0.147621f},
|
||||
{0.688191f, -0.587785f, -0.425325f},
|
||||
{0.587785f, -0.425325f, -0.688191f},
|
||||
{0.000000f, -0.955423f, -0.295242f},
|
||||
{0.000000f, -1.000000f, 0.000000f},
|
||||
{0.262866f, -0.951056f, -0.162460f},
|
||||
{0.000000f, -0.850651f, 0.525731f},
|
||||
{0.000000f, -0.955423f, 0.295242f},
|
||||
{0.238856f, -0.864188f, 0.442863f},
|
||||
{0.262866f, -0.951056f, 0.162460f},
|
||||
{0.500000f, -0.809017f, 0.309017f},
|
||||
{0.716567f, -0.681718f, 0.147621f},
|
||||
{0.525731f, -0.850651f, 0.000000f},
|
||||
{-0.238856f, -0.864188f, -0.442863f},
|
||||
{-0.500000f, -0.809017f, -0.309017f},
|
||||
{-0.262866f, -0.951056f, -0.162460f},
|
||||
{-0.850651f, -0.525731f, 0.000000f},
|
||||
{-0.716567f, -0.681718f, -0.147621f},
|
||||
{-0.716567f, -0.681718f, 0.147621f},
|
||||
{-0.525731f, -0.850651f, 0.000000f},
|
||||
{-0.500000f, -0.809017f, 0.309017f},
|
||||
{-0.238856f, -0.864188f, 0.442863f},
|
||||
{-0.262866f, -0.951056f, 0.162460f},
|
||||
{-0.864188f, -0.442863f, 0.238856f},
|
||||
{-0.809017f, -0.309017f, 0.500000f},
|
||||
{-0.688191f, -0.587785f, 0.425325f},
|
||||
{-0.681718f, -0.147621f, 0.716567f},
|
||||
{-0.442863f, -0.238856f, 0.864188f},
|
||||
{-0.587785f, -0.425325f, 0.688191f},
|
||||
{-0.309017f, -0.500000f, 0.809017f},
|
||||
{-0.147621f, -0.716567f, 0.681718f},
|
||||
{-0.425325f, -0.688191f, 0.587785f},
|
||||
{-0.162460f, -0.262866f, 0.951056f},
|
||||
{0.442863f, -0.238856f, 0.864188f},
|
||||
{0.162460f, -0.262866f, 0.951056f},
|
||||
{0.309017f, -0.500000f, 0.809017f},
|
||||
{0.147621f, -0.716567f, 0.681718f},
|
||||
{0.000000f, -0.525731f, 0.850651f},
|
||||
{0.425325f, -0.688191f, 0.587785f},
|
||||
{0.587785f, -0.425325f, 0.688191f},
|
||||
{0.688191f, -0.587785f, 0.425325f},
|
||||
{-0.955423f, 0.295242f, 0.000000f},
|
||||
{-0.951056f, 0.162460f, 0.262866f},
|
||||
{-1.000000f, 0.000000f, 0.000000f},
|
||||
{-0.850651f, 0.000000f, 0.525731f},
|
||||
{-0.955423f, -0.295242f, 0.000000f},
|
||||
{-0.951056f, -0.162460f, 0.262866f},
|
||||
{-0.864188f, 0.442863f, -0.238856f},
|
||||
{-0.951056f, 0.162460f, -0.262866f},
|
||||
{-0.809017f, 0.309017f, -0.500000f},
|
||||
{-0.864188f, -0.442863f, -0.238856f},
|
||||
{-0.951056f, -0.162460f, -0.262866f},
|
||||
{-0.809017f, -0.309017f, -0.500000f},
|
||||
{-0.681718f, 0.147621f, -0.716567f},
|
||||
{-0.681718f, -0.147621f, -0.716567f},
|
||||
{-0.850651f, 0.000000f, -0.525731f},
|
||||
{-0.688191f, 0.587785f, -0.425325f},
|
||||
{-0.587785f, 0.425325f, -0.688191f},
|
||||
{-0.425325f, 0.688191f, -0.587785f},
|
||||
{-0.425325f, -0.688191f, -0.587785f},
|
||||
{-0.587785f, -0.425325f, -0.688191f},
|
||||
{-0.688191f, -0.587785f, -0.425325f}};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_DEBUG_
|
||||
#define _TYRA_DEBUG_
|
||||
|
||||
#include <tamtypes.h>
|
||||
#include <math3d.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define PRINT_LOG(TEXT) printf("LOG: " TEXT " (" __FILE__ ")\n")
|
||||
#define PRINT_ERR(TEXT) printf("---\n--- ---\n--- --- --- ERR: " TEXT " (" __FILE__ ")\n--- ---\n---\n")
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_MATH_
|
||||
#define _TYRA_MATH_
|
||||
|
||||
#include <tamtypes.h>
|
||||
#include <math3d.h>
|
||||
#include "../models/math/vector3.hpp"
|
||||
|
||||
class Vector3; // Forward definition
|
||||
|
||||
void manyVec3ToNative(VECTOR *t_result, Vector3 *t_vec, int t_amount, float t_fourthVal);
|
||||
void vec3ToNative(VECTOR t_result, Vector3 &t_vec, float t_fourthVal);
|
||||
|
||||
class Math
|
||||
{
|
||||
|
||||
public:
|
||||
const static float HALF_ANG2RAD = 3.14159265358979323846 / 360.0;
|
||||
const static float PI = 3.1415926535897932384626433832795F;
|
||||
const static float HALF_PI = 1.5707963267948966192313216916398F;
|
||||
static float cos(float x);
|
||||
static inline float sin(float x) { return cos(x - HALF_PI); };
|
||||
static float sqrt(float x);
|
||||
static float invSqrt(float x);
|
||||
|
||||
private:
|
||||
Math();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_STRING_
|
||||
#define _TYRA_STRING_
|
||||
|
||||
#include <tamtypes.h>
|
||||
|
||||
class String
|
||||
{
|
||||
|
||||
public:
|
||||
static char *createCopy(char *source);
|
||||
static u32 getLength(char *a);
|
||||
static char *createConcatenated(char *a, char *b);
|
||||
static char *createWithoutExtension(char *source);
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user