--- a/src/raytracermodule.cc Sat Apr 12 02:02:45 2008 +0200
+++ b/src/raytracermodule.cc Mon Apr 14 12:51:50 2008 +0200
@@ -248,6 +248,7 @@
static PyObject *Material_setPhong(PyObject* self, PyObject* args);
static PyObject *Material_setReflectivity(PyObject* self, PyObject* args);
static PyObject *Material_setTransmissivity(PyObject* self, PyObject* args);
+static PyObject *Material_setSmooth(PyObject* self, PyObject* args);
static PyTypeObject MaterialType = {
PyObject_HEAD_INIT(NULL)
@@ -272,6 +273,7 @@
{"setPhong", (PyCFunction)Material_setPhong, METH_VARARGS, "Set ambient, diffuse, specular and shininess Phong model constants."},
{"setReflectivity", (PyCFunction)Material_setReflectivity, METH_VARARGS, "Set reflectivity."},
{"setTransmissivity", (PyCFunction)Material_setTransmissivity, METH_VARARGS, "Set transmissivity and refraction index."},
+ {"setSmooth", (PyCFunction)Material_setSmooth, METH_VARARGS, "Set triangle smoothing."},
{NULL, NULL}
};
@@ -345,6 +347,20 @@
return Py_None;
}
+static PyObject* Material_setSmooth(PyObject* self, PyObject* args)
+{
+ int smooth;
+
+ if (!PyArg_ParseTuple(args, "i", &smooth))
+ return NULL;
+
+ ((MaterialObject *)self)->material->setSmooth(smooth);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
//=========================== NormalVertex Object ===========================
typedef struct {
@@ -389,19 +405,27 @@
PyObject *TNor = NULL;
Float vx, vy, vz, nx=0, ny=0, nz=0;
- if (!PyArg_ParseTupleAndKeywords(args, kwd, "O!|O!", kwdlist,
- &PyTuple_Type, &TVer, &PyTuple_Type, &TNor))
- return NULL;
-
- if (!PyArg_ParseTuple(TVer, "fff", &vx, &vy, &vz))
+ if (!PyArg_ParseTupleAndKeywords(args, kwd, "O|O!", kwdlist,
+ &TVer, &PyTuple_Type, &TNor))
return NULL;
- if (TNor)
- if (!PyArg_ParseTuple(TNor, "fff", &nx, &ny, &nz))
+ if (!TNor && TVer->ob_type == &NormalVertexType)
+ {
+ v = PyObject_New(NormalVertexObject, &NormalVertexType);
+ v->nvertex = new NormalVertex(((NormalVertexObject*)TVer)->nvertex);
+ }
+ else
+ {
+ if (!PyArg_ParseTuple(TVer, "fff", &vx, &vy, &vz))
return NULL;
- v = PyObject_New(NormalVertexObject, &NormalVertexType);
- v->nvertex = new NormalVertex(Vector3(vx, vy, vz), Vector3(nx, ny, nz));
+ if (TNor)
+ if (!PyArg_ParseTuple(TNor, "fff", &nx, &ny, &nz))
+ return NULL;
+
+ v = PyObject_New(NormalVertexObject, &NormalVertexType);
+ v->nvertex = new NormalVertex(Vector3(vx, vy, vz), Vector3(nx, ny, nz));
+ }
return (PyObject*)v;
}
@@ -580,7 +604,6 @@
static void Triangle_Destructor(PyObject* self);
static PyObject *Triangle_Getattr(PyObject *self, char *name);
static PyObject *Triangle_getNormal(PyObject* self, PyObject* args);
-static PyObject *Triangle_setSmooth(PyObject* self, PyObject* args);
static PyTypeObject TriangleType = {
PyObject_HEAD_INIT(NULL)
@@ -603,7 +626,6 @@
static PyMethodDef TriangleMethods[] = {
{"getNormal", (PyCFunction)Triangle_getNormal, METH_NOARGS, "Get normal of whole triangle."},
- {"setSmooth", (PyCFunction)Triangle_setSmooth, METH_NOARGS, "Set the triangle smooth."},
{NULL, NULL}
};
@@ -649,13 +671,6 @@
return obj;
}
-static PyObject* Triangle_setSmooth(PyObject* self, PyObject* args)
-{
- ((TriangleObject *)self)->triangle->setSmooth();
- Py_INCREF(Py_None);
- return Py_None;
-}
-
//=========================== Raytracer Object ===========================
typedef struct {