diff -r fbd1d2f7d94e -r fc18ac4833f2 src/raytracermodule.cc --- a/src/raytracermodule.cc Sat Nov 24 23:55:54 2007 +0100 +++ b/src/raytracermodule.cc Sun Nov 25 15:50:01 2007 +0100 @@ -224,27 +224,27 @@ return Py_FindMethod(SphereMethods, self, name); } -//=========================== Plane Object =========================== +//=========================== Box Object =========================== typedef struct { PyObject_HEAD - Plane *shape; -} PlaneObject; + Box *shape; +} BoxObject; -static PyObject *Plane_Constructor(PyObject* self, PyObject* args, PyObject *kwd); -static void Plane_Destructor(PyObject* self); -static PyObject *Plane_Getattr(PyObject *self, char *name); +static PyObject *Box_Constructor(PyObject* self, PyObject* args, PyObject *kwd); +static void Box_Destructor(PyObject* self); +static PyObject *Box_Getattr(PyObject *self, char *name); -static PyTypeObject PlaneType = { +static PyTypeObject BoxType = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ - "Plane", /*tp_name*/ - sizeof(PlaneObject), /*tp_basicsize*/ + "Box", /*tp_name*/ + sizeof(BoxObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ - Plane_Destructor, /*tp_dealloc*/ + Box_Destructor, /*tp_dealloc*/ 0, /*tp_print*/ - Plane_Getattr, /*tp_getattr*/ + Box_Getattr, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ @@ -254,40 +254,44 @@ 0, /*tp_hash */ }; -static PyMethodDef PlaneMethods[] = { +static PyMethodDef BoxMethods[] = { {NULL, NULL} }; -static PyObject* Plane_Constructor(PyObject* self, PyObject* args, PyObject *kwd) +static PyObject* Box_Constructor(PyObject* self, PyObject* args, PyObject *kwd) { - PlaneObject *v; + BoxObject *v; MaterialObject *material; - static char *kwdlist[] = {"normal", "d", "material", NULL}; - PyObject *TNorm = NULL; - float nx, ny, nz, d; + static char *kwdlist[] = {"L", "H", "material", NULL}; + PyObject *TL = NULL; + PyObject *TH = NULL; + float lx, ly, lz, hx, hy, hz; - if (!PyArg_ParseTupleAndKeywords(args, kwd, "O!fO!", kwdlist, - &PyTuple_Type, &TNorm, &d, &MaterialType, &material)) + if (!PyArg_ParseTupleAndKeywords(args, kwd, "O!O!O!", kwdlist, + &PyTuple_Type, &TL, &PyTuple_Type, &TH, &MaterialType, &material)) return NULL; - if (!PyArg_ParseTuple(TNorm, "fff", &nx, &ny, &nz)) + if (!PyArg_ParseTuple(TL, "fff", &lx, &ly, &lz)) return NULL; - v = PyObject_New(PlaneObject, &PlaneType); - v->shape = new Plane(Vector3(nx, ny, nz), d, material->material); + if (!PyArg_ParseTuple(TH, "fff", &hx, &hy, &hz)) + return NULL; + + v = PyObject_New(BoxObject, &BoxType); + v->shape = new Box(Vector3(lx, ly, lz), Vector3(hx, hy, hz), material->material); Py_INCREF(material); return (PyObject*)v; } -static void Plane_Destructor(PyObject* self) +static void Box_Destructor(PyObject* self) { - delete ((PlaneObject *)self)->shape; + delete ((BoxObject *)self)->shape; PyObject_Del(self); } -static PyObject *Plane_Getattr(PyObject *self, char *name) +static PyObject *Box_Getattr(PyObject *self, char *name) { - return Py_FindMethod(PlaneMethods, self, name); + return Py_FindMethod(BoxMethods, self, name); } //=========================== Triangle Object =========================== @@ -479,7 +483,7 @@ return NULL; ((RaytracerObject *)self)->raytracer->addshape( - ((PlaneObject*)obj)->shape); + ((BoxObject*)obj)->shape); ((RaytracerObject *)self)->children->push_back(obj); Py_INCREF(obj); @@ -526,8 +530,8 @@ METH_VARARGS | METH_KEYWORDS, "Material object constructor."}, {"Sphere", (PyCFunction) Sphere_Constructor, METH_VARARGS | METH_KEYWORDS, "Sphere object constructor."}, - {"Plane", (PyCFunction) Plane_Constructor, - METH_VARARGS | METH_KEYWORDS, "Plane object constructor."}, + {"Box", (PyCFunction) Box_Constructor, + METH_VARARGS | METH_KEYWORDS, "Box object constructor."}, {"Triangle", (PyCFunction) Triangle_Constructor, METH_VARARGS | METH_KEYWORDS, "Triangle object constructor."}, {NULL, NULL}