camera.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2010, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 #ifndef RVIZ_ROS_CLIENT_CAMERA_H
00031 #define RVIZ_ROS_CLIENT_CAMERA_H
00032 
00033 #include "single_scene_object.h"
00034 #include <rve_msgs/make_vector3.h>
00035 #include <rve_msgs/make_quaternion.h>
00036 #include <rve_msgs/Matrix4.h>
00037 
00038 #include <rve_common/uuid.h>
00039 #include <rve_render_client/forwards.h>
00040 
00041 namespace rve_interfaces
00042 {
00043 class CameraProxy;
00044 }
00045 
00046 namespace rve_render_client
00047 {
00048 
00049 class Camera : public SingleSceneObject
00050 {
00051 public:
00052   virtual void doCreate(ContextInfo& info);
00053   virtual void doDestroy(ContextInfo& info);
00054   virtual void getContextDependencies(V_UUID& deps) {}
00055   rve_interfaces::CameraProxy* getProxy(const ContextInfo& info);
00056 
00057   void setPosition(const rve_msgs::Vector3& pos);
00058 
00063   void setOrientation(const rve_msgs::Quaternion& orient);
00064 
00067   void lookAt(const rve_msgs::Vector3& point);
00068 
00072   void setDirection(const rve_msgs::Vector3& dir);
00073   void move(const rve_msgs::Vector3& v);
00074   void moveRelative(const rve_msgs::Vector3& v);
00075   void rotate(const rve_msgs::Quaternion& q);
00076 
00077   void setTransform(const rve_msgs::Vector3& pos, const rve_msgs::Quaternion& orient);
00078 
00079   void setAspectRatio( float width_over_height );
00080 
00081   void setProjectionMatrixFactory( const ProjectionMatrixFactoryPtr& factory );
00082   const ProjectionMatrixFactoryPtr& getProjectionMatrixFactory() const { return projection_matrix_factory_; }
00083 
00084   Scene* getScene() { return scene_; }
00085 
00086   template<typename T>
00087   void setPosition(T t)
00088   {
00089     setPosition(rve_msgs::makeVector3(t));
00090   }
00091 
00092   template<typename T>
00093   void setOrientation(T t)
00094   {
00095     setOrientation(rve_msgs::makeQuaternion(t));
00096   }
00097 
00098   template<typename T>
00099   void lookAt(T t)
00100   {
00101     lookAt(rve_msgs::makeVector3(t));
00102   }
00103 
00104   template<typename T>
00105   void move(T t)
00106   {
00107     move(rve_msgs::makeVector3(t));
00108   }
00109 
00110   template<typename T>
00111   void moveRelative(T t)
00112   {
00113     moveRelative(rve_msgs::makeVector3(t));
00114   }
00115 
00116   template<typename T>
00117   void rotate(T t)
00118   {
00119     rotate(rve_msgs::makeQuaternion(t));
00120   }
00121 
00122   template<typename T>
00123   void rotateRelative(T t)
00124   {
00125     rotateRelative(rve_msgs::makeQuaternion(t));
00126   }
00127 
00128   template <typename V, typename Q>
00129   void setTransform(V v, Q q)
00130   {
00131     setTransform(rve_msgs::makeVector3(v), rve_msgs::makeQuaternion(q));
00132   }
00133 
00134   const rve_msgs::Vector3& getPosition() { return position_; }
00135   const rve_msgs::Quaternion& getOrientation() { return orientation_; }
00136   const rve_msgs::Matrix4& getProjectionMatrix() { return projection_matrix_; }
00137 
00138 private:
00139 
00140   Camera();
00141   ~Camera();
00142 
00157   void setProjectionMatrix(const rve_msgs::Matrix4& matrix);
00158 
00159   friend class ProjectionMatrixFactory;
00160 
00161   rve_msgs::Vector3 position_;
00162   rve_msgs::Quaternion orientation_;
00163   rve_msgs::Matrix4 projection_matrix_;
00164   uint32_t proxy_index_;
00165 
00166   Scene* scene_;  // A camera can only actually be attached to a single scene
00167 
00168   friend CameraPtr createCamera(Scene*);
00169 
00170   ProjectionMatrixFactoryPtr projection_matrix_factory_;
00171 
00173   float aspect_ratio_;
00174 };
00175 
00176 CameraPtr createCamera(Scene* scene);
00177 
00178 } // namespace rve_render_client
00179 
00180 #endif // RVIZ_ROS_CLIENT_CAMERA_H


rve_render_client
Author(s): Josh Faust
autogenerated on Wed Dec 11 2013 14:31:32