Skip to content
This repository has been archived by the owner on Dec 22, 2024. It is now read-only.

Commit

Permalink
#23, #1: Convert 010 Editor template to structs
Browse files Browse the repository at this point in the history
  • Loading branch information
Xaymar committed Mar 1, 2024
1 parent 625341e commit 6443a00
Showing 1 changed file with 173 additions and 12 deletions.
185 changes: 173 additions & 12 deletions source/stingray_unit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,184 @@
#include <cinttypes>
#include <cstddef>
#include <list>
#include "stingray.hpp"
#include "stingray_data.hpp"

namespace stingray {
class unit {
private:
stingray::data_110000F0::meta_t _meta;
uint8_t const* _data;
size_t _data_sz;
namespace unit {
enum class element_type : uint32_t {
POSITION = 0,
_1 = 1,
_2 = 2,
_3 = 3,
TEXCOORD = 4,
// This is usually always 0xFFFFFFFF
_5 = 5,
// These two are only present with a .bones file.
_BONES_6 = 6,
_BONES_7 = 7,
};

public:
~unit();
unit(stingray::data_110000F0::meta_t meta);
enum class element_format : uint32_t {
F32VEC2 = 1,
F32VEC3 = 2,

size_t size();
_4_4B_WIDE = 4,
_24_4B_WIDE = 24,
_25_4B_WIDE = 25,
_26_4B_WIDE = 26,

std::string extension();
F16VEC2 = 29,
};

std::list<std::pair<void const*, size_t>> sections();
};
struct datatype_t {
uint32_t magic;
uint32_t __unk0;

struct element_t {
element_type type;
element_format format;
uint32_t layer;
uint32_t __unk0;
uint32_t __unk1;
} element[16];
uint32_t elements;
uint32_t __unk1;

struct {
uint32_t magic;
uint32_t __unk0;
uint32_t __unk1;
uint32_t __unk2;
uint32_t vertices;
uint32_t vertex_stride;
uint32_t __unk3;
uint32_t __unk4;
uint32_t __unk5;
uint32_t __unk6;
} __unk2;

struct {
uint32_t magic;
uint32_t __unk00;
uint32_t __unk01;
uint32_t __unk02;
uint32_t indices;
uint32_t __unk03;
uint32_t __unk04;
uint32_t __unk05;
uint32_t __unk06;
uint32_t __unk07;
uint32_t vertex_offset;
uint32_t vertex_size;
uint32_t index_offset;
uint32_t index_size;
uint32_t __unk08;
uint32_t __unk09;
uint32_t __unk10;
uint32_t __unk11;
} __unk3;
};

struct meshinfo_group_t {
uint32_t __unk0;
uint32_t vertex_offset;
uint32_t vertices;
uint32_t index_offset;
uint32_t indices;
uint32_t __unk1;
};

struct meshinfo_t {
uint32_t __unk00;
uint32_t __unk01;
uint32_t __unk02;
uint32_t __unk03;
uint32_t __unk04;
uint32_t __unk05;
uint32_t __unk06;
uint32_t __unk07;
uint32_t __unk08;
uint32_t __unk09;
stingray::thin_hash_t node;
uint32_t __unk10;
uint32_t __unk11;
uint32_t __unk12;
uint32_t __unk13;
uint32_t datatype_index;
uint32_t __unk14;
uint32_t __unk15;
uint32_t __unk16;
uint32_t __unk17;
uint32_t __unk18;
uint32_t __unk19;
uint32_t __unk20;
uint32_t __unk21;
uint32_t __unk22;
uint32_t __unk23;
uint32_t materials;
uint32_t material_offset;
uint32_t __unk24;
uint32_t __unk25;
uint32_t groups;
uint32_t group_offset;

// at this+material_offset:
// stingray::thin_hash_t material[materials];

// at this+group_offset:
// stingray::unit::mesh_group_t group[groups];
};

struct unit_materials_t {
uint32_t count;
//stingray::thin_hash_t keys[count];
//stingray::hash_t values[count];
};

struct unit_t {
uint32_t __unk00;
uint32_t __unk01;
stingray::hash_t bones;
uint32_t __unk02;
uint32_t __unk03;
stingray::hash_t __unkhash00;
stingray::hash_t state_machine;
uint32_t __unk04;
uint32_t __unk05;
uint32_t __unkoffset0;
uint32_t nodes_offset;
uint32_t __unkoffset2;
uint32_t __unkoffset3;
uint32_t __unk06;
uint32_t __unk07;
uint32_t __unk08;
uint32_t __unkoffset4;
uint32_t __unkoffset5;
uint32_t __unk09;
uint32_t __unkoffset6;
uint32_t datatypes_offset;
uint32_t meshdata_offset;
uint32_t meshinfo_offset;
uint32_t __unk10;
uint32_t __unk11;
uint32_t materials_offset;
};

class unit {
stingray::data_110000F0::meta_t _meta;
uint8_t const* _data;
size_t _data_sz;

public:
~unit();
unit(stingray::data_110000F0::meta_t meta);

size_t size();

std::string extension();

std::list<std::pair<void const*, size_t>> sections();
};
} // namespace unit
} // namespace stingray

0 comments on commit 6443a00

Please sign in to comment.