Skip to content

Instantly share code, notes, and snippets.

@Five-Damned-Dollarz
Last active March 16, 2022 11:28
Lithtech Jupiter EX (FEAR 2) world template for 010Editor
// Lithtech Jupiter EX Wld (FEAR 2)
const uint FearVersion=126;
void LTPad(const uint pos)
{
if ((pos & 3)!=0) FSkip(4-(pos & 3));
}
struct LTVector
{
float x, y, z;
};
struct LTQuaternion
{
float x, y, z, w;
};
struct LTPlane
{
LTVector normal;
float distance;
};
struct LTString
{
ushort length;
char content[length];
};
struct CString
{
char str[];
};
struct Header
{
char magic[4];
if (magic!="WLDP")
Warning("File may not be a FEAR 2 world.");
uint version;
if (version!=FearVersion)
Warning("File may not be a valid FEAR 2 version.");
LTVector vec[5]; // maybe part of BSP section?
} header <bgcolor=cLtGray>;
struct WorldModelsSection
{
uint node_count;
byte subdivision_flags[Ceil((float)node_count/8)] <format=binary>;
uint string_count;
uint string_length;
uint normal_count;
uint bsp_count;
uint unk_count;
uint unk_count;
uint unk_count;
uint unk_count;
uint float_count;
float unk_floats[float_count];
struct {
CString strings[string_count] <optimize=false>;
} string_container <bgcolor=cLtBlue>;
char pad[string_length-sizeof(string_container)] <hidden=true>;
struct LTStringTable
{
struct {
uint a, b;
} entries[string_count];
} string_table;
struct {
LTVector normals[normal_count];
} normals <bgcolor=cLtGreen>;
struct UnknownTable {
SetBackColor(cLtRed);
uint a;
short b, b;
};
struct LTFace(byte& tris) {
byte a, a; // inside, outside area index?
short b; // surface flags?
uint normal_index; //short c, c;
float plane_distance;
uint tri[tris];
};
struct {
struct Bsp
{
SetBackColor(cLtBlue);
/*
0 = ??
1 = point count
2 = face count?
3 = ??
4 = ??
*/
uint counts[5];
LTVector vecs_[2];
byte tris[counts[2]];
struct {
local uint i=0;
for(i=0; i<counts[2]; ++i)
{
LTFace face(tris[i]);
}
} face_countainer;
UnknownTable unk_table[counts[4]];
LTVector verts[counts[1]];
} bsp[bsp_count] <optimize=false>;
} bsp_container;
struct PhysicsSection
{
SetBackColor(cLtPurple);
uint count;
struct {
LTVector vec;
LTQuaternion rot;
uint a, a, a;
LTVector vec;
LTQuaternion rot;
} a;
struct PhysicsShape
{
uint id;
float mass, density;
float unk[7];
LTVector vec;
LTQuaternion rot;
} physics_shape;
uint vec_count, unk_count;
LTVector vecs[vec_count];
if (vec_count<0x10000)
ushort tris[unk_count];
else
uint tris[unk_count];
float unk[4];
} physics_section;
} world_model_section;
struct UnkSection
{
uint section_size; // in bytes
//byte section_chunk[section_size];
struct {
byte block[512];
} unk_blocks[section_size/512];
} unk_section <bgcolor=0xFF88FF>;
struct NewSection // physics shapes same as world00p?
{
struct UnkPack // probably bsp_count length?
{
local uint count=0;
local uint type_id;
while((type_id=ReadUInt())!=0)
{
struct UnkStruct__ {
int i; // 0, 2, 3, 5, 6 seen
//FSkip(4);
switch(type_id)
{
case 0:
//float unk[7];
break;
case 2:
case 558657322: // what the fuck?
case 892953272:
case 885026190:
case 885026191:
float unk[6]; // mass, density, etc.
break;
case 3:
float unk[3];
break;
case 5:
float unk[7]; // Vector + Quaternion
break;
case 6:
int unk_____________;
break;
case 7:
float mat[16];
break;
//default:
//Assert(0, "broken i");
}
} block;
++count;
}
if (count==0) FSkip(4);
float posrot[7];
} pack[world_model_section.bsp_count] <optimize=false>;
} new_section <bgcolor=0x99DD33>;
FSeek(0xC6D3C7); // 0x850366 in m03; 0x6FBC98 in m04; 0xC6C537 in m04b; 0xBAF1CD in m05; 0xA2D155 in m10
struct BundleSection
{
uint unk; // 1
ushort unk_, unk_;
uint str_length;
ushort unk_, unk_; // 3 = 800
ushort unk_, unk_; // 5 = 2400
uint unk;
uint unk_table_count;
uint aratana_count;
uint unk;
uint unk;
uint node_count;
uint unk;
uint unk;
uint unk; // 1
local uint str_start=FTell();
char str_dat[str_length];
FSeek(str_start);
struct {
local uint i=0;
local uint temp_pad=0;
for(i=0; i<3000; ++i) // 1626 = m03, 1769 = m10?
{
CString str_test;
temp_pad=sizeof(str_test) & 3;
if (temp_pad!=0) struct { byte buf[4-temp_pad]; } pad <hidden=true>;
}
} strings;
FSeek(str_start+str_length);
struct {
uint id;
uint count;
uint unk[count];
} unk_table; // 3548 = m03; 2303 = m04; 1377 = m05, 2683 = m10?
//uint buf_table[(2683*4-sizeof(unk_table))/4];
struct {
uint unk[4]; // 0 = name index, 1, 2 = msg index, 3 = sound index
uint type_id; // 104857600, 78643200
//
uint count;
uint buf[count];
//
uint count;
uint buf_[count];
} unk_table_[unk[1]] <optimize=false>;
/*struct {
uint unk;
struct {
uint count;
uint idx[count];
} entries[8] <optimize=false>;
} contain;*/
struct {
struct { // portals?
int i;
int i;
int count;
LTPlane planes[count];
struct {
int count;
LTVector vecs[count];
} faces[count] <optimize=false>;
} aratana_section[aratana_count] <optimize=false, bgcolor=0x22FF88>;
} aratana_container;
struct {
struct Node
{
int count;
int unk_[count]; // refs to aratana?
int flags; // maybe?
float unk; // radius or distance?
int next, next; // -1 = end of chain
} nodes[node_count] <optimize=false>;
} node_container;
} bundle_section;
struct UnkSection_
{
struct Unk_ {
int count;
struct {
LTPlane plane;
int count;
LTVector vecs[count];
} things[count] <optimize=false>;
} things[1] <optimize=false>;
int count, data_size;
local uint pos_save=FTell();
FSkip(data_size);
struct DataTable
{
struct {
uint size;
enum <uint> {
KeyframerId=1789855876,
AiNavMeshId=2213837873,
Dat2693Id=2693,
// FEAR 2
Dat1413762391=1413762391,
} type_id; //short unk, unk;
uint offset;
} entries[count];
} data_table;
struct {
local uint i=0;
for(i=0; i<count; ++i)
{
FSeek(pos_save+data_table.entries[i].offset);
switch(data_table.entries[i].type_id)
{
case KeyframerId:
struct Keyframer { // probably Keyframer?
int a, b, c;
int size; // in bytes
struct Frame { // Frame?
float time;
float b, c, d, e; // vector position + compressed rotation?
short unk, str_idx; // unk might be part of comp. rotation
} buf[size/sizeof(Frame)];
// if there's any non -1 str_idx then there's command strings here!
} blocks;
break;
case AiNavMeshId:
struct {
int a, b, c;
struct {
uint id; //, idx;
ushort a, b;
} entries[c];
uint count;
struct {
uint id, idx;
float floats[9];
int a, b;
LTVector normal;
} __[count];
uint count;
struct {
uint id; //, idx;
} ___[count];
uint count;
struct {
uint id; //, idx;
} ____[count];
uint count;
struct {
uint id; //, idx;
} _____[count];
uint count;
struct {
uint id; //, idx;
} _______[count];
uint count;
LTVector vecs[count]; // normals?
uint count;
struct {
//byte buf[84];
int id, id_2, id_3, neg_one;
int count;
float floats[9];
int count_[7];
} size_84b[count];
uint count;
uint unk_[count]; // index to size_84b[]?
uint count;
struct {
uint id;
int unk_[3];
float unk[4];
} unk_struct_[count];
uint count;
struct {
//byte buf[56];
uint id;
uint unk_ref_id;
uint unk;
uint count; // maybe children?
uint self_id;
int buf[9];
} size_56b[count];
uint count;
uint unk_ids[count*4];
uint count;
uint unk_ids_[count*4];
uint count;
struct {
uint id;
float unk;
uint offset, size, accum;
} unk_struct__[count];
// FEAR 2
uint count;
struct {
int a, b, c, d;
} unk_struct___[count];
uint count;
LTVector vecs_[count];
uint count;
struct {
int a, b;
} unk[count];
uint str_length;
char strings_buf[str_length];
uint count;
uint count_;
struct {
uint a, b;
LTString strings[b];
} ohtunho[count] <optimize=false>;
byte oadhnahta[7] <comment="Unknown">;
uint count;
struct {
LTVector pos;
LTQuaternion rot;
char name[32];
char flags[32];
char shape_type[32];
LTVector dimensions;
LTVector normal;
} shape[count];
uint count;
struct {
int a;
float b[6]; // [1] and [4] = flags?
int c[6];
} buf_[count];
uint count;
int unk_idx[count]; // indices to size_84b?
} ai_nav_mesh;
break;
case Dat2693Id:
struct {
uint count; if (count==0) uint unk;
LTVector vecs[3];
struct {
uint count;
float floats[count*5+9];
} unk[count] <optimize=false>;
} block;
break;
case Dat1413762391:
struct {
uint a;
uint b;
uint str_length;
char strings[str_length];
struct {
uint string_index;
short d, d;
uint c;
struct {
LTVector vec;
// maybe compressed quat?
int a;
short b, b;
int a;
} eohatuns[d[0]+d[1]];
} odun[b] <optimize=false>;
} unk_block;
break;
//default:
//Assert(0, "Unknown type_id");
}
//struct { byte pad[data_table.entries[i].size-sizeof(blocks)]; } buf <hidden=true>;
}
} data_container;
/*uint unk;
struct {
int counts[4];
struct {
float v, v, v, v;
short a, a;
short b, b;
} unk_struct_2[counts[3]];
} something[5] <optimize=false>;
FSeek(pos_save+counts);
struct {
int a;
short b, b;
int c; // increments by prev.a, appears to also be LTPad'd
} whatever[counts[3]];*/
} unk_section <bgcolor=0x8822FF>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment