Skip to content
ProgSys edited this page May 10, 2020 · 51 revisions

The GEO file contains geometry and animations organized as a scene graph. Similar to the GLTF file format.

File structure

Header

The file starts with a header:

struct geofileHeader
{
    int unk1;
    int number_of_nodes; // Total number of scene nodes
    int unk3;
    int number_of_transformations; // Total number of transformations
    int number_of_keyframes; // Total number of keframes
    int offset_to_first_model; // Offset to first model (geometry) data
    int number_of_models; // Total number of models (geometry)
    int unk6; 
}

Scene graph

Transformations

The header is followed by a list of transformations (geofileHeader.number_of_transformations):

struct geofileTransformation
{
    glm::vec3 position; // (xyz-float) All values are multiplied by 10.
    float unk7;
    glm::vec3 rotation;  // (xyz-float) Euler angles YXZ in degree. All values are multiplied by 10.
    float unk8;
    glm::vec3 scale;  // (xyz-float) All values are multiplied by 100.
    float unk9;
    float unk10, unk11, unk12, unk13;
}

I use OpenGl so my axes are different, here are my conversion functions:

glm::vec3 fromDisaPosition(const glm::vec3& position) { return glm::vec3(-position.x, -position.y, position.z) / 10.0f; }
glm::quat fromDisaRotation(const glm::vec3& rotation){
	const glm::vec3 eulerRotation = glm::radians(glm::vec3(
		-rotation.z / 10.0f,
		-rotation.y / 10.0f,
		rotation.x / 10.0f
	));
	return glm::quat(glm::eulerAngleYXZ(
		eulerRotation.y, eulerRotation.z, eulerRotation.x
	));
}
glm::vec3 fromDisaScale(const glm::vec3& scale) { return scale / 100.0f; }

Keyframes

Next are the keyframes (geofileHeader.number_of_keyframes):

struct geofileKeyframe{
    unsigned short value;
    unsigned short time;
};

What exactly they do must be discovered.

Nodes

Next are the nodes of the scene tree (geofileHeader.number_of_nodes):

struct geofileTreeNode
{
    short parent_index; // The index of the parent node. 0 is root so 1 is first entry
    short transformation_index;
    short number_of_transformations; // Must be at least 1. 
    short model_index; // If -1, then node is a pure transformation node.
    short transformation_mode; // 2 or 3 is a Billboard, rest ist normal?
    short keyframe_index; // Is 0, if node is not animated
    short number_of_keyframes; // Is 0, if node is not animated
}

Models

Buffer data (geometry and texture) starts at the given offset inside the header.

Each Model consists out of a header, surface data, triangle data, uv data and textures:

Model header

struct geofileModelHeader 
{
    int number_of_triangles; // Each trianlge has 3 vertices
    int unk9;
    int number_of_surfaces;
    int number_of_textures;
    int start_offset_texture; // Offset starts from the model header location
    int end_offset_model; // Offset starts from the model header location
    int size_of_triangles; 
    int unk12; 
}

Model surface

The model header is followed by a surface list (geofileModelHeader.number_of_surfaces):

struct geofileSurface{
    unsigned char unk1a, unk1b, unk1c, unk1d; //somekind of blend mode or alpha values?
    unsigned short texture_index; // Can be 0, then this surface has no texture. (Default texture is Black?)
    unsigned short lenght; // Number of vertices inside surface (start is the sum of previous lenghts)
    int unk4, unk5; //somekind of texture effects?
}

Geometry buffer (vertices and UV)

First are the vertices. There total size is model.header.number_of_triangles * 3 * sizeof(glm::vec3).

Second are the UV values. They are a bit strange as they are only present for used vertices, so there total size is not as you would expect: model.header.number_of_triangles * 2 * sizeof(glm::vec2) but rather the sum of surface lengths: sumLength * 2 * sizeof(glm::vec2).

Textures

The texures start at the given offset inside model header.

Each texture begins with a header:

struct geofileTextureHeader{
    unsigned int total_size; // the total byte size of the texture
    unsigned short width, height, colortable_quantity;
    unsigned char powerWidth, powerHeight; // The power of 
    unsigned int unk4;
}

Next follows the colortable filled with ARGB(8888). Afterwards, the indeces to the colortable.

If colortable is smaller 16 then each index has 4 bits else 8 bit:

int pixelDataSize = texture.header.width * texture.header.height; // base size
if (texture.header.colortableSize <= 16) pixelDataSize /= 2.0; // with 16 colors you only need 4 bit (half byte)

Clone this wiki locally