summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-07-16 21:31:59 +0000
committerTavian Barnes <tavianator@gmail.com>2009-07-16 21:31:59 +0000
commitcf3d6906df7ffb4efa5398832e44ab31fe3b2721 (patch)
tree0ed55ed0a315a27ccb42d3953ceaa9b02a868abd
parentbbe317fb2bde1b2b88df66e5426c9ee78e40a0b6 (diff)
downloaddimension-cf3d6906df7ffb4efa5398832e44ab31fe3b2721.tar.xz
Don't take a transformation matrix in dmnsn_new_perspective_camera().
-rw-r--r--libdimension/cameras.c8
-rw-r--r--libdimension/dimension/cameras.h4
-rw-r--r--libdimensionxx/cameras.cpp4
-rw-r--r--libdimensionxx/dimensionxx/cameras.hpp2
-rw-r--r--tests/tests.c3
-rw-r--r--tests/testsxx.cpp3
6 files changed, 13 insertions, 11 deletions
diff --git a/libdimension/cameras.c b/libdimension/cameras.c
index 9e0642f..54c7e7f 100644
--- a/libdimension/cameras.c
+++ b/libdimension/cameras.c
@@ -30,9 +30,9 @@ static dmnsn_line dmnsn_perspective_camera_ray_fn(const dmnsn_camera *camera,
/* Create a new perspective camera. Rays are aimed from the origin to a screen
located on the z = 1 frame, from (-0.5, -0.5) to (0.5, 0.5). Rays are then
- transformed by the matrix `trans'. */
+ transformed by the camera's transformation matrix. */
dmnsn_camera *
-dmnsn_new_perspective_camera(dmnsn_matrix trans)
+dmnsn_new_perspective_camera()
{
dmnsn_matrix *ptr;
dmnsn_camera *camera = dmnsn_new_camera();
@@ -43,11 +43,11 @@ dmnsn_new_perspective_camera(dmnsn_matrix trans)
dmnsn_delete_camera(camera);
return NULL;
}
- *ptr = trans;
- camera->ptr = ptr;
+ *ptr = dmnsn_identity_matrix();
camera->ray_fn = &dmnsn_perspective_camera_ray_fn;
camera->free_fn = &free;
+ camera->ptr = ptr;
}
return camera;
}
diff --git a/libdimension/dimension/cameras.h b/libdimension/dimension/cameras.h
index b135693..cc7ad4c 100644
--- a/libdimension/dimension/cameras.h
+++ b/libdimension/dimension/cameras.h
@@ -27,8 +27,8 @@
/* A perspective camera, at the origin, looking at (0, 0, 1). The feild of view
is the section of the plane z = 1 from (-0.5, -0.5) to (0.5, 0.5). Rays are
- transformed by the transformation matrix `trans'. */
-dmnsn_camera *dmnsn_new_perspective_camera(dmnsn_matrix trans);
+ transformed by the camera's transformation matrix. */
+dmnsn_camera *dmnsn_new_perspective_camera();
/* Get or set the transformation matrix */
dmnsn_matrix dmnsn_get_perspective_camera_trans(const dmnsn_camera *camera);
diff --git a/libdimensionxx/cameras.cpp b/libdimensionxx/cameras.cpp
index f9f8302..9c44fef 100644
--- a/libdimensionxx/cameras.cpp
+++ b/libdimensionxx/cameras.cpp
@@ -23,8 +23,8 @@
namespace Dimension
{
// Create a perspective camera
- Perspective_Camera::Perspective_Camera(const Matrix& trans)
- : Camera(dmnsn_new_perspective_camera(trans.dmnsn()))
+ Perspective_Camera::Perspective_Camera()
+ : Camera(dmnsn_new_perspective_camera())
{
if (!dmnsn()) {
throw Dimension_Error("Failed to allocate perspective camera.");
diff --git a/libdimensionxx/dimensionxx/cameras.hpp b/libdimensionxx/dimensionxx/cameras.hpp
index ea08535..648c3da 100644
--- a/libdimensionxx/dimensionxx/cameras.hpp
+++ b/libdimensionxx/dimensionxx/cameras.hpp
@@ -29,7 +29,7 @@ namespace Dimension
class Perspective_Camera : public Camera
{
public:
- Perspective_Camera(const Matrix& trans);
+ Perspective_Camera();
// ~Perspective_Camera();
// Get/set the transformation matrix
diff --git a/tests/tests.c b/tests/tests.c
index ed00b64..f8c02de 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -65,12 +65,13 @@ dmnsn_new_default_scene()
);
/* Create a perspective camera */
- scene->camera = dmnsn_new_perspective_camera(trans);
+ scene->camera = dmnsn_new_perspective_camera();
if (!scene->camera) {
dmnsn_delete_canvas(scene->canvas);
dmnsn_delete_scene(scene);
return NULL;
}
+ dmnsn_set_perspective_camera_trans(scene->camera, trans);
/* Now make our objects */
diff --git a/tests/testsxx.cpp b/tests/testsxx.cpp
index a8fa762..fa8c2f0 100644
--- a/tests/testsxx.cpp
+++ b/tests/testsxx.cpp
@@ -30,7 +30,8 @@ namespace Dimension
Canvas canvas(768, 480);
// Camera
- Perspective_Camera camera(
+ Perspective_Camera camera;
+ camera.trans(
Matrix::rotation(Vector(0.0, 1.0, 0.0))
* Matrix::translation(Vector(0.0, 0.0, -4.0))
* Matrix::scale(