mesh_texture -> texture
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ EE_OBJS = \
|
||||
models/mesh_material.o \
|
||||
models/mesh.o \
|
||||
models/sprite.o \
|
||||
models/mesh_texture.o \
|
||||
models/texture.o \
|
||||
modules/audio.o \
|
||||
modules/camera_base.o \
|
||||
modules/file_service.o \
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <tamtypes.h>
|
||||
#include "../models/mesh_texture.hpp"
|
||||
#include "../models/texture.hpp"
|
||||
|
||||
/** Class responsible for loading images in bmp format */
|
||||
class BmpLoader
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
BmpLoader();
|
||||
~BmpLoader();
|
||||
|
||||
void load(MeshTexture &o_texture, char *t_subfolder, char *t_name, char *t_extension);
|
||||
void load(Texture &o_texture, char *t_subfolder, char *t_name, char *t_extension);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <tamtypes.h>
|
||||
#include "../models/mesh_texture.hpp"
|
||||
#include "../models/texture.hpp"
|
||||
|
||||
/** Class responsible for loading images in bmp format */
|
||||
class PngLoader
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
PngLoader();
|
||||
~PngLoader();
|
||||
|
||||
void load(MeshTexture &o_texture, char *t_subfolder, char *t_name, char *t_extension);
|
||||
void load(Texture &o_texture, char *t_subfolder, char *t_name, char *t_extension);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include "math/vector3.hpp"
|
||||
#include "math/plane.hpp"
|
||||
#include "./mesh_texture.hpp"
|
||||
#include "./texture.hpp"
|
||||
#include "./mesh_frame.hpp"
|
||||
#include <tamtypes.h>
|
||||
#include <draw_types.h>
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _TYRA_MESH_TEXTURE_
|
||||
#define _TYRA_MESH_TEXTURE_
|
||||
#ifndef _TYRA_TEXTURE_
|
||||
#define _TYRA_TEXTURE_
|
||||
|
||||
#include <tamtypes.h>
|
||||
#include <draw_sampling.h>
|
||||
@@ -27,15 +27,15 @@ enum TextureType
|
||||
|
||||
/**
|
||||
* Class which contains texture data.
|
||||
* Textures are paired with meshes via addLink() and
|
||||
* removeLink() functions which use meshId and materialId.
|
||||
* Textures are paired with meshes/sprites via addLink() and
|
||||
* removeLink() functions which use meshId/spriteId and materialId (for mesh).
|
||||
*/
|
||||
class MeshTexture
|
||||
class Texture
|
||||
{
|
||||
|
||||
public:
|
||||
MeshTexture();
|
||||
~MeshTexture();
|
||||
Texture();
|
||||
~Texture();
|
||||
|
||||
// ----
|
||||
// Getters
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
const s32 getIndexOfLink(const u32 &t_meshId, const u32 &t_materialId) const
|
||||
{
|
||||
for (u32 i = 0; i < texLinks.size(); i++)
|
||||
if (texLinks[i].materialId == t_materialId && texLinks[i].meshId == t_meshId)
|
||||
if (texLinks[i].materialId == t_materialId && texLinks[i].meshOrSpriteId == t_meshId)
|
||||
return i;
|
||||
return -1;
|
||||
};
|
||||
@@ -16,7 +16,7 @@
|
||||
struct TextureLink
|
||||
{
|
||||
/** Mesh id or sprite id */
|
||||
u32 meshId;
|
||||
u32 meshOrSpriteId;
|
||||
/** Mesh material id or 0 if is sprite */
|
||||
u32 materialId;
|
||||
};
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "../models/screen_settings.hpp"
|
||||
#include "../models/light_bulb.hpp"
|
||||
#include "../models/render_data.hpp"
|
||||
#include "../models/mesh_texture.hpp"
|
||||
#include "../models/texture.hpp"
|
||||
|
||||
/** Class responsible for sending data packets via GIF (PATH3) */
|
||||
class GifSender
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
void addClear(zbuffer_t *t_zBuffer);
|
||||
void sendPacket();
|
||||
void sendClear(zbuffer_t *t_zBuffer);
|
||||
static void sendTexture(MeshTexture &texture, texbuffer_t *t_texBuffer);
|
||||
static void sendTexture(Texture &texture, texbuffer_t *t_texBuffer);
|
||||
|
||||
private:
|
||||
xyz_t *xyz;
|
||||
|
||||
@@ -107,11 +107,11 @@ public:
|
||||
TextureRepository *getTextureRepository() { return &textureRepo; };
|
||||
|
||||
private:
|
||||
void changeTexture(MeshTexture *t_tex);
|
||||
void changeTexture(Texture *t_tex);
|
||||
u32 lastTextureId;
|
||||
texbuffer_t textureBuffer;
|
||||
u8 isTextureVRAMAllocated, isVSyncEnabled;
|
||||
void allocateTextureBuffer(MeshTexture *t_texture);
|
||||
void allocateTextureBuffer(Texture *t_texture);
|
||||
void deallocateTextureBuffer();
|
||||
void flipBuffers();
|
||||
void beginFrameIfNeeded();
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
// ----
|
||||
|
||||
/** Returns all repository textures. */
|
||||
std::vector<MeshTexture *> *getAll() { return &textures; }
|
||||
std::vector<Texture *> *getAll() { return &textures; }
|
||||
|
||||
u32 getTexturesCount() const { return static_cast<u32>(textures.size()); };
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
* Returns single texture.
|
||||
* NULL if not found.
|
||||
*/
|
||||
MeshTexture *getBySprite(const u32 &t_spriteId)
|
||||
Texture *getBySprite(const u32 &t_spriteId)
|
||||
{
|
||||
for (u32 i = 0; i < textures.size(); i++)
|
||||
if (textures[i]->isLinkedWith(t_spriteId))
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
* Returns single texture.
|
||||
* NULL if not found.
|
||||
*/
|
||||
MeshTexture *getByMesh(const u32 &t_meshId, const u32 &t_materialId)
|
||||
Texture *getByMesh(const u32 &t_meshId, const u32 &t_materialId)
|
||||
{
|
||||
for (u32 i = 0; i < textures.size(); i++)
|
||||
if (textures[i]->isLinkedWith(t_meshId, t_materialId))
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
* Returns single texture.
|
||||
* NULL if not found.
|
||||
*/
|
||||
MeshTexture *getByTextureId(const u32 &t_id) const
|
||||
Texture *getByTextureId(const u32 &t_id) const
|
||||
{
|
||||
for (u32 i = 0; i < textures.size(); i++)
|
||||
if (t_id == textures[i]->getId())
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
* @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, TextureFormat t_format);
|
||||
Texture *add(char *t_subfolder, char *t_name, TextureFormat t_format);
|
||||
|
||||
/**
|
||||
* Add linked textures in given subpath for mesh material names.
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<MeshTexture *> textures;
|
||||
std::vector<Texture *> textures;
|
||||
BmpLoader bmpLoader;
|
||||
PngLoader pngLoader;
|
||||
};
|
||||
|
||||
@@ -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(MeshTexture &o_texture, char *t_subfolder, char *t_name, char *t_extension)
|
||||
void BmpLoader::load(Texture &o_texture, char *t_subfolder, char *t_name, char *t_extension)
|
||||
{
|
||||
char *path_part1 = String::createConcatenated(t_subfolder, t_name);
|
||||
char *path_part2 = String::createConcatenated("host:", path_part1);
|
||||
|
||||
@@ -31,7 +31,7 @@ PngLoader::~PngLoader() {}
|
||||
* @param t_name Without extension. Example "skyfall2"
|
||||
* @param t_extension With dot and extension. Example ".png"
|
||||
*/
|
||||
void PngLoader::load(MeshTexture &o_texture, char *t_subfolder, char *t_name, char *t_extension)
|
||||
void PngLoader::load(Texture &o_texture, char *t_subfolder, char *t_name, char *t_extension)
|
||||
{
|
||||
char *path_part1 = String::createConcatenated(t_subfolder, t_name);
|
||||
char *path_part2 = String::createConcatenated("host:", path_part1);
|
||||
|
||||
@@ -13,7 +13,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/models/texture.hpp"
|
||||
#include "../include/utils/debug.hpp"
|
||||
#include "../include/utils/string.hpp"
|
||||
#include <cstdlib>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||
*/
|
||||
|
||||
#include "../include/models/mesh_texture.hpp"
|
||||
#include "../include/models/texture.hpp"
|
||||
#include "../include/utils/string.hpp"
|
||||
#include <cstdlib>
|
||||
#include <draw_sampling.h>
|
||||
@@ -17,7 +17,7 @@
|
||||
// Constructors/Destructors
|
||||
// ----
|
||||
|
||||
MeshTexture::MeshTexture()
|
||||
Texture::Texture()
|
||||
{
|
||||
id = rand() % 1000000;
|
||||
_isSizeSet = false;
|
||||
@@ -25,7 +25,7 @@ MeshTexture::MeshTexture()
|
||||
setDefaultWrapSettings();
|
||||
}
|
||||
|
||||
MeshTexture::~MeshTexture()
|
||||
Texture::~Texture()
|
||||
{
|
||||
if (getTextureLinksCount() > 0)
|
||||
texLinks.clear();
|
||||
@@ -39,7 +39,7 @@ MeshTexture::~MeshTexture()
|
||||
// Methods
|
||||
// ----
|
||||
|
||||
void MeshTexture::setSize(const u8 &t_width, const u8 &t_height, const TextureType &t_type)
|
||||
void Texture::setSize(const u8 &t_width, const u8 &t_height, const TextureType &t_type)
|
||||
{
|
||||
if (_isSizeSet)
|
||||
{
|
||||
@@ -55,7 +55,7 @@ void MeshTexture::setSize(const u8 &t_width, const u8 &t_height, const TextureTy
|
||||
_isSizeSet = true;
|
||||
}
|
||||
|
||||
void MeshTexture::setName(char *t_val)
|
||||
void Texture::setName(char *t_val)
|
||||
{
|
||||
if (_isNameSet)
|
||||
{
|
||||
@@ -66,7 +66,7 @@ void MeshTexture::setName(char *t_val)
|
||||
_isNameSet = true;
|
||||
}
|
||||
|
||||
void MeshTexture::setDefaultWrapSettings()
|
||||
void Texture::setDefaultWrapSettings()
|
||||
{
|
||||
wrapSettings.horizontal = WRAP_REPEAT;
|
||||
wrapSettings.vertical = WRAP_REPEAT;
|
||||
@@ -76,24 +76,24 @@ void MeshTexture::setDefaultWrapSettings()
|
||||
wrapSettings.minv = 0;
|
||||
}
|
||||
|
||||
void MeshTexture::setWrapSettings(const WrapSettings t_horizontal, const WrapSettings t_vertical)
|
||||
void Texture::setWrapSettings(const WrapSettings t_horizontal, const WrapSettings t_vertical)
|
||||
{
|
||||
wrapSettings.horizontal = t_horizontal;
|
||||
wrapSettings.vertical = t_vertical;
|
||||
}
|
||||
|
||||
void MeshTexture::addLink(const u32 &t_meshId, const u32 &t_materialId)
|
||||
void Texture::addLink(const u32 &t_meshId, const u32 &t_materialId)
|
||||
{
|
||||
TextureLink link;
|
||||
link.materialId = t_materialId;
|
||||
link.meshId = t_meshId;
|
||||
link.meshOrSpriteId = t_meshId;
|
||||
texLinks.push_back(link);
|
||||
}
|
||||
|
||||
void MeshTexture::addLink(const u32 &t_spriteId)
|
||||
void Texture::addLink(const u32 &t_spriteId)
|
||||
{
|
||||
TextureLink link;
|
||||
link.materialId = 0;
|
||||
link.meshId = t_spriteId;
|
||||
link.meshOrSpriteId = t_spriteId;
|
||||
texLinks.push_back(link);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ GifSender::~GifSender()
|
||||
#include <gs_gp.h>
|
||||
|
||||
/** Send texture via GIF */
|
||||
void GifSender::sendTexture(MeshTexture &texture, texbuffer_t *t_texBuffer)
|
||||
void GifSender::sendTexture(Texture &texture, texbuffer_t *t_texBuffer)
|
||||
{
|
||||
packet2_t *packet2 = packet2_create(15, P2_TYPE_NORMAL, P2_MODE_CHAIN, false);
|
||||
packet2_update(
|
||||
|
||||
@@ -59,7 +59,7 @@ Renderer::~Renderer() {}
|
||||
// ----
|
||||
|
||||
/** Configure and allocate vRAM for texture buffer */
|
||||
void Renderer::allocateTextureBuffer(MeshTexture *t_texture)
|
||||
void Renderer::allocateTextureBuffer(Texture *t_texture)
|
||||
{
|
||||
textureBuffer.width = t_texture->getWidth();
|
||||
textureBuffer.psm = t_texture->getType();
|
||||
@@ -83,7 +83,7 @@ void Renderer::deallocateTextureBuffer()
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::changeTexture(MeshTexture *t_tex)
|
||||
void Renderer::changeTexture(Texture *t_tex)
|
||||
{
|
||||
if (t_tex != NULL)
|
||||
{
|
||||
@@ -211,7 +211,7 @@ 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;
|
||||
MeshTexture *tex = textureRepo.getByMesh(t_mesh.getId(), t_mesh.getMaterial(i).getId());
|
||||
Texture *tex = textureRepo.getByMesh(t_mesh.getId(), t_mesh.getMaterial(i).getId());
|
||||
changeTexture(tex);
|
||||
gifSender->initPacket(context);
|
||||
u32 vertCount = t_mesh.getMaterial(i).getFacesCount();
|
||||
@@ -259,7 +259,7 @@ 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];
|
||||
MeshTexture *tex = textureRepo.getByMesh(t_mesh.getId(), t_mesh.getMaterial(i).getId());
|
||||
Texture *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);
|
||||
|
||||
@@ -35,9 +35,9 @@ TextureRepository::~TextureRepository()
|
||||
// Methods
|
||||
// ----
|
||||
|
||||
MeshTexture *TextureRepository::add(char *t_subfolder, char *t_name, TextureFormat t_format)
|
||||
Texture *TextureRepository::add(char *t_subfolder, char *t_name, TextureFormat t_format)
|
||||
{
|
||||
MeshTexture *texture = new MeshTexture();
|
||||
Texture *texture = new Texture();
|
||||
if (t_format == BMP)
|
||||
bmpLoader.load(*texture, t_subfolder, t_name, ".bmp");
|
||||
else
|
||||
@@ -51,7 +51,7 @@ void TextureRepository::addByMesh(char *t_path, Mesh &mesh, TextureFormat t_form
|
||||
{
|
||||
for (u32 i = 0; i < mesh.getMaterialsCount(); i++)
|
||||
{
|
||||
MeshTexture *texture = new MeshTexture();
|
||||
Texture *texture = new Texture();
|
||||
if (t_format == BMP)
|
||||
bmpLoader.load(*texture, t_path, mesh.getMaterial(i).getName(), ".bmp");
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user