diff --git a/.gitignore b/.gitignore index 11ec5ab..16c10ff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .vscode/ *.[Bb][Mm][Pp] +*.[Pp][Nn][Gg] *.[Oo][Bb][Jj] *.[Ww][Aa][Vv] *.[Dd][Ff][Ff] diff --git a/src/engine/include/models/math/point.hpp b/src/engine/include/models/math/point.hpp index 3ef83a9..f12c690 100644 --- a/src/engine/include/models/math/point.hpp +++ b/src/engine/include/models/math/point.hpp @@ -32,6 +32,7 @@ public: ~Point(); void set(const float &t_x, const float &t_y); + void rotate(const float &t_angle, const float &t_x, const float &t_y); void set(const Point &v); const void print() const; }; diff --git a/src/engine/include/models/mesh_texture.hpp b/src/engine/include/models/mesh_texture.hpp index e237d57..9d91298 100644 --- a/src/engine/include/models/mesh_texture.hpp +++ b/src/engine/include/models/mesh_texture.hpp @@ -17,6 +17,13 @@ #include "./texture_link.hpp" #include "../include/utils/debug.hpp" #include +#include + +enum TextureType +{ + TEX_TYPE_RGB = GS_PSM_24, // BMP + TEX_TYPE_RGBA = GS_PSM_32 // PNG +}; /** * Class which contains texture data. @@ -46,15 +53,17 @@ public: const u8 &getHeight() const { return height; }; + const TextureType &getType() const { return _type; }; + u32 getTextureLinksCount() const { return static_cast(texLinks.size()); }; texwrap_t *getWrapSettings() { return &wrapSettings; }; /** - * Returns always width * width * 3. - * 3 because of RGB + * Returns always width * width * 3/4. + * 3 for RGB, 4 for RGBA. */ - u32 getDataSize() const { return width * height * 3; }; + u32 getDataSize() const { return _type == TEX_TYPE_RGB ? width * height * 3 : width * height * 4; }; /** * Texture data, used by renderer. @@ -83,6 +92,12 @@ public: 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 // ---- @@ -92,7 +107,7 @@ public: * Do not call this method unless you know what you do. * Should be called by data loader. */ - void setSize(const u8 &t_width, const u8 &t_height); + void setSize(const u8 &t_width, const u8 &t_height, const TextureType &t_type); /** * Do not call this method unless you know what you do. @@ -101,8 +116,8 @@ public: void setHeight(const u8 &t_val) { height = t_val; } /** - * Set texture name. - * Should be the file name without extension + * Do not call this method unless you know what you do. + * Should be called by data loader. */ void setData(const u32 &t_index, const unsigned char &t_val) { data[t_index] = t_val; } @@ -119,9 +134,12 @@ public: // Other // ---- - /** Assign texture to mesh and mesh material */ + /** Assign texture to mesh and mesh material. */ void addLink(const u32 &t_meshId, const u32 &t_materialId); + /** Assign texture to sprite. */ + void addLink(const u32 &t_spriteId); + const u8 &isNameSet() const { return _isNameSet; }; const u8 &isSizeSet() const { return _isSizeSet; }; @@ -135,13 +153,31 @@ public: return false; }; - void removeLink(const u32 &t_index) { texLinks.erase(texLinks.begin() + t_index); } + const u8 isLinkedWith(const u32 &t_spriteId) const + { + s32 index = getIndexOfLink(t_spriteId); + if (index != -1) + return true; + else + return false; + }; - void removeLink(const u32 &t_meshId, const u32 &t_materialId) + 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) { s32 index = getIndexOfLink(t_meshId, t_materialId); if (index != -1) - removeLink(index); + removeLinkByIndex(index); else PRINT_ERR("Cant remove link, because it was not found!"); } @@ -150,6 +186,7 @@ private: void setDefaultWrapSettings(); texwrap_t wrapSettings; char *name; + TextureType _type; std::vector texLinks; u32 id; u8 width, height, _isNameSet, _isSizeSet; diff --git a/src/engine/include/models/sprite.hpp b/src/engine/include/models/sprite.hpp new file mode 100644 index 0000000..14772c5 --- /dev/null +++ b/src/engine/include/models/sprite.hpp @@ -0,0 +1,67 @@ +/* +# ______ ____ ___ +# | \/ ____| |___| +# | | | \ | | +#----------------------------------------------------------------------- +# Copyright 2020, tyra - https://github.com/h4570/tyra +# Licenced under Apache License 2.0 +# Sandro Sobczyński +*/ + +#ifndef _TYRA_SPRITE_ +#define _TYRA_SPRITE_ + +#include +#include +#include + +/** + * Class which have contain 2D image data. + */ +class Sprite +{ + +public: + Sprite(); + ~Sprite(); + + Point position, size; + float scale; + color_t color; + clutbuffer_t clut; + + // ---- + // Getters + // ---- + + /** Auto generated unique Id. */ + inline const u32 &getId() const { return id; }; + + // ---- + // Setters + // ---- + + // ---- + // Other + // ---- + + /** Flip texture horizontally. */ + inline void flipHorizontally(const u8 &t_set) { _flipH = t_set; }; + + /** Flip texture vertically. */ + inline void flipVertically(const u8 &t_set) { _flipV = t_set; }; + + /** Check if texture is vertically flipped. */ + inline const u8 &isFlippedVertically() const { return _flipV; }; + + /** Check if texture is horizontally flipped. */ + inline const u8 &isFlippedHorizontally() const { return _flipH; }; + +private: + u32 id; + u8 _isSizeSet, _flipH, _flipV; + void setDefaultColor(); + void setDefaultLODAndClut(); +}; + +#endif diff --git a/src/engine/include/models/texture_link.hpp b/src/engine/include/models/texture_link.hpp index c0f363d..ee7d309 100644 --- a/src/engine/include/models/texture_link.hpp +++ b/src/engine/include/models/texture_link.hpp @@ -15,7 +15,10 @@ struct TextureLink { - u32 meshId, materialId; + /** Mesh id or sprite id */ + u32 meshId; + /** Mesh material id or 0 if is sprite */ + u32 materialId; }; #endif diff --git a/src/engine/include/modules/renderer.hpp b/src/engine/include/modules/renderer.hpp index 3aa3b07..b3657ce 100644 --- a/src/engine/include/modules/renderer.hpp +++ b/src/engine/include/modules/renderer.hpp @@ -17,6 +17,7 @@ #include "gif_sender.hpp" #include "vif_sender.hpp" #include "../models/math/plane.hpp" +#include "../models/sprite.hpp" #include "../models/screen_settings.hpp" #include "../models/render_data.hpp" #include "./texture_repository.hpp" @@ -39,6 +40,8 @@ public: /// --- Draw: PATH3 + void draw(Sprite &t_sprite); + /** * Draw many meshes with lighting information. * Slowest way of rendering (PATH 3, using EE and GIF). @@ -103,14 +106,12 @@ public: TextureRepository *getTextureRepository() { return &textureRepo; }; - void drawRectangle(); - private: - void changeTexture(const Mesh &t_mesh, u32 t_materialId); + void changeTexture(MeshTexture *t_tex); u32 lastTextureId; texbuffer_t textureBuffer; u8 isTextureVRAMAllocated, isVSyncEnabled; - void allocateTextureBuffer(u16 t_width, u16 t_height); + void allocateTextureBuffer(MeshTexture *t_texture); void deallocateTextureBuffer(); void flipBuffers(); void beginFrameIfNeeded(); diff --git a/src/engine/include/modules/texture_repository.hpp b/src/engine/include/modules/texture_repository.hpp index 659d1e7..ded7eaa 100644 --- a/src/engine/include/modules/texture_repository.hpp +++ b/src/engine/include/modules/texture_repository.hpp @@ -17,6 +17,13 @@ #include "../models/mesh.hpp" #include "../models/mesh_frame.hpp" #include "../loaders/bmp_loader.hpp" +#include "../loaders/png_loader.hpp" + +enum TextureFormat +{ + BMP, + PNG +}; /** Class responsible for intializing draw env, textures and buffers */ class TextureRepository @@ -35,6 +42,18 @@ public: u32 getTexturesCount() const { return static_cast(textures.size()); }; + /** + * Returns single texture. + * NULL if not found. + */ + MeshTexture *getBySprite(const u32 &t_spriteId) + { + for (u32 i = 0; i < textures.size(); i++) + if (textures[i]->isLinkedWith(t_spriteId)) + return textures[i]; + return NULL; + } + /** * Returns single texture. * NULL if not found. @@ -79,20 +98,22 @@ public: // Other // ---- - /** Add unlinked texture. - * NOTICE: BMP (RGB 888 24bit, without color information) is suppored only! + /** + * Add unlinked texture. * @param t_subfolder Relative path. Ex.: "textures/" * @param t_name Filename without extension. Ex.: "water" - * + * @param t_format if you want to use BMP, be sure that you have + * BMP with RGB 888 24bit, without color information. */ - MeshTexture *add(char *t_subfolder, char *t_name); + MeshTexture *add(char *t_subfolder, char *t_name, TextureFormat t_format); /** * Add linked textures in given subpath for mesh material names. - * NOTICE: BMP (RGB 888 24bit, without color information) is suppored only! - * @param t_path Relative path where textures should be searched + * @param t_path Relative path where textures should be searched. + * @param t_format if you want to use BMP, be sure that you have + * BMP with RGB 888 24bit, without color information. */ - void addByMesh(char *t_path, Mesh &mesh); + void addByMesh(char *t_path, Mesh &mesh, TextureFormat t_format); /** * Remove texture from repository. @@ -115,7 +136,8 @@ public: private: std::vector textures; - BmpLoader loader; + BmpLoader bmpLoader; + PngLoader pngLoader; }; #endif diff --git a/src/engine/loaders/bmp_loader.cpp b/src/engine/loaders/bmp_loader.cpp index 3eaa753..1be56f8 100644 --- a/src/engine/loaders/bmp_loader.cpp +++ b/src/engine/loaders/bmp_loader.cpp @@ -50,10 +50,8 @@ void BmpLoader::load(MeshTexture &o_texture, char *t_subfolder, char *t_name, ch u32 width = (u32)header[18]; u32 height = (u32)header[22]; - o_texture.setSize(width, height); + o_texture.setSize(width, height, TEX_TYPE_RGB); printf("BMPLoader - width: %d | height: %d\n", width, height); - if (width > 128 || height > 128) - PRINT_ERR("Given texture is big for PS2. Please strict to 128x128 max"); u64 rowPadded = (width * 3 + 3) & (~3); diff --git a/src/engine/models/math/point.cpp b/src/engine/models/math/point.cpp index ef6caa5..fa94652 100644 --- a/src/engine/models/math/point.cpp +++ b/src/engine/models/math/point.cpp @@ -9,6 +9,7 @@ */ #include "../../include/models/math/point.hpp" +#include "../../include/utils/math.hpp" #include @@ -55,6 +56,21 @@ void Point::set(const Point &v) y = v.y; } +void Point::rotate(const float &t_angle, const float &t_x, const float &t_y) +{ + float s = Math::sin(t_angle); + float c = Math::cos(t_angle); + + x -= t_x; + y -= t_y; + + float xnew = x * c - y * s; + float ynew = x * s + y * c; + + x = xnew + t_x; + y = ynew + t_y; +} + const void Point::print() const { printf("Point(%f, %f)\n", x, y); diff --git a/src/engine/models/mesh_texture.cpp b/src/engine/models/mesh_texture.cpp index f47f44f..a7dea89 100644 --- a/src/engine/models/mesh_texture.cpp +++ b/src/engine/models/mesh_texture.cpp @@ -39,15 +39,18 @@ MeshTexture::~MeshTexture() // Methods // ---- -void MeshTexture::setSize(const u8 &t_width, const u8 &t_height) +void MeshTexture::setSize(const u8 &t_width, const u8 &t_height, const TextureType &t_type) { if (_isSizeSet) { PRINT_ERR("Can't set size, because was already set!"); return; } + if (t_width > 256 || t_height > 256) + PRINT_ERR("Given texture can be too big for PS2. Please strict to 256x256 max. Prefer 128x128."); width = t_width; height = t_height; + _type = t_type; data = new unsigned char[getDataSize()]; _isSizeSet = true; } @@ -86,3 +89,11 @@ void MeshTexture::addLink(const u32 &t_meshId, const u32 &t_materialId) link.meshId = t_meshId; texLinks.push_back(link); } + +void MeshTexture::addLink(const u32 &t_spriteId) +{ + TextureLink link; + link.materialId = 0; + link.meshId = t_spriteId; + texLinks.push_back(link); +} diff --git a/src/engine/models/sprite.cpp b/src/engine/models/sprite.cpp new file mode 100644 index 0000000..160d8c5 --- /dev/null +++ b/src/engine/models/sprite.cpp @@ -0,0 +1,55 @@ +/* +# ______ ____ ___ +# | \/ ____| |___| +# | | | \ | | +#----------------------------------------------------------------------- +# Copyright 2020, tyra - https://github.com/h4570/tyra +# Licenced under Apache License 2.0 +# Sandro Sobczyński +*/ + +#include "../include/models/sprite.hpp" +#include "../include/utils/debug.hpp" +#include "../include/utils/string.hpp" +#include + +// ---- +// Constructors/Destructors +// ---- + +Sprite::Sprite() +{ + id = rand() % 1000000; + _isSizeSet = false; + _flipH = false; + _flipV = false; + scale = 1.0F; + setDefaultColor(); + setDefaultLODAndClut(); +} + +Sprite::~Sprite() {} + +// ---- +// Methods +// ---- + +/** Set's default object color + no transparency */ +void Sprite::setDefaultColor() +{ + color.r = 0x80; + color.g = 0x80; + color.b = 0x80; + color.a = 0x80; + color.q = 0.0F; +} + +/** Sets texture level of details settings and CLUT settings */ +void Sprite::setDefaultLODAndClut() +{ + clut.storage_mode = CLUT_STORAGE_MODE1; + clut.start = 0; + clut.psm = 0; + clut.load_method = CLUT_NO_LOAD; + clut.address = 0; +} diff --git a/src/engine/modules/renderer.cpp b/src/engine/modules/renderer.cpp index dd43e6a..800b403 100644 --- a/src/engine/modules/renderer.cpp +++ b/src/engine/modules/renderer.cpp @@ -59,16 +59,16 @@ Renderer::~Renderer() {} // ---- /** Configure and allocate vRAM for texture buffer */ -void Renderer::allocateTextureBuffer(u16 t_width, u16 t_height) +void Renderer::allocateTextureBuffer(MeshTexture *t_texture) { - textureBuffer.width = t_width; - textureBuffer.psm = GS_PSM_24; - textureBuffer.address = graph_vram_allocate(t_width, t_height, GS_PSM_24, GRAPH_ALIGN_BLOCK); + textureBuffer.width = t_texture->getWidth(); + textureBuffer.psm = t_texture->getType(); + textureBuffer.info.components = textureBuffer.psm == TEX_TYPE_RGBA ? TEXTURE_COMPONENTS_RGBA : TEXTURE_COMPONENTS_RGB; + textureBuffer.address = graph_vram_allocate(t_texture->getWidth(), t_texture->getHeight(), textureBuffer.psm, GRAPH_ALIGN_BLOCK); if (textureBuffer.address <= 1) PRINT_ERR("Texture buffer allocation error. No memory!"); - textureBuffer.info.width = draw_log2(t_width); - textureBuffer.info.height = draw_log2(t_height); - textureBuffer.info.components = TEXTURE_COMPONENTS_RGB; + textureBuffer.info.width = draw_log2(t_texture->getWidth()); + textureBuffer.info.height = draw_log2(t_texture->getHeight()); textureBuffer.info.function = TEXTURE_FUNCTION_MODULATE; isTextureVRAMAllocated = true; } @@ -83,47 +83,47 @@ void Renderer::deallocateTextureBuffer() } } -void Renderer::changeTexture(const Mesh &t_mesh, u32 t_materialId) +void Renderer::changeTexture(MeshTexture *t_tex) { - - MeshTexture *tex = textureRepo.getByMesh(t_mesh.getId(), t_materialId); - if (tex != NULL) + if (t_tex != NULL) { - if (tex->getId() != lastTextureId) + if (t_tex->getId() != lastTextureId) { - lastTextureId = tex->getId(); + lastTextureId = t_tex->getId(); deallocateTextureBuffer(); - allocateTextureBuffer(tex->getWidth(), tex->getHeight()); - GifSender::sendTexture(*tex, &textureBuffer); + allocateTextureBuffer(t_tex); + GifSender::sendTexture(*t_tex, &textureBuffer); } } else PRINT_ERR("Texture was not found in texture repository!"); } -void Renderer::drawRectangle() +void Renderer::draw(Sprite &t_sprite) { + texrect_t rect; + rect.t0.s = t_sprite.isFlippedHorizontally() ? 128.0F : 0.0F; + rect.t0.t = t_sprite.isFlippedVertically() ? 128.0F : 0.0F; + rect.t1.s = t_sprite.isFlippedHorizontally() ? 0.0F : 128.0F; + rect.t1.t = t_sprite.isFlippedVertically() ? 0.0F : 128.0F; + rect.color.r = t_sprite.color.r; + rect.color.g = t_sprite.color.g; + rect.color.b = t_sprite.color.b; + rect.color.a = t_sprite.color.a; + rect.color.q = 0; + rect.v0.x = t_sprite.position.x; + rect.v0.y = t_sprite.position.y; + rect.v0.z = (u32)-1; + rect.v1.x = (t_sprite.size.x * t_sprite.scale) + t_sprite.position.x; + rect.v1.y = (t_sprite.size.y * t_sprite.scale) + t_sprite.position.y; + rect.v1.z = (u32)-1; beginFrameIfNeeded(); - packet2_t *packet2 = packet2_create(20, P2_TYPE_NORMAL, P2_MODE_NORMAL, 0); + changeTexture(textureRepo.getBySprite(t_sprite.getId())); + packet2_t *packet2 = packet2_create(12, P2_TYPE_NORMAL, P2_MODE_NORMAL, 0); packet2_update(packet2, draw_primitive_xyoffset(packet2->next, 0, 2048, 2048)); - - int loop0 = 10; - - packet2_add_s64(packet2, GIF_SET_TAG(4, 0, 0, 0, GIF_FLG_PACKED, 1)); - packet2_add_s64(packet2, GIF_REG_AD); - - packet2_add_s64(packet2, GIF_SET_PRIM(6, 0, 0, 0, 0, 0, 0, 0, 0)); - packet2_add_s64(packet2, GIF_REG_PRIM); - - packet2_add_s64(packet2, GIF_SET_RGBAQ((loop0 * 10), 0, 255 - (loop0 * 10), 0x80, 0x3F800000)); - packet2_add_s64(packet2, GIF_REG_RGBAQ); - - packet2_add_s64(packet2, GIF_SET_XYZ(((loop0 * 20) << 4) + (2048 << 4), ((loop0 * 10) << 4) + (2048 << 4), -128)); - packet2_add_s64(packet2, GIF_REG_XYZ2); - - packet2_add_s64(packet2, GIF_SET_XYZ((((loop0 * 20) + 100) << 4) + (2048 << 4), (((loop0 * 10) + 100) << 4) + (2048 << 4), -128)); - packet2_add_s64(packet2, GIF_REG_XYZ2); - + packet2_utils_gif_add_set(packet2, 1); + packet2_utils_gs_add_texbuff_clut(packet2, &textureBuffer, &t_sprite.clut); + packet2_update(packet2, draw_rect_textured(packet2->next, 0, &rect)); packet2_update(packet2, draw_primitive_xyoffset( packet2->next, @@ -211,7 +211,8 @@ void Renderer::drawByPath3(Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount) { if (t_mesh.shouldBeFrustumCulled && !t_mesh.getMaterial(i).isInFrustum(renderData.frustumPlanes, t_mesh.position)) return; - changeTexture(t_mesh, t_mesh.getMaterial(i).getId()); + MeshTexture *tex = textureRepo.getByMesh(t_mesh.getId(), t_mesh.getMaterial(i).getId()); + changeTexture(tex); gifSender->initPacket(context); u32 vertCount = t_mesh.getMaterial(i).getFacesCount(); VECTOR *vertices = new VECTOR[vertCount]; @@ -258,7 +259,8 @@ void Renderer::draw(Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount) VECTOR __attribute__((aligned(16))) vertices[vertCount]; VECTOR __attribute__((aligned(16))) normals[vertCount]; VECTOR __attribute__((aligned(16))) coordinates[vertCount]; - changeTexture(t_mesh, t_mesh.getMaterial(i).getId()); + MeshTexture *tex = textureRepo.getByMesh(t_mesh.getId(), t_mesh.getMaterial(i).getId()); + changeTexture(tex); vertCount = t_mesh.getDrawData(i, vertices, normals, coordinates, rotatedCamera); vifSender->drawMesh(&renderData, perspective, vertCount, vertices, normals, coordinates, t_mesh, t_bulbs, t_bulbsCount, &textureBuffer); } diff --git a/src/engine/modules/texture_repository.cpp b/src/engine/modules/texture_repository.cpp index 255afc6..036ee25 100644 --- a/src/engine/modules/texture_repository.cpp +++ b/src/engine/modules/texture_repository.cpp @@ -35,21 +35,27 @@ TextureRepository::~TextureRepository() // Methods // ---- -MeshTexture *TextureRepository::add(char *t_subfolder, char *t_name) +MeshTexture *TextureRepository::add(char *t_subfolder, char *t_name, TextureFormat t_format) { MeshTexture *texture = new MeshTexture(); - loader.load(*texture, t_subfolder, t_name, ".bmp"); + if (t_format == BMP) + bmpLoader.load(*texture, t_subfolder, t_name, ".bmp"); + else + pngLoader.load(*texture, t_subfolder, t_name, ".png"); texture->setName(t_name); textures.push_back(texture); return texture; } -void TextureRepository::addByMesh(char *t_path, Mesh &mesh) +void TextureRepository::addByMesh(char *t_path, Mesh &mesh, TextureFormat t_format) { for (u32 i = 0; i < mesh.getMaterialsCount(); i++) { MeshTexture *texture = new MeshTexture(); - loader.load(*texture, t_path, mesh.getMaterial(i).getName(), ".bmp"); + if (t_format == BMP) + bmpLoader.load(*texture, t_path, mesh.getMaterial(i).getName(), ".bmp"); + else + pngLoader.load(*texture, t_path, mesh.getMaterial(i).getName(), ".png"); texture->setName(mesh.getMaterial(i).getName()); texture->addLink(mesh.getId(), mesh.getMaterial(i).getId()); textures.push_back(texture); diff --git a/src/samples/ari/Makefile b/src/samples/ari/Makefile index e06585d..e7e0d88 100644 --- a/src/samples/ari/Makefile +++ b/src/samples/ari/Makefile @@ -8,6 +8,7 @@ EE_OBJS = \ ../../engine/models/mesh_frame.o \ ../../engine/models/mesh_material.o \ ../../engine/models/mesh.o \ + ../../engine/models/sprite.o \ ../../engine/models/mesh_texture.o \ ../../engine/modules/audio.o \ ../../engine/modules/camera_base.o \ @@ -25,6 +26,7 @@ EE_OBJS = \ ../../engine/loaders/dff_loader.o \ ../../engine/loaders/md2_loader.o \ ../../engine/loaders/obj_loader.o \ + ../../engine/loaders/png_loader.o \ ../../engine/vu1_progs/draw3D.o \ ../../engine/engine.o \ camera.o \ @@ -32,8 +34,11 @@ EE_OBJS = \ ari.o \ main.o -EE_LIBS = -ldraw -lgraph -lmath3d -lpacket -ldma -lpacket2 -lpad -laudsrv -lc -lstdc++ -EE_INCS := -I./../../engine/include $(EE_INCS) +EE_LIBS = -ldraw -lgraph -lmath3d -lpacket -ldma -lpacket2 -lpad -laudsrv -lc -lstdc++ -lpng -lz +EE_INCS := -I./../../engine/include -I$(PS2SDK)/ports/include $(EE_INCS) +EE_LDFLAGS := -L$(PS2SDK)/ports/lib $(EE_LDFLAGS) +EE_CFLAGS := -DHAVE_LIBPNG -DHAVE_ZLIB $(EE_CFLAGS) +EE_CXXFLAGS := -DHAVE_LIBPNG -DHAVE_ZLIB $(EE_CXXFLAGS) EE_DVP = dvp-as EE_VCL = vcl diff --git a/src/samples/ari/ari.cpp b/src/samples/ari/ari.cpp index bfdf545..505b19b 100644 --- a/src/samples/ari/ari.cpp +++ b/src/samples/ari/ari.cpp @@ -48,6 +48,10 @@ void Ari::onInit() island.shouldBeBackfaceCulled = true; island.shouldBeFrustumCulled = false; + fist.size.set(100.0F, 100.0F); + MeshTexture *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; @@ -58,7 +62,7 @@ void Ari::onInit() waterFloors[0].loadObj("water/", "water", 5.0F, false); waterFloors[0].position.set(0.0F, 8.0F, 0.0F); - texRepo->addByMesh("water/", waterFloors[0]); + texRepo->addByMesh("water/", waterFloors[0], BMP); for (u8 i = 0; i < WATER_TILES_COUNT; i++) { spirals[i].x = 1.0F; @@ -74,11 +78,11 @@ void Ari::onInit() ->addLink(waterFloors[i].getId(), waterFloors[i].getMaterial(0).getId()); } - texRepo->addByMesh("sunnyisl/", island); - texRepo->addByMesh("sunnyisl/", islandAddons); - texRepo->addByMesh("skybox/", skybox); - texRepo->addByMesh("ari/", player.mesh); - engine->audio.playSong(); + 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() @@ -98,8 +102,8 @@ void Ari::onUpdate() if (engine->pad.isCircleClicked) engine->audio.playADPCM(adpcm2); camera.update(engine->pad, player.mesh); - engine->renderer->drawRectangle(); engine->renderer->draw(skybox); + engine->renderer->draw(fist); engine->renderer->draw(island); engine->renderer->draw(islandAddons); engine->renderer->draw(player.mesh); diff --git a/src/samples/ari/ari.hpp b/src/samples/ari/ari.hpp index 1f88735..549d7dc 100644 --- a/src/samples/ari/ari.hpp +++ b/src/samples/ari/ari.hpp @@ -17,6 +17,7 @@ #include #include "objects/player.hpp" #include +#include #include #include "./camera.hpp" @@ -39,6 +40,7 @@ private: Player player; Mesh island, islandAddons, skybox; Mesh *waterFloors; + Sprite fist; audsrv_adpcm_t *adpcm1, *adpcm2; Point *spirals; Camera camera; diff --git a/src/samples/floors/Makefile b/src/samples/floors/Makefile index bb45494..269b5c7 100644 --- a/src/samples/floors/Makefile +++ b/src/samples/floors/Makefile @@ -8,6 +8,7 @@ EE_OBJS = \ ../../engine/models/mesh_frame.o \ ../../engine/models/mesh_material.o \ ../../engine/models/mesh.o \ + ../../engine/models/sprite.o \ ../../engine/models/mesh_texture.o \ ../../engine/modules/audio.o \ ../../engine/modules/camera_base.o \ @@ -25,6 +26,7 @@ EE_OBJS = \ ../../engine/loaders/dff_loader.o \ ../../engine/loaders/md2_loader.o \ ../../engine/loaders/obj_loader.o \ + ../../engine/loaders/png_loader.o \ ../../engine/vu1_progs/draw3D.o \ ../../engine/engine.o \ managers/light_manager.o \ @@ -36,10 +38,14 @@ EE_OBJS = \ floors.o \ main.o -EE_LIBS = -ldraw -lgraph -lmath3d -lpacket -ldma -lpad -lpacket2 -laudsrv -lc -lstdc++ -EE_INCS := -I./../../engine/include $(EE_INCS) +EE_LIBS = -ldraw -lgraph -lmath3d -lpacket -ldma -lpacket2 -lpad -laudsrv -lc -lstdc++ -lpng -lz +EE_INCS := -I./../../engine/include -I$(PS2SDK)/ports/include $(EE_INCS) +EE_LDFLAGS := -L$(PS2SDK)/ports/lib $(EE_LDFLAGS) +EE_CFLAGS := -DHAVE_LIBPNG -DHAVE_ZLIB $(EE_CFLAGS) +EE_CXXFLAGS := -DHAVE_LIBPNG -DHAVE_ZLIB $(EE_CXXFLAGS) EE_DVP = dvp-as -EE_VCL = openvcl +EE_VCL = vcl + all: $(EE_BIN) $(EE_STRIP) --strip-all $(EE_BIN)