implemented alpha texture repository
This commit is contained in:
@@ -54,8 +54,23 @@ public:
|
||||
u8 isMd2Loaded, isObjLoaded, isDffLoaded, isSpecInitialized;
|
||||
clutbuffer_t clut;
|
||||
lod_t lod;
|
||||
u32 id;
|
||||
MeshTexture *textures;
|
||||
|
||||
/** Array of materials. Size of getMaterialsCount() */
|
||||
MeshMaterial *getMaterials() const { return obj->frames[0].getMaterials(); };
|
||||
|
||||
const u32 &getMaterialsCount() const { return obj->frames[0].getMaterialsCount(); };
|
||||
|
||||
/** Returns material, which is a mesh "subgroup". */
|
||||
MeshMaterial &getMaterial(const u32 &i) const { return obj->frames[0].getMaterial(i); };
|
||||
|
||||
/**
|
||||
* Returns material, which is a mesh "subgroup".
|
||||
* NULL if not found.
|
||||
*/
|
||||
MeshMaterial *getMaterialById(const u32 &t_id) const { return obj->frames[0].getMaterialById(t_id); }
|
||||
|
||||
private:
|
||||
void setupLodAndClut();
|
||||
void setDefaultWrapSettings(texwrap_t &t_wrapSettings);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#ifndef _TYRA_MESH_FRAME_
|
||||
#define _TYRA_MESH_FRAME_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <tamtypes.h>
|
||||
#include "math/point.hpp"
|
||||
#include "math/vector3.hpp"
|
||||
@@ -50,6 +51,18 @@ public:
|
||||
/** Returns material, which is a mesh "subgroup". */
|
||||
MeshMaterial &getMaterial(const u32 &i) const { return materials[i]; };
|
||||
|
||||
/**
|
||||
* Returns material, which is a mesh "subgroup".
|
||||
* NULL if not found.
|
||||
*/
|
||||
MeshMaterial *getMaterialById(const u32 &t_id) const
|
||||
{
|
||||
for (u32 i = 0; i < materialsCount; i++)
|
||||
if (materials[i].getId() == t_id)
|
||||
return &materials[i];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** Array of vertices. Size of getVertexCount() */
|
||||
Vector3 *getVertices() const { return vertices; };
|
||||
|
||||
|
||||
@@ -106,15 +106,23 @@ public:
|
||||
// ----
|
||||
|
||||
/** Assign texture to mesh and mesh material */
|
||||
void addLink(u32 t_meshId, u32 t_materialId);
|
||||
void addLink(const u32 &t_meshId, const u32 &t_materialId);
|
||||
|
||||
/** Remove mesh and mesh material assignment */
|
||||
void removeLink(u32 t_meshId, u32 t_materialId);
|
||||
void removeLink(const u32 &t_meshId, const u32 &t_materialId);
|
||||
|
||||
const u8 &isNameSet() const { return _isNameSet; };
|
||||
|
||||
const u8 &isSizeSet() const { return _isSizeSet; };
|
||||
|
||||
const u8 isLinkedWith(const u32 &t_meshId, const u32 &t_materialId) const
|
||||
{
|
||||
for (u32 i = 0; i < texLinkCount; i++)
|
||||
if (texLinks[i].materialId == t_materialId && texLinks[i].meshId == t_meshId)
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
private:
|
||||
void setDefaultWrapSettings();
|
||||
texwrap_t wrapSettings;
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
TextureRepository *getTextureRepository() { return &textureRepo; };
|
||||
|
||||
private:
|
||||
void changeTexture(Mesh *t_mesh, u8 t_textureIndex);
|
||||
void changeTexture(Mesh *t_mesh, u32 t_materialId);
|
||||
u32 lastTextureId;
|
||||
texbuffer_t textureBuffer;
|
||||
u8 isTextureVRAMAllocated;
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
#include <tamtypes.h>
|
||||
#include <draw_buffers.h>
|
||||
#include "../models/mesh.hpp"
|
||||
#include "../models/mesh_frame.hpp"
|
||||
#include "../loaders/bmp_loader.hpp"
|
||||
|
||||
/** Class responsible for intializing draw env, textures and buffers */
|
||||
class TextureRepository
|
||||
@@ -23,7 +25,64 @@ public:
|
||||
TextureRepository();
|
||||
~TextureRepository();
|
||||
|
||||
// ----
|
||||
// Getters
|
||||
// ----
|
||||
|
||||
/** Returns all repository textures. */
|
||||
MeshTexture **getAll() const { return textures; }
|
||||
|
||||
const u32 &getTexturesCount() const { return texturesCount; };
|
||||
|
||||
/**
|
||||
* Returns single texture.
|
||||
* NULL if not found.
|
||||
*/
|
||||
MeshTexture *getByMesh(const u32 &t_meshId, const u32 &t_materialId)
|
||||
{
|
||||
for (u32 i = 0; i < texturesCount; i++)
|
||||
if (textures[i]->isLinkedWith(t_meshId, t_materialId))
|
||||
return textures[i];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns single texture.
|
||||
* NULL if not found.
|
||||
*/
|
||||
MeshTexture *getByTextureId(const u32 &t_id) const
|
||||
{
|
||||
for (u32 i = 0; i < texturesCount; i++)
|
||||
if (t_id == textures[i]->getId())
|
||||
return textures[i];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ----
|
||||
// Setters
|
||||
// ----
|
||||
|
||||
// ----
|
||||
// Other
|
||||
// ----
|
||||
|
||||
/** Add single unlinked texture to repository. */
|
||||
MeshTexture *add(char *t_subfolder, char *t_name);
|
||||
|
||||
/** Add linked textures in given subpath for mesh material names. */
|
||||
void addByMesh(char *t_path, Mesh &mesh);
|
||||
|
||||
/**
|
||||
* Remove texture from repository.
|
||||
* Texture is NOT destructed.
|
||||
*/
|
||||
void remove(u32 textureId);
|
||||
|
||||
private:
|
||||
void increaseArray(u32 newLength);
|
||||
u32 texturesCount;
|
||||
MeshTexture **textures;
|
||||
BmpLoader loader;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user