Permalink
Browse files

added projectPoint

  • Loading branch information...
elliotwoods committed Mar 3, 2012
1 parent dbc1f3e commit c9fe85c9f480ac116006296a3e8b0b1feb95bedd
Showing with 9 additions and 0 deletions.
  1. +7 −0 src/ofxRay/ofProjector.cpp
  2. +2 −0 src/ofxRay/ofProjector.h
@@ -199,4 +199,11 @@ namespace ofxRay {
ofMatrix4x4 Projector::getViewProjectionMatrix() const {
return this->getViewMatrix() * this->getProjectionMatrix();
}
+
+ //----------
+ ofVec3f Projector::projectPoint(const ofVec3f& point) const {
+ ofVec4f point4(point.x, point.y, point.z, 1.0f);
+ point4 = point4 * this->getViewProjectionMatrix();
+ return ofVec3f(point4.x / point4.w, point4.y / point4.w, point4.z / point4.w);
+ }
}
View
@@ -51,6 +51,8 @@ namespace ofxRay {
ofMatrix4x4 getProjectionMatrix() const;
ofMatrix4x4 getViewProjectionMatrix() const;
+ ofVec3f projectPoint(const ofVec3f& point) const;
+
protected:
int width;
int height;

0 comments on commit c9fe85c

Please sign in to comment.