diff options
author | Tavian Barnes <tavianator@gmail.com> | 2009-07-01 04:45:00 +0000 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2009-07-01 04:45:00 +0000 |
commit | e701e589c6a8bc4dd25d6c3e42947b83b09c24dd (patch) | |
tree | ab5bf2df0a9ce16c395e55dffdfabc5fc3f2aa9b | |
parent | e957408cb8cd200696a081b4f5c749c5294110ec (diff) | |
download | dimension-e701e589c6a8bc4dd25d6c3e42947b83b09c24dd.tar.xz |
Wrap objects' transformation matricies in C++.
-rw-r--r-- | libdimensionxx/dimensionxx/object.hpp | 5 | ||||
-rw-r--r-- | libdimensionxx/object.cpp | 12 | ||||
-rw-r--r-- | libdimensionxx/objects.cpp | 2 |
3 files changed, 18 insertions, 1 deletions
diff --git a/libdimensionxx/dimensionxx/object.hpp b/libdimensionxx/dimensionxx/object.hpp index 6eaca83..af9bbcd 100644 --- a/libdimensionxx/dimensionxx/object.hpp +++ b/libdimensionxx/dimensionxx/object.hpp @@ -32,6 +32,11 @@ namespace Dimension // No-op, made pure virtual virtual ~Object() = 0; + // Get/set the transformation matrix + Matrix trans(); + void trans(const Matrix& trans); + + // Object callbacks virtual Array<double> intersections(const Line& l); virtual bool inside(const Vector& point); diff --git a/libdimensionxx/object.cpp b/libdimensionxx/object.cpp index 61a887c..7d66206 100644 --- a/libdimensionxx/object.cpp +++ b/libdimensionxx/object.cpp @@ -26,6 +26,18 @@ namespace Dimension Object::~Object() { } + Matrix + Object::trans() + { + return Matrix(m_object->trans); + } + + void + Object::trans(const Matrix& trans) + { + m_object->trans = trans.dmnsn(); + } + // Intersection list for the line l Array<double> Object::intersections(const Line& l) diff --git a/libdimensionxx/objects.cpp b/libdimensionxx/objects.cpp index 1a63494..1b78731 100644 --- a/libdimensionxx/objects.cpp +++ b/libdimensionxx/objects.cpp @@ -42,7 +42,7 @@ namespace Dimension : Object(dmnsn_new_cube()) { if (!m_object) { - throw Dimension_Error("Failed to allocate sphere."); + throw Dimension_Error("Failed to allocate cube."); } } |