# HG changeset patch # User Radek Brich # Date 1208761509 -7200 # Node ID 20dee9819b17b188475a7b4f39d479cc76051f98 # Parent 09aedbf5f95f832882e75d04ffb4bc80f8012ba3 unify capitalization of method names in C++ and Python diff -r 09aedbf5f95f -r 20dee9819b17 TODO --- a/TODO Mon Apr 21 08:47:36 2008 +0200 +++ b/TODO Mon Apr 21 09:05:09 2008 +0200 @@ -4,8 +4,7 @@ Future Plans ============ - * changing main ray tracing algoritm to more flexible architecture with a Sampler object: - - enhance Sampler to support subsampling + * enhance Sampler to support subsampling * namespace * kd-tree: - optimize structures @@ -17,7 +16,6 @@ * absorbtion of refracted rays in dense materials (can be computed using shape distance and some 'absorbance' constant) * implement efficient AABB-ray intersection using Plucker coordinates * generalization: Camera "shader" (ray generator), surface shader and maybe light & background shaders - * unify capitalization of method names in C++ and Python New Classes? ============ diff -r 09aedbf5f95f -r 20dee9819b17 ccdemos/textures.cc --- a/ccdemos/textures.cc Mon Apr 21 08:47:36 2008 +0200 +++ b/ccdemos/textures.cc Mon Apr 21 09:05:09 2008 +0200 @@ -269,7 +269,7 @@ { pyrit_verbosity = 2; Float *fdata = (Float *) malloc(w*h*3*sizeof(Float)); - rt.ambientocclusion(300, 5.0, 0.5); + rt.ambientOcclusion(300, 5.0, 0.5); DefaultSampler sampler(fdata, w, h); sampler.setOversample(2); sampler.setSubsample(1); diff -r 09aedbf5f95f -r 20dee9819b17 demos/boxes.py --- a/demos/boxes.py Mon Apr 21 08:47:36 2008 +0200 +++ b/demos/boxes.py Mon Apr 21 09:05:09 2008 +0200 @@ -6,10 +6,10 @@ rt = Raytracer() light1 = Light(position=(0.0, 5.0, -5.0), colour=(0.7, 0.3, 0.6)) -rt.addlight(light1) +rt.addLight(light1) light2 = Light(position=(-2.0, 10.0, -2.0), colour=(0.4, 0.6, 0.3)) -rt.addlight(light2) +rt.addLight(light2) mat0 = Material(colour=(0.7, 0.7, 0.7)) mat0.setReflectivity(0.0) @@ -17,7 +17,7 @@ for y in range(8): for z in range(8): box = Box(L=(-4.3+x, -4.6+y, -8.6+z), H=(-3.7+x, -4.0+y, -8.0+z), material=mat0) - rt.addshape(box) + rt.addShape(box) imagesize = (800, 600) data = rt.render(imagesize) diff -r 09aedbf5f95f -r 20dee9819b17 demos/buddha.py --- a/demos/buddha.py Mon Apr 21 08:47:36 2008 +0200 +++ b/demos/buddha.py Mon Apr 21 09:05:09 2008 +0200 @@ -14,7 +14,7 @@ mat, scale=20.0, trans=(0,-3,0)) light = Light(position=(-5.0, 2.0, 8.0), colour=(0.9, 0.3, 0.6)) -rt.addlight(light) +rt.addLight(light) imagesize = (800, 600) data = rt.render(imagesize) diff -r 09aedbf5f95f -r 20dee9819b17 demos/bunny.py --- a/demos/bunny.py Mon Apr 21 08:47:36 2008 +0200 +++ b/demos/bunny.py Mon Apr 21 09:05:09 2008 +0200 @@ -18,20 +18,20 @@ mat0 = Material(colour=(0.1, 0.2, 0.6)) box1 = Box(L=(-20.0, -1.7, -20.0), H=(20.0, -1.5, 20.0), material=mat0) -rt.addshape(box1) +rt.addShape(box1) mat1 = Material(colour=(0.5, 0.5, 0.2)) mat1.setReflectivity(0.0) box2 = Box(L=(-20.0, -20.0, -10.0), H=(20.0, 20.0, -12.0), material=mat1) -rt.addshape(box2) +rt.addShape(box2) light = Light(position=(-5.0, 3.0, 10.0), colour=(0.8, 0.5, 0.6)) #light.castshadows(0) -rt.addlight(light) +rt.addLight(light) light2 = Light(position=(4.0, 1.0, 10.0), colour=(0.5, 0.55, 0.7)) #light2.castshadows(0) -rt.addlight(light2) +rt.addLight(light2) imagesize = (800, 600) data = rt.render(imagesize) diff -r 09aedbf5f95f -r 20dee9819b17 demos/car.py --- a/demos/car.py Mon Apr 21 08:47:36 2008 +0200 +++ b/demos/car.py Mon Apr 21 09:05:09 2008 +0200 @@ -10,14 +10,14 @@ cam = Camera(eye=(0.,2.,8.)) rotx=0.15 cam.rotate((cos(rotx),-sin(rotx),0.,0.)) -rt.setcamera(cam) +rt.setCamera(cam) LoadLightwaveLwoFile(rt, "../models/lwo/Nissan300ZX.lwo", scale=0.4, trans=(-0.2,0,0.3)) light1 = Light(position=(-5.0, 20.0, 8.0), colour=(0.9, 0.9, 0.9)) -rt.addlight(light1) +rt.addLight(light1) light2 = Light(position=(5.0, 10.0, 10.0), colour=(0.9, 0.7, 0.7)) -rt.addlight(light2) +rt.addLight(light2) imagesize = (800, 600) data = rt.render(imagesize) diff -r 09aedbf5f95f -r 20dee9819b17 demos/dragon.py --- a/demos/dragon.py Mon Apr 21 08:47:36 2008 +0200 +++ b/demos/dragon.py Mon Apr 21 09:05:09 2008 +0200 @@ -14,10 +14,10 @@ mat, scale=(-29.0, 29.0, -29.0), trans=(0.0, -3.6, 0.0)) light1 = Light(position=(-5.0, 2.0, 8.0), colour=(0.9, 0.3, 0.2)) -rt.addlight(light1) +rt.addLight(light1) light2 = Light(position=(3.0, 0.0, 9.0), colour=(0.0, 1.0, 0.2)) -rt.addlight(light2) +rt.addLight(light2) imagesize = (800, 600) data = rt.render(imagesize) diff -r 09aedbf5f95f -r 20dee9819b17 demos/lworeader.py --- a/demos/lworeader.py Mon Apr 21 08:47:36 2008 +0200 +++ b/demos/lworeader.py Mon Apr 21 09:05:09 2008 +0200 @@ -270,4 +270,4 @@ v = [vertices[x] for x in f[0:3]] matidx = f[3]-1 face = Triangle(v[0], v[1], v[2], materials[matidx]) - rt.addshape(face) + rt.addShape(face) diff -r 09aedbf5f95f -r 20dee9819b17 demos/objreader.py --- a/demos/objreader.py Mon Apr 21 08:47:36 2008 +0200 +++ b/demos/objreader.py Mon Apr 21 09:05:09 2008 +0200 @@ -16,4 +16,4 @@ if ln[0] == "f": f = [vertices[int(x)-1] for x in ln[1:4]] face = Triangle(NormalVertex(f[0]), NormalVertex(f[1]), NormalVertex(f[2]), mat) - rt.addshape(face) + rt.addShape(face) diff -r 09aedbf5f95f -r 20dee9819b17 demos/plyreader.py --- a/demos/plyreader.py Mon Apr 21 08:47:36 2008 +0200 +++ b/demos/plyreader.py Mon Apr 21 09:05:09 2008 +0200 @@ -44,7 +44,7 @@ for i in range(3): normals[int(x)][i] += n[i] vertex_face_num[int(x)] += 1 - rt.addshape(face) + rt.addShape(face) face_num -= 1 # interpolate normals at vertices diff -r 09aedbf5f95f -r 20dee9819b17 demos/render_nff.py --- a/demos/render_nff.py Mon Apr 21 08:47:36 2008 +0200 +++ b/demos/render_nff.py Mon Apr 21 09:05:09 2008 +0200 @@ -47,12 +47,12 @@ # set camera as specified cam = Camera(eye=eye, lookat=lookat, up=up) cam.setAngle(angle/180*pi) - rt.setcamera(cam) + rt.setCamera(cam) elif ln[0] == 'b': # Background color - rt.setbgcolour((float(ln[1]), float(ln[2]), float(ln[3]))) + rt.setBgColour((float(ln[1]), float(ln[2]), float(ln[3]))) elif ln[0] == 'l': # Light pos = (float(ln[1]), float(ln[2]), float(ln[3])) - rt.addlight(Light(position=pos)) + rt.addLight(Light(position=pos)) elif ln[0] == 'f': # Fill color and shading parameters colour = (float(ln[1]), float(ln[2]), float(ln[3])) mat = Material(colour=colour) @@ -61,7 +61,7 @@ elif ln[0] == 's': # Sphere center = (float(ln[1]), float(ln[2]), float(ln[3])) radius = float(ln[4]) - rt.addshape(Sphere(centre=center, radius=radius, material=mat)) + rt.addShape(Sphere(centre=center, radius=radius, material=mat)) elif ln[0] == 'p': # Polygon vertex_count = int(ln[1]) vertices = [] @@ -69,9 +69,9 @@ ln = f.readline().split() vertex = (float(ln[0]), float(ln[1]), float(ln[2])) vertices.append(NormalVertex(vertex)) - rt.addshape(Triangle(vertices[0], vertices[1], vertices[2], mat)) + rt.addShape(Triangle(vertices[0], vertices[1], vertices[2], mat)) for i in range(vertex_count)[3:]: - rt.addshape(Triangle(vertices[0], vertices[i-1], vertices[i], mat)) + rt.addShape(Triangle(vertices[0], vertices[i-1], vertices[i], mat)) elif ln[0] == 'pp': # Polygonal patch mat.setSmooth(True) vertex_count = int(ln[1]) @@ -81,9 +81,9 @@ vertex = (float(ln[0]), float(ln[1]), float(ln[2])) normal = (float(ln[3]), float(ln[4]), float(ln[5])) vertices.append(NormalVertex(vertex, normal)) - rt.addshape(Triangle(vertices[0], vertices[1], vertices[2], mat)) + rt.addShape(Triangle(vertices[0], vertices[1], vertices[2], mat)) for i in range(vertex_count)[3:]: - rt.addshape(Triangle(vertices[0], vertices[i-1], vertices[i], mat)) + rt.addShape(Triangle(vertices[0], vertices[i-1], vertices[i], mat)) elif ln[0] == '#': # Comment pass else: diff -r 09aedbf5f95f -r 20dee9819b17 demos/spheres_ao.py --- a/demos/spheres_ao.py Mon Apr 21 08:47:36 2008 +0200 +++ b/demos/spheres_ao.py Mon Apr 21 09:05:09 2008 +0200 @@ -4,32 +4,32 @@ import Image rt = Raytracer() -rt.ambientocclusion(samples=100, distance=16.0, angle=0.5) +rt.ambientOcclusion(samples=100, distance=16.0, angle=0.5) light1 = Light(position=(0.0, 5.0, -5.0), colour=(0.7, 0.3, 0.6)) -light1.castshadows(False) -rt.addlight(light1) +light1.castShadows(False) +rt.addLight(light1) light2 = Light(position=(-2.0, 10.0, -2.0), colour=(0.4, 0.6, 0.3)) -light2.castshadows(False) -rt.addlight(light2) +light2.castShadows(False) +rt.addLight(light2) mat0 = Material(colour=(0.7, 0.7, 0.7)) box = Box(L=(-20.0, -1.2, -20.0), H=(20.0, -1.0, 20.0), material=mat0) -rt.addshape(box) +rt.addShape(box) mat1 = Material(colour=(1.0, 0.0, 0.0)) bigsphere = Sphere(centre=(3.0, 2.0, -7.0), radius=3.0, material=mat1) -rt.addshape(bigsphere) +rt.addShape(bigsphere) mat2 = Material(colour=(0.0, 1.0, 0.0)) smallsphere = Sphere(centre=(-5.5, 1.5, -8.0), radius=2.0, material=mat2) -rt.addshape(smallsphere) +rt.addShape(smallsphere) mat3 = Material(colour=(0.0, 0.0, 1.0)) tinysphere = Sphere(centre=(-1.2, 0.0, -2.0), radius=0.5, material=mat3) -rt.addshape(tinysphere) +rt.addShape(tinysphere) imagesize = (800, 600) data = rt.render(imagesize) diff -r 09aedbf5f95f -r 20dee9819b17 demos/spheres_glass.py --- a/demos/spheres_glass.py Mon Apr 21 08:47:36 2008 +0200 +++ b/demos/spheres_glass.py Mon Apr 21 09:05:09 2008 +0200 @@ -7,28 +7,28 @@ rt = Raytracer() light1 = Light(position=(0.0, 4.0, -3.0), colour=(0.9, 0.3, 0.6)) -rt.addlight(light1) +rt.addLight(light1) #light2 = SphericalLight(position=(-2.0, 5.0, 1.0), radius=3.0, colour=(0.7, 1.0, 0.3)) light2 = Light(position=(-2.0, -4.0, -1.0), colour=(0.7, 1.0, 0.3)) -rt.addlight(light2) +rt.addLight(light2) light2 = Light(position=(2.0, 5.0, 1.0), colour=(0.8, 0.9, 1.0)) -rt.addlight(light2) +rt.addLight(light2) mat0 = Material(colour=(0.1, 0.2, 0.9)) box = Box(L=(-20.0, -2.2, -20.0), H=(20.0, -2.0, 20.0), material=mat0) -rt.addshape(box) +rt.addShape(box) mat1 = Material(colour=(1.0, 0.2, 0.1)) mat1.setReflectivity(0.7) bigsphere = Sphere(centre=(2.0, 1.0, -5.0), radius=2.5, material=mat1) -rt.addshape(bigsphere) +rt.addShape(bigsphere) mat2 = Material(colour=(0.1, 0.4, 0.2)) mat2.setReflectivity(0.6) smallsphere = Sphere(centre=(-4.5, 0.5, -8.0), radius=2.0, material=mat2) -rt.addshape(smallsphere) +rt.addShape(smallsphere) mat3 = Material(colour=(0.9, 0.9, 1.0)) mat3.setPhong(0.2, 1.0, 0.2) @@ -36,7 +36,7 @@ mat3.setReflectivity(0.1) for i in range(10): sph = Sphere(centre=(-5.0+i, -1.5, -4.0), radius=0.5, material=mat3) - rt.addshape(sph) + rt.addShape(sph) rendersize = (800, 600) data = rt.render(rendersize) diff -r 09aedbf5f95f -r 20dee9819b17 demos/spheres_shadow.py --- a/demos/spheres_shadow.py Mon Apr 21 08:47:36 2008 +0200 +++ b/demos/spheres_shadow.py Mon Apr 21 09:05:09 2008 +0200 @@ -6,27 +6,27 @@ rt = Raytracer() light1 = Light(position=(0.0, 5.0, -5.0), colour=(0.7, 0.3, 0.6)) -rt.addlight(light1) +rt.addLight(light1) light2 = Light(position=(-2.0, 10.0, -2.0), colour=(0.4, 0.6, 0.3)) -rt.addlight(light2) +rt.addLight(light2) mat0 = Material(colour=(0.7, 0.7, 0.7)) box = Box(L=(-20.0, -1.2, -20.0), H=(20.0, -1.0, 20.0), material=mat0) -rt.addshape(box) +rt.addShape(box) mat1 = Material(colour=(1.0, 0.0, 0.0)) bigsphere = Sphere(centre=(3.0, 2.0, -7.0), radius=3.0, material=mat1) -rt.addshape(bigsphere) +rt.addShape(bigsphere) mat2 = Material(colour=(0.0, 1.0, 0.0)) smallsphere = Sphere(centre=(-5.5, 1.5, -8.0), radius=2.0, material=mat2) -rt.addshape(smallsphere) +rt.addShape(smallsphere) mat3 = Material(colour=(0.0, 0.0, 1.0)) tinysphere = Sphere(centre=(-1.2, 0.0, -2.0), radius=0.5, material=mat3) -rt.addshape(tinysphere) +rt.addShape(tinysphere) imagesize = (800, 600) data = rt.render(imagesize) diff -r 09aedbf5f95f -r 20dee9819b17 demos/triangles_monkey.py --- a/demos/triangles_monkey.py Mon Apr 21 08:47:36 2008 +0200 +++ b/demos/triangles_monkey.py Mon Apr 21 09:05:09 2008 +0200 @@ -9,7 +9,7 @@ LoadWavefrontObjFile(rt, "../models/obj/monkey.obj", mat, 1.5) light = Light(position=(-5.0, 2.0, 8.0), colour=(0.9, 0.3, 0.6)) -rt.addlight(light) +rt.addLight(light) imagesize = (800, 600) data = rt.render(imagesize) diff -r 09aedbf5f95f -r 20dee9819b17 demos/triangles_sphere.py --- a/demos/triangles_sphere.py Mon Apr 21 08:47:36 2008 +0200 +++ b/demos/triangles_sphere.py Mon Apr 21 09:05:09 2008 +0200 @@ -9,12 +9,12 @@ LoadWavefrontObjFile(rt, "../models/obj/sphere.obj", mat, 1.5) light1 = Light(position=(0.0, 2.0, 6.0), colour=(0.9, 0.3, 0.6)) -light1.castshadows(False); -rt.addlight(light1) +light1.castShadows(False); +rt.addLight(light1) light2 = Light(position=(-2.0, -5.0, 7.0), colour=(0.7, 1.0, 0.3)) -light2.castshadows(False); -rt.addlight(light2) +light2.castShadows(False); +rt.addLight(light2) imagesize = (800, 600) data = rt.render(imagesize) diff -r 09aedbf5f95f -r 20dee9819b17 include/raytracer.h --- a/include/raytracer.h Mon Apr 21 08:47:36 2008 +0200 +++ b/include/raytracer.h Mon Apr 21 09:05:09 2008 +0200 @@ -98,7 +98,7 @@ void setBgColour(const Colour &bg) { bg_colour = bg; }; void setMaxDepth(int newdepth) { max_depth = newdepth; }; - void ambientocclusion(int samples, Float distance, Float angle); + void ambientOcclusion(int samples, Float distance, Float angle); void setThreads(int num) { num_threads = num; }; }; diff -r 09aedbf5f95f -r 20dee9819b17 src/raytracer.cc --- a/src/raytracer.cc Mon Apr 21 08:47:36 2008 +0200 +++ b/src/raytracer.cc Mon Apr 21 09:05:09 2008 +0200 @@ -544,7 +544,7 @@ delete[] sample_queue; } -void Raytracer::ambientocclusion(int samples, Float distance, Float angle) +void Raytracer::ambientOcclusion(int samples, Float distance, Float angle) { ao_samples = samples; ao_distance = distance; diff -r 09aedbf5f95f -r 20dee9819b17 src/raytracermodule.cc --- a/src/raytracermodule.cc Mon Apr 21 08:47:36 2008 +0200 +++ b/src/raytracermodule.cc Mon Apr 21 09:05:09 2008 +0200 @@ -41,7 +41,7 @@ static PyObject *Light_Constructor(PyObject* self, PyObject* args, PyObject *kwd); static void Light_Destructor(PyObject* self); static PyObject *Light_Getattr(PyObject *self, char *name); -static PyObject *Light_castshadows(PyObject* self, PyObject* args); +static PyObject *Light_castShadows(PyObject* self, PyObject* args); static PyTypeObject LightType = { PyObject_HEAD_INIT(NULL) @@ -63,7 +63,7 @@ }; static PyMethodDef LightMethods[] = { - {"castshadows", (PyCFunction)Light_castshadows, METH_VARARGS, "Enable or disable shadows from this light."}, + {"castShadows", (PyCFunction)Light_castShadows, METH_VARARGS, "Enable or disable shadows from this light."}, {NULL, NULL} }; @@ -100,7 +100,7 @@ return Py_FindMethod(LightMethods, self, name); } -static PyObject *Light_castshadows(PyObject* self, PyObject* args) +static PyObject *Light_castShadows(PyObject* self, PyObject* args) { int shadows = 1; @@ -714,11 +714,11 @@ static void Raytracer_Destructor(PyObject* self); static PyObject *Raytracer_Getattr(PyObject *self, char *name); static PyObject *Raytracer_render(PyObject* self, PyObject* args); -static PyObject *Raytracer_setcamera(PyObject* self, PyObject* args); -static PyObject *Raytracer_setbgcolour(PyObject* self, PyObject* args); -static PyObject *Raytracer_addshape(PyObject* self, PyObject* args); -static PyObject *Raytracer_addlight(PyObject* self, PyObject* args); -static PyObject *Raytracer_ambientocclusion(PyObject* self, PyObject* args, PyObject *kwd); +static PyObject *Raytracer_setCamera(PyObject* self, PyObject* args); +static PyObject *Raytracer_setBgColour(PyObject* self, PyObject* args); +static PyObject *Raytracer_addShape(PyObject* self, PyObject* args); +static PyObject *Raytracer_addLight(PyObject* self, PyObject* args); +static PyObject *Raytracer_ambientOcclusion(PyObject* self, PyObject* args, PyObject *kwd); static PyTypeObject RaytracerType = { PyObject_HEAD_INIT(NULL) @@ -741,11 +741,11 @@ static PyMethodDef RaytracerMethods[] = { {"render", (PyCFunction)Raytracer_render, METH_VARARGS, "Render scene and return image data."}, - {"setcamera", (PyCFunction)Raytracer_setcamera, METH_VARARGS, "Set camera for the scene."}, - {"setbgcolour", (PyCFunction)Raytracer_setbgcolour, METH_VARARGS, "Set background colour."}, - {"addshape", (PyCFunction)Raytracer_addshape, METH_VARARGS, "Add new shape to scene."}, - {"addlight", (PyCFunction)Raytracer_addlight, METH_VARARGS, "Add new light source to scene."}, - {"ambientocclusion", (PyCFunction)Raytracer_ambientocclusion, METH_VARARGS | METH_KEYWORDS, + {"setCamera", (PyCFunction)Raytracer_setCamera, METH_VARARGS, "Set camera for the scene."}, + {"setBgColour", (PyCFunction)Raytracer_setBgColour, METH_VARARGS, "Set background colour."}, + {"addShape", (PyCFunction)Raytracer_addShape, METH_VARARGS, "Add new shape to scene."}, + {"addLight", (PyCFunction)Raytracer_addLight, METH_VARARGS, "Add new light source to scene."}, + {"ambientOcclusion", (PyCFunction)Raytracer_ambientOcclusion, METH_VARARGS | METH_KEYWORDS, "Set ambient occlusion parametrs - samples: int (0 = disable), distance: float, angle: float."}, {NULL, NULL} }; @@ -819,7 +819,7 @@ return o; } -static PyObject* Raytracer_setcamera(PyObject* self, PyObject* args) +static PyObject* Raytracer_setCamera(PyObject* self, PyObject* args) { CameraObject *cam; @@ -833,7 +833,7 @@ return Py_None; } -static PyObject* Raytracer_setbgcolour(PyObject* self, PyObject* args) +static PyObject* Raytracer_setBgColour(PyObject* self, PyObject* args) { Float r,g,b; @@ -846,7 +846,7 @@ return Py_None; } -static PyObject* Raytracer_addshape(PyObject* self, PyObject* args) +static PyObject* Raytracer_addShape(PyObject* self, PyObject* args) { PyObject *obj; @@ -862,7 +862,7 @@ return Py_None; } -static PyObject* Raytracer_addlight(PyObject* self, PyObject* args) +static PyObject* Raytracer_addLight(PyObject* self, PyObject* args) { LightObject *lightobj; @@ -875,7 +875,7 @@ return Py_None; } -static PyObject* Raytracer_ambientocclusion(PyObject* self, PyObject* args, PyObject *kwd) +static PyObject* Raytracer_ambientOcclusion(PyObject* self, PyObject* args, PyObject *kwd) { int samples = 0; Float distance = 0.0, angle = 0.0; @@ -885,7 +885,7 @@ &samples, &distance, &angle)) return NULL; - ((RaytracerObject *)self)->raytracer->ambientocclusion(samples, distance, angle); + ((RaytracerObject *)self)->raytracer->ambientOcclusion(samples, distance, angle); Py_INCREF(Py_None); return Py_None; }