Wednesday 1 July 2015

Metasequoia Script - Read uklogo.pak

uklogo.pak is the file which stores the title graphic for classic Tomb Raider games (TR1 to TR5).

uklogo.pak

In this post I will write a script that reads the uklogo.pak file.

The first four bytes of the uklogo.pak file are an integer while the rest of the file is the red, green and blue pixel data.

The pixel data is zlib compressed and the integer at the start of the file gives the size of the pixel data when it is decompressed.

The pixel data is stored as 24 bit colour which means one byte for each colour.

The uklogo.pak graphic has dimensions (width x height) 512px  x 256px and black pixels (r=0,g=0,b=0) are transparent when the title is displayed in game.

With this information we can read the uklogo.pak and visualise it in Metasequoia.

Firstly use the Primitive command to create a plane in Metasequoia with the following properties.

plane properties
Change the colour of the material used for the plane to black.

plane

Enter the following Python script into Metasequoia’s Script Editor. The Script Editor is only available from the Panel menu in registered copies of Metasequoia.



Make sure the plane object is the current object by selecting it in the Object Panel and that nothing of the mesh is selected before running the script using Script>Run in the Script Editor.

Note that because of the high number iterations through the loop the script takes a few minutes to finish.

You may have to set Metasequoia to show only faces and not lines or points to see the logo properly.

result

After running the script the non black pixels should be selected so you can use extrude to make the title 3D.

Extrude selected faces

3D Logo

No comments:

Post a Comment