00001 #ifndef GSGL_SG_FREEVIEW_H 00002 #define GSGL_SG_FREEVIEW_H 00003 00004 // 00005 // $Id: freeview.hpp 2 2008-03-01 20:58:50Z kulibali $ 00006 // 00007 // Copyright (c) 2008, The Periapsis Project. All rights reserved. 00008 // 00009 // Redistribution and use in source and binary forms, with or without 00010 // modification, are permitted provided that the following conditions are 00011 // met: 00012 // 00013 // * Redistributions of source code must retain the above copyright notice, 00014 // this list of conditions and the following disclaimer. 00015 // 00016 // * Redistributions in binary form must reproduce the above copyright 00017 // notice, this list of conditions and the following disclaimer in the 00018 // documentation and/or other materials provided with the distribution. 00019 // 00020 // * Neither the name of the The Periapsis Project nor the names of its 00021 // contributors may be used to endorse or promote products derived from 00022 // this software without specific prior written permission. 00023 // 00024 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 00025 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 00026 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00027 // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 00028 // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00029 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00030 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00031 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00032 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00033 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00034 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00035 // 00036 00037 #include "scenegraph/scenegraph.hpp" 00038 #include "scenegraph/node.hpp" 00039 #include "scenegraph/event.hpp" 00040 #include "scenegraph/camera.hpp" 00041 00042 #include "math/vector.hpp" 00043 #include "math/quaternion.hpp" 00044 #include "data/string.hpp" 00045 #include "data/broker.hpp" 00046 00047 namespace gsgl 00048 { 00049 00050 namespace scenegraph 00051 { 00052 00053 /// A freely rotatable viewpoint. 00054 class SCENEGRAPH_API freeview 00055 : public node 00056 { 00057 camera *cam; 00058 sg_event::event_code last_code; 00059 bool relative; 00060 00061 unsigned long transition_end_tick; 00062 gsgl::real_t transition_angular_velocity; 00063 math::vector transition_axis; 00064 00065 gsgl::real_t transition_linear_velocity; 00066 math::vector transition_path; 00067 00068 public: 00069 freeview(const gsgl::string & name, node *parent); 00070 freeview(const data::config_record & conf); 00071 virtual ~freeview(); 00072 00073 camera *get_camera() { return cam; } 00074 bool is_relative() const { return relative; } 00075 00076 void reset(gsgl::scenegraph::context *c = 0); 00077 00078 virtual void update(gsgl::scenegraph::context *c); 00079 virtual bool handle_event(gsgl::scenegraph::context *c, sg_event & e); 00080 00081 BROKER_DECLARE_CREATOR(gsgl::scenegraph::freeview); 00082 00083 private: 00084 bool rot_absolute(sg_event::event_code code, gsgl::scenegraph::context *c); 00085 bool rot_relative(sg_event::event_code code, gsgl::scenegraph::context *c); 00086 }; // class freeview 00087 00088 } // namespace scenegraph 00089 00090 } // namespace gsgl 00091 00092 #endif