diff --git a/src/engine/include/loaders/bmp_loader.hpp b/src/engine/include/loaders/bmp_loader.hpp index b386b64..b5d04c3 100644 --- a/src/engine/include/loaders/bmp_loader.hpp +++ b/src/engine/include/loaders/bmp_loader.hpp @@ -13,7 +13,7 @@ #include #include -#include "../models/texture.hpp" +#include "../models/mesh_texture.hpp" /** Class responsible for loading images in bmp format */ class BmpLoader @@ -23,7 +23,7 @@ public: BmpLoader(); ~BmpLoader(); - void load(Texture &o_texture, char *t_subfolder, char *t_name, char *t_extension); + void load(MeshTexture &o_texture, char *t_subfolder, char *t_name, char *t_extension); }; #endif diff --git a/src/engine/include/models/mesh_frame.hpp b/src/engine/include/models/mesh_frame.hpp index a5c0afa..bca6eff 100644 --- a/src/engine/include/models/mesh_frame.hpp +++ b/src/engine/include/models/mesh_frame.hpp @@ -16,6 +16,12 @@ #include "math/vector3.hpp" #include "./mesh_material.hpp" +/** + * Class which contains core mesh data + * which are needed for drawing. + * Static object (not animated), will have + * only one instance of this class. + */ class MeshFrame { diff --git a/src/engine/include/models/mesh_material.hpp b/src/engine/include/models/mesh_material.hpp index 027292c..66658fd 100644 --- a/src/engine/include/models/mesh_material.hpp +++ b/src/engine/include/models/mesh_material.hpp @@ -13,9 +13,9 @@ #include -/** Class which contains draw data for mesh part. +/** Class which contains draw instructions for part mesh of mesh. * Mesh can have many materials. - * For example, car can have three materials: + * For example, car mesh can have three materials: * body, tires and windows. */ class MeshMaterial diff --git a/src/engine/include/models/mesh_spec.hpp b/src/engine/include/models/mesh_spec.hpp index 514d2f4..64b8652 100644 --- a/src/engine/include/models/mesh_spec.hpp +++ b/src/engine/include/models/mesh_spec.hpp @@ -12,7 +12,7 @@ #define _TYRA_OBJECT3D_SPEC_ #include "math/vector3.hpp" -#include "./texture.hpp" +#include "./mesh_texture.hpp" #include #include #include @@ -30,7 +30,7 @@ public: void allocateMemory(); void setupLodAndClut(); - Texture *textures; + MeshTexture *textures; private: }; diff --git a/src/engine/include/models/mesh_texture.hpp b/src/engine/include/models/mesh_texture.hpp new file mode 100644 index 0000000..82324a1 --- /dev/null +++ b/src/engine/include/models/mesh_texture.hpp @@ -0,0 +1,53 @@ +/* +# ______ ____ ___ +# | \/ ____| |___| +# | | | \ | | +#----------------------------------------------------------------------- +# Copyright 2020, tyra - https://github.com/h4570/tyra +# Licenced under Apache License 2.0 +# Sandro Sobczyński +*/ + +#ifndef _TYRA_MESH_TEXTURE_ +#define _TYRA_MESH_TEXTURE_ + +#include +#include + +/** + * Class which contains texture data + * Textures are paired with material via material id. + * Additionaly, you can load two textures for single material + * and switch materialId here to change texture. + */ +class MeshTexture +{ + +public: + MeshTexture(); + ~MeshTexture(); + + // ---- + // Getters + // ---- + + // ---- + // Setters + // ---- + + // ---- + // Other + // ---- + + // TODO + + u32 id; + unsigned char *data; + texwrap_t wrapSettings; + char *name; + u8 width, height; + +private: +}; + +#endif diff --git a/src/engine/include/models/texture.hpp b/src/engine/include/models/texture.hpp index 1e607f8..5d27443 100644 --- a/src/engine/include/models/texture.hpp +++ b/src/engine/include/models/texture.hpp @@ -11,16 +11,6 @@ #ifndef _TYRA_TEXTURE_ #define _TYRA_TEXTURE_ -#include -#include -struct Texture -{ - u32 id; - unsigned char *data; - texwrap_t wrapSettings; - char *name; - u8 width, height; -}; #endif diff --git a/src/engine/include/modules/gif_sender.hpp b/src/engine/include/modules/gif_sender.hpp index 5350336..03e1d4e 100644 --- a/src/engine/include/modules/gif_sender.hpp +++ b/src/engine/include/modules/gif_sender.hpp @@ -22,6 +22,7 @@ #include "../models/screen_settings.hpp" #include "../models/light_bulb.hpp" #include "../models/render_data.hpp" +#include "../models/mesh_texture.hpp" /** Class responsible for sending data packets via GIF (PATH3) */ class GifSender @@ -36,7 +37,7 @@ public: void addClear(zbuffer_t *t_zBuffer); void sendPacket(); void sendClear(zbuffer_t *t_zBuffer); - static void sendTexture(Texture &texture, texbuffer_t *t_texBuffer); + static void sendTexture(MeshTexture &texture, texbuffer_t *t_texBuffer); private: xyz_t *xyz; diff --git a/src/engine/loaders/bmp_loader.cpp b/src/engine/loaders/bmp_loader.cpp index 983bc8a..503894a 100644 --- a/src/engine/loaders/bmp_loader.cpp +++ b/src/engine/loaders/bmp_loader.cpp @@ -30,7 +30,7 @@ BmpLoader::~BmpLoader() {} * @param t_name Without extension. Example "skyfall2" * @param t_extension With dot and extension. Example ".BMP" */ -void BmpLoader::load(Texture &o_texture, char *t_subfolder, char *t_name, char *t_extension) +void BmpLoader::load(MeshTexture &o_texture, char *t_subfolder, char *t_name, char *t_extension) { char *t_path_part = String::createConcatenated(t_subfolder, t_name); char *t_path = String::createConcatenated(t_path_part, t_extension); diff --git a/src/engine/models/mesh.cpp b/src/engine/models/mesh.cpp index aea4123..5a19074 100644 --- a/src/engine/models/mesh.cpp +++ b/src/engine/models/mesh.cpp @@ -14,6 +14,7 @@ #include "../include/loaders/md2_loader.hpp" #include "../include/loaders/dff_loader.hpp" #include "../include/loaders/bmp_loader.hpp" +#include "../include/models/mesh_texture.hpp" #include "../include/utils/debug.hpp" #include "../include/utils/string.hpp" @@ -178,7 +179,7 @@ void Mesh::loadTextures(char *t_subfolder, char *t_extension) BmpLoader bmpLoader = BmpLoader(); if (isObjLoaded) { - spec->textures = new Texture[obj->frames[0].getMaterialsCount()]; + spec->textures = new MeshTexture[obj->frames[0].getMaterialsCount()]; for (u8 i = 0; i < obj->frames[0].getMaterialsCount(); i++) { bmpLoader.load(spec->textures[i], t_subfolder, obj->frames[0].getMaterial(i).getName(), t_extension); @@ -187,13 +188,13 @@ void Mesh::loadTextures(char *t_subfolder, char *t_extension) } else if (isMd2Loaded) { - spec->textures = new Texture[1]; + spec->textures = new MeshTexture[1]; bmpLoader.load(spec->textures[0], t_subfolder, md2->filename, t_extension); setDefaultWrapSettings(spec->textures[0].wrapSettings); } else if (isDffLoaded) { - spec->textures = new Texture[dff->clump.geometryList.geometries[0].materialList.data.materialCount]; + spec->textures = new MeshTexture[dff->clump.geometryList.geometries[0].materialList.data.materialCount]; for (u8 i = 0; i < dff->clump.geometryList.geometries[0].materialList.data.materialCount; i++) for (u8 j = 0; j < dff->clump.geometryList.geometries[0].materialList.materials[i].data.textureCount; j++) { diff --git a/src/engine/models/mesh_texture.cpp b/src/engine/models/mesh_texture.cpp new file mode 100644 index 0000000..86fb8e5 --- /dev/null +++ b/src/engine/models/mesh_texture.cpp @@ -0,0 +1,28 @@ +/* +# ______ ____ ___ +# | \/ ____| |___| +# | | | \ | | +#----------------------------------------------------------------------- +# Copyright 2020, tyra - https://github.com/h4570/tyra +# Licenced under Apache License 2.0 +# Sandro Sobczyński +*/ + +#include "../include/models/mesh_texture.hpp" +#include "../include/utils/debug.hpp" + +// ---- +// Constructors/Destructors +// ---- + +MeshTexture::MeshTexture() +{ +} + +MeshTexture::~MeshTexture() +{ +} + +// ---- +// Methods +// ---- diff --git a/src/engine/modules/gif_sender.cpp b/src/engine/modules/gif_sender.cpp index 046b548..9361605 100644 --- a/src/engine/modules/gif_sender.cpp +++ b/src/engine/modules/gif_sender.cpp @@ -51,7 +51,7 @@ GifSender::~GifSender() #include /** Send texture via GIF */ -void GifSender::sendTexture(Texture &texture, texbuffer_t *t_texBuffer) +void GifSender::sendTexture(MeshTexture &texture, texbuffer_t *t_texBuffer) { const u16 packetSize = 40; packet_t *packet = packet_init(packetSize, PACKET_NORMAL); diff --git a/src/samples/ari/Makefile b/src/samples/ari/Makefile index 3e5f0a1..0f46ff9 100644 --- a/src/samples/ari/Makefile +++ b/src/samples/ari/Makefile @@ -11,6 +11,7 @@ EE_OBJS = \ ../../engine/models/mesh_material.o \ ../../engine/models/mesh.o \ ../../engine/models/mesh_spec.o \ + ../../engine/models/mesh_texture.o \ ../../engine/models/obj_model.o \ ../../engine/modules/audio.o \ ../../engine/modules/camera_base.o \