Important information: this site is currently scheduled to go offline indefinitely by end of the year.

Noesis tutorial Zlib

Read or post any tutorial related to file format analysis for modding purposes.
Post Reply
chrrox
Moderator
Posts: 2602
Joined: Sun May 18, 2008 3:01 pm
Has thanked: 57 times
Been thanked: 1422 times

Noesis tutorial Zlib

Post by chrrox »

In this tutorial ill go over how to load a file format that uses zlib compression directly in noesis.
The game is a free to play mmo called Rise of Immortals http://www.riseofimmortals.com/
This code also works on other Petroglyph games using the alo format.
Download the client for free for a sample of your own
Ok in this particular format the file contains one zlib chunk that needs to be decompressed to gain access to the model
They only give us the compressed size and a constant offset the data starts at.
So the format of these alo files is
Bytes 01 - 16 #Header Information
Bytes 17 - 20 #Compressed size
Offset 36 #Start of zlib data

So knowing this we can use this code here to get the raw file in memory to work with

Code: Select all

#load the model
def noepyLoadModel(data, mdlList):
    ctx = rapi.rpgCreateContext()
    bs = NoeBitStream(data)
    bs.seek(16, NOESEEK_ABS)
    compsize = bs.read("i")
    bs.seek(36, NOESEEK_ABS)
    decompData = bytearray()
    cmpData = bs.readBytes(compsize[0])
    decompSize = rapi.getInflatedSize(cmpData)
    decompData += rapi.decompInflate(cmpData, decompSize)
    bs.seek(0, NOESEEK_ABS)
    bs = NoeBitStream(decompData, NOE_LITTLEENDIAN)
So what are we doing here
We create a context with
ctx = rapi.rpgCreateContext()
Then we open our byte stream
bs = NoeBitStream(data)
Then We get the compressed size of the zlib chunk

Code: Select all

bs.seek(16, NOESEEK_ABS)
compsize = bs.read("i")
Now we setup a place to hold our new byte stream pieces "you only need to do this if you want to add multiple streams together but it will also work for one stream "

Code: Select all

decompData = bytearray()
Now we store our compressed chunk

Code: Select all

cmpData = bs.readBytes(compsize[0])
Then we get the uncompressed size of that chunk with this command

Code: Select all

decompSize = rapi.getInflatedSize(cmpData)
Now we add our uncompressed data to our container we did earlier

Code: Select all

decompData += rapi.decompInflate(cmpData, decompSize)
We Now go back to the start of the file because we don't need any of the original header and we replace our bs with the new uncompressed model

Code: Select all

bs.seek(0, NOESEEK_ABS)
bs = NoeBitStream(decompData, NOE_LITTLEENDIAN)
Now you can handle the model just as if it were uncompressed.
The end result
Image
If anyone has any questions on anything done in this model format just ask.
You do not have the required permissions to view the files attached to this post.
Acewell
VIP member
VIP member
Posts: 1330
Joined: Wed Nov 05, 2008 12:16 pm
Has thanked: 2710 times
Been thanked: 884 times

Re: Noesis tutorial Zlib

Post by Acewell »

thanks for the tutorial! :D
chrrox wrote:This code also works on other Petroglyph games using the alo format.
your import script doesn't seem to work with Petroglyph's "Star Wars: Empire at War" *.alo models.
here is the *.alo format spec if you're feeling up to modifying yours:
http://modtools.petrolution.net/docs/AloFileFormat
Last edited by Acewell on Wed Feb 07, 2018 1:53 am, edited 1 time in total.
chrrox
Moderator
Posts: 2602
Joined: Sun May 18, 2008 3:01 pm
Has thanked: 57 times
Been thanked: 1422 times

Re: Noesis tutorial Zlib

Post by chrrox »

sample files would be a lot better i tested it with this game and guardians of graxia.
Acewell
VIP member
VIP member
Posts: 1330
Joined: Wed Nov 05, 2008 12:16 pm
Has thanked: 2710 times
Been thanked: 884 times

Re: Noesis tutorial Zlib

Post by Acewell »

here is some samples:
*samples provided on request*

thanks!
Last edited by Acewell on Wed Feb 07, 2018 1:53 am, edited 3 times in total.
chrrox
Moderator
Posts: 2602
Joined: Sun May 18, 2008 3:01 pm
Has thanked: 57 times
Been thanked: 1422 times

Re: Noesis tutorial Zlib

Post by chrrox »

there are already tools to import the models on that site why not use those?
http://modtools.petrolution.net/tools/
Acewell
VIP member
VIP member
Posts: 1330
Joined: Wed Nov 05, 2008 12:16 pm
Has thanked: 2710 times
Been thanked: 884 times

Re: Noesis tutorial Zlib

Post by Acewell »

nevermind i may write an alo import script for Noesis soon. (:

edit
there is now a alo/ala import/export script for Blender 2.79 now. :D
https://focumentation.fandom.com/wiki/Blender
Last edited by Acewell on Tue Jan 28, 2020 2:47 pm, edited 2 times in total.
Post Reply