|
1 /* |
|
2 * raytracermodule.h: raytracer module for Python |
|
3 * |
|
4 * This file is part of Pyrit Ray Tracer. |
|
5 * |
|
6 * Copyright 2006, 2007, 2008 Radek Brich |
|
7 * |
|
8 * Permission is hereby granted, free of charge, to any person obtaining a copy |
|
9 * of this software and associated documentation files (the "Software"), to deal |
|
10 * in the Software without restriction, including without limitation the rights |
|
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
12 * copies of the Software, and to permit persons to whom the Software is |
|
13 * furnished to do so, subject to the following conditions: |
|
14 * |
|
15 * The above copyright notice and this permission notice shall be included in |
|
16 * all copies or substantial portions of the Software. |
|
17 * |
|
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
24 * THE SOFTWARE. |
|
25 */ |
|
26 |
|
27 #ifndef RAYTRACERMODULE_H |
|
28 #define RAYTRACERMODULE_H |
|
29 |
|
30 #include <Python.h> |
|
31 #include "raytracer.h" |
|
32 #include "octree.h" |
|
33 #include "kdtree.h" |
|
34 |
|
35 |
|
36 #define TYPE_OBJECT(name, basicsize, dealloc, flags, doc, methods, members, base, init) \ |
|
37 { \ |
|
38 PyObject_HEAD_INIT(NULL) \ |
|
39 0, /* ob_size */ \ |
|
40 (name), /* tp_name */ \ |
|
41 (basicsize), /* tp_basicsize*/ \ |
|
42 0, /* tp_itemsize*/ \ |
|
43 (dealloc), /* tp_dealloc*/ \ |
|
44 0, /* tp_print*/\ |
|
45 0, /* tp_getattr*/\ |
|
46 0, /* tp_setattr*/\ |
|
47 0, /* tp_compare*/\ |
|
48 0, /* tp_repr*/\ |
|
49 0, /* tp_as_number*/\ |
|
50 0, /* tp_as_sequence*/\ |
|
51 0, /* tp_as_mapping*/\ |
|
52 0, /* tp_hash */\ |
|
53 0, /* tp_call*/\ |
|
54 0, /* tp_str*/\ |
|
55 PyObject_GenericGetAttr, /* tp_getattro*/\ |
|
56 0, /* tp_setattro*/\ |
|
57 0, /* tp_as_buffer*/\ |
|
58 (flags), /* tp_flags*/\ |
|
59 (doc), /* tp_doc */\ |
|
60 0, /* tp_traverse */\ |
|
61 0, /* tp_clear */\ |
|
62 0, /* tp_richcompare */\ |
|
63 0, /* tp_weaklistoffset */\ |
|
64 0, /* tp_iter */\ |
|
65 0, /* tp_iternext */\ |
|
66 (methods), /* tp_methods */\ |
|
67 (members), /* tp_members */\ |
|
68 0, /* tp_getset */\ |
|
69 (base), /* tp_base */\ |
|
70 0, /* tp_dict */ \ |
|
71 0, /* tp_descr_get */ \ |
|
72 0, /* tp_descr_set */ \ |
|
73 0, /* tp_dictoffset */ \ |
|
74 (init), /* tp_init */ \ |
|
75 0, /* tp_alloc */ \ |
|
76 0, /* tp_new */ \ |
|
77 0, /* tp_free */ \ |
|
78 } |
|
79 |
|
80 /** Light object */ |
|
81 typedef struct { |
|
82 PyObject_HEAD |
|
83 Light *light; |
|
84 } LightObject; |
|
85 |
|
86 /** Camera object */ |
|
87 typedef struct { |
|
88 PyObject_HEAD |
|
89 Camera *camera; |
|
90 } CameraObject; |
|
91 |
|
92 /** Pixmap object */ |
|
93 typedef struct { |
|
94 PyObject_HEAD |
|
95 const Pixmap *pixmap; |
|
96 } PixmapObject; |
|
97 |
|
98 /** abstract TextureMap object */ |
|
99 typedef struct { |
|
100 PyObject_HEAD |
|
101 TextureMap *texturemap; |
|
102 } TextureMapObject; |
|
103 |
|
104 /** PlanarMap object - inherits TextureMap */ |
|
105 typedef struct { |
|
106 TextureMapObject texturemap; |
|
107 } PlanarMapObject; |
|
108 |
|
109 /** CubicMap object - inherits TextureMap */ |
|
110 typedef struct { |
|
111 TextureMapObject texturemap; |
|
112 } CubicMapObject; |
|
113 |
|
114 /** CylinderMap object - inherits TextureMap */ |
|
115 typedef struct { |
|
116 TextureMapObject texturemap; |
|
117 } CylinderMapObject; |
|
118 |
|
119 /** SphereMap object - inherits TextureMap */ |
|
120 typedef struct { |
|
121 TextureMapObject texturemap; |
|
122 } SphereMapObject; |
|
123 |
|
124 /** abstract ColourMap object */ |
|
125 typedef struct { |
|
126 PyObject_HEAD |
|
127 ColourMap *colourmap; |
|
128 } ColourMapObject; |
|
129 |
|
130 /** LinearColourMap object - inherits ColourMap */ |
|
131 typedef struct { |
|
132 ColourMapObject colourmap; |
|
133 } LinearColourMapObject; |
|
134 |
|
135 /** BoundColourMap object - inherits ColourMap */ |
|
136 typedef struct { |
|
137 ColourMapObject colourmap; |
|
138 Float *bounds; |
|
139 Colour *colours; |
|
140 } BoundColourMapObject; |
|
141 |
|
142 /** abstract Texture object */ |
|
143 typedef struct { |
|
144 PyObject_HEAD |
|
145 Texture *texture; |
|
146 } TextureObject; |
|
147 |
|
148 /** ImageTexture object - inherits Texture */ |
|
149 typedef struct { |
|
150 TextureObject texture; |
|
151 } ImageTextureObject; |
|
152 |
|
153 /** CheckersTexture object - inherits Texture */ |
|
154 typedef struct { |
|
155 TextureObject texture; |
|
156 } CheckersTextureObject; |
|
157 |
|
158 /** CloudTexture object - inherits Texture */ |
|
159 typedef struct { |
|
160 TextureObject texture; |
|
161 } CloudTextureObject; |
|
162 |
|
163 /** Material object */ |
|
164 typedef struct { |
|
165 PyObject_HEAD |
|
166 Material *material; |
|
167 } MaterialObject; |
|
168 |
|
169 /** NormalVertex object */ |
|
170 typedef struct { |
|
171 PyObject_HEAD |
|
172 NormalVertex *nvertex; |
|
173 } NormalVertexObject; |
|
174 |
|
175 /** abstract Shape object */ |
|
176 typedef struct { |
|
177 PyObject_HEAD |
|
178 Shape *shape; |
|
179 } ShapeObject; |
|
180 |
|
181 /** Triangle object - inherits Shape */ |
|
182 typedef struct { |
|
183 ShapeObject shape; |
|
184 } TriangleObject; |
|
185 |
|
186 /** Sphere object - inherits Shape */ |
|
187 typedef struct { |
|
188 ShapeObject shape; |
|
189 } SphereObject; |
|
190 |
|
191 /** Box object - inherits Shape */ |
|
192 typedef struct { |
|
193 ShapeObject shape; |
|
194 } BoxObject; |
|
195 |
|
196 /** abstract Sampler object */ |
|
197 typedef struct { |
|
198 PyObject_HEAD |
|
199 Sampler *sampler; |
|
200 } SamplerObject; |
|
201 |
|
202 /** DefaultSampler object - inherits Sampler */ |
|
203 typedef struct { |
|
204 SamplerObject sampler; |
|
205 } DefaultSamplerObject; |
|
206 |
|
207 /** Container object */ |
|
208 typedef struct { |
|
209 PyObject_HEAD |
|
210 Container *container; |
|
211 } ContainerObject; |
|
212 |
|
213 /** Octree object - inherits Container */ |
|
214 typedef struct { |
|
215 ContainerObject container; |
|
216 } OctreeObject; |
|
217 |
|
218 /** KdTree object - inherits Container */ |
|
219 typedef struct { |
|
220 ContainerObject container; |
|
221 } KdTreeObject; |
|
222 |
|
223 /** main Raytracer object */ |
|
224 typedef struct { |
|
225 PyObject_HEAD |
|
226 Raytracer *raytracer; |
|
227 vector<PyObject*> *children; |
|
228 } RaytracerObject; |
|
229 |
|
230 #endif |