mesh_texture refactoring #1
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <tamtypes.h>
|
#include <tamtypes.h>
|
||||||
#include "../models/texture.hpp"
|
#include "../models/mesh_texture.hpp"
|
||||||
|
|
||||||
/** Class responsible for loading images in bmp format */
|
/** Class responsible for loading images in bmp format */
|
||||||
class BmpLoader
|
class BmpLoader
|
||||||
@@ -23,7 +23,7 @@ public:
|
|||||||
BmpLoader();
|
BmpLoader();
|
||||||
~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
|
#endif
|
||||||
|
|||||||
@@ -16,6 +16,12 @@
|
|||||||
#include "math/vector3.hpp"
|
#include "math/vector3.hpp"
|
||||||
#include "./mesh_material.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
|
class MeshFrame
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,9 @@
|
|||||||
|
|
||||||
#include <tamtypes.h>
|
#include <tamtypes.h>
|
||||||
|
|
||||||
/** Class which contains draw data for mesh part.
|
/** Class which contains draw instructions for part mesh of mesh.
|
||||||
* Mesh can have many materials.
|
* Mesh can have many materials.
|
||||||
* For example, car can have three materials:
|
* For example, car mesh can have three materials:
|
||||||
* body, tires and windows.
|
* body, tires and windows.
|
||||||
*/
|
*/
|
||||||
class MeshMaterial
|
class MeshMaterial
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
#define _TYRA_OBJECT3D_SPEC_
|
#define _TYRA_OBJECT3D_SPEC_
|
||||||
|
|
||||||
#include "math/vector3.hpp"
|
#include "math/vector3.hpp"
|
||||||
#include "./texture.hpp"
|
#include "./mesh_texture.hpp"
|
||||||
#include <tamtypes.h>
|
#include <tamtypes.h>
|
||||||
#include <draw_buffers.h>
|
#include <draw_buffers.h>
|
||||||
#include <draw_sampling.h>
|
#include <draw_sampling.h>
|
||||||
@@ -30,7 +30,7 @@ public:
|
|||||||
|
|
||||||
void allocateMemory();
|
void allocateMemory();
|
||||||
void setupLodAndClut();
|
void setupLodAndClut();
|
||||||
Texture *textures;
|
MeshTexture *textures;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
# ______ ____ ___
|
||||||
|
# | \/ ____| |___|
|
||||||
|
# | | | \ | |
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||||
|
# Licenced under Apache License 2.0
|
||||||
|
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TYRA_MESH_TEXTURE_
|
||||||
|
#define _TYRA_MESH_TEXTURE_
|
||||||
|
|
||||||
|
#include <tamtypes.h>
|
||||||
|
#include <draw_sampling.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
@@ -11,16 +11,6 @@
|
|||||||
#ifndef _TYRA_TEXTURE_
|
#ifndef _TYRA_TEXTURE_
|
||||||
#define _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
|
#endif
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "../models/screen_settings.hpp"
|
#include "../models/screen_settings.hpp"
|
||||||
#include "../models/light_bulb.hpp"
|
#include "../models/light_bulb.hpp"
|
||||||
#include "../models/render_data.hpp"
|
#include "../models/render_data.hpp"
|
||||||
|
#include "../models/mesh_texture.hpp"
|
||||||
|
|
||||||
/** Class responsible for sending data packets via GIF (PATH3) */
|
/** Class responsible for sending data packets via GIF (PATH3) */
|
||||||
class GifSender
|
class GifSender
|
||||||
@@ -36,7 +37,7 @@ public:
|
|||||||
void addClear(zbuffer_t *t_zBuffer);
|
void addClear(zbuffer_t *t_zBuffer);
|
||||||
void sendPacket();
|
void sendPacket();
|
||||||
void sendClear(zbuffer_t *t_zBuffer);
|
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:
|
private:
|
||||||
xyz_t *xyz;
|
xyz_t *xyz;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ BmpLoader::~BmpLoader() {}
|
|||||||
* @param t_name Without extension. Example "skyfall2"
|
* @param t_name Without extension. Example "skyfall2"
|
||||||
* @param t_extension With dot and extension. Example ".BMP"
|
* @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_part = String::createConcatenated(t_subfolder, t_name);
|
||||||
char *t_path = String::createConcatenated(t_path_part, t_extension);
|
char *t_path = String::createConcatenated(t_path_part, t_extension);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "../include/loaders/md2_loader.hpp"
|
#include "../include/loaders/md2_loader.hpp"
|
||||||
#include "../include/loaders/dff_loader.hpp"
|
#include "../include/loaders/dff_loader.hpp"
|
||||||
#include "../include/loaders/bmp_loader.hpp"
|
#include "../include/loaders/bmp_loader.hpp"
|
||||||
|
#include "../include/models/mesh_texture.hpp"
|
||||||
#include "../include/utils/debug.hpp"
|
#include "../include/utils/debug.hpp"
|
||||||
#include "../include/utils/string.hpp"
|
#include "../include/utils/string.hpp"
|
||||||
|
|
||||||
@@ -178,7 +179,7 @@ void Mesh::loadTextures(char *t_subfolder, char *t_extension)
|
|||||||
BmpLoader bmpLoader = BmpLoader();
|
BmpLoader bmpLoader = BmpLoader();
|
||||||
if (isObjLoaded)
|
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++)
|
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);
|
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)
|
else if (isMd2Loaded)
|
||||||
{
|
{
|
||||||
spec->textures = new Texture[1];
|
spec->textures = new MeshTexture[1];
|
||||||
bmpLoader.load(spec->textures[0], t_subfolder, md2->filename, t_extension);
|
bmpLoader.load(spec->textures[0], t_subfolder, md2->filename, t_extension);
|
||||||
setDefaultWrapSettings(spec->textures[0].wrapSettings);
|
setDefaultWrapSettings(spec->textures[0].wrapSettings);
|
||||||
}
|
}
|
||||||
else if (isDffLoaded)
|
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 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++)
|
for (u8 j = 0; j < dff->clump.geometryList.geometries[0].materialList.materials[i].data.textureCount; j++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../include/models/mesh_texture.hpp"
|
||||||
|
#include "../include/utils/debug.hpp"
|
||||||
|
|
||||||
|
// ----
|
||||||
|
// Constructors/Destructors
|
||||||
|
// ----
|
||||||
|
|
||||||
|
MeshTexture::MeshTexture()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
MeshTexture::~MeshTexture()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----
|
||||||
|
// Methods
|
||||||
|
// ----
|
||||||
@@ -51,7 +51,7 @@ GifSender::~GifSender()
|
|||||||
#include <gs_gp.h>
|
#include <gs_gp.h>
|
||||||
|
|
||||||
/** Send texture via GIF */
|
/** 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;
|
const u16 packetSize = 40;
|
||||||
packet_t *packet = packet_init(packetSize, PACKET_NORMAL);
|
packet_t *packet = packet_init(packetSize, PACKET_NORMAL);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ EE_OBJS = \
|
|||||||
../../engine/models/mesh_material.o \
|
../../engine/models/mesh_material.o \
|
||||||
../../engine/models/mesh.o \
|
../../engine/models/mesh.o \
|
||||||
../../engine/models/mesh_spec.o \
|
../../engine/models/mesh_spec.o \
|
||||||
|
../../engine/models/mesh_texture.o \
|
||||||
../../engine/models/obj_model.o \
|
../../engine/models/obj_model.o \
|
||||||
../../engine/modules/audio.o \
|
../../engine/modules/audio.o \
|
||||||
../../engine/modules/camera_base.o \
|
../../engine/modules/camera_base.o \
|
||||||
|
|||||||
Reference in New Issue
Block a user