Implement writer for raw materials

This commit is contained in:
Jan
2023-07-29 02:08:10 +02:00
parent 5db7bc2d4c
commit d48e0519ac
7 changed files with 329 additions and 0 deletions

View File

@ -0,0 +1,35 @@
#include "MaterialCommon.h"
using namespace material;
CommonConstant::CommonConstant()
: m_literal{}
{
}
CommonMaterial::CommonMaterial()
: m_game_flags(0u),
m_sort_key(0u),
m_texture_atlas_row_count(0u),
m_texture_atlas_column_count(0u),
m_surface_flags(0u),
m_contents(0u),
m_ref_state_bits{}
{
}
CommonTexture::CommonTexture()
: m_sampler_state(0u),
m_semantic(0u)
{
}
CommonWaterDef::CommonWaterDef()
: m_texture_width(0u),
m_horizontal_world_length(0u),
m_vertical_world_length(0u),
m_amplitude(0u),
m_wind_speed(0u),
m_wind_direction{}
{
}

View File

@ -0,0 +1,61 @@
#pragma once
#include <cstdint>
#include <memory>
#include <string>
#include <vector>
namespace material
{
class CommonWaterDef
{
public:
int m_texture_width;
float m_horizontal_world_length;
float m_vertical_world_length;
float m_amplitude;
float m_wind_speed;
float m_wind_direction[2];
CommonWaterDef();
};
class CommonTexture
{
public:
std::string m_name;
uint8_t m_sampler_state;
uint8_t m_semantic;
std::string m_image_name;
std::unique_ptr<CommonWaterDef> m_water_def;
CommonTexture();
};
class CommonConstant
{
public:
std::string m_name;
float m_literal[4];
CommonConstant();
};
class CommonMaterial
{
public:
std::string m_name;
uint8_t m_game_flags;
uint8_t m_sort_key;
uint8_t m_texture_atlas_row_count;
uint8_t m_texture_atlas_column_count;
uint32_t m_surface_flags;
uint32_t m_contents;
uint32_t m_ref_state_bits[2];
std::vector<CommonTexture> m_textures;
std::vector<CommonConstant> m_constants;
std::string m_techset_name;
CommonMaterial();
};
}

View File

@ -0,0 +1,59 @@
#pragma once
#include <cstdint>
namespace material
{
struct MaterialRawOatHeader
{
uint8_t magic[3];
uint8_t version;
};
struct MaterialInfoRaw
{
uint32_t nameOffset;
uint8_t gameFlags;
uint8_t sortKey;
uint8_t textureAtlasRowCount;
uint8_t textureAtlasColumnCount;
uint32_t surfaceFlags;
uint32_t contents;
};
struct MaterialRaw
{
MaterialInfoRaw info;
uint32_t refStateBits[2];
uint16_t textureCount;
uint16_t constantCount;
uint32_t techSetNameOffset;
uint32_t textureTableOffset;
uint32_t constantTableOffset;
};
struct MaterialTextureDefRaw
{
uint32_t nameOffset;
uint8_t samplerState;
uint8_t semantic;
uint32_t imageNameOffset;
uint32_t waterDefOffset;
};
struct MaterialWaterDefRaw
{
uint32_t textureWidth;
float horizontalWorldLength;
float verticalWorldLength;
float amplitude;
float windSpeed;
float windDirection[2];
};
struct MaterialConstantDefRaw
{
uint32_t nameOffset;
float literal[4];
};
}