-
Notifications
You must be signed in to change notification settings - Fork 0
/
object.h
139 lines (116 loc) · 2.73 KB
/
object.h
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#pragma once
#include "file.h"
#include "dlb_types.h"
#include "dlb_hash.h"
typedef enum {
F_NULL,
// Atomic types
F_ATOM_INT,
F_ATOM_UINT,
F_ATOM_FLOAT,
F_ATOM_STRING,
F_ATOM_END = F_ATOM_STRING,
// Object types
F_TA_VEC3,
F_TA_RGB,
F_TA_VEC4,
F_TA_RGBA,
F_TA_TRANSFORM,
F_TA_SUN_LIGHT,
F_TA_POINT_LIGHT,
F_TA_MATERIAL,
F_TA_MESH,
F_TA_SHADER,
F_TA_TEXTURE,
F_TA_ENTITY,
F_COUNT,
} ta_field_type;
typedef struct {
ta_field_type type;
const char *name;
int offset;
bool alias;
} ta_schema_field;
typedef struct {
ta_field_type type;
const char *name;
ta_schema_field *fields;
} ta_schema;
extern ta_schema tg_schemas[];
extern dlb_hash tg_schemas_by_name;
const char *ta_field_type_str(ta_field_type type);
void obj_field_add(ta_schema *obj, ta_field_type type, const char *name,
u32 offset, bool alias);
ta_schema_field *obj_field_find(ta_field_type type, const char *name);
void obj_register();
////////////////////////////////////////////////////////////////////////////////
typedef struct {
float x, y, z;
} ta_vec3;
typedef struct {
float r, g, b;
} ta_rgb;
typedef struct {
float x, y, z, w;
} ta_vec4;
typedef struct {
float r, g, b, a;
} ta_rgba;
typedef struct {
ta_vec3 position;
ta_vec4 rotation;
ta_vec3 scale;
} ta_transform;
////////////////////////////////////////////////////////////////////////////////
typedef struct ta_scene_s ta_scene;
typedef struct ta_sun_light_s {
ta_scene *scene;
const char *name;
ta_vec3 direction;
ta_vec3 color;
} ta_sun_light;
typedef struct ta_point_light_s {
ta_scene *scene;
const char *name;
ta_vec3 position;
ta_vec3 color;
} ta_point_light;
typedef struct ta_material_s {
ta_scene *scene;
const char *name;
//ta_texture *texture; // TODO: Use file id?
} ta_material;
typedef struct ta_mesh_s {
ta_scene *scene;
const char *name;
const char *path;
} ta_mesh;
typedef struct ta_shader_s {
ta_scene *scene;
const char *name;
const char *path;
} ta_shader;
typedef struct ta_texture_s {
ta_scene *scene;
const char *name;
const char *path;
} ta_texture;
typedef enum {
ENTITY_DEFAULT
} ta_entity_type;
typedef struct ta_entity_s ta_entity;
typedef struct ta_entity_s {
ta_scene *scene;
const char *name;
ta_entity_type type;
const char *material;
const char *mesh;
const char *shader;
const char *texture;
ta_transform transform;
ta_entity *parent;
//ta_entity *next; // TODO: Is a sibling linked list useful?
ta_entity **children;
} ta_entity;
void obj_print(FILE *f, ta_field_type type, u8 *ptr, int level);
ta_material *entity_material(ta_entity *e);