8b65783640a20d7aa89f3cb794d3bcfcb6eee36c
[csgray] / src / csgimpl.h
1 #ifndef CSGIMPL_H_
2 #define CSGIMPL_H_
3
4 #include "csgray.h"
5
6 enum {
7         OB_NULL,
8         OB_SPHERE,
9         OB_CYLINDER,
10         OB_PLANE,
11         OB_BOX,
12         OB_UNION,
13         OB_INTERSECTION,
14         OB_SUBTRACTION
15 };
16
17 struct object {
18         int type;
19
20         float r, g, b;
21         float emr, emg, emb;
22         float roughness;
23         float opacity;
24         int metallic;
25
26         float xform[16], inv_xform[16];
27
28         csg_object *next;
29         csg_object *plt_next;
30
31         void (*destroy)(csg_object*);
32 };
33
34 struct sphere {
35         struct object ob;
36         float rad;
37 };
38
39 struct cylinder {
40         struct object ob;
41         float rad;
42 };
43
44 struct plane {
45         struct object ob;
46         float nx, ny, nz;
47         float d;
48 };
49
50 struct csgop {
51         struct object ob;
52         csg_object *a, *b;
53 };
54
55 union csg_object {
56         struct object ob;
57         struct sphere sph;
58         struct cylinder cyl;
59         struct plane plane;
60         struct csgop un, isect, sub;
61 };
62
63 struct camera {
64         float x, y, z;
65         float tx, ty, tz;
66         float ux, uy, uz;
67         float fov;
68
69         float xform[16];
70 };
71
72 #endif  /* CSGIMPL_H_ */