Page 1 of 1

Noesis tutorial Zlib

Posted: Mon Dec 05, 2011 7:04 pm
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.

Re: Noesis tutorial Zlib

Posted: Wed Dec 07, 2011 12:02 am
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

Re: Noesis tutorial Zlib

Posted: Wed Dec 07, 2011 1:00 am
by chrrox
sample files would be a lot better i tested it with this game and guardians of graxia.

Re: Noesis tutorial Zlib

Posted: Wed Dec 07, 2011 4:37 am
by Acewell
here is some samples:
*samples provided on request*

thanks!

Re: Noesis tutorial Zlib

Posted: Wed Dec 07, 2011 5:04 am
by chrrox
there are already tools to import the models on that site why not use those?
http://modtools.petrolution.net/tools/

Re: Noesis tutorial Zlib

Posted: Wed Dec 07, 2011 5:19 am
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