added cylinder primitive
[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, height;
42 };
43
44 struct plane {
45         struct object ob;
46         float nx, ny, nz;
47         float d;
48 };
49
50 struct box {
51         struct object ob;
52         float xsz, ysz, zsz;
53 };
54
55 struct csgop {
56         struct object ob;
57         csg_object *a, *b;
58 };
59
60 union csg_object {
61         struct object ob;
62         struct sphere sph;
63         struct cylinder cyl;
64         struct plane plane;
65         struct box box;
66         struct csgop un, isect, sub;
67 };
68
69 struct camera {
70         float x, y, z;
71         float tx, ty, tz;
72         float ux, uy, uz;
73         float fov;
74
75         float xform[16];
76 };
77
78 int csg_dbg_pixel;
79
80 #endif  /* CSGIMPL_H_ */