Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
PredatorCZ committed Jul 31, 2024
1 parent b2e1452 commit f981736
Show file tree
Hide file tree
Showing 18 changed files with 3,732 additions and 131 deletions.
2 changes: 1 addition & 1 deletion 3rd_party/spike
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ add_subdirectory(common)
target_link_libraries(spike_cli insomnia-objects)
add_spike_subdir(extract)
add_spike_subdir(effect)
add_spike_subdir(levelmain)
add_spike_subdir(main)

set(TPD_PATH ${CMAKE_CURRENT_SOURCE_DIR}/3rd_party/fragmented/3rd_party)
add_spike_subdir(3rd_party/fragmented/psarc)
49 changes: 46 additions & 3 deletions common/include/insomnia/classes/moby.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "insomnia/internal/base.hpp"
#include "spike/type/matrix44.hpp"

struct Primitive : CoreClass {
struct PrimitiveV2 : CoreClass {
static constexpr uint32 ID = 0xdd00;

uint32 indexOffset;
Expand All @@ -42,7 +42,7 @@ struct Primitive : CoreClass {
struct Mesh : CoreClass {
static constexpr uint32 ID = 0xd700;

es::PointerX86<Primitive> primitives;
es::PointerX86<PrimitiveV2> primitives;
uint32 numPrimitives;
};

Expand All @@ -67,7 +67,7 @@ struct Skeleton : CoreClass {
uint32 off2;
};

struct Moby : CoreClass {
struct MobyV2 : CoreClass {
static constexpr uint32 ID = 0xd100;

float unk00[4];
Expand Down Expand Up @@ -102,3 +102,46 @@ struct Moby : CoreClass {
es::PointerX86<char> unkData6;
uint32 null01[12];
};

struct PrimitiveV1 : CoreClass {
static constexpr uint32 ID = 0xdd00;

uint16 materialIndex;
uint16 numVertices;
uint16 numIndices;
uint8 numJoints;
uint8 vertexFormat;
uint32 indexOffset;
uint32 vertexBufferOffset;
es::PointerX86<uint16> joints;
uint32 unk[3];
};

struct MeshV1 : CoreClass {
es::PointerX86<PrimitiveV1> primitives;
uint32 numPrimitives;
};

struct MobyV1 : CoreClass {
static constexpr uint32 ID = 0xd100;

float unk00[4];
uint16 unk01;
uint16 unk02;
uint16 numBones;
uint16 unk03;
uint16 numMeshes;
uint16 mobyId;
uint16 null00;
uint8 anotherSet; // bool?
uint8 null01;
es::PointerX86<Skeleton> skeleton;
es::PointerX86<char> unkData0;
es::PointerX86<MeshV1> meshes;
es::PointerX86<char> unkData1;
uint32 null02;
uint32 indexBufferOffset;
int32 vertexBufferOffset;
float meshScale;
uint32 unkRest[32];
};
163 changes: 163 additions & 0 deletions common/include/insomnia/classes/resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ static constexpr uint32 ResourceTiePathLookupId = 0x3410;
static constexpr uint32 ResourceShrubPathLookupId = 0xb700;
static constexpr uint32 ResourceCinematicPathLookupId = 0x17d00;

template <uint32 id_> struct ResourceNameLookup : CoreClass {
static constexpr uint32 ID = id_;
Hash hash;
es::PointerX86<char> path;
uint32 unk;

bool operator<(const Hash other) const { return hash < other; }
bool operator==(const Hash other) const { return hash == other; }
bool operator==(uint32 other) const { return hash.part2 == other; }
};

using ResourceMobyPath = ResourceNameLookup<0x9480>;
using ResourceTiePath = ResourceNameLookup<0x9280>;

struct EffectTextureBuffer : CoreClass {
static constexpr uint32 ID = 0x5300;
char data;
Expand All @@ -61,3 +75,152 @@ struct IndexBuffer : CoreClass {
static constexpr uint32 ID = 0xe100;
uint16 data;
};

struct LevelVertexBuffer : CoreClass {
static constexpr uint32 ID = 0x9000;
char data;
};

struct LevelIndexBuffer : CoreClass {
static constexpr uint32 ID = 0x9100;
uint16 data;
};

struct RegionMesh : CoreClass {
static constexpr uint32 ID = 0x6200;

float unk[16];
Vector position;
uint16 materialIndex;
uint16 unk6;
uint32 unk3;
uint32 indexOffset;
uint32 vertexOffset;
uint16 numIndices;
uint16 numVerties;
uint32 unk2[5];
float meshScale;
uint32 unk4[2];
};

struct RegionMeshV2 : CoreClass {
static constexpr uint32 ID = 0x6200;

float unk[16];
uint32 indexOffset;
uint32 vertexOffset;
uint16 numIndices;
uint16 numVerties;
uint16 unk7[2];
uint16 materialIndex;
uint16 unk6;
uint32 unk2[3];
Vector position;
uint32 unk4;
float unk5[4];
};

struct ShrubPrimitive : CoreClass {
static constexpr uint32 ID = 0xB200;
uint16 materialIndex;
uint16 unk1;
uint16 numVertices;
uint16 numIndices;
uint32 vertexBufferOffset;
uint32 indexOffset;
uint16 unk4[8];
};

struct Shrub : CoreClass {
static constexpr uint32 ID = 0xB300;
float unk0[20];
es::PointerX86<ShrubPrimitive> primitives;
uint32 numPrimitives;
uint32 null00[2];
uint16 unk1[2];
float meshScale;
float unk2[6];
};

struct ShrubInstance : CoreClass {
static constexpr uint32 ID = 0x9500;
es::Matrix44 tm;
float unk0[4];
es::PointerX86<Shrub> shrub;
int32 unk1[11];
};

struct FoliageBranchLod {
uint32 indexOffset;
uint16 numIndices;
uint16 unk;
};

struct SpriteLodRange {
uint32 indexBegin;
uint32 indexEnd;
uint32 unk0;
float unk1;
};

struct SpriteRange {
uint16 indexBegin;
uint16 indexEnd;
uint16 positionsOffset;
uint16 numSprites;
};

struct Foliage : CoreClass {
static constexpr uint32 ID = 0xc200;
uint32 unk0;
uint16 unk4;
uint16 unk6;
uint32 textureIndex;
uint32 unk5;
uint32 indexOffset;
uint32 null0;
uint32 branchVertexOffset;
uint32 unk1;
FoliageBranchLod branchLods[4];
uint32 spriteVertexOffset;
uint32 usedSpriteLods;
SpriteLodRange spriteLodRanges[6];
float unk2[4];
es::PointerX86<float> spritePositions;
uint32 usedSpriteRanges;
SpriteRange spriteRanges[8];
float unk3[8];
};

struct FoliageInstance : CoreClass {
static constexpr uint32 ID = 0x9700;

es::Matrix44 tm;
float unk0[33];
es::PointerX86<Foliage> foliage;
uint32 unk1[2];
uint32 unk[4];
};

struct HighmipTextureData : CoreClass {
static constexpr uint32 ID = 0x9800;

uint32 dataOffset;
uint16 dataSize;
uint16 textureIndex;
int16 unk0;
uint16 unk2;
uint32 null0;
};

struct PlantPrimitive : CoreClass {
static constexpr uint32 ID = 0xC700;

uint32 vertexBufferOffset;
uint32 indexOffset;
uint32 numIndices;
uint32 unk0;
float unk1[4];
uint16 materialIndex;
uint32 unk2[3];
};
93 changes: 81 additions & 12 deletions common/include/insomnia/classes/shader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@ struct TextureResource : CoreClass {
bool operator==(uint32 other) const { return hash == other; }
};

struct Material : CoreClass {
static constexpr uint32 ID = 0x5000;
int32 diffuseMapId;
int32 normalMapId;
int32 specularMapId;
int32 detailMapId;
uint32 unk0; // flags?
Vector4A16 values[6];
};

struct TextureFlags {
using location = BitMemberDecl<3, 2>;
using isCubemap = BitMemberDecl<2, 1>;
Expand Down Expand Up @@ -119,12 +109,24 @@ struct TextureControl3 {

using TextureControl3Type = TextureControl3::Type;

enum class TextureFormat : uint8 {
R8 = 0x81,
RGB5A1,
RGBA4,
R5G6B5,
RGBA8,
BC1,
BC2,
BC3,
RG8 = 0x8B
};

// NV4097_SET_*TEXTURE_* registry dump
struct Texture : CoreClass {
static constexpr uint32 ID = 0x5200;
uint32 offset;
uint16 numMips;
uint8 format;
TextureFormat format;
TextureFlagsType flags;
TextureAddressType address;
TextureControl0Type control0;
Expand All @@ -135,7 +137,74 @@ struct Texture : CoreClass {
uint32 borderColor;
};

struct ShaderResource : CoreClass {
struct LightmapTexture : Texture {
static constexpr uint32 ID = 0x5400;
};

struct ShadowmapTexture : Texture {
static constexpr uint32 ID = 0x5410;
};

struct LightmapTextureV1 : Texture {
static constexpr uint32 ID = 0x5500;
};

struct TextureV1 : Texture {
static constexpr uint32 ID = 0x5300;
};

struct BlendmapTextureV1 : Texture {
static constexpr uint32 ID = 0x5800;
};

struct MaterialV1 : CoreClass {
static constexpr uint32 ID = 0x5001;

float unk0[5];
uint32 unk1[2];
bool unkFlag : 1;
bool useSpecular : 1;
bool useGlossiness : 1;
bool useNormalMap : 1;
bool useDetailMap : 1;
bool restFlags : 3;
uint8 blendMode;
uint8 unk2;
uint8 null0;
es::PointerX86<Texture> textures[4];
Vector4A16 values[5];
};

struct MaterialV1_5 : CoreClass {
static constexpr uint32 ID = 0x5000;

es::PointerX86<Texture> diffuse;
es::PointerX86<Texture> normal;
es::PointerX86<Texture> specular;
es::PointerX86<Texture> detail;
bool unkFlag : 1;
bool useSpecular : 1;
bool useGlossiness : 1;
bool useNormalMap : 1;
bool useDetailMap : 1;
bool restFlags : 3;
uint8 blendMode;
uint8 unk0;
uint8 unk1;
Vector4A16 values[6];
};

struct Material : CoreClass {
static constexpr uint32 ID = 0x5000;
int32 diffuseMapId;
int32 normalMapId;
int32 specularMapId;
int32 detailMapId;
uint32 unk0; // flags?
Vector4A16 values[6];
};

struct MaterialResourceNameLookup : CoreClass {
static constexpr uint32 ID = 0x5d00;
Hash hash;
es::PointerX86<char> lookupPath;
Expand Down
Loading

0 comments on commit f981736

Please sign in to comment.