fix tex decod
This commit is contained in:
parent
4f14a8b5e9
commit
18a06af6f7
|
@ -25,7 +25,7 @@ TexturedMesh* readTexturedMesh(string dataPath, const char* lmpName, const char*
|
|||
VifDecoder vifDecoder;
|
||||
TexDecoder texDecoder;
|
||||
texturedMesh->meshList = vifDecoder.decode(vifEntry->data,0);
|
||||
texturedMesh->texture = texDecoder.decode(texEntry->data, 0);
|
||||
texturedMesh->texture = texDecoder.decode(texEntry->data, texEntry->length);
|
||||
|
||||
for (auto& mesh : *texturedMesh->meshList){
|
||||
mesh->adjustUVs(texturedMesh->texture->widthPixels, texturedMesh->texture->heightPixels);
|
||||
|
@ -66,7 +66,7 @@ int main(int argc, char **argv) {
|
|||
const char* lmpName = "DWARF.LMP";
|
||||
vector<string> meshNames;
|
||||
meshNames.push_back("dwarf");
|
||||
// meshNames.push_back("hair");
|
||||
meshNames.push_back("hair");
|
||||
|
||||
Model* model = readModel(dataPath, lmpName, meshNames, "l_idlea");
|
||||
|
||||
|
|
|
@ -6,17 +6,17 @@
|
|||
|
||||
#pragma optimize( "", off )
|
||||
|
||||
Texture* TexDecoder::decode(const unsigned char* data, int ps2Addr)
|
||||
Texture* TexDecoder::decode(const unsigned char* data, int len)
|
||||
{
|
||||
int finalw = DataUtil::getLEShort(data, 0);
|
||||
int finalh = DataUtil::getLEShort(data, 02);
|
||||
|
||||
int curIdx = DataUtil::getLEInt(data, 0x10);
|
||||
|
||||
return decode(finalw, finalh, data, curIdx - ps2Addr);
|
||||
return decode(finalw, finalh, data, curIdx, len);
|
||||
}
|
||||
|
||||
Texture* TexDecoder::decode(int finalw, int finalh, const unsigned char* data, int curIdx)
|
||||
Texture* TexDecoder::decode(int finalw, int finalh, const unsigned char* data, int curIdx, int len)
|
||||
{
|
||||
int sourcew = finalw;
|
||||
int sourceh = finalh;
|
||||
|
@ -56,7 +56,7 @@ Texture* TexDecoder::decode(int finalw, int finalh, const unsigned char* data, i
|
|||
int totalRrw = 0;
|
||||
bool eop = false;
|
||||
// Need to find a better way than this.
|
||||
while (!eop || totalRrw < dbw) {
|
||||
while (curIdx < len && (!eop || totalRrw < dbw)) {
|
||||
GIFTag* gifTag3 = new GIFTag();
|
||||
gifTag3->parse(data, curIdx);
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ class Palette;
|
|||
class TexDecoder
|
||||
{
|
||||
public:
|
||||
Texture* decode(const unsigned char* data, int ps2Addr);
|
||||
Texture* decode(int finalw, int finalh, const unsigned char* data, int curIdx);
|
||||
Texture* decode(const unsigned char* data, int len);
|
||||
Texture* decode(int finalw, int finalh, const unsigned char* data, int curIdx, int len);
|
||||
|
||||
private:
|
||||
void readPixels32(const unsigned char* data, Palette* palette, int startOffset, int startx, int starty, int rrw, int rrh, int dbw, int dbh);
|
||||
|
|
Reference in a new issue