Skip to content

Commit

Permalink
Fixed texture export problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayveer committed Mar 13, 2021
1 parent d2a1d42 commit 9c484af
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ This is a plugin for [Noesis](https://richwhitehouse.com/index.php?content=inc_p

![picture](https://github.com/Jayveer/MGS-MDP-Noesis/blob/master/model.png?raw=true)

### Latest Changes
- Fixed a problem where textures weren't auto applying on export
- Fixed winding order

### To Do
- Reasearch how model files with no vertex buffer are read.
Expand Down
4 changes: 2 additions & 2 deletions mat.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ void bindMat(MdpFace* face, BYTE* fileBuffer, noeRAPI_t* rapi, CArrayList<noesis
noeMat->name = rapi->Noesis_PooledString(matName);

//set tex name
std::string texStr = intToHexString(mat->strcode);
char texName[7];
std::string texStr = intToHexString(mat->strcode) + ".tga";
char texName[11];
strcpy_s(texName, texStr.c_str());

//check if texture already exists
Expand Down
12 changes: 6 additions & 6 deletions mgs/txp/txp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ int Txp::getNumInfo() {
return header->numInfo;
}

void Txp::setRapi(noeRAPI_t* rapi) {
this->rapi = rapi;
}

bool Txp::containsTexture(uint32_t strcode) {
return getIdx(strcode) > -1;
}
Expand Down Expand Up @@ -109,21 +113,17 @@ void unswizzle8(uint8_t* src, uint8_t* dst, int width, int height) {
}
}

uint8_t* decompress(uint8_t* src, int decompressedSize) {
noeRAPI_t rapi = noeRAPI_t();
void* ctx = rapi.rpgCreateContext();
uint8_t* Txp::decompress(uint8_t* src, int decompressedSize) {
uint32_t compressedSize = *(uint32_t*)src;

uint8_t* compressedData = src + 4;
uint8_t* decompressedData = new uint8_t[decompressedSize];

rapi.Decomp_Inflate(src, decompressedData, compressedSize, decompressedSize);
rapi->Decomp_Inflate(src, decompressedData, compressedSize, decompressedSize);

rapi.rpgDestroyContext(ctx);
return decompressedData;
}


uint8_t* Txp::unswizzle(TxpImage* image, int& size) {
int width = image->width & 0xFFF;
int height = image->height & 0xFFF;
Expand Down
3 changes: 3 additions & 0 deletions mgs/txp/txp.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,18 @@ class Txp {
~Txp();
int getNumInfo();
void getAllTextures();
void setRapi(noeRAPI_t* rapi);
uint32_t getStrcodeAtIndex(int idx);
bool containsTexture(uint32_t strcode);
uint8_t* getTextureIndexed(int idx, int& size, int& bpp);
uint8_t* getTexture(uint32_t strcode, int& size, int& bpp);
private:
noeRAPI_t* rapi;
uint8_t* txpData;
TxpHeader* header;

int getIdx(uint32_t strcode);
uint8_t* unswizzle(TxpImage* image, int& size);
uint8_t* decompress(uint8_t* src, int decompressedSize);
uint8_t* paintPixels(TxpColour* clut, uint8_t* pixels, int width, int height, int maxWidth, int& size, int16_t xOffset, int16_t yOffset);
};

0 comments on commit 9c484af

Please sign in to comment.