implemented alpha texture repository
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "../include/models/mesh_texture.hpp"
|
||||
#include "../include/utils/debug.hpp"
|
||||
#include "../include/utils/string.hpp"
|
||||
#include <cstdlib>
|
||||
|
||||
// ----
|
||||
// Constructors/Destructors
|
||||
@@ -31,6 +32,7 @@ Mesh::Mesh()
|
||||
isObjLoaded = false;
|
||||
isDffLoaded = false;
|
||||
isSpecInitialized = false;
|
||||
id = rand() % 1000000;
|
||||
scale = 1.0F;
|
||||
}
|
||||
|
||||
@@ -110,7 +112,6 @@ void Mesh::loadObj(char *t_subfolder, char *t_objFile, Vector3 &t_initPos, float
|
||||
setVerticesReference(obj->getFacesCount(), obj->frames[0].getVertices());
|
||||
setDefaultColor();
|
||||
isObjLoaded = true;
|
||||
loadTextures(t_subfolder, ".bmp");
|
||||
}
|
||||
|
||||
void Mesh::setObj(Vector3 &t_initPos, ObjModel *t_objModel)
|
||||
@@ -171,12 +172,6 @@ void Mesh::loadTextures(char *t_subfolder, char *t_extension)
|
||||
BmpLoader bmpLoader = BmpLoader();
|
||||
if (isObjLoaded)
|
||||
{
|
||||
textures = new MeshTexture[obj->frames[0].getMaterialsCount()];
|
||||
for (u8 i = 0; i < obj->frames[0].getMaterialsCount(); i++)
|
||||
{
|
||||
bmpLoader.load(textures[i], t_subfolder, obj->frames[0].getMaterial(i).getName(), t_extension);
|
||||
// setDefaultWrapSettings(spec->textures[i].wrapSettings);
|
||||
}
|
||||
}
|
||||
else if (isMd2Loaded)
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
MeshMaterial::MeshMaterial()
|
||||
{
|
||||
id = rand() % 100000;
|
||||
id = rand() % 1000000;
|
||||
facesCount = 0;
|
||||
_isNameSet = false;
|
||||
_areFacesAllocated = false;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
MeshTexture::MeshTexture()
|
||||
{
|
||||
id = rand() % 100000;
|
||||
id = rand() % 1000000;
|
||||
texLinkCount = 0;
|
||||
_isSizeSet = false;
|
||||
_isNameSet = false;
|
||||
@@ -81,30 +81,33 @@ void MeshTexture::setWrapSettings(const WrapSettings t_horizontal, const WrapSet
|
||||
wrapSettings.vertical = t_vertical;
|
||||
}
|
||||
|
||||
void MeshTexture::addLink(u32 t_meshId, u32 t_materialId)
|
||||
void MeshTexture::addLink(const u32 &t_meshId, const u32 &t_materialId)
|
||||
{
|
||||
TextureLink *savedLinks = texLinks;
|
||||
texLinks = new TextureLink[++texLinkCount];
|
||||
for (u32 i = 0; i < texLinkCount - 1; i++)
|
||||
texLinks = new TextureLink[texLinkCount + 1];
|
||||
for (u32 i = 0; i < texLinkCount; i++)
|
||||
{
|
||||
texLinks[i].materialId = savedLinks[i].materialId;
|
||||
texLinks[i].meshId = savedLinks[i].meshId;
|
||||
}
|
||||
delete[] savedLinks;
|
||||
if (texLinkCount != 0)
|
||||
delete[] savedLinks;
|
||||
texLinkCount++;
|
||||
texLinks[texLinkCount - 1].materialId = t_materialId;
|
||||
texLinks[texLinkCount - 1].meshId = t_meshId;
|
||||
}
|
||||
|
||||
void MeshTexture::removeLink(u32 t_meshId, u32 t_materialId)
|
||||
void MeshTexture::removeLink(const u32 &t_meshId, const u32 &t_materialId)
|
||||
{
|
||||
TextureLink *savedLinks = texLinks;
|
||||
texLinks = new TextureLink[--texLinkCount];
|
||||
texLinks = new TextureLink[texLinkCount - 1];
|
||||
u32 savedCount = 0;
|
||||
for (u32 i = 0; i < texLinkCount + 1; i++)
|
||||
for (u32 i = 0; i < texLinkCount; i++)
|
||||
if (savedLinks[i].materialId != t_materialId && savedLinks[i].meshId != t_meshId)
|
||||
{
|
||||
texLinks[savedCount++].materialId = savedLinks[i].materialId;
|
||||
texLinks[savedCount++].meshId = savedLinks[i].meshId;
|
||||
}
|
||||
delete[] savedLinks;
|
||||
texLinkCount--;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user