00001 /* 00002 * Copyright (c) 2013, 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_OCULUS_DISPLAY_H 00031 #define RVIZ_OCULUS_DISPLAY_H 00032 00033 #ifndef Q_MOC_RUN 00034 #include <boost/shared_ptr.hpp> 00035 #include <tf/transform_broadcaster.h> 00036 #endif 00037 00038 #include <QObject> 00039 00040 #include <OGRE/OgreRenderTargetListener.h> 00041 00042 #include "rviz/display.h" 00043 00044 namespace Ogre 00045 { 00046 class SceneNode; 00047 class RenderWindow; 00048 } 00049 00050 namespace rviz 00051 { 00052 class BoolProperty; 00053 class StringProperty; 00054 class RenderWidget; 00055 class FloatProperty; 00056 class VectorProperty; 00057 class TfFrameProperty; 00058 } 00059 00060 namespace oculus_rviz_plugins 00061 { 00062 00063 class Oculus; 00064 00069 class OculusDisplay: public rviz::Display, public Ogre::RenderTargetListener 00070 { 00071 Q_OBJECT 00072 public: 00073 OculusDisplay(); 00074 virtual ~OculusDisplay(); 00075 00076 // Overrides from Display 00077 virtual void onInitialize(); 00078 virtual void update( float wall_dt, float ros_dt ); 00079 virtual void reset(); 00080 00081 // Overrides from Ogre::RenderTargetListener 00082 virtual void preRenderTargetUpdate( const Ogre::RenderTargetEvent& evt ); 00083 virtual void postRenderTargetUpdate( const Ogre::RenderTargetEvent& evt ); 00084 00085 protected: 00086 00087 virtual void onEnable(); 00088 virtual void onDisable(); 00089 00090 void updateCamera(); 00091 00092 protected Q_SLOTS: 00093 00094 void onFullScreenChanged(); 00095 void onPredictionDtChanged(); 00096 void onPubTfChanged(); 00097 void onFollowCamChanged(); 00098 00099 void onScreenCountChanged( int newCount ); 00100 00101 private: 00102 00103 rviz::BoolProperty *fullscreen_property_; 00104 rviz::FloatProperty *prediction_dt_property_; 00105 00106 rviz::BoolProperty *pub_tf_property_; 00107 rviz::StringProperty *pub_tf_frame_property_; 00108 00109 rviz::BoolProperty *follow_cam_property_; 00110 rviz::BoolProperty *horizontal_property_; 00111 rviz::TfFrameProperty *tf_frame_property_; 00112 rviz::VectorProperty *offset_property_; 00113 00114 rviz::FloatProperty *near_clip_property_; 00115 00116 rviz::RenderWidget *render_widget_; 00117 Ogre::SceneNode *scene_node_; 00118 00119 #ifndef Q_MOC_RUN 00120 tf::TransformBroadcaster tf_pub_; 00121 boost::shared_ptr<Oculus> oculus_; 00122 #endif 00123 }; 00124 00125 } // namespace rviz 00126 00127 #endif 00128