added MeshTexture class
This commit is contained in:
@@ -166,12 +166,12 @@ u32 Mesh::getVertexCount()
|
||||
|
||||
void Mesh::setDefaultWrapSettings(texwrap_t &t_wrapSettings)
|
||||
{
|
||||
t_wrapSettings.horizontal = WRAP_REPEAT;
|
||||
t_wrapSettings.vertical = WRAP_REPEAT;
|
||||
t_wrapSettings.maxu = 0;
|
||||
t_wrapSettings.maxv = 0;
|
||||
t_wrapSettings.minu = 0;
|
||||
t_wrapSettings.minv = 0;
|
||||
// t_wrapSettings.horizontal = WRAP_REPEAT;
|
||||
// t_wrapSettings.vertical = WRAP_REPEAT;
|
||||
// t_wrapSettings.maxu = 0;
|
||||
// t_wrapSettings.maxv = 0;
|
||||
// t_wrapSettings.minu = 0;
|
||||
// t_wrapSettings.minv = 0;
|
||||
}
|
||||
|
||||
void Mesh::loadTextures(char *t_subfolder, char *t_extension)
|
||||
@@ -183,14 +183,14 @@ void Mesh::loadTextures(char *t_subfolder, char *t_extension)
|
||||
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);
|
||||
setDefaultWrapSettings(spec->textures[i].wrapSettings);
|
||||
// setDefaultWrapSettings(spec->textures[i].wrapSettings);
|
||||
}
|
||||
}
|
||||
else if (isMd2Loaded)
|
||||
{
|
||||
spec->textures = new MeshTexture[1];
|
||||
bmpLoader.load(spec->textures[0], t_subfolder, md2->filename, t_extension);
|
||||
setDefaultWrapSettings(spec->textures[0].wrapSettings);
|
||||
// setDefaultWrapSettings(spec->textures[0].wrapSettings);
|
||||
}
|
||||
else if (isDffLoaded)
|
||||
{
|
||||
@@ -199,7 +199,7 @@ void Mesh::loadTextures(char *t_subfolder, char *t_extension)
|
||||
for (u8 j = 0; j < dff->clump.geometryList.geometries[0].materialList.materials[i].data.textureCount; j++)
|
||||
{
|
||||
bmpLoader.load(spec->textures[i], t_subfolder, dff->clump.geometryList.geometries[0].materialList.materials[i].textures[j].textureName.text, t_extension);
|
||||
setDefaultWrapSettings(spec->textures[i].wrapSettings);
|
||||
// setDefaultWrapSettings(spec->textures[i].wrapSettings);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -9,7 +9,10 @@
|
||||
*/
|
||||
|
||||
#include "../include/models/mesh_texture.hpp"
|
||||
#include "../include/utils/string.hpp"
|
||||
#include "../include/utils/debug.hpp"
|
||||
#include <cstdlib>
|
||||
#include <draw_sampling.h>
|
||||
|
||||
// ----
|
||||
// Constructors/Destructors
|
||||
@@ -17,12 +20,61 @@
|
||||
|
||||
MeshTexture::MeshTexture()
|
||||
{
|
||||
id = rand() % 100000;
|
||||
materialId = 0;
|
||||
_isSizeSet = false;
|
||||
_isNameSet = false;
|
||||
setDefaultWrapSettings();
|
||||
}
|
||||
|
||||
MeshTexture::~MeshTexture()
|
||||
{
|
||||
if (_isNameSet)
|
||||
delete[] name;
|
||||
if (_isSizeSet)
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
// ----
|
||||
// Methods
|
||||
// ----
|
||||
|
||||
void MeshTexture::setSize(const u8 &t_width, const u8 &t_height)
|
||||
{
|
||||
if (_isSizeSet)
|
||||
{
|
||||
PRINT_ERR("Can't set size, because was already set!");
|
||||
return;
|
||||
}
|
||||
width = t_width;
|
||||
height = t_height;
|
||||
data = new unsigned char[getDataSize()];
|
||||
_isSizeSet = true;
|
||||
}
|
||||
|
||||
void MeshTexture::setName(char *t_val)
|
||||
{
|
||||
if (_isNameSet)
|
||||
{
|
||||
PRINT_ERR("Can't set name, because was already set!");
|
||||
return;
|
||||
}
|
||||
name = String::createCopy(t_val);
|
||||
_isNameSet = true;
|
||||
}
|
||||
|
||||
void MeshTexture::setDefaultWrapSettings()
|
||||
{
|
||||
wrapSettings.horizontal = WRAP_REPEAT;
|
||||
wrapSettings.vertical = WRAP_REPEAT;
|
||||
wrapSettings.maxu = 0;
|
||||
wrapSettings.maxv = 0;
|
||||
wrapSettings.minu = 0;
|
||||
wrapSettings.minv = 0;
|
||||
}
|
||||
|
||||
void MeshTexture::setWrapSettings(const WrapSettings t_horizontal, const WrapSettings t_vertical)
|
||||
{
|
||||
wrapSettings.horizontal = t_horizontal;
|
||||
wrapSettings.vertical = t_vertical;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user