summaryrefslogtreecommitdiff
path: root/src/factories/LightsFactory.h
blob: a063ddfcae92402ae9a379e5490a7d4b9fe9c44a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once

#include "BaseFactory.h"

struct Light_tRaw {
  uint8_t	col[3];		/* diffuse light value (rgba) */
  int8_t 		pad1;
  uint8_t	colc[3];	/* copy of diffuse light value (rgba) */
  int8_t 		pad2;
  int8_t	dir[3];		/* direction of light (normalized) */
  int8_t 		pad3;
};

union LightRaw {
    Light_tRaw	l;
    long long int	force_structure_alignment[2];
};

struct Ambient_tRaw {
  uint8_t	col[3];		/* ambient light value (rgba) */
  int8_t 		pad1;
  uint8_t	colc[3];	/* copy of ambient light value (rgba) */
  int8_t 		pad2;
};


union AmbientRaw {
    Ambient_tRaw	l;
    long long int	force_structure_alignment[1];
};

struct Lights1Raw {
    AmbientRaw	a;
    LightRaw	l[1];
};

class LightsData : public IParsedData {
public:
    Lights1Raw mLights;

    LightsData(Lights1Raw lights) : mLights(lights) {}
};

class LightsHeaderExporter : public BaseExporter {
    void Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName, YAML::Node& node, std::string* replacement) override;
};

class LightsBinaryExporter : public BaseExporter {
    void Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName, YAML::Node& node, std::string* replacement) override;
};

class LightsCodeExporter : public BaseExporter {
    void Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName, YAML::Node& node, std::string* replacement) override;
};

class LightsFactory : public BaseFactory {
public:
    std::optional<std::shared_ptr<IParsedData>> parse(std::vector<uint8_t>& buffer, YAML::Node& data) override;
    std::optional<std::shared_ptr<IParsedData>> parse_modding(std::vector<uint8_t>& buffer, YAML::Node& data) override {
        return std::nullopt;
    }
    inline std::unordered_map<ExportType, std::shared_ptr<BaseExporter>> GetExporters() override {
        return {
            REGISTER(Code, LightsCodeExporter)
            REGISTER(Header, LightsHeaderExporter)
            REGISTER(Binary, LightsBinaryExporter)
        };
    }
    bool SupportModdedAssets() override { return false; }
};