author | Radek Brich <radek.brich@devl.cz> |
Thu, 15 May 2008 00:07:25 +0200 | |
branch | pyrit |
changeset 96 | 9eb71e76c7fd |
parent 93 | 96d65f841791 |
child 97 | 2a853d284a6a |
permissions | -rw-r--r-- |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1 |
/* |
96
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
2 |
* raytracermodule.cc: raytracer module for Python |
44 | 3 |
* |
4 |
* This file is part of Pyrit Ray Tracer. |
|
5 |
* |
|
48
a4913301c626
begin moving subsampling and oversampling to Sampler
Radek Brich <radek.brich@devl.cz>
parents:
47
diff
changeset
|
6 |
* Copyright 2006, 2007, 2008 Radek Brich |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
7 |
* |
44 | 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. |
|
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
25 |
*/ |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
26 |
|
96
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
27 |
#include "raytracermodule.h" |
1
e74bf781067e
use python-config, strip python version from demos, change [PyRit] to [pyrit] -- should use unix name everywhere
Radek Brich <radek.brich@devl.cz>
parents:
0
diff
changeset
|
28 |
|
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
29 |
#include <vector> |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
30 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
31 |
|
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
32 |
//=========================== Light Source Object =========================== |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
33 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
34 |
static PyObject *Light_Constructor(PyObject* self, PyObject* args, PyObject *kwd); |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
35 |
static void Light_Destructor(PyObject* self); |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
72
diff
changeset
|
36 |
static PyObject *Light_castShadows(PyObject* self, PyObject* args); |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
37 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
38 |
static PyMethodDef LightMethods[] = { |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
72
diff
changeset
|
39 |
{"castShadows", (PyCFunction)Light_castShadows, METH_VARARGS, "Enable or disable shadows from this light."}, |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
40 |
{NULL, NULL} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
41 |
}; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
42 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
43 |
static PyTypeObject LightType = |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
44 |
TYPE_OBJECT( |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
45 |
"Light", /* tp_name */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
46 |
sizeof(LightObject), /* tp_basicsize */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
47 |
Light_Destructor, /* tp_dealloc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
48 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
49 |
"Light type", /* tp_doc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
50 |
LightMethods, /* tp_methods */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
51 |
0, /* tp_members */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
52 |
0, /* tp_base */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
53 |
0 /* tp_init */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
54 |
); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
55 |
|
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
56 |
static PyObject* Light_Constructor(PyObject* self, PyObject* args, PyObject *kwd) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
57 |
{ |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
58 |
LightObject *v; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
59 |
static char *kwdlist[] = {"position", "colour", NULL}; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
60 |
PyObject *TPos, *TCol = NULL; |
22 | 61 |
Float px, py, pz; |
93 | 62 |
Float cr = 0.9f, cg = 0.9f, cb = 0.9f; |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
63 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
64 |
if (!PyArg_ParseTupleAndKeywords(args, kwd, "O!|O!", kwdlist, |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
65 |
&PyTuple_Type, &TPos, &PyTuple_Type, &TCol)) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
66 |
return NULL; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
67 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
68 |
if (!PyArg_ParseTuple(TPos, "fff", &px, &py, &pz)) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
69 |
return NULL; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
70 |
if (TCol && !PyArg_ParseTuple(TCol, "fff", &cr, &cg, &cb)) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
71 |
return NULL; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
72 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
73 |
v = PyObject_New(LightObject, &LightType); |
91 | 74 |
v->light = new Light(Vector(px, py, pz), Colour(cr, cg, cb)); |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
75 |
return (PyObject*)v; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
76 |
} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
77 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
78 |
static void Light_Destructor(PyObject* self) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
79 |
{ |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
80 |
delete ((LightObject *)self)->light; |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
81 |
self->ob_type->tp_free(self); |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
82 |
} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
83 |
|
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
72
diff
changeset
|
84 |
static PyObject *Light_castShadows(PyObject* self, PyObject* args) |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
85 |
{ |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
86 |
int shadows = 1; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
87 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
88 |
if (!PyArg_ParseTuple(args, "i", &shadows)) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
89 |
return NULL; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
90 |
|
21
79b516a3803d
naive color driven sub-sampling
Radek Brich <radek.brich@devl.cz>
parents:
20
diff
changeset
|
91 |
((LightObject *)self)->light->castShadows(shadows); |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
92 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
93 |
Py_INCREF(Py_None); |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
94 |
return Py_None; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
95 |
} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
96 |
|
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
97 |
//=========================== Camera Object =========================== |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
98 |
|
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
99 |
static PyObject *Camera_Constructor(PyObject* self, PyObject* args, PyObject *kwd); |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
100 |
static void Camera_Destructor(PyObject* self); |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
101 |
static PyObject *Camera_setEye(PyObject* self, PyObject* args); |
72
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
102 |
static PyObject *Camera_setAngle(PyObject* self, PyObject* args); |
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
103 |
static PyObject *Camera_rotate(PyObject* self, PyObject* args); |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
104 |
|
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
105 |
static PyMethodDef CameraMethods[] = { |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
106 |
{"setEye", (PyCFunction)Camera_setEye, METH_VARARGS, "Set eye of the camera."}, |
72
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
107 |
{"setAngle", (PyCFunction)Camera_setAngle, METH_VARARGS, "Set vertical angle of view."}, |
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
108 |
{"rotate", (PyCFunction)Camera_rotate, METH_VARARGS, "Rotate camera with a quaternion."}, |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
109 |
{NULL, NULL} |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
110 |
}; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
111 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
112 |
static PyTypeObject CameraType = |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
113 |
TYPE_OBJECT( |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
114 |
"Camera", /* tp_name */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
115 |
sizeof(CameraObject), /* tp_basicsize */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
116 |
Camera_Destructor, /* tp_dealloc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
117 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
118 |
"Camera type", /* tp_doc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
119 |
CameraMethods, /* tp_methods */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
120 |
0, /* tp_members */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
121 |
0, /* tp_base */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
122 |
0 /* tp_init */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
123 |
); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
124 |
|
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
125 |
static PyObject* Camera_Constructor(PyObject* self, PyObject* args, PyObject *kwd) |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
126 |
{ |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
127 |
CameraObject *v; |
72
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
128 |
static char *kwdlist[] = {"eye", "lookat", "up", "p", "u", "v", NULL}; |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
129 |
PyObject *TEye = NULL, *TLookAt = NULL, *TUp = NULL, |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
130 |
*Tp = NULL, *Tu = NULL, *Tv = NULL; |
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
131 |
Float ex=0.0, ey=0.0, ez=10.0; |
72
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
132 |
Float lax=0.0, lay=0.0, laz=0.0; |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
133 |
Float upx=0.0, upy=1.0, upz=0.0; |
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
134 |
Float px=0.0, py=0.0, pz=-1.0; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
135 |
Float ux=-1.0, uy=0.0, uz=0.0; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
136 |
Float vx=0.0, vy=1.0, vz=0.0; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
137 |
|
72
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
138 |
if (!PyArg_ParseTupleAndKeywords(args, kwd, "|O!O!O!O!O!O!", kwdlist, |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
139 |
&PyTuple_Type, &TEye, &PyTuple_Type, &TLookAt, &PyTuple_Type, &TUp, |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
140 |
&PyTuple_Type, &Tp, &PyTuple_Type, &Tu, &PyTuple_Type, &Tv)) |
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
141 |
return NULL; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
142 |
|
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
143 |
if (TEye) |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
144 |
if (!PyArg_ParseTuple(TEye, "fff", &ex, &ey, &ez)) |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
145 |
return NULL; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
146 |
|
72
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
147 |
if (TLookAt) |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
148 |
if (!PyArg_ParseTuple(TLookAt, "fff", &lax, &lay, &laz)) |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
149 |
return NULL; |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
150 |
|
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
151 |
if (TUp) |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
152 |
if (!PyArg_ParseTuple(TUp, "fff", &upx, &upy, &upz)) |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
153 |
return NULL; |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
154 |
|
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
155 |
if (Tp) |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
156 |
if (!PyArg_ParseTuple(Tp, "fff", &px, &py, &pz)) |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
157 |
return NULL; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
158 |
|
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
159 |
if (Tu) |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
160 |
if (!PyArg_ParseTuple(Tu, "fff", &ux, &uy, &uz)) |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
161 |
return NULL; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
162 |
|
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
163 |
if (Tv) |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
164 |
if (!PyArg_ParseTuple(Tv, "fff", &vx, &vy, &vz)) |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
165 |
return NULL; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
166 |
|
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
167 |
v = PyObject_New(CameraObject, &CameraType); |
72
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
168 |
if (TLookAt) |
91 | 169 |
v->camera = new Camera(Vector(ex, ey, ez), |
170 |
Vector(lax, lay, laz), Vector(upx, upy, upz)); |
|
72
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
171 |
else |
91 | 172 |
v->camera = new Camera(Vector(ex, ey, ez), |
173 |
Vector(px, py, pz), Vector(ux, uy, uz), Vector(vx, vy, vz)); |
|
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
174 |
return (PyObject*)v; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
175 |
} |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
176 |
|
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
177 |
static void Camera_Destructor(PyObject* self) |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
178 |
{ |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
179 |
delete ((CameraObject *)self)->camera; |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
180 |
self->ob_type->tp_free(self); |
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
181 |
} |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
182 |
|
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
183 |
static PyObject *Camera_setEye(PyObject* self, PyObject* args) |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
184 |
{ |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
185 |
PyObject *TEye = NULL; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
186 |
Float ex=0.0, ey=0.0, ez=10.0; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
187 |
|
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
188 |
if (!PyArg_ParseTuple(args, "O!", &PyTuple_Type, &TEye)) |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
189 |
return NULL; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
190 |
|
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
191 |
if (TEye) |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
192 |
if (!PyArg_ParseTuple(TEye, "fff", &ex, &ey, &ez)) |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
193 |
return NULL; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
194 |
|
91 | 195 |
((CameraObject *)self)->camera->setEye(Vector(ex, ey, ez)); |
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
196 |
|
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
197 |
Py_INCREF(Py_None); |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
198 |
return Py_None; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
199 |
} |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
200 |
|
72
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
201 |
static PyObject *Camera_setAngle(PyObject* self, PyObject* args) |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
202 |
{ |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
203 |
Float angle; |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
204 |
|
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
205 |
if (!PyArg_ParseTuple(args, "f", &angle)) |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
206 |
return NULL; |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
207 |
|
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
208 |
((CameraObject *)self)->camera->setAngle(angle); |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
209 |
|
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
210 |
Py_INCREF(Py_None); |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
211 |
return Py_None; |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
212 |
} |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
213 |
|
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
214 |
static PyObject *Camera_rotate(PyObject* self, PyObject* args) |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
215 |
{ |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
216 |
PyObject *Tq = NULL; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
217 |
Float qa, qb, qc, qd; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
218 |
|
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
219 |
if (!PyArg_ParseTuple(args, "O!", &PyTuple_Type, &Tq)) |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
220 |
return NULL; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
221 |
|
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
222 |
if (!PyArg_ParseTuple(Tq, "ffff", &qa, &qb, &qc, &qd)) |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
223 |
return NULL; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
224 |
|
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
225 |
((CameraObject *)self)->camera->rotate(Quaternion(qa, qb, qc, qd).normalize()); |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
226 |
|
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
227 |
Py_INCREF(Py_None); |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
228 |
return Py_None; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
229 |
} |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
230 |
|
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
231 |
|
96
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
232 |
//=========================== Pixmap Object =========================== |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
233 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
234 |
static PyObject* Pixmap_Constructor(PyObject* self, PyObject* args, PyObject *kwd); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
235 |
static PyObject* Pixmap_getWidth(PyObject* self, PyObject* args); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
236 |
static PyObject* Pixmap_getHeight(PyObject* self, PyObject* args); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
237 |
static PyObject* Pixmap_getCharData(PyObject* self, PyObject* args); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
238 |
static PyObject* Pixmap_writePNG(PyObject* self, PyObject* args); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
239 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
240 |
static PyMethodDef PixmapMethods[] = { |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
241 |
{"getWidth", (PyCFunction)Pixmap_getWidth, METH_NOARGS, "Get width of pixmap."}, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
242 |
{"getHeight", (PyCFunction)Pixmap_getHeight, METH_NOARGS, "Get height of pixmap."}, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
243 |
{"getCharData", (PyCFunction)Pixmap_getCharData, METH_NOARGS, "Get raw byte data."}, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
244 |
{"writePNG", (PyCFunction)Pixmap_writePNG, METH_VARARGS, "Write pixmap to PNG file."}, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
245 |
{NULL, NULL} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
246 |
}; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
247 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
248 |
static PyTypeObject PixmapType = |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
249 |
TYPE_OBJECT( |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
250 |
"Pixmap", /* tp_name */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
251 |
sizeof(PixmapObject), /* tp_basicsize */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
252 |
0, /* tp_dealloc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
253 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
254 |
"Pixmap type", /* tp_doc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
255 |
PixmapMethods, /* tp_methods */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
256 |
0, /* tp_members */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
257 |
0, /* tp_base */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
258 |
0 /* tp_init */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
259 |
); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
260 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
261 |
static PyObject* Pixmap_Constructor(PyObject* self, PyObject* args, PyObject *kwd) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
262 |
{ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
263 |
int w = 0, h = 0; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
264 |
PixmapObject *v; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
265 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
266 |
if (!PyArg_ParseTuple(args, "(ii)", &w, &h)) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
267 |
return NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
268 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
269 |
v = PyObject_New(PixmapObject, &PixmapType); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
270 |
v->pixmap = new Pixmap(w, h); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
271 |
return (PyObject*)v; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
272 |
} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
273 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
274 |
static PyObject* Pixmap_getWidth(PyObject* self, PyObject* args) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
275 |
{ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
276 |
return Py_BuildValue("i", ((PixmapObject *)self)->pixmap->getWidth()); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
277 |
} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
278 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
279 |
static PyObject* Pixmap_getHeight(PyObject* self, PyObject* args) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
280 |
{ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
281 |
return Py_BuildValue("i", ((PixmapObject *)self)->pixmap->getHeight()); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
282 |
} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
283 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
284 |
static PyObject *Pixmap_getCharData(PyObject* self, PyObject* args) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
285 |
{ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
286 |
unsigned char *chardata; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
287 |
int w,h; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
288 |
PyObject *o; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
289 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
290 |
chardata = ((PixmapObject *)self)->pixmap->getCharData(); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
291 |
w = ((PixmapObject *)self)->pixmap->getWidth(); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
292 |
h = ((PixmapObject *)self)->pixmap->getHeight(); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
293 |
o = Py_BuildValue("s#", chardata, w*h*3); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
294 |
delete[] chardata; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
295 |
return o; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
296 |
} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
297 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
298 |
static PyObject *Pixmap_writePNG(PyObject* self, PyObject* args) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
299 |
{ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
300 |
const char *fname; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
301 |
int res; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
302 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
303 |
if (!PyArg_ParseTuple(args, "s", &fname)) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
304 |
return NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
305 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
306 |
res = ((PixmapObject *)self)->pixmap->writePNG(fname); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
307 |
return Py_BuildValue("i", res); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
308 |
} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
309 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
310 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
311 |
//=========================== TextureMap Object (abstract) =========================== |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
312 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
313 |
static void TextureMap_Destructor(PyObject* self); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
314 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
315 |
static PyMethodDef TextureMapMethods[] = { |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
316 |
{NULL, NULL} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
317 |
}; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
318 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
319 |
static PyTypeObject TextureMapType = |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
320 |
TYPE_OBJECT( |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
321 |
"TextureMap", /* tp_name */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
322 |
sizeof(TextureMapObject), /* tp_basicsize */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
323 |
TextureMap_Destructor, /* tp_dealloc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
324 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
325 |
"TextureMap type (abstract)", /* tp_doc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
326 |
TextureMapMethods, /* tp_methods */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
327 |
0, /* tp_members */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
328 |
0, /* tp_base */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
329 |
0 /* tp_init */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
330 |
); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
331 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
332 |
static void TextureMap_Destructor(PyObject* self) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
333 |
{ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
334 |
delete ((TextureMapObject *)self)->texturemap; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
335 |
self->ob_type->tp_free(self); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
336 |
} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
337 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
338 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
339 |
//=========================== PlanarMap Object =========================== |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
340 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
341 |
static PyObject *PlanarMap_Constructor(PyObject* self, PyObject* args, PyObject *kwd); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
342 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
343 |
static PyMethodDef PlanarMapMethods[] = { |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
344 |
{NULL, NULL} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
345 |
}; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
346 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
347 |
static PyTypeObject PlanarMapType = |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
348 |
TYPE_OBJECT( |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
349 |
"PlanarMap", /* tp_name */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
350 |
sizeof(PlanarMapObject), /* tp_basicsize */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
351 |
0, /* tp_dealloc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
352 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
353 |
"PlanarMap type", /* tp_doc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
354 |
PlanarMapMethods, /* tp_methods */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
355 |
0, /* tp_members */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
356 |
&TextureMapType, /* tp_base */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
357 |
0 /* tp_init */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
358 |
); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
359 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
360 |
static PyObject* PlanarMap_Constructor(PyObject* self, PyObject* args, PyObject *kwd) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
361 |
{ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
362 |
PlanarMapObject *v; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
363 |
static char *kwdlist[] = {"center", "size", NULL}; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
364 |
PyObject *Tcenter = NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
365 |
Vector center; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
366 |
Float size; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
367 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
368 |
if (!PyArg_ParseTupleAndKeywords(args, kwd, "O!f", kwdlist, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
369 |
&PyTuple_Type, &Tcenter, &size)) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
370 |
return NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
371 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
372 |
if (!PyArg_ParseTuple(Tcenter, "fff", ¢er.x, ¢er.y, ¢er.z)) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
373 |
return NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
374 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
375 |
v = PyObject_New(PlanarMapObject, &PlanarMapType); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
376 |
v->texturemap.texturemap = new PlanarMap(center, size); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
377 |
return (PyObject*)v; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
378 |
} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
379 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
380 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
381 |
//=========================== CubicMap Object =========================== |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
382 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
383 |
static PyObject *CubicMap_Constructor(PyObject* self, PyObject* args, PyObject *kwd); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
384 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
385 |
static PyMethodDef CubicMapMethods[] = { |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
386 |
{NULL, NULL} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
387 |
}; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
388 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
389 |
static PyTypeObject CubicMapType = |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
390 |
TYPE_OBJECT( |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
391 |
"CubicMap", /* tp_name */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
392 |
sizeof(CubicMapObject), /* tp_basicsize */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
393 |
0, /* tp_dealloc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
394 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
395 |
"CubicMap type", /* tp_doc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
396 |
CubicMapMethods, /* tp_methods */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
397 |
0, /* tp_members */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
398 |
&TextureMapType, /* tp_base */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
399 |
0 /* tp_init */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
400 |
); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
401 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
402 |
static PyObject* CubicMap_Constructor(PyObject* self, PyObject* args, PyObject *kwd) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
403 |
{ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
404 |
CubicMapObject *v; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
405 |
static char *kwdlist[] = {"center", "size", NULL}; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
406 |
PyObject *Tcenter = NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
407 |
Vector center; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
408 |
Float size; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
409 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
410 |
if (!PyArg_ParseTupleAndKeywords(args, kwd, "O!f", kwdlist, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
411 |
&PyTuple_Type, &Tcenter, &size)) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
412 |
return NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
413 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
414 |
if (!PyArg_ParseTuple(Tcenter, "fff", ¢er.x, ¢er.y, ¢er.z)) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
415 |
return NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
416 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
417 |
v = PyObject_New(CubicMapObject, &CubicMapType); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
418 |
v->texturemap.texturemap = new CubicMap(center, size); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
419 |
return (PyObject*)v; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
420 |
} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
421 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
422 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
423 |
//=========================== CylinderMap Object =========================== |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
424 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
425 |
static PyObject *CylinderMap_Constructor(PyObject* self, PyObject* args, PyObject *kwd); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
426 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
427 |
static PyMethodDef CylinderMapMethods[] = { |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
428 |
{NULL, NULL} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
429 |
}; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
430 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
431 |
static PyTypeObject CylinderMapType = |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
432 |
TYPE_OBJECT( |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
433 |
"CylinderMap", /* tp_name */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
434 |
sizeof(CylinderMapObject), /* tp_basicsize */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
435 |
0, /* tp_dealloc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
436 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
437 |
"CylinderMap type", /* tp_doc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
438 |
CylinderMapMethods, /* tp_methods */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
439 |
0, /* tp_members */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
440 |
&TextureMapType, /* tp_base */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
441 |
0 /* tp_init */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
442 |
); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
443 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
444 |
static PyObject* CylinderMap_Constructor(PyObject* self, PyObject* args, PyObject *kwd) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
445 |
{ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
446 |
CylinderMapObject *v; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
447 |
static char *kwdlist[] = {"center", "size", NULL}; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
448 |
PyObject *Tcenter = NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
449 |
Vector center; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
450 |
Float size; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
451 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
452 |
if (!PyArg_ParseTupleAndKeywords(args, kwd, "O!f", kwdlist, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
453 |
&PyTuple_Type, &Tcenter, &size)) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
454 |
return NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
455 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
456 |
if (!PyArg_ParseTuple(Tcenter, "fff", ¢er.x, ¢er.y, ¢er.z)) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
457 |
return NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
458 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
459 |
v = PyObject_New(CylinderMapObject, &CylinderMapType); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
460 |
v->texturemap.texturemap = new CylinderMap(center, size); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
461 |
return (PyObject*)v; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
462 |
} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
463 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
464 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
465 |
//=========================== SphereMap Object =========================== |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
466 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
467 |
static PyObject *SphereMap_Constructor(PyObject* self, PyObject* args, PyObject *kwd); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
468 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
469 |
static PyMethodDef SphereMapMethods[] = { |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
470 |
{NULL, NULL} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
471 |
}; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
472 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
473 |
static PyTypeObject SphereMapType = |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
474 |
TYPE_OBJECT( |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
475 |
"SphereMap", /* tp_name */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
476 |
sizeof(SphereMapObject), /* tp_basicsize */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
477 |
0, /* tp_dealloc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
478 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
479 |
"SphereMap type", /* tp_doc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
480 |
SphereMapMethods, /* tp_methods */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
481 |
0, /* tp_members */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
482 |
&TextureMapType, /* tp_base */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
483 |
0 /* tp_init */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
484 |
); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
485 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
486 |
static PyObject* SphereMap_Constructor(PyObject* self, PyObject* args, PyObject *kwd) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
487 |
{ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
488 |
SphereMapObject *v; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
489 |
static char *kwdlist[] = {"center", "size", NULL}; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
490 |
PyObject *Tcenter = NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
491 |
Vector center; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
492 |
Float size; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
493 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
494 |
if (!PyArg_ParseTupleAndKeywords(args, kwd, "O!f", kwdlist, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
495 |
&PyTuple_Type, &Tcenter, &size)) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
496 |
return NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
497 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
498 |
if (!PyArg_ParseTuple(Tcenter, "fff", ¢er.x, ¢er.y, ¢er.z)) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
499 |
return NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
500 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
501 |
v = PyObject_New(SphereMapObject, &SphereMapType); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
502 |
v->texturemap.texturemap = new SphereMap(center, size); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
503 |
return (PyObject*)v; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
504 |
} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
505 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
506 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
507 |
//=========================== ColourMap Object (abstract) =========================== |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
508 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
509 |
static void ColourMap_Destructor(PyObject* self); |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
510 |
|
96
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
511 |
static PyMethodDef ColourMapMethods[] = { |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
512 |
{NULL, NULL} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
513 |
}; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
514 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
515 |
static PyTypeObject ColourMapType = |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
516 |
TYPE_OBJECT( |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
517 |
"ColourMap", /* tp_name */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
518 |
sizeof(ColourMapObject), /* tp_basicsize */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
519 |
ColourMap_Destructor, /* tp_dealloc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
520 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
521 |
"ColourMap type (abstract)", /* tp_doc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
522 |
ColourMapMethods, /* tp_methods */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
523 |
0, /* tp_members */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
524 |
0, /* tp_base */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
525 |
0 /* tp_init */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
526 |
); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
527 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
528 |
static void ColourMap_Destructor(PyObject* self) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
529 |
{ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
530 |
delete ((ColourMapObject *)self)->colourmap; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
531 |
self->ob_type->tp_free(self); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
532 |
} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
533 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
534 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
535 |
//=========================== LinearColourMap Object =========================== |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
536 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
537 |
static PyObject *LinearColourMap_Constructor(PyObject* self, PyObject* args, PyObject *kwd); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
538 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
539 |
static PyMethodDef LinearColourMapMethods[] = { |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
540 |
{NULL, NULL} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
541 |
}; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
542 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
543 |
static PyTypeObject LinearColourMapType = |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
544 |
TYPE_OBJECT( |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
545 |
"LinearColourMap", /* tp_name */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
546 |
sizeof(LinearColourMapObject), /* tp_basicsize */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
547 |
0, /* tp_dealloc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
548 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
549 |
"LinearColourMap type", /* tp_doc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
550 |
LinearColourMapMethods, /* tp_methods */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
551 |
0, /* tp_members */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
552 |
&ColourMapType, /* tp_base */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
553 |
0 /* tp_init */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
554 |
); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
555 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
556 |
static PyObject* LinearColourMap_Constructor(PyObject* self, PyObject* args, PyObject *kwd) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
557 |
{ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
558 |
LinearColourMapObject *v; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
559 |
static char *kwdlist[] = {"clow", "chigh", NULL}; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
560 |
PyObject *Tclow = NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
561 |
PyObject *Tchigh = NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
562 |
Vector clow, chigh; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
563 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
564 |
if (!PyArg_ParseTupleAndKeywords(args, kwd, "O!O!", kwdlist, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
565 |
&PyTuple_Type, &Tclow, &PyTuple_Type, &Tchigh)) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
566 |
return NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
567 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
568 |
if (!PyArg_ParseTuple(Tclow, "fff", &clow.x, &clow.y, &clow.z)) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
569 |
return NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
570 |
if (!PyArg_ParseTuple(Tchigh, "fff", &chigh.x, &chigh.y, &chigh.z)) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
571 |
return NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
572 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
573 |
v = PyObject_New(LinearColourMapObject, &LinearColourMapType); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
574 |
v->colourmap.colourmap = new LinearColourMap(clow, chigh); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
575 |
return (PyObject*)v; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
576 |
} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
577 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
578 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
579 |
//=========================== BoundColourMap Object =========================== |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
580 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
581 |
static PyObject *BoundColourMap_Constructor(PyObject* self, PyObject* args, PyObject *kwd); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
582 |
static void BoundColourMap_Destructor(PyObject* self); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
583 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
584 |
static PyMethodDef BoundColourMapMethods[] = { |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
585 |
{NULL, NULL} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
586 |
}; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
587 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
588 |
static PyTypeObject BoundColourMapType = |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
589 |
TYPE_OBJECT( |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
590 |
"BoundColourMap", /* tp_name */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
591 |
sizeof(BoundColourMapObject), /* tp_basicsize */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
592 |
BoundColourMap_Destructor, /* tp_dealloc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
593 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
594 |
"BoundColourMap type", /* tp_doc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
595 |
BoundColourMapMethods, /* tp_methods */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
596 |
0, /* tp_members */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
597 |
&ColourMapType, /* tp_base */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
598 |
0 /* tp_init */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
599 |
); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
600 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
601 |
static PyObject* BoundColourMap_Constructor(PyObject* self, PyObject* args, PyObject *kwd) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
602 |
{ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
603 |
BoundColourMapObject *v; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
604 |
static char *kwdlist[] = {"bounds", "colours", NULL}; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
605 |
PyObject *Tbounds = NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
606 |
PyObject *Tcolours = NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
607 |
PyObject *o; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
608 |
int num; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
609 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
610 |
if (!PyArg_ParseTupleAndKeywords(args, kwd, "O!O!", kwdlist, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
611 |
&PyTuple_Type, &Tbounds, &PyTuple_Type, &Tcolours)) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
612 |
return NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
613 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
614 |
/* get lesser of the sizes */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
615 |
num = PyTuple_GET_SIZE(Tbounds); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
616 |
if (num > PyTuple_GET_SIZE(Tcolours)) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
617 |
num = PyTuple_GET_SIZE(Tcolours); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
618 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
619 |
v = PyObject_New(BoundColourMapObject, &BoundColourMapType); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
620 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
621 |
v->bounds = new Float[num]; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
622 |
v->colours = new Colour[num]; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
623 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
624 |
for (int i = 0; i < num; i++) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
625 |
{ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
626 |
o = PyTuple_GET_ITEM(Tbounds, i); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
627 |
v->bounds[i] = PyFloat_AsDouble(o); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
628 |
o = PyTuple_GET_ITEM(Tcolours, i); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
629 |
if (!PyArg_ParseTuple(o, "fff", &v->colours[i].r, &v->colours[i].g, &v->colours[i].b)) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
630 |
return NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
631 |
} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
632 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
633 |
v->colourmap.colourmap = new BoundColourMap(v->bounds, v->colours); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
634 |
return (PyObject*)v; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
635 |
} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
636 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
637 |
static void BoundColourMap_Destructor(PyObject* self) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
638 |
{ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
639 |
delete ((BoundColourMapObject *)self)->bounds; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
640 |
delete ((BoundColourMapObject *)self)->colours; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
641 |
self->ob_type->tp_free(self); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
642 |
} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
643 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
644 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
645 |
//=========================== Texture Object (abstract) =========================== |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
646 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
647 |
static void Texture_Destructor(PyObject* self); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
648 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
649 |
static PyMethodDef TextureMethods[] = { |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
650 |
{NULL, NULL} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
651 |
}; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
652 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
653 |
static PyTypeObject TextureType = |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
654 |
TYPE_OBJECT( |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
655 |
"Texture", /* tp_name */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
656 |
sizeof(TextureObject), /* tp_basicsize */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
657 |
Texture_Destructor, /* tp_dealloc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
658 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
659 |
"Texture type (abstract)", /* tp_doc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
660 |
TextureMethods, /* tp_methods */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
661 |
0, /* tp_members */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
662 |
0, /* tp_base */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
663 |
0 /* tp_init */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
664 |
); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
665 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
666 |
static void Texture_Destructor(PyObject* self) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
667 |
{ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
668 |
delete ((TextureObject *)self)->texture; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
669 |
self->ob_type->tp_free(self); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
670 |
} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
671 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
672 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
673 |
//=========================== ImageTexture Object =========================== |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
674 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
675 |
static PyObject *ImageTexture_Constructor(PyObject* self, PyObject* args, PyObject *kwd); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
676 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
677 |
static PyMethodDef ImageTextureMethods[] = { |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
678 |
{NULL, NULL} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
679 |
}; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
680 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
681 |
static PyTypeObject ImageTextureType = |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
682 |
TYPE_OBJECT( |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
683 |
"ImageTexture", /* tp_name */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
684 |
sizeof(ImageTextureObject), /* tp_basicsize */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
685 |
0, /* tp_dealloc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
686 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
687 |
"ImageTexture type", /* tp_doc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
688 |
ImageTextureMethods, /* tp_methods */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
689 |
0, /* tp_members */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
690 |
&TextureType, /* tp_base */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
691 |
0 /* tp_init */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
692 |
); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
693 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
694 |
static PyObject* ImageTexture_Constructor(PyObject* self, PyObject* args, PyObject *kwd) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
695 |
{ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
696 |
ImageTextureObject *v; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
697 |
static char *kwdlist[] = {"tmap", "image", NULL}; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
698 |
TextureMapObject *tmap = NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
699 |
PixmapObject *image = NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
700 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
701 |
if (!PyArg_ParseTupleAndKeywords(args, kwd, "O!O!", kwdlist, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
702 |
&TextureMapType, &tmap, &PixmapType, &image)) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
703 |
return NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
704 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
705 |
v = PyObject_New(ImageTextureObject, &ImageTextureType); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
706 |
v->texture.texture = new ImageTexture(tmap->texturemap, image->pixmap); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
707 |
Py_INCREF(tmap); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
708 |
Py_INCREF(image); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
709 |
return (PyObject*)v; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
710 |
} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
711 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
712 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
713 |
//=========================== CheckersTexture Object =========================== |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
714 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
715 |
static PyObject *CheckersTexture_Constructor(PyObject* self, PyObject* args, PyObject *kwd); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
716 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
717 |
static PyMethodDef CheckersTextureMethods[] = { |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
718 |
{NULL, NULL} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
719 |
}; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
720 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
721 |
static PyTypeObject CheckersTextureType = |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
722 |
TYPE_OBJECT( |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
723 |
"CheckersTexture", /* tp_name */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
724 |
sizeof(CheckersTextureObject), /* tp_basicsize */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
725 |
0, /* tp_dealloc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
726 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
727 |
"CheckersTexture type", /* tp_doc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
728 |
CheckersTextureMethods, /* tp_methods */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
729 |
0, /* tp_members */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
730 |
&TextureType, /* tp_base */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
731 |
0 /* tp_init */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
732 |
); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
733 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
734 |
static PyObject* CheckersTexture_Constructor(PyObject* self, PyObject* args, PyObject *kwd) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
735 |
{ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
736 |
CheckersTextureObject *v; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
737 |
static char *kwdlist[] = {"tmap", "cmap", NULL}; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
738 |
TextureMapObject *tmap = NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
739 |
ColourMapObject *cmap = NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
740 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
741 |
if (!PyArg_ParseTupleAndKeywords(args, kwd, "O!O!", kwdlist, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
742 |
&TextureMapType, &tmap, &ColourMapType, &cmap)) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
743 |
return NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
744 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
745 |
v = PyObject_New(CheckersTextureObject, &CheckersTextureType); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
746 |
v->texture.texture = new CheckersTexture(tmap->texturemap, cmap->colourmap); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
747 |
Py_INCREF(tmap); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
748 |
Py_INCREF(cmap); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
749 |
return (PyObject*)v; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
750 |
} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
751 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
752 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
753 |
//=========================== CloudTexture Object =========================== |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
754 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
755 |
static PyObject *CloudTexture_Constructor(PyObject* self, PyObject* args, PyObject *kwd); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
756 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
757 |
static PyMethodDef CloudTextureMethods[] = { |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
758 |
{NULL, NULL} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
759 |
}; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
760 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
761 |
static PyTypeObject CloudTextureType = |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
762 |
TYPE_OBJECT( |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
763 |
"CloudTexture", /* tp_name */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
764 |
sizeof(CloudTextureObject), /* tp_basicsize */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
765 |
0, /* tp_dealloc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
766 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
767 |
"CloudTexture type", /* tp_doc */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
768 |
CloudTextureMethods, /* tp_methods */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
769 |
0, /* tp_members */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
770 |
&TextureType, /* tp_base */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
771 |
0 /* tp_init */ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
772 |
); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
773 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
774 |
static PyObject* CloudTexture_Constructor(PyObject* self, PyObject* args, PyObject *kwd) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
775 |
{ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
776 |
CloudTextureObject *v; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
777 |
static char *kwdlist[] = {"detail", "cmap", NULL}; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
778 |
Float detail; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
779 |
ColourMapObject *cmap = NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
780 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
781 |
if (!PyArg_ParseTupleAndKeywords(args, kwd, "fO!", kwdlist, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
782 |
&detail, &ColourMapType, &cmap)) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
783 |
return NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
784 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
785 |
v = PyObject_New(CloudTextureObject, &CloudTextureType); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
786 |
v->texture.texture = new CloudTexture(detail, cmap->colourmap); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
787 |
Py_INCREF(cmap); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
788 |
return (PyObject*)v; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
789 |
} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
790 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
791 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
792 |
//=========================== Material Object =========================== |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
793 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
794 |
static PyObject *Material_Constructor(PyObject* self, PyObject* args, PyObject *kwd); |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
795 |
static void Material_Destructor(PyObject* self); |
31 | 796 |
static PyObject *Material_setPhong(PyObject* self, PyObject* args); |
797 |
static PyObject *Material_setReflectivity(PyObject* self, PyObject* args); |
|
798 |
static PyObject *Material_setTransmissivity(PyObject* self, PyObject* args); |
|
69
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
799 |
static PyObject *Material_setSmooth(PyObject* self, PyObject* args); |
96
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
800 |
static PyObject *Material_setTexture(PyObject* self, PyObject* args); |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
801 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
802 |
static PyMethodDef MaterialMethods[] = { |
31 | 803 |
{"setPhong", (PyCFunction)Material_setPhong, METH_VARARGS, "Set ambient, diffuse, specular and shininess Phong model constants."}, |
804 |
{"setReflectivity", (PyCFunction)Material_setReflectivity, METH_VARARGS, "Set reflectivity."}, |
|
805 |
{"setTransmissivity", (PyCFunction)Material_setTransmissivity, METH_VARARGS, "Set transmissivity and refraction index."}, |
|
69
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
806 |
{"setSmooth", (PyCFunction)Material_setSmooth, METH_VARARGS, "Set triangle smoothing."}, |
96
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
807 |
{"setTexture", (PyCFunction)Material_setTexture, METH_VARARGS, "Set the texture."}, |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
808 |
{NULL, NULL} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
809 |
}; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
810 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
811 |
static PyTypeObject MaterialType = |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
812 |
TYPE_OBJECT( |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
813 |
"Material", /* tp_name */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
814 |
sizeof(MaterialObject), /* tp_basicsize */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
815 |
Material_Destructor, /* tp_dealloc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
816 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
817 |
"Material type", /* tp_doc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
818 |
MaterialMethods, /* tp_methods */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
819 |
0, /* tp_members */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
820 |
0, /* tp_base */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
821 |
0 /* tp_init */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
822 |
); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
823 |
|
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
824 |
static PyObject* Material_Constructor(PyObject* self, PyObject* args, PyObject *kwd) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
825 |
{ |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
826 |
MaterialObject *v; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
827 |
static char *kwdlist[] = {"colour", NULL}; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
828 |
PyObject *TCol = NULL; |
22 | 829 |
Float cr=1.0, cg=1.0, cb=1.0; |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
830 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
831 |
if (!PyArg_ParseTupleAndKeywords(args, kwd, "|O!", kwdlist, |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
832 |
&PyTuple_Type, &TCol)) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
833 |
return NULL; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
834 |
|
28
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
835 |
if (TCol) |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
836 |
if (!PyArg_ParseTuple(TCol, "fff", &cr, &cg, &cb)) |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
837 |
return NULL; |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
838 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
839 |
v = PyObject_New(MaterialObject, &MaterialType); |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
840 |
v->material = new Material(Colour(cr, cg, cb)); |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
841 |
return (PyObject*)v; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
842 |
} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
843 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
844 |
static void Material_Destructor(PyObject* self) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
845 |
{ |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
846 |
delete ((MaterialObject *)self)->material; |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
847 |
self->ob_type->tp_free(self); |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
848 |
} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
849 |
|
31 | 850 |
static PyObject *Material_setPhong(PyObject* self, PyObject* args) |
851 |
{ |
|
852 |
Float amb, dif, spec, shin = 0.5; |
|
853 |
||
854 |
if (!PyArg_ParseTuple(args, "fff|f", &amb, &dif, &spec, &shin)) |
|
855 |
return NULL; |
|
856 |
||
857 |
((MaterialObject *)self)->material->setPhong(amb, dif, spec, shin); |
|
858 |
||
859 |
Py_INCREF(Py_None); |
|
860 |
return Py_None; |
|
861 |
} |
|
862 |
||
863 |
static PyObject *Material_setReflectivity(PyObject* self, PyObject* args) |
|
864 |
{ |
|
865 |
Float refl; |
|
866 |
||
867 |
if (!PyArg_ParseTuple(args, "f", &refl)) |
|
868 |
return NULL; |
|
869 |
||
870 |
((MaterialObject *)self)->material->setReflectivity(refl); |
|
871 |
||
872 |
Py_INCREF(Py_None); |
|
873 |
return Py_None; |
|
874 |
} |
|
875 |
||
876 |
static PyObject *Material_setTransmissivity(PyObject* self, PyObject* args) |
|
877 |
{ |
|
93 | 878 |
Float trans, rindex = 1.3f; |
31 | 879 |
|
880 |
if (!PyArg_ParseTuple(args, "f|f", &trans, &rindex)) |
|
881 |
return NULL; |
|
882 |
||
883 |
((MaterialObject *)self)->material->setTransmissivity(trans, rindex); |
|
884 |
||
885 |
Py_INCREF(Py_None); |
|
886 |
return Py_None; |
|
887 |
} |
|
888 |
||
69
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
889 |
static PyObject* Material_setSmooth(PyObject* self, PyObject* args) |
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
890 |
{ |
96
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
891 |
int smooth = 1; |
69
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
892 |
|
96
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
893 |
if (!PyArg_ParseTuple(args, "|i", &smooth)) |
69
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
894 |
return NULL; |
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
895 |
|
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
896 |
((MaterialObject *)self)->material->setSmooth(smooth); |
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
897 |
|
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
898 |
Py_INCREF(Py_None); |
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
899 |
return Py_None; |
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
900 |
} |
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
901 |
|
96
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
902 |
static PyObject* Material_setTexture(PyObject* self, PyObject* args) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
903 |
{ |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
904 |
TextureObject *tex; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
905 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
906 |
if (!PyArg_ParseTuple(args, "O!", &TextureType, &tex)) |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
907 |
return NULL; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
908 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
909 |
((MaterialObject *)self)->material->setTexture(tex->texture); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
910 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
911 |
Py_INCREF(tex); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
912 |
Py_INCREF(Py_None); |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
913 |
return Py_None; |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
914 |
} |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
915 |
|
69
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
916 |
|
28
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
917 |
//=========================== NormalVertex Object =========================== |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
918 |
|
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
919 |
static PyObject *NormalVertex_Constructor(PyObject* self, PyObject* args, PyObject *kwd); |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
920 |
static void NormalVertex_Destructor(PyObject* self); |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
921 |
static PyObject *NormalVertex_setNormal(PyObject* self, PyObject* args); |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
922 |
|
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
923 |
static PyMethodDef NormalVertexMethods[] = { |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
924 |
{"setNormal", (PyCFunction)NormalVertex_setNormal, METH_VARARGS, "Set normal of this vertex."}, |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
925 |
{NULL, NULL} |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
926 |
}; |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
927 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
928 |
static PyTypeObject NormalVertexType = |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
929 |
TYPE_OBJECT( |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
930 |
"NormalVertex", /* tp_name */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
931 |
sizeof(NormalVertexObject), /* tp_basicsize */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
932 |
NormalVertex_Destructor, /* tp_dealloc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
933 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
934 |
"NormalVertex type", /* tp_doc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
935 |
NormalVertexMethods, /* tp_methods */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
936 |
0, /* tp_members */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
937 |
0, /* tp_base */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
938 |
0 /* tp_init */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
939 |
); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
940 |
|
28
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
941 |
static PyObject* NormalVertex_Constructor(PyObject* self, PyObject* args, PyObject *kwd) |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
942 |
{ |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
943 |
NormalVertexObject *v; |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
944 |
static char *kwdlist[] = {"vector", "normal", NULL}; |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
945 |
PyObject *TVer = NULL; |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
946 |
PyObject *TNor = NULL; |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
947 |
Float vx, vy, vz, nx=0, ny=0, nz=0; |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
948 |
|
69
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
949 |
if (!PyArg_ParseTupleAndKeywords(args, kwd, "O|O!", kwdlist, |
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
950 |
&TVer, &PyTuple_Type, &TNor)) |
28
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
951 |
return NULL; |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
952 |
|
69
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
953 |
if (!TNor && TVer->ob_type == &NormalVertexType) |
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
954 |
{ |
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
955 |
v = PyObject_New(NormalVertexObject, &NormalVertexType); |
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
956 |
v->nvertex = new NormalVertex(((NormalVertexObject*)TVer)->nvertex); |
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
957 |
} |
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
958 |
else |
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
959 |
{ |
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
960 |
if (!PyArg_ParseTuple(TVer, "fff", &vx, &vy, &vz)) |
28
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
961 |
return NULL; |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
962 |
|
69
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
963 |
if (TNor) |
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
964 |
if (!PyArg_ParseTuple(TNor, "fff", &nx, &ny, &nz)) |
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
965 |
return NULL; |
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
966 |
|
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
967 |
v = PyObject_New(NormalVertexObject, &NormalVertexType); |
91 | 968 |
v->nvertex = new NormalVertex(Vector(vx, vy, vz), Vector(nx, ny, nz)); |
69
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
60
diff
changeset
|
969 |
} |
28
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
970 |
return (PyObject*)v; |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
971 |
} |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
972 |
|
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
973 |
static void NormalVertex_Destructor(PyObject* self) |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
974 |
{ |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
975 |
delete ((NormalVertexObject *)self)->nvertex; |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
976 |
self->ob_type->tp_free(self); |
28
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
977 |
} |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
978 |
|
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
979 |
static PyObject *NormalVertex_setNormal(PyObject* self, PyObject* args) |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
980 |
{ |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
981 |
PyObject *TNor = NULL; |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
982 |
Float nx, ny, nz; |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
983 |
|
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
984 |
if (!PyArg_ParseTuple(args, "O!", &PyTuple_Type, &TNor)) |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
985 |
return NULL; |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
986 |
|
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
987 |
if (!PyArg_ParseTuple(TNor, "fff", &nx, &ny, &nz)) |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
988 |
return NULL; |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
989 |
|
91 | 990 |
((NormalVertexObject *)self)->nvertex->setNormal(Vector(nx,ny,nz).normalize()); |
28
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
991 |
|
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
992 |
Py_INCREF(Py_None); |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
993 |
return Py_None; |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
994 |
} |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
995 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
996 |
//=========================== Shape Object (abstract) =========================== |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
997 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
998 |
static void Shape_Destructor(PyObject* self); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
999 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1000 |
static PyMethodDef ShapeMethods[] = { |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1001 |
{NULL, NULL} |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1002 |
}; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1003 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1004 |
static PyTypeObject ShapeType = |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1005 |
TYPE_OBJECT( |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1006 |
"Shape", /* tp_name */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1007 |
sizeof(ShapeObject), /* tp_basicsize */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1008 |
Shape_Destructor, /* tp_dealloc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1009 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1010 |
"Shape type (abstract)", /* tp_doc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1011 |
ShapeMethods, /* tp_methods */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1012 |
0, /* tp_members */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1013 |
0, /* tp_base */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1014 |
0 /* tp_init */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1015 |
); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1016 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1017 |
static void Shape_Destructor(PyObject* self) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1018 |
{ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1019 |
delete ((ShapeObject *)self)->shape; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1020 |
self->ob_type->tp_free(self); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1021 |
} |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1022 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1023 |
//=========================== Triangle Object =========================== |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1024 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1025 |
static PyObject *Triangle_Constructor(PyObject* self, PyObject* args, PyObject *kwd); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1026 |
static PyObject *Triangle_getNormal(PyObject* self, PyObject* args); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1027 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1028 |
static PyMethodDef TriangleMethods[] = { |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1029 |
{"getNormal", (PyCFunction)Triangle_getNormal, METH_NOARGS, "Get normal of whole triangle."}, |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1030 |
{NULL, NULL} |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1031 |
}; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1032 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1033 |
static PyTypeObject TriangleType = |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1034 |
TYPE_OBJECT( |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1035 |
"Triangle", /* tp_name */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1036 |
sizeof(TriangleObject), /* tp_basicsize */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1037 |
0, /* tp_dealloc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1038 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1039 |
"Triangle type", /* tp_doc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1040 |
TriangleMethods, /* tp_methods */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1041 |
0, /* tp_members */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1042 |
&ShapeType, /* tp_base */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1043 |
0 /* tp_init */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1044 |
); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1045 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1046 |
static PyObject* Triangle_Constructor(PyObject* self, PyObject* args, PyObject *kwd) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1047 |
{ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1048 |
TriangleObject *v; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1049 |
MaterialObject *material; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1050 |
static char *kwdlist[] = {"A", "B", "C", "material", NULL}; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1051 |
NormalVertexObject *A, *B, *C; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1052 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1053 |
if (!PyArg_ParseTupleAndKeywords(args, kwd, "O!O!O!O!", kwdlist, |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1054 |
&NormalVertexType, &A, &NormalVertexType, &B, &NormalVertexType, &C, |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1055 |
&MaterialType, &material)) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1056 |
return NULL; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1057 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1058 |
v = PyObject_New(TriangleObject, &TriangleType); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1059 |
v->shape.shape = new Triangle(A->nvertex, B->nvertex, C->nvertex, material->material); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1060 |
Py_INCREF(material); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1061 |
Py_INCREF(A); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1062 |
Py_INCREF(B); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1063 |
Py_INCREF(C); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1064 |
return (PyObject*)v; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1065 |
} |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1066 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1067 |
static PyObject* Triangle_getNormal(PyObject* self, PyObject* args) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1068 |
{ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1069 |
PyObject *obj; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1070 |
|
91 | 1071 |
Vector N = ((Triangle*)((TriangleObject *)self)->shape.shape)->getNormal(); |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1072 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1073 |
obj = Py_BuildValue("(fff)", N.x, N.y, N.z); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1074 |
return obj; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1075 |
} |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1076 |
|
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1077 |
//=========================== Sphere Object =========================== |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1078 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1079 |
static PyObject *Sphere_Constructor(PyObject* self, PyObject* args, PyObject *kwd); |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1080 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1081 |
static PyMethodDef SphereMethods[] = { |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1082 |
{NULL, NULL} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1083 |
}; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1084 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1085 |
static PyTypeObject SphereType = |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1086 |
TYPE_OBJECT( |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1087 |
"Sphere", /* tp_name */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1088 |
sizeof(SphereObject), /* tp_basicsize */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1089 |
0, /* tp_dealloc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1090 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1091 |
"Sphere type", /* tp_doc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1092 |
SphereMethods, /* tp_methods */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1093 |
0, /* tp_members */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1094 |
&ShapeType, /* tp_base */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1095 |
0 /* tp_init */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1096 |
); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1097 |
|
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1098 |
static PyObject* Sphere_Constructor(PyObject* self, PyObject* args, PyObject *kwd) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1099 |
{ |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1100 |
SphereObject *v; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1101 |
MaterialObject *material; |
96
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1102 |
static char *kwdlist[] = {"center", "radius", "material", NULL}; |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1103 |
PyObject *TCentre = NULL; |
22 | 1104 |
Float cx, cy, cz, radius; |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1105 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1106 |
if (!PyArg_ParseTupleAndKeywords(args, kwd, "O!fO!", kwdlist, |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1107 |
&PyTuple_Type, &TCentre, &radius, &MaterialType, &material)) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1108 |
return NULL; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1109 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1110 |
if (!PyArg_ParseTuple(TCentre, "fff", &cx, &cy, &cz)) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1111 |
return NULL; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1112 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1113 |
v = PyObject_New(SphereObject, &SphereType); |
91 | 1114 |
v->shape.shape = new Sphere(Vector(cx, cy, cz), radius, material->material); |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1115 |
Py_INCREF(material); |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1116 |
return (PyObject*)v; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1117 |
} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1118 |
|
14
fc18ac4833f2
replace Plane with axis-aligned Box (because infinite Plane is not usable with kd-tree)
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
1119 |
//=========================== Box Object =========================== |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1120 |
|
14
fc18ac4833f2
replace Plane with axis-aligned Box (because infinite Plane is not usable with kd-tree)
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
1121 |
static PyObject *Box_Constructor(PyObject* self, PyObject* args, PyObject *kwd); |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1122 |
|
14
fc18ac4833f2
replace Plane with axis-aligned Box (because infinite Plane is not usable with kd-tree)
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
1123 |
static PyMethodDef BoxMethods[] = { |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1124 |
{NULL, NULL} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1125 |
}; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1126 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1127 |
static PyTypeObject BoxType = |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1128 |
TYPE_OBJECT( |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1129 |
"Box", /* tp_name */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1130 |
sizeof(BoxObject), /* tp_basicsize */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1131 |
0, /* tp_dealloc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1132 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1133 |
"Box type", /* tp_doc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1134 |
BoxMethods, /* tp_methods */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1135 |
0, /* tp_members */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1136 |
&ShapeType, /* tp_base */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1137 |
0 /* tp_init */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1138 |
); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1139 |
|
14
fc18ac4833f2
replace Plane with axis-aligned Box (because infinite Plane is not usable with kd-tree)
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
1140 |
static PyObject* Box_Constructor(PyObject* self, PyObject* args, PyObject *kwd) |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1141 |
{ |
14
fc18ac4833f2
replace Plane with axis-aligned Box (because infinite Plane is not usable with kd-tree)
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
1142 |
BoxObject *v; |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1143 |
MaterialObject *material; |
14
fc18ac4833f2
replace Plane with axis-aligned Box (because infinite Plane is not usable with kd-tree)
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
1144 |
static char *kwdlist[] = {"L", "H", "material", NULL}; |
fc18ac4833f2
replace Plane with axis-aligned Box (because infinite Plane is not usable with kd-tree)
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
1145 |
PyObject *TL = NULL; |
fc18ac4833f2
replace Plane with axis-aligned Box (because infinite Plane is not usable with kd-tree)
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
1146 |
PyObject *TH = NULL; |
22 | 1147 |
Float lx, ly, lz, hx, hy, hz; |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1148 |
|
14
fc18ac4833f2
replace Plane with axis-aligned Box (because infinite Plane is not usable with kd-tree)
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
1149 |
if (!PyArg_ParseTupleAndKeywords(args, kwd, "O!O!O!", kwdlist, |
fc18ac4833f2
replace Plane with axis-aligned Box (because infinite Plane is not usable with kd-tree)
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
1150 |
&PyTuple_Type, &TL, &PyTuple_Type, &TH, &MaterialType, &material)) |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1151 |
return NULL; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1152 |
|
14
fc18ac4833f2
replace Plane with axis-aligned Box (because infinite Plane is not usable with kd-tree)
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
1153 |
if (!PyArg_ParseTuple(TL, "fff", &lx, &ly, &lz)) |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1154 |
return NULL; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1155 |
|
14
fc18ac4833f2
replace Plane with axis-aligned Box (because infinite Plane is not usable with kd-tree)
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
1156 |
if (!PyArg_ParseTuple(TH, "fff", &hx, &hy, &hz)) |
fc18ac4833f2
replace Plane with axis-aligned Box (because infinite Plane is not usable with kd-tree)
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
1157 |
return NULL; |
fc18ac4833f2
replace Plane with axis-aligned Box (because infinite Plane is not usable with kd-tree)
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
1158 |
|
fc18ac4833f2
replace Plane with axis-aligned Box (because infinite Plane is not usable with kd-tree)
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
1159 |
v = PyObject_New(BoxObject, &BoxType); |
91 | 1160 |
v->shape.shape = new Box(Vector(lx, ly, lz), Vector(hx, hy, hz), material->material); |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1161 |
Py_INCREF(material); |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1162 |
return (PyObject*)v; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1163 |
} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1164 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1165 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1166 |
//=========================== Sampler Object (abstract) =========================== |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1167 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1168 |
static void Sampler_Destructor(PyObject* self); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1169 |
static PyObject* Sampler_getPixmap(PyObject* self, PyObject* args); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1170 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1171 |
static PyMethodDef SamplerMethods[] = { |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1172 |
{"getPixmap", (PyCFunction)Sampler_getPixmap, METH_NOARGS, "Get sampler's pixmap."}, |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1173 |
{NULL, NULL} |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1174 |
}; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1175 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1176 |
static PyTypeObject SamplerType = |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1177 |
TYPE_OBJECT( |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1178 |
"Sampler", /* tp_name */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1179 |
sizeof(SamplerObject), /* tp_basicsize */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1180 |
Sampler_Destructor, /* tp_dealloc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1181 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1182 |
"Sampler type (abstract)", /* tp_doc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1183 |
SamplerMethods, /* tp_methods */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1184 |
0, /* tp_members */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1185 |
0, /* tp_base */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1186 |
0 /* tp_init */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1187 |
); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1188 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1189 |
static void Sampler_Destructor(PyObject* self) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1190 |
{ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1191 |
delete ((SamplerObject *)self)->sampler; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1192 |
self->ob_type->tp_free(self); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1193 |
} |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1194 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1195 |
static PyObject* Sampler_getPixmap(PyObject* self, PyObject* args) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1196 |
{ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1197 |
PixmapObject *v = PyObject_New(PixmapObject, &PixmapType); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1198 |
v->pixmap = &((SamplerObject *)self)->sampler->getPixmap(); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1199 |
return (PyObject*)v; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1200 |
} |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1201 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1202 |
//=========================== DefaultSampler Object =========================== |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1203 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1204 |
static PyObject *DefaultSampler_Constructor(PyObject* self, PyObject* args, PyObject *kwd); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1205 |
static PyObject* DefaultSampler_setSubsample(PyObject* self, PyObject* args); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1206 |
static PyObject* DefaultSampler_setOversample(PyObject* self, PyObject* args); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1207 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1208 |
static PyMethodDef DefaultSamplerMethods[] = { |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1209 |
{"setSubsample", (PyCFunction)DefaultSampler_setSubsample, METH_VARARGS, "Set subsampling mode."}, |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1210 |
{"setOversample", (PyCFunction)DefaultSampler_setOversample, METH_VARARGS, "Set oversampling mode."}, |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1211 |
{NULL, NULL} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1212 |
}; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1213 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1214 |
static PyTypeObject DefaultSamplerType = |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1215 |
TYPE_OBJECT( |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1216 |
"DefaultSampler", /* tp_name */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1217 |
sizeof(DefaultSamplerObject), /* tp_basicsize */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1218 |
0, /* tp_dealloc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1219 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1220 |
"DefaultSampler type", /* tp_doc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1221 |
DefaultSamplerMethods, /* tp_methods */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1222 |
0, /* tp_members */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1223 |
&SamplerType, /* tp_base */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1224 |
0 /* tp_init */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1225 |
); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1226 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1227 |
static PyObject* DefaultSampler_Constructor(PyObject* self, PyObject* args, PyObject *kwd) |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1228 |
{ |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1229 |
int w = 0, h = 0; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1230 |
PyObject *o1, *o2; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1231 |
DefaultSamplerObject *v; |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1232 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1233 |
if (!PyArg_ParseTuple(args, "O|O", &o1, &o2)) |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1234 |
return NULL; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1235 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1236 |
if (PyTuple_Check(o1)) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1237 |
{ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1238 |
if (!PyArg_ParseTuple(o1, "ii", &w, &h)) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1239 |
return NULL; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1240 |
} |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1241 |
else |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1242 |
if (!PyArg_ParseTuple(args, "ii", &w, &h)) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1243 |
return NULL; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1244 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1245 |
v = PyObject_New(DefaultSamplerObject, &DefaultSamplerType); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1246 |
v->sampler.sampler = new DefaultSampler(w, h); |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1247 |
return (PyObject*)v; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1248 |
} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1249 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1250 |
static PyObject* DefaultSampler_setSubsample(PyObject* self, PyObject* args) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1251 |
{ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1252 |
int size = 0; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1253 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1254 |
if (!PyArg_ParseTuple(args, "i", &size)) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1255 |
return NULL; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1256 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1257 |
((DefaultSampler *)((DefaultSamplerObject *)self)->sampler.sampler)->setSubsample(size); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1258 |
Py_INCREF(Py_None); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1259 |
return Py_None; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1260 |
} |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1261 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1262 |
static PyObject* DefaultSampler_setOversample(PyObject* self, PyObject* args) |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1263 |
{ |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1264 |
int osa = 0; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1265 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1266 |
if (!PyArg_ParseTuple(args, "i", &osa)) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1267 |
return NULL; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1268 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1269 |
((DefaultSampler *)((DefaultSamplerObject *)self)->sampler.sampler)->setOversample(osa); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1270 |
Py_INCREF(Py_None); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1271 |
return Py_None; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1272 |
} |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1273 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1274 |
//=========================== Container Object =========================== |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1275 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1276 |
static PyObject *Container_Constructor(PyObject* self, PyObject* args); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1277 |
static void Container_Destructor(PyObject* self); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1278 |
static PyObject* Container_optimize(PyObject* self, PyObject* args); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1279 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1280 |
static PyMethodDef ContainerMethods[] = { |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1281 |
{"optimize", (PyCFunction)Container_optimize, METH_NOARGS, "Build acceleration structures."}, |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1282 |
{NULL, NULL} |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1283 |
}; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1284 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1285 |
static PyTypeObject ContainerType = |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1286 |
TYPE_OBJECT( |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1287 |
"Container", /* tp_name */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1288 |
sizeof(ContainerObject), /* tp_basicsize */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1289 |
Container_Destructor, /* tp_dealloc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1290 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1291 |
"Container type", /* tp_doc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1292 |
ContainerMethods, /* tp_methods */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1293 |
0, /* tp_members */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1294 |
0, /* tp_base */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1295 |
0 /* tp_init */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1296 |
); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1297 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1298 |
static PyObject* Container_Constructor(PyObject* self, PyObject* args) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1299 |
{ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1300 |
ContainerObject *v; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1301 |
v = PyObject_New(ContainerObject, &ContainerType); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1302 |
v->container = new Container(); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1303 |
return (PyObject*)v; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1304 |
} |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1305 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1306 |
static void Container_Destructor(PyObject* self) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1307 |
{ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1308 |
delete ((ContainerObject *)self)->container; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1309 |
self->ob_type->tp_free(self); |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1310 |
} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1311 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1312 |
static PyObject* Container_optimize(PyObject* self, PyObject* args) |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1313 |
{ |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1314 |
((ContainerObject *)self)->container->optimize(); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1315 |
Py_INCREF(Py_None); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1316 |
return Py_None; |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1317 |
} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1318 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1319 |
//=========================== Octree Object =========================== |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1320 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1321 |
static PyObject* Octree_Constructor(PyObject* self, PyObject* args); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1322 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1323 |
static PyMethodDef OctreeMethods[] = { |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1324 |
{NULL, NULL} |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1325 |
}; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1326 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1327 |
static PyTypeObject OctreeType = |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1328 |
TYPE_OBJECT( |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1329 |
"Octree", /* tp_name */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1330 |
sizeof(OctreeObject), /* tp_basicsize */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1331 |
0, /* tp_dealloc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1332 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1333 |
"Octree type", /* tp_doc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1334 |
OctreeMethods, /* tp_methods */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1335 |
0, /* tp_members */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1336 |
&ContainerType, /* tp_base */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1337 |
0 /* tp_init */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1338 |
); |
28
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
1339 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1340 |
static PyObject* Octree_Constructor(PyObject* self, PyObject* args) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1341 |
{ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1342 |
OctreeObject *v; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1343 |
v = PyObject_New(OctreeObject, &OctreeType); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1344 |
v->container.container = new Octree(); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1345 |
return (PyObject*)v; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1346 |
} |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1347 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1348 |
//=========================== KdTree Object =========================== |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1349 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1350 |
static PyObject* KdTree_Constructor(PyObject* self, PyObject* args); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1351 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1352 |
static PyMethodDef KdTreeMethods[] = { |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1353 |
{NULL, NULL} |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1354 |
}; |
28
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
1355 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1356 |
static PyTypeObject KdTreeType = |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1357 |
TYPE_OBJECT( |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1358 |
"KdTree", /* tp_name */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1359 |
sizeof(KdTreeObject), /* tp_basicsize */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1360 |
0, /* tp_dealloc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1361 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1362 |
"KdTree type", /* tp_doc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1363 |
KdTreeMethods, /* tp_methods */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1364 |
0, /* tp_members */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1365 |
&ContainerType, /* tp_base */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1366 |
0 /* tp_init */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1367 |
); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1368 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1369 |
static PyObject* KdTree_Constructor(PyObject* self, PyObject* args) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1370 |
{ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1371 |
KdTreeObject *v; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1372 |
v = PyObject_New(KdTreeObject, &KdTreeType); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1373 |
v->container.container = new KdTree(); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1374 |
return (PyObject*)v; |
28
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
1375 |
} |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
1376 |
|
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1377 |
//=========================== Raytracer Object =========================== |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1378 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1379 |
static PyObject *Raytracer_Constructor(PyObject* self, PyObject* args); |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1380 |
static void Raytracer_Destructor(PyObject* self); |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1381 |
static PyObject *Raytracer_render(PyObject* self, PyObject* args); |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1382 |
static PyObject *Raytracer_setSampler(PyObject* self, PyObject* args); |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
72
diff
changeset
|
1383 |
static PyObject *Raytracer_setCamera(PyObject* self, PyObject* args); |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1384 |
static PyObject *Raytracer_setTop(PyObject* self, PyObject* args); |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
72
diff
changeset
|
1385 |
static PyObject *Raytracer_setBgColour(PyObject* self, PyObject* args); |
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
72
diff
changeset
|
1386 |
static PyObject *Raytracer_addShape(PyObject* self, PyObject* args); |
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
72
diff
changeset
|
1387 |
static PyObject *Raytracer_addLight(PyObject* self, PyObject* args); |
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
72
diff
changeset
|
1388 |
static PyObject *Raytracer_ambientOcclusion(PyObject* self, PyObject* args, PyObject *kwd); |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1389 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1390 |
static PyMethodDef RaytracerMethods[] = { |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1391 |
{"render", (PyCFunction)Raytracer_render, METH_NOARGS, "Render scene."}, |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1392 |
{"setSampler", (PyCFunction)Raytracer_setSampler, METH_VARARGS, "Set sampler."}, |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
72
diff
changeset
|
1393 |
{"setCamera", (PyCFunction)Raytracer_setCamera, METH_VARARGS, "Set camera for the scene."}, |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1394 |
{"setTop", (PyCFunction)Raytracer_setTop, METH_VARARGS, "Set top container for shapes."}, |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
72
diff
changeset
|
1395 |
{"setBgColour", (PyCFunction)Raytracer_setBgColour, METH_VARARGS, "Set background colour."}, |
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
72
diff
changeset
|
1396 |
{"addShape", (PyCFunction)Raytracer_addShape, METH_VARARGS, "Add new shape to scene."}, |
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
72
diff
changeset
|
1397 |
{"addLight", (PyCFunction)Raytracer_addLight, METH_VARARGS, "Add new light source to scene."}, |
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
72
diff
changeset
|
1398 |
{"ambientOcclusion", (PyCFunction)Raytracer_ambientOcclusion, METH_VARARGS | METH_KEYWORDS, |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1399 |
"Set ambient occlusion parametrs - samples: int (0 = disable), distance: float, angle: float."}, |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1400 |
{NULL, NULL} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1401 |
}; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1402 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1403 |
static PyTypeObject RaytracerType = |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1404 |
TYPE_OBJECT( |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1405 |
"Raytracer", /* tp_name */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1406 |
sizeof(RaytracerObject), /* tp_basicsize */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1407 |
Raytracer_Destructor, /* tp_dealloc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1408 |
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1409 |
"Raytracer type", /* tp_doc */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1410 |
RaytracerMethods, /* tp_methods */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1411 |
0, /* tp_members */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1412 |
0, /* tp_base */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1413 |
0 /* tp_init */ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1414 |
); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1415 |
|
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1416 |
static PyObject* Raytracer_Constructor(PyObject* self, PyObject* args) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1417 |
{ |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1418 |
RaytracerObject *v; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1419 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1420 |
if(!PyArg_ParseTuple(args, "")) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1421 |
return NULL; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1422 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1423 |
v = PyObject_New(RaytracerObject, &RaytracerType); |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1424 |
v->raytracer = new Raytracer(); |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1425 |
v->children = new vector<PyObject*>(); |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1426 |
return (PyObject*)v; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1427 |
} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1428 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1429 |
static void Raytracer_Destructor(PyObject* self) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1430 |
{ |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1431 |
vector<PyObject*>::iterator o; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1432 |
for (o = ((RaytracerObject *)self)->children->begin(); |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1433 |
o != ((RaytracerObject *)self)->children->end(); o++) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1434 |
Py_DECREF(*o); |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1435 |
delete ((RaytracerObject *)self)->raytracer; |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1436 |
self->ob_type->tp_free(self); |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1437 |
} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1438 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1439 |
static PyObject* Raytracer_render(PyObject* self, PyObject* args) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1440 |
{ |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1441 |
((RaytracerObject *)self)->raytracer->render(); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1442 |
Py_INCREF(Py_None); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1443 |
return Py_None; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1444 |
} |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1445 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1446 |
static PyObject* Raytracer_setSampler(PyObject* self, PyObject* args) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1447 |
{ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1448 |
SamplerObject *samp; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1449 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1450 |
if (!PyArg_ParseTuple(args, "O!", &SamplerType, &samp)) |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1451 |
return NULL; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1452 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1453 |
((RaytracerObject *)self)->raytracer->setSampler(samp->sampler); |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1454 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1455 |
Py_INCREF(samp); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1456 |
Py_INCREF(Py_None); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1457 |
return Py_None; |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1458 |
} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1459 |
|
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
72
diff
changeset
|
1460 |
static PyObject* Raytracer_setCamera(PyObject* self, PyObject* args) |
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
1461 |
{ |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
1462 |
CameraObject *cam; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
1463 |
|
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
1464 |
if (!PyArg_ParseTuple(args, "O!", &CameraType, &cam)) |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
1465 |
return NULL; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
1466 |
|
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
1467 |
((RaytracerObject *)self)->raytracer->setCamera(cam->camera); |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
1468 |
|
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
1469 |
Py_INCREF(cam); |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
1470 |
Py_INCREF(Py_None); |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
1471 |
return Py_None; |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
1472 |
} |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
1473 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1474 |
static PyObject* Raytracer_setTop(PyObject* self, PyObject* args) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1475 |
{ |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1476 |
ContainerObject *cont; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1477 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1478 |
if (!PyArg_ParseTuple(args, "O!", &ContainerType, &cont)) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1479 |
return NULL; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1480 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1481 |
((RaytracerObject *)self)->raytracer->setTop(cont->container); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1482 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1483 |
Py_INCREF(cont); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1484 |
Py_INCREF(Py_None); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1485 |
return Py_None; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1486 |
} |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1487 |
|
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
72
diff
changeset
|
1488 |
static PyObject* Raytracer_setBgColour(PyObject* self, PyObject* args) |
72
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
1489 |
{ |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
1490 |
Float r,g,b; |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
1491 |
|
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
1492 |
if (!PyArg_ParseTuple(args, "(fff)", &r, &g, &b)) |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
1493 |
return NULL; |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
1494 |
|
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
1495 |
((RaytracerObject *)self)->raytracer->setBgColour(Colour(r,g,b)); |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
1496 |
|
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
1497 |
Py_INCREF(Py_None); |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
1498 |
return Py_None; |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
1499 |
} |
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
1500 |
|
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
72
diff
changeset
|
1501 |
static PyObject* Raytracer_addShape(PyObject* self, PyObject* args) |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1502 |
{ |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1503 |
ShapeObject *shape; |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1504 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1505 |
if (!PyArg_ParseTuple(args, "O!", &ShapeType, &shape)) |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1506 |
return NULL; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1507 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1508 |
((RaytracerObject *)self)->raytracer->addShape(shape->shape); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1509 |
((RaytracerObject *)self)->children->push_back((PyObject*)shape); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1510 |
Py_INCREF(shape); |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1511 |
Py_INCREF(Py_None); |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1512 |
return Py_None; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1513 |
} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1514 |
|
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
72
diff
changeset
|
1515 |
static PyObject* Raytracer_addLight(PyObject* self, PyObject* args) |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1516 |
{ |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1517 |
LightObject *lightobj; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1518 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1519 |
if (!PyArg_ParseTuple(args, "O!", &LightType, &lightobj)) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1520 |
return NULL; |
72
7c3f38dff082
kd-tree building - check all axes for best split, add additional shape-bbox check
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
1521 |
((RaytracerObject *)self)->raytracer->addLight(lightobj->light); |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1522 |
((RaytracerObject *)self)->children->push_back((PyObject*)lightobj); |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1523 |
Py_INCREF(lightobj); |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1524 |
Py_INCREF(Py_None); |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1525 |
return Py_None; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1526 |
} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1527 |
|
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
72
diff
changeset
|
1528 |
static PyObject* Raytracer_ambientOcclusion(PyObject* self, PyObject* args, PyObject *kwd) |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1529 |
{ |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1530 |
int samples = 0; |
22 | 1531 |
Float distance = 0.0, angle = 0.0; |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1532 |
static char *kwdlist[] = {"samples", "distance", "angle", NULL}; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1533 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1534 |
if (!PyArg_ParseTupleAndKeywords(args, kwd, "iff", kwdlist, |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1535 |
&samples, &distance, &angle)) |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1536 |
return NULL; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1537 |
|
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
72
diff
changeset
|
1538 |
((RaytracerObject *)self)->raytracer->ambientOcclusion(samples, distance, angle); |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1539 |
Py_INCREF(Py_None); |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1540 |
return Py_None; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1541 |
} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1542 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1543 |
//=========================== Module Methods =========================== |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1544 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1545 |
static PyMethodDef ModuleMethods[] = { |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1546 |
{"Light", (PyCFunction) Light_Constructor, |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1547 |
METH_VARARGS | METH_KEYWORDS, "Light source object constructor."}, |
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
1548 |
{"Camera", (PyCFunction) Camera_Constructor, |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
48
diff
changeset
|
1549 |
METH_VARARGS | METH_KEYWORDS, "Camera object constructor."}, |
96
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1550 |
{"Pixmap", (PyCFunction) Pixmap_Constructor, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1551 |
METH_VARARGS | METH_KEYWORDS, "Pixmap object constructor."}, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1552 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1553 |
{"PlanarMap", (PyCFunction) PlanarMap_Constructor, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1554 |
METH_VARARGS | METH_KEYWORDS, "PlanarMap object constructor."}, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1555 |
{"CubicMap", (PyCFunction) CubicMap_Constructor, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1556 |
METH_VARARGS | METH_KEYWORDS, "CubicMap object constructor."}, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1557 |
{"SphereMap", (PyCFunction) SphereMap_Constructor, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1558 |
METH_VARARGS | METH_KEYWORDS, "SphereMap object constructor."}, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1559 |
{"CylinderMap", (PyCFunction) CylinderMap_Constructor, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1560 |
METH_VARARGS | METH_KEYWORDS, "CylinderMap object constructor."}, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1561 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1562 |
{"LinearColourMap", (PyCFunction) LinearColourMap_Constructor, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1563 |
METH_VARARGS | METH_KEYWORDS, "LinearColourMap object constructor."}, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1564 |
{"BoundColourMap", (PyCFunction) BoundColourMap_Constructor, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1565 |
METH_VARARGS | METH_KEYWORDS, "BoundColourMap object constructor."}, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1566 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1567 |
{"ImageTexture", (PyCFunction) ImageTexture_Constructor, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1568 |
METH_VARARGS | METH_KEYWORDS, "ImageTexture object constructor."}, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1569 |
{"CheckersTexture", (PyCFunction) CheckersTexture_Constructor, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1570 |
METH_VARARGS | METH_KEYWORDS, "CheckersTexture object constructor."}, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1571 |
{"CloudTexture", (PyCFunction) CloudTexture_Constructor, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1572 |
METH_VARARGS | METH_KEYWORDS, "CloudTexture object constructor."}, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1573 |
|
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1574 |
{"Material", (PyCFunction) Material_Constructor, |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1575 |
METH_VARARGS | METH_KEYWORDS, "Material object constructor."}, |
28
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
1576 |
{"NormalVertex", (PyCFunction) NormalVertex_Constructor, |
ffe83ca074f3
smooth triangles (aka Phong shading)
Radek Brich <radek.brich@devl.cz>
parents:
22
diff
changeset
|
1577 |
METH_VARARGS | METH_KEYWORDS, "NormalVertex object constructor."}, |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1578 |
{"Triangle", (PyCFunction) Triangle_Constructor, |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1579 |
METH_VARARGS | METH_KEYWORDS, "Triangle object constructor."}, |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1580 |
{"Sphere", (PyCFunction) Sphere_Constructor, |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1581 |
METH_VARARGS | METH_KEYWORDS, "Sphere object constructor."}, |
14
fc18ac4833f2
replace Plane with axis-aligned Box (because infinite Plane is not usable with kd-tree)
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
1582 |
{"Box", (PyCFunction) Box_Constructor, |
fc18ac4833f2
replace Plane with axis-aligned Box (because infinite Plane is not usable with kd-tree)
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
1583 |
METH_VARARGS | METH_KEYWORDS, "Box object constructor."}, |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1584 |
{"DefaultSampler", (PyCFunction) DefaultSampler_Constructor, |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1585 |
METH_VARARGS | METH_KEYWORDS, "DefaultSampler object constructor."}, |
96
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1586 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1587 |
{"Container", (PyCFunction) Container_Constructor, |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1588 |
METH_NOARGS, "Container object constructor."}, |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1589 |
{"Octree", (PyCFunction) Octree_Constructor, |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1590 |
METH_NOARGS, "Octree object constructor."}, |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1591 |
{"KdTree", (PyCFunction) KdTree_Constructor, |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1592 |
METH_NOARGS, "KdTree object constructor."}, |
96
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1593 |
|
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1594 |
{"Raytracer", (PyCFunction) Raytracer_Constructor, |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1595 |
METH_VARARGS, "Raytracer object constructor."}, |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1596 |
{NULL, NULL} |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1597 |
}; |
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1598 |
|
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1599 |
|
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1600 |
extern "C" void initpyrit(void) |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1601 |
{ |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1602 |
PyObject* m; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1603 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1604 |
if (PyType_Ready(&RaytracerType) < 0 |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1605 |
|| PyType_Ready(&LightType) < 0 |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1606 |
|| PyType_Ready(&CameraType) < 0 |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1607 |
|| PyType_Ready(&MaterialType) < 0 |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1608 |
|| PyType_Ready(&NormalVertexType) < 0 |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1609 |
|| PyType_Ready(&ShapeType) < 0 |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1610 |
|| PyType_Ready(&TriangleType) < 0 |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1611 |
|| PyType_Ready(&SphereType) < 0 |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1612 |
|| PyType_Ready(&BoxType) < 0 |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1613 |
|| PyType_Ready(&PixmapType) < 0 |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1614 |
|| PyType_Ready(&SamplerType) < 0 |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1615 |
|| PyType_Ready(&DefaultSamplerType) < 0 |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1616 |
|| PyType_Ready(&ContainerType) < 0 |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1617 |
|| PyType_Ready(&OctreeType) < 0 |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1618 |
|| PyType_Ready(&KdTreeType) < 0 |
96
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1619 |
|| PyType_Ready(&TextureMapType) < 0 |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1620 |
|| PyType_Ready(&PlanarMapType) < 0 |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1621 |
|| PyType_Ready(&CubicMapType) < 0 |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1622 |
|| PyType_Ready(&CylinderMapType) < 0 |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1623 |
|| PyType_Ready(&SphereMapType) < 0 |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1624 |
|| PyType_Ready(&ColourMapType) < 0 |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1625 |
|| PyType_Ready(&LinearColourMapType) < 0 |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1626 |
|| PyType_Ready(&BoundColourMapType) < 0 |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1627 |
|| PyType_Ready(&TextureType) < 0 |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1628 |
|| PyType_Ready(&ImageTextureType) < 0 |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1629 |
|| PyType_Ready(&CheckersTextureType) < 0 |
9eb71e76c7fd
added Python binding for material.h classes
Radek Brich <radek.brich@devl.cz>
parents:
93
diff
changeset
|
1630 |
|| PyType_Ready(&CloudTextureType) < 0 |
90
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1631 |
) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1632 |
return; |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1633 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1634 |
m = Py_InitModule3("pyrit", ModuleMethods, "Pyrit ray tracer."); |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1635 |
|
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1636 |
if (m == NULL) |
f6a72eb99631
rename Python module from 'raytracer' to 'pyrit'
Radek Brich <radek.brich@devl.cz>
parents:
89
diff
changeset
|
1637 |
return; |
0
3547b885df7e
initial commit, raytracer source as written year ago and unchanged since 2007-03-25
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1638 |
} |