removed unused information from texture,

don't copy the data, give a pointer,
there is some data left, need to find out if it's from these changes
This commit is contained in:
Anakin 2016-11-24 19:40:17 +01:00
parent 97a38d5260
commit e1e8e165fe
4 changed files with 38 additions and 42 deletions

View File

@ -9,22 +9,13 @@ public:
~TextureTGA(); ~TextureTGA();
private: private:
std::vector<std::uint8_t> vui8Pixels; std::vector<std::uint8_t>* vui8Pixels;
bool bCompressed; std::uint32_t ui32BpP;
std::uint32_t ui32IDLength;
bool bColorTabel;
std::uint32_t ui32PicType;
std::uint32_t ui32PaletteBegin;
std::uint32_t ui32PaletteLength;
std::uint32_t ui32PaletteBpP;
std::uint32_t ui32Width; std::uint32_t ui32Width;
std::uint32_t ui32Height; std::uint32_t ui32Height;
std::uint32_t ui32Size;
std::uint32_t ui32BpP;
std::uint32_t ui32Attribut;
public: public:
std::vector<std::uint8_t> getData() const; std::vector<std::uint8_t>* getData() const;
bool hasAlpha() const; bool hasAlpha() const;
std::uint32_t getWidth() const; std::uint32_t getWidth() const;
std::uint32_t getHeight() const; std::uint32_t getHeight() const;

View File

@ -329,6 +329,21 @@ void Object::analyseGeomChunks(Modl * dataDestination, std::list<ChunkHeader*>&
{ {
for (std::list<ChunkHeader*>::iterator it = chunkList.begin(); it != chunkList.end(); it++) for (std::list<ChunkHeader*>::iterator it = chunkList.begin(); it != chunkList.end(); it++)
{ {
if (!strcmp("BBOX", (*it)->name))
{
fsMesh.seekg((*it)->position);
std::uint32_t tempValue;
fsMesh.read(reinterpret_cast<char*>(&tempValue), sizeof(tempValue));
/*
float[4] 16 Quaternion Rotation in XYZW.
float[3] 12 Center of the BBox.
float[3] 12 Extents of the BBox(width / 2, height / 2, depth / 2).
float 4 Bounding sphere radius.*/
continue;
}
if (!strcmp("SEGM", (*it)->name)) if (!strcmp("SEGM", (*it)->name))
{ {
// get all subchunks // get all subchunks

View File

@ -455,7 +455,7 @@ void OpenGLController::loadMsh(const char * path)
tempData->alpha = tempTex.hasAlpha(); tempData->alpha = tempTex.hasAlpha();
tempData->width = tempTex.getWidth(); tempData->width = tempTex.getWidth();
tempData->height = tempTex.getHeight(); tempData->height = tempTex.getHeight();
tempData->data = new std::vector<std::uint8_t>(tempTex.getData()); tempData->data = tempTex.getData();
} }
catch (std::invalid_argument e) catch (std::invalid_argument e)
{ {

View File

@ -13,35 +13,26 @@ TextureTGA::TextureTGA(const char * filePath)
std::uint8_t ui8x18Header[19] = { 0 }; std::uint8_t ui8x18Header[19] = { 0 };
fsPicture.read(reinterpret_cast<char*>(&ui8x18Header), sizeof(ui8x18Header)-1); fsPicture.read(reinterpret_cast<char*>(&ui8x18Header), sizeof(ui8x18Header)-1);
//get variables
vui8Pixels = new std::vector<std::uint8_t>;
bool bCompressed;
std::uint32_t ui32IDLength;
std::uint32_t ui32PicType;
std::uint32_t ui32PaletteLength;
std::uint32_t ui32Size;
// extract all information from header // extract all information from header
ui32IDLength = ui8x18Header[0]; ui32IDLength = ui8x18Header[0];
bColorTabel = ui8x18Header[1] == 1;
ui32PicType = ui8x18Header[2]; ui32PicType = ui8x18Header[2];
ui32PaletteBegin = ui8x18Header[4] * 0x100 + ui8x18Header[3];
ui32PaletteLength = ui8x18Header[6] * 0x100 + ui8x18Header[5]; ui32PaletteLength = ui8x18Header[6] * 0x100 + ui8x18Header[5];
ui32PaletteBpP = ui8x18Header[7];
ui32Width = ui8x18Header[13] * 0x100 + ui8x18Header[12]; ui32Width = ui8x18Header[13] * 0x100 + ui8x18Header[12];
ui32Height = ui8x18Header[15] * 0x100 + ui8x18Header[14]; ui32Height = ui8x18Header[15] * 0x100 + ui8x18Header[14];
ui32BpP = ui8x18Header[16]; ui32BpP = ui8x18Header[16];
ui32Attribut = ui8x18Header[17];
// calculate some more information // calculate some more information
ui32Size = ui32Width * ui32Height * ui32BpP/8; ui32Size = ui32Width * ui32Height * ui32BpP/8;
bCompressed = ui32PicType == 9 || ui32PicType == 10; bCompressed = ui32PicType == 9 || ui32PicType == 10;
vui8Pixels.resize(ui32Size); vui8Pixels->resize(ui32Size);
/* consol output of the header
std::cout << "Header\n"
<< "ID länge: " << ui32IDLength << std::endl
<< "Farbtabelle: " << (int)bColorTabel << std::endl
<< "Bildtype: " << ui32PicType << std::endl
<< "Palletenbegin: " << ui32PaletteBegin << std::endl
<< "Palletenlängen: " << ui32PaletteLength << std::endl
<< "Bits pro Palleteneintrag: " << ui32PaletteBpP << std::endl
<< "Breite: " << ui32Width << std::endl
<< "Höhe: " << ui32Height << std::endl
<< "Bit pro Pixel: " << ui32BpP << std::endl
<< "Bild Attribute: " << ui32Attribut << std::endl;*/
// jump to the data block // jump to the data block
fsPicture.seekg(ui32IDLength + ui32PaletteLength, std::ios_base::cur); fsPicture.seekg(ui32IDLength + ui32PaletteLength, std::ios_base::cur);
@ -49,7 +40,7 @@ TextureTGA::TextureTGA(const char * filePath)
// If not compressed 24 or 32 bit // If not compressed 24 or 32 bit
if (ui32PicType == 2 && (ui32BpP == 24 || ui32BpP == 32)) if (ui32PicType == 2 && (ui32BpP == 24 || ui32BpP == 32))
{ {
fsPicture.read(reinterpret_cast<char*>(vui8Pixels.data()), ui32Size); fsPicture.read(reinterpret_cast<char*>(vui8Pixels->data()), ui32Size);
} }
// else if compressed 24 or 32 bit // else if compressed 24 or 32 bit
else if (ui32PicType == 10 && (ui32BpP == 24 || ui32BpP == 32)) // compressed else if (ui32PicType == 10 && (ui32BpP == 24 || ui32BpP == 32)) // compressed
@ -70,10 +61,10 @@ TextureTGA::TextureTGA(const char * filePath)
for (int i = 0; i <= tempChunkHeader; i++) for (int i = 0; i <= tempChunkHeader; i++)
{ {
vui8Pixels[tempByteIndex++] = tempData[0]; vui8Pixels->at(tempByteIndex++) = tempData[0];
vui8Pixels[tempByteIndex++] = tempData[1]; vui8Pixels->at(tempByteIndex++) = tempData[1];
vui8Pixels[tempByteIndex++] = tempData[2]; vui8Pixels->at(tempByteIndex++) = tempData[2];
if(ui32BpP == 32) vui8Pixels[tempByteIndex++] = tempData[3]; if(ui32BpP == 32) vui8Pixels->at(tempByteIndex++) = tempData[3];
} }
} }
else // data count else // data count
@ -85,10 +76,10 @@ TextureTGA::TextureTGA(const char * filePath)
{ {
fsPicture.read(reinterpret_cast<char*>(&tempData), ui32BpP/8); fsPicture.read(reinterpret_cast<char*>(&tempData), ui32BpP/8);
vui8Pixels[tempByteIndex++] = tempData[0]; vui8Pixels->at(tempByteIndex++) = tempData[0];
vui8Pixels[tempByteIndex++] = tempData[1]; vui8Pixels->at(tempByteIndex++) = tempData[1];
vui8Pixels[tempByteIndex++] = tempData[2]; vui8Pixels->at(tempByteIndex++) = tempData[2];
if (ui32BpP == 32) vui8Pixels[tempByteIndex++] = tempData[3]; if (ui32BpP == 32) vui8Pixels->at(tempByteIndex++) = tempData[3];
} }
} }
} while (tempByteIndex < ui32Size); } while (tempByteIndex < ui32Size);
@ -105,10 +96,9 @@ TextureTGA::TextureTGA(const char * filePath)
TextureTGA::~TextureTGA() TextureTGA::~TextureTGA()
{ {
vui8Pixels.clear();
} }
std::vector<std::uint8_t> TextureTGA::getData() const std::vector<std::uint8_t>* TextureTGA::getData() const
{ {
return vui8Pixels; return vui8Pixels;
} }