Skip to content

Commit

Permalink
Merge pull request #85 from h4570/develop
Browse files Browse the repository at this point in the history
Added latest changes, make Tyra working on latest PS2SDK (GCC11)
  • Loading branch information
h4570 committed Feb 6, 2021
2 parents afa98e8 + 8bd5476 commit 7b2e411
Show file tree
Hide file tree
Showing 38 changed files with 886 additions and 673 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.31.2] - 2021-02-06

### Added
- Id to MeshFrame
- Non textured rendering (RGBA only)

### Changed
- Moved color from mesh to mesh material.
- OBJ Loader refactor
- Logic of loadFrom()
- Migrated to GCC9 (valid with latest PS2SDK)

### Removed
- Removed MeshId from TextureLink, TextureRepository

## [1.29.1] - 2020-12-27
### Added
- Created libpacket2 in PS2SDK
Expand Down Expand Up @@ -96,6 +111,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Makefile
- Primitive floors sample

[1.31.2]: https://github.com/h4570/tyra/compare/v1.29.1-alpha...v1.31.2-alpha
[1.29.1]: https://github.com/h4570/tyra/compare/1.1.0...v1.29.1-alpha
[1.1.0]: https://github.com/h4570/tyra/compare/1.0.0...1.1.0
[1.0.0]: https://github.com/h4570/tyra/compare/1.0.0
13 changes: 5 additions & 8 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<img src="http://apgcglz.cluster028.hosting.ovh.net/tyra/github-splash.png" alt="Logo" width="100%" height="auto">
</a>

<h3 align="center">Tyra - alpha 1.29.1</h3>
<h3 align="center">Tyra - alpha 1.31.2</h3>

<p align="center">
Open source game engine for PlayStation 2™
Expand Down Expand Up @@ -45,10 +45,7 @@

## About The Project

<img src="http://apgcglz.cluster028.hosting.ovh.net/tyra/1.29.1/tyra.gif" alt="sample" width="600" height="auto">

### Contributors wanted [![Discord](https://img.shields.io/badge/discord-Tyra-brightgreen?logo=discord)](https://discord.gg/NhhTmg3Gm5)
We will be grateful for any help. If you dont know PS2.. don't worry, we are open to explain how things work.
<img src="http://apgcglz.cluster028.hosting.ovh.net/tyra/1.31.2/tyra.gif" alt="sample" width="600" height="auto">

### Samples
* [Dolphin](https://github.com/h4570/tyra/tree/master/src/samples/dolphin)
Expand Down Expand Up @@ -87,7 +84,7 @@ In our Discord channel, there is detailed tutorial which will help you with sett

This is an example of how to list things you need to use the software.
* PS2 DEV environment - [PS2DEV](https://github.com/ps2dev/ps2dev)
* At least #674b6f4 PS2SDK (01.12.2020) - [PS2SDK](https://github.com/ps2dev/ps2sdk)
* At least #e8e9edb PS2SDK (06.02.2021) - [PS2SDK](https://github.com/ps2dev/ps2sdk)
* PS2 Emulator. For example [PCSX2](https://pcsx2.net/)

## Extra info
Expand All @@ -98,7 +95,7 @@ This is an example of how to list things you need to use the software.
## Roadmap

### Roadmap for next master release:
[January 2021 Roadmap](https://github.com/h4570/tyra/projects/4)
[Next release roadmap](https://github.com/h4570/tyra/projects/4)

## Tyra team

Expand Down Expand Up @@ -139,7 +136,7 @@ Distributed under the Apache License 2.0 License. See `LICENSE` for more informa
Without these guys, everything would be harder:
* Dr Henry Fortuna - for code sources
* Rick Gaiser - for help and new GCC!
* Lukasz D.K. - for huge archive of PS2 stuff-
* Lukasz D.K. - for huge archive of PS2 stuff
* Guilherme Lampert - for code sources
* Jesper Svennevid, Daniel Collin - for openvcl's code samples
* Whole PS2DEV team
Expand Down
6 changes: 3 additions & 3 deletions src/engine/Makefile.pref
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
EE_LIBS := $(EE_LIBS) -ldraw -lgraph -lmath3d -lpacket -ldma -lpacket2 -lpad -laudsrv -lc -lstdc++ -lpng -lz
EE_LIBS := $(EE_LIBS) -ldraw -lcdvd -lgraph -lmath3d -lpacket -ldma -lpacket2 -lpad -laudsrv -lc -lstdc++ -lpng -lz
EE_INCS := -I$(TYRA_DIR)/include -I$(PS2SDK)/ports/include $(EE_INCS)
EE_LDFLAGS := -L$(PS2SDK)/ports/lib -L$(TYRA_DIR) $(EE_LDFLAGS)
EE_CFLAGS := -DHAVE_LIBPNG -DHAVE_ZLIB $(EE_CFLAGS)
EE_CXXFLAGS := -DHAVE_LIBPNG -DHAVE_ZLIB $(EE_CXXFLAGS)
EE_CFLAGS := -DHAVE_LIBPNG -D_XCDVD -DHAVE_ZLIB $(EE_CFLAGS)
EE_CXXFLAGS := -DHAVE_LIBPNG -D_XCDVD -DHAVE_ZLIB $(EE_CXXFLAGS)
EE_DVP = dvp-as
EE_VCL = vcl
EE_VCLPP = vclpp
Expand Down
7 changes: 3 additions & 4 deletions src/engine/include/models/mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "./texture.hpp"
#include "./mesh_frame.hpp"
#include <tamtypes.h>
#include <draw_types.h>
#include <draw_buffers.h>
#include <draw_sampling.h>
#include "./anim_state.hpp"
Expand All @@ -43,7 +42,6 @@ class Mesh
* When true, mesh materials are not drawn when they are outside of view frustum.
*/
u8 shouldBeFrustumCulled;
color_t color;
clutbuffer_t clut;
lod_t lod;

Expand Down Expand Up @@ -176,6 +174,8 @@ class Mesh

void setAnimSpeed(const float &t_value) { animState.speed = t_value; }

const u8 &areFramesAllocated() const { return _areFramesAllocated; };

/**
* Check if this class loaded mesh data first.
* Meshes which use loadFrom() method have false there.
Expand Down Expand Up @@ -207,9 +207,8 @@ class Mesh
AnimState animState;
MeshFrame *frames;
u32 id, framesCount;
u8 _isMother;
u8 _isMother, _areFramesAllocated;
Vector3 calc3Vectors[3];
void setDefaultColor();
void setDefaultLODAndClut();
};

Expand Down
26 changes: 24 additions & 2 deletions src/engine/include/models/mesh_frame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ class MeshFrame
// Getters
// ----

/**
* Auto generated unique Id.
* Core role of this variable is to select correct texture to draw
*/
const u32 &getId() const { return id; };

const u32 &getVertexCount() const { return vertexCount; };
const u32 &getSTsCount() const { return stsCount; };
const u32 &getNormalsCount() const { return normalsCount; };
Expand Down Expand Up @@ -119,12 +125,27 @@ class MeshFrame
// Other
// ----

/**
* Check if this object is mother.
* Mother = object loaded with loadObj(), loadDff()..
* Have all mother data: vertex, st, etc..
* Non-mother = object loaded with loadFrom().
* Have reference copy to mother data: vertex, st, etc..
*
* When you will destruct mother object, all vertex, st data will be deleted.
* When you will destruct non-mother object, all vertex, st data will be NOT deleted.
*/
const u8 &isMother() const { return _isMother; };

const u8 &areSTsAllocated() const { return _areSTsAllocated; };
const u8 &areVerticesAllocated() const { return _areVerticesAllocated; };
const u8 &areNormalsAllocated() const { return _areNormalsAllocated; };
const u8 &areMaterialsAllocated() const { return _areMaterialsAllocated; };
const u8 &isBoundingBoxCalculated() const { return _isBoundingBoxCalculated; };

/** Create reference copy (non-mother) */
void copyFrom(MeshFrame *t_refCopy);

/** Set STs count and allocate memory. */
void allocateSTs(const u32 &t_val);

Expand All @@ -146,12 +167,13 @@ class MeshFrame

private:
BoundingBox *boundingBoxObj;
u8 _areSTsAllocated,
u8 _isMother,
_areSTsAllocated,
_areVerticesAllocated,
_areNormalsAllocated,
_areMaterialsAllocated,
_isBoundingBoxCalculated;
u32 vertexCount, stsCount, normalsCount, materialsCount;
u32 vertexCount, stsCount, normalsCount, materialsCount, id;
MeshMaterial *materials;
Point __attribute__((aligned(16))) * sts;
Vector3 __attribute__((aligned(16))) * vertices, *normals;
Expand Down
43 changes: 42 additions & 1 deletion src/engine/include/models/mesh_material.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define _TYRA_MESH_MATERIAL_

#include <tamtypes.h>
#include <draw_types.h>
#include "bounding_box.hpp"
#include "./math/vector3.hpp"
#include "./math/plane.hpp"
Expand All @@ -29,6 +30,8 @@ class MeshMaterial
MeshMaterial();
~MeshMaterial();

color_t color;

// ----
// Getters
// ----
Expand Down Expand Up @@ -104,11 +107,43 @@ class MeshMaterial
/** Set material name. */
void setName(char *t_val);

/**
* Do not call this method unless you know what you do.
* Should be called by data loader.
*/
void setSTsPresent(const u8 &b) { _areSTsPresent = b; };

/**
* Do not call this method unless you know what you do.
* Should be called by data loader.
*/
void setNormalsPresent(const u8 &b) { _areNormalsPresent = b; };

// ----
// Other
// ----

const u8 &areSTsPresent() const { return _areSTsPresent; };

const u8 &areNormalsPresent() const { return _areNormalsPresent; };

/** Create reference copy (non-mother) */
void copyFrom(MeshMaterial *t_refCopy);

const u8 &isNameSet() const { return _isNameSet; };

/**
* Check if this object is mother.
* Mother = object loaded with loadObj(), loadDff()..
* Have all mother data: vertex faces, st faces, etc..
* Non-mother = object loaded with loadFrom().
* Have reference copy to mother data: vertex faces, st faces, etc..
*
* When you will destruct mother object, all faces data will be deleted.
* When you will destruct non-mother object, all faces data will be NOT deleted.
*/
const u8 &isMother() const { return _isMother; };

const u8 &areFacesAllocated() const { return _areFacesAllocated; };

/** Set faces count and allocate memory. */
Expand All @@ -125,10 +160,16 @@ class MeshMaterial
u8 isInFrustum(Plane *t_frustumPlanes, const Vector3 &position);

private:
void setDefaultColor();
BoundingBox *boundingBoxObj;
u32 facesCount, id;
u32 *vertexFaces, *stFaces, *normalFaces;
u8 _isNameSet, _areFacesAllocated, _isBoundingBoxCalculated;
u8 _isMother,
_isNameSet,
_areFacesAllocated,
_isBoundingBoxCalculated,
_areSTsPresent,
_areNormalsPresent;
char *name;
};

Expand Down
51 changes: 21 additions & 30 deletions src/engine/include/models/texture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,18 @@ class Texture
/**
* Returns index of link.
* -1 if not found.
* @param t_id
* For 3D: Mesh material id.
* For 2D: Sprite id.
*/
const s32 getIndexOfLink(const u32 &t_meshId, const u32 &t_materialId) const
const s32 getIndexOfLink(const u32 &t_id) const
{
for (u32 i = 0; i < texLinks.size(); i++)
if (texLinks[i].materialId == t_materialId && texLinks[i].meshOrSpriteId == t_meshId)
if (texLinks[i].id == t_id)
return i;
return -1;
};

/**
* Returns index of link.
* -1 if not found.
*/
inline const s32 getIndexOfLink(const u32 &t_spriteId) const { return getIndexOfLink(t_spriteId, 0); };

// ----
// Setters
// ----
Expand Down Expand Up @@ -144,18 +141,15 @@ class Texture

const u8 &isSizeSet() const { return _isSizeSet; };

const u8 isLinkedWith(const u32 &t_meshId, const u32 &t_materialId) const
{
s32 index = getIndexOfLink(t_meshId, t_materialId);
if (index != -1)
return true;
else
return false;
};

const u8 isLinkedWith(const u32 &t_spriteId) const
/**
* Check if texture is linked with Mesh/Sprite.
* @param t_id
* For 3D: Mesh material id.
* For 2D: Sprite id.
*/
const u8 isLinkedWith(const u32 &t_id) const
{
s32 index = getIndexOfLink(t_spriteId);
s32 index = getIndexOfLink(t_id);
if (index != -1)
return true;
else
Expand All @@ -164,18 +158,15 @@ class Texture

void removeLinkByIndex(const u32 &t_index) { texLinks.erase(texLinks.begin() + t_index); }

void removeLinkBySprite(const u32 &t_spriteId)
{
s32 index = getIndexOfLink(t_spriteId);
if (index != -1)
removeLinkByIndex(index);
else
PRINT_ERR("Cant remove link, because it was not found!");
}

void removeLinkByMesh(const u32 &t_meshId, const u32 &t_materialId)
/**
* Remove texture link with given Mesh/Sprite.
* @param t_id
* For 3D: Mesh material id.
* For 2D: Sprite id.
*/
void removeLinkById(const u32 &t_id)
{
s32 index = getIndexOfLink(t_meshId, t_materialId);
s32 index = getIndexOfLink(t_id);
if (index != -1)
removeLinkByIndex(index);
else
Expand Down
9 changes: 5 additions & 4 deletions src/engine/include/models/texture_link.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@

struct TextureLink
{
/** Mesh id or sprite id */
u32 meshOrSpriteId;
/** Mesh material id or 0 if is sprite */
u32 materialId;
/**
* For 3D: Mesh material id.
* For 2D: Sprite id.
*/
u32 id;
};

#endif
1 change: 1 addition & 0 deletions src/engine/include/modules/audio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class Audio

private:
u8 songLoaded, volume, realVolume, songPlaying, songInLoop, songFinished;
u8 hack; // TODO
std::vector<AudioListenerRef *> songListeners;
FILE *wav;
audsrv_fmt_t format;
Expand Down
4 changes: 2 additions & 2 deletions src/engine/include/modules/gif_sender.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class GifSender
~GifSender();

void initPacket(u8 context);
void addObject(RenderData *t_renderData, Mesh &t_mesh, u32 vertexCount, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer);
void addObject(RenderData *t_renderData, Mesh &t_mesh, u32 vertexCount, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer, color_t *t_color);
void addClear(zbuffer_t *t_zBuffer, color_t *t_rgb);
void sendPacket();
void sendClear(zbuffer_t *t_zBuffer, color_t *t_rgb);
Expand All @@ -54,7 +54,7 @@ class GifSender
float halfScreenW, halfScreenH;
MATRIX localWorld, localScreen, localLight;

void calc3DObject(Matrix t_perspective, Mesh &t_mesh, u32 vertexCount, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, RenderData *t_renderData, LightBulb *t_bulbs, u16 t_bulbsCount);
void calc3DObject(Matrix t_perspective, Mesh &t_mesh, u32 vertexCount, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, RenderData *t_renderData, LightBulb *t_bulbs, u16 t_bulbsCount, color_t *t_color);
void convertCalcs(u32 t_vertCount, VECTOR *t_vertices, VECTOR *t_colors, VECTOR *t_sts, color_t &t_color);
void addCurrentCalcs(u32 &t_vertexCount);
};
Expand Down
Loading

0 comments on commit 7b2e411

Please sign in to comment.