Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

sgluFlyCamera.hpp

00001 /*****************************************************************************
00002  * SGL: A Scene Graph Library
00003  *
00004  * Copyright (C) 1997-2001  Scott McMillan   All Rights Reserved.
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public
00017  * License along with this library; if not, write to the Free
00018  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  *****************************************************************************
00020  *     File: sgluFlyCamera.hpp
00021  *  Created: 21 March 1997
00022  *  Summary: free-fly camera subclass def - was dmGLFLyCamera.hpp
00023  *****************************************************************************/
00024 
00025 #ifndef __SGLU_FLY_CAMERA_HPP
00026 #define __SGLU_FLY_CAMERA_HPP
00027 
00028 #include <sglu.h>
00029 #include <sgluCamera.hpp>
00030 #include <sgluMouse.hpp>
00031 
00032 class SGLU_DLL_API sgluFlyCamera : public sgluCamera
00033 {
00034 public:
00035    sgluFlyCamera();
00036    virtual ~sgluFlyCamera();
00037 
00038    void reset();
00039    void setTranslationScale(float scale) {m_trans_scale = scale;}
00040 
00041    // Lower level functions to affect camera state changes
00042    void updateAzimuth(float delta_azimuth);
00043    void updateElevation(float delta_elevation);
00044    void updateFlyPos(float delta_pos_ff[3]);
00045    void updateFlyPos(float delta_x, float delta_y, float delta_z);
00046 
00047    void setAzimuth(float azimuth);
00048    void setElevation(float elevation);
00049    void setFlyPos(float pos_ff[3]);
00050    void setFlyPos(float x, float y, float z);
00051 
00052    // the update() function sets the current m_view_mat that defines the
00053    // camera's position with respect to the GAPI's base coordinate system.
00054    //
00055    //   update(mouse *) changes the camera position and orientation
00056    //            according to the mouse position relative to the screen and
00057    //            which mouse buttons are being pressed, and computes the new
00058    //            matrix from these values:
00059    //            - the camera position can be moved right/left and up/down with
00060    //              the middle mouse button and the distance 
00061    //              from the center of the window using
00062    //            - the position is modified forward/backward using the right
00063    //              mouse button and the vertical distance from the center of
00064    //              the window
00065    //            - the heading and pitch can be modified using the left mouse
00066    //              button and the horizontal and vertical distances from the
00067    //              center of the window respectively.
00068    //
00069    // NOTE that in either case applyView() from HtPfCamera must be called to
00070    // push the changes to the channel view matrix.
00071    void update(sgluMouse *mouse);
00072 
00073    void applyView();
00074 
00075    SGLU_DLL_API friend ostream& operator<<(
00076       ostream &ostrm, const sgluFlyCamera &cam);
00077 
00078 private:  // not implemented
00079    sgluFlyCamera(const sgluFlyCamera&);
00080    sgluFlyCamera &operator=(const sgluFlyCamera&);
00081 
00082 private:
00083    float m_pos_ff[3];                        // current camera position
00084    float m_look_at[3], m_up[3];
00085    float m_elevation, m_sin_el, m_cos_el;    // elevation angle in degrees
00086    float m_azimuth,   m_sin_az, m_cos_az;    // azimuth angle in degrees
00087 
00088    float m_trans_scale;
00089 };
00090 
00091 #endif

Generated at Mon Jul 1 18:00:06 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001