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