summaryrefslogtreecommitdiff
path: root/src/objects/object.h
blob: 9c9f60caa00ecae97d3d19062098069a7e0a65cb (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
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef _OBJECT_H
#define _OBJECT_H

#include "model.h"
#include "effect.h"

namespace Mauri
{

enum ObjectAlignment
{
    CENTER = 0
};

enum BlendMode
{
    TRANSLUCENT = 0,
    NORMAL
};

class Object
{
  public:
    Object() = default;
    ~Object();

    u32 id;
    std::string name;

    bool visible;

    std::vector<u32> deps;

    bool fullscreen = false;
    bool passthrough = false;

    vec3 angles;
    vec2 size;
    vec3 scale;
    vec3 origin;
    vec3 color;
    f32 alpha;
    s32 color_blend_mode;

    vec4 color4;

    mat4x4 model_model;
    mat4x4 combine_model;

    RenderObject *model_object = nullptr;
    RenderObject *combine_object = nullptr;

    static auto parse(Parser &pr, const json &root) -> Object *;

    auto get_target_buffer() const -> const std::string &;
    auto get_texture_buffer() const -> const std::string &;

    auto swap_buffers() -> void { buffer_switch = !buffer_switch; }

    bool loaded = false;
    bool loaded_as_dep = false;

    Model *model = nullptr;
    std::vector<Effect *> effects;

    std::vector<RenderPass *> passes;

    auto load(Engine *engine) -> void;
    auto create_objects(Engine *engine, Texture *texture) -> void;

    auto draw(Engine *engine) -> void;

  private:
    bool buffer_switch;
    std::string buffer_a;
    std::string buffer_b;

    auto draw_internal(Engine *engine) -> void;
};

} // namespace Mauri

#endif // _OBJECT_H