Reverse Engineering Lugaru assets

The place to discuss all things Lugaru.
David
Project Leader
Posts: 1995
Joined: Wed Nov 19, 2003 10:45 pm
Contact:

Post by David » Wed May 21, 2008 3:16 am

There are 3 ints, not 6 shorts. If that gives weird results then there is probably something wrong with the int size, endianness, or signing. The texture coordinates are stored in the same format as the vertex coordinates, so if they are weird it could mean that the ints are a different size than you are assuming they are, and that is shifting all the bytes for the floats.

User avatar
Makrond
Posts: 498
Joined: Mon Jun 25, 2007 11:34 pm

Post by Makrond » Wed May 21, 2008 5:26 am

Gee, suddenly David can remember a lot about the .solid format. :P

User avatar
BunnyWithStick
Gramps, Jr.
Posts: 4297
Joined: Mon Dec 05, 2005 12:14 am
Location: New Zealand

Post by BunnyWithStick » Wed May 21, 2008 8:55 am

Yeah…

(This'd be a good time for a certain "Asian Smiley" but I only use forum smileys… Huh.)

User avatar
Renegade_Turner
Gramps
Posts: 6942
Joined: Tue Sep 27, 2005 11:59 am

Post by Renegade_Turner » Wed May 21, 2008 9:42 am

Yeah they might bring down your internet credibility. :P

User avatar
rudel_ic
official Wolfire heckler
Posts: 2193
Joined: Sun Aug 28, 2005 11:19 pm
Location: Hamburg City
Contact:

Post by rudel_ic » Wed May 21, 2008 2:42 pm

David wrote:There are 3 ints, not 6 shorts. If that gives weird results then there is probably something wrong with the int size, endianness, or signing. The texture coordinates are stored in the same format as the vertex coordinates, so if they are weird it could mean that the ints are a different size than you are assuming they are, and that is shifting all the bytes for the floats.
Little endian doesn't work for integers nor for floats here, the values make less sense.

As for the index positions, they seem to be correct.

The indices sure look like shorts; if they are integers, I've got no clue how to reconstruct them.

I'm nowhere yet again.

User avatar
Chainsaw man
Posts: 1492
Joined: Mon Mar 17, 2008 6:13 am
Location: New Zealand

Post by Chainsaw man » Wed May 21, 2008 2:49 pm

Belive in your cause Rudel_ic!
You can unlock the secrits of the secrits of the engine...

David
Project Leader
Posts: 1995
Joined: Wed Nov 19, 2003 10:45 pm
Contact:

Post by David » Wed May 21, 2008 4:26 pm

Makrond wrote:Gee, suddenly David can remember a lot about the .solid format. :P
Rudel posted the format in the first post, I just don't have the converter programs any more :(

User avatar
Chainsaw man
Posts: 1492
Joined: Mon Mar 17, 2008 6:13 am
Location: New Zealand

Post by Chainsaw man » Wed May 21, 2008 5:15 pm

Lies, all lies, you have hidden them :P

User avatar
BunnyWithStick
Gramps, Jr.
Posts: 4297
Joined: Mon Dec 05, 2005 12:14 am
Location: New Zealand

Post by BunnyWithStick » Wed May 21, 2008 9:47 pm

Chainsaw man wrote:Belive in your cause Rudel_ic!
You can unlock the secrits of the secrits of the engine...
You can unlock the secrets of the secrets of the secrets of the secrets of the secrets of the engine! Congratulations!

User avatar
Makrond
Posts: 498
Joined: Mon Jun 25, 2007 11:34 pm

Post by Makrond » Thu May 22, 2008 1:24 am

Huh... anyone else find it ironic that David has less posts than BwS?

Yup, I'm special. [/offtopic]

Wait, how big is the box.solid when you actually put it in-game? If it's really big, then maybe those 3Fs and 80s have a place.

No, no, that can't be right.

Damn my limited knowledge of 3D formats!

I don't know if this will help, becuse this is a completely random, probably completely different format, but contains most of what I know to be in 3D models:
1. The Header.
The SKM header is as follows (I will use the C++ notation for the sake of simplicity of writing a plugin, if someone wil agree to make one in the future):

int BoneCount; // the number of bones in the SKM
int BoneOffset; // the offset to the bones' definition
int MaterialCount; // the number of materials in the SKM
int MaterialOffset; // the offset to the materials' definition
int VertexCount; // the number of vertices in the SKM
int VertexOffset; // the offset to the vertices' definition
int TriangleCount; // the number of triangles in the SKM
int TriangleOffset; // the offset to the triangles' definition
unsigned UNUSED_1; // padding, unused
unsigned UNUSED_2; // padding, unused
And something a little more relevant:
4. The Vertex Definitions.
The vertex definitions are located at the VertexOffset and can be represented by the following structure:

vec3 Position; // the vertex position (vec3 = a combination of four floats; x,y,z, and an unused float value that may be coming from the fact that the structure is aligned to 128bits for SSE - thx to Leksey for finding out this extra padding that was missing!)
vec3 Normal; // the vertex normal (position normal?)
vec2 Texture; // the position of the texture (vec2 = a combination of two floats)
short UNUSED; // padding, is ignored
short WeightCount; // the count of weights for this vertex to follow (defines the number of associated bones and their weights to follow)
short Bones[6]; // the list of bones associated with this vertex; always six entries.
float Weights[6]; // the array of weights for the associated bones; always six entries.

User avatar
rudel_ic
official Wolfire heckler
Posts: 2193
Joined: Sun Aug 28, 2005 11:19 pm
Location: Hamburg City
Contact:

Post by rudel_ic » Thu May 22, 2008 2:03 am

Thanks, but these are different formats. The format that I quoted from zip is seemingly correct, and we're almost there, but the details remain to be unsolved.

As for the 3Fs and 80s, they are to be expected for floats. Just look up "floating point" in wikipedia for clarification. One would expect floats in the range from 0 to 1 for texture mapping, but that's not a necessity at all, just a convention.

.solid representation scale (and orientation) in-game is something that will be interesting once we have the format cracked. It most likely doesn't provide clues.

What could lead to further conclusions is having the original models, but I don't expect them to be still present on David's hard drives.

Let's sum up what we think we know so far. We're currently assuming the following formats in this very order:

Code: Select all

1 short - number of vertices V (2 bytes)
1 short - number of triangles T (2 bytes)
3 x V floats - x,y,z coordinates of vertices (3 x 4 x V bytes)
T x ( 3 integers, then 3x2 floats ) - 3 integer indices referencing vertices for triangles, followed by u and v texture mapping floats for each vertex (T x ( 3 x 4 + 3 x 2 x 4 ) bytes)
This checks out considering the total number of bytes. It also goes well with the structural appearance of the HEX representation of the files.

There are still problems with reconstructing the integer values and it is unclear whether or not the assumed float format is correct.

Most likely, values are stored as big endian, so the most significant byte of a value has the lowest address. An indicator for that are the shorts at the beginning of a .solid.
Still, the byte order could be messed up.

User avatar
rudel_ic
official Wolfire heckler
Posts: 2193
Joined: Sun Aug 28, 2005 11:19 pm
Location: Hamburg City
Contact:

Post by rudel_ic » Sat May 24, 2008 3:59 am

Alright, we're getting to results. Here's a quick test:
Image
The crosses ended up upside-down, so I had to rotate them in-game. Lugaru is teh satanic by default confirmed.

At the moment there is no texture-mapping (predefined texmap bytes, the same for all triangles).

Making round or really complicated objects crashes Lugaru. I don't know why that is. The best results stem from making a cube and extruding its faces in some way.

I you're interested, the .x file and the .solid file both can be found at
http://lugaruspace.50megs.com/models/
Please be kind, the bandwidth of that site is very very limited.

The next stations are figuring out why round / complicated models don't work, how to do texture mapping correctly and then we're set. There's light at the end of the tunnel.

There are still subtleties beyond tex mapping I'm struggling with, so it's not perfect at all so far.

An example is the number of vertices - Blender exports one vertex multiple times under certain circumstances, that's a damn waste. Killing redundancy and then remapping the triangles is possible, I'm in the process of doing this, but the complexity is high (complexity as in the CS term), and that's no good. We'll see how it will turn out after a certain amount of polish.

Another example is whether or not the triangle mapping is robust. I haven't tried more than 255 vertices / triangles yet for this very reason.

The byte order for triangle mapping is messed up. Interpreting the indices as repeated shorts did the trick so far.
The pattern of use for vertex indices is use-use-repeat-use-repeat-0000. I'm pretty sure this will fail once there are more than 255 triangles / vertices.


What I can do is try to convert your models if you give me a link to them.
Models have to be triangles, they need to have materials, uv texture mapping is necessary, there may be only one model in your scene, no animations.
The reasons for these limitations are embedded in the parser and in the engine.

I accept .blender scenes with just the model (camera + light is fine too) or .x files. I can try to get other formats to work, but don't expect wonders.

If you want a model converted, upload it to rapidshare or whatever and then PM me the link. I'll convert it and try it out. If I succeed, I upload the .solid to rapidshare and optionally post it to the forums. If Lugaru crashes with your .solid, you won't get it.

Why do I not release the source code / a binary? Simply because I want a stable and fast solution released that works on all platforms. Before that's the case, the converter will stay here. Don't bug me about it. There's still lots to do before a release from me can be expected.

peace

User avatar
Count Roland
Posts: 2937
Joined: Tue Sep 25, 2007 11:15 pm
Location: Galapagos Islands, rodeoin some turtles.
Contact:

Post by Count Roland » Sat May 24, 2008 4:02 am

you really are getting somewhere, I'm surprised your initiative hasn't run out by now

User avatar
rudel_ic
official Wolfire heckler
Posts: 2193
Joined: Sun Aug 28, 2005 11:19 pm
Location: Hamburg City
Contact:

Post by rudel_ic » Sat May 24, 2008 4:02 am

I never give up.

User avatar
rudel_ic
official Wolfire heckler
Posts: 2193
Joined: Sun Aug 28, 2005 11:19 pm
Location: Hamburg City
Contact:

Post by rudel_ic » Sat May 24, 2008 4:09 am

Note that you have to rename .solids to used names after you copy them to the Lugaru/Data/Models folder. Make a backup of the file of which you're borrowing the name.

Post Reply