GlBasicSimulator.h

Go to the documentation of this file.
00001 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
00002  *
00003  * VR Juggler is (C) Copyright 1998-2005 by Iowa State University
00004  *
00005  * Original Authors:
00006  *   Allen Bierbaum, Christopher Just,
00007  *   Patrick Hartling, Kevin Meinert,
00008  *   Carolina Cruz-Neira, Albert Baker
00009  *
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Library General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2 of the License, or (at your option) any later version.
00014  *
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Library General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Library General Public
00021  * License along with this library; if not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00023  * Boston, MA 02111-1307, USA.
00024  *
00025  * -----------------------------------------------------------------
00026  * File:          $RCSfile$
00027  * Date modified: $Date: 2006-07-12 17:21:40 -0500 (Wed, 12 Jul 2006) $
00028  * Version:       $Revision: 19032 $
00029  * -----------------------------------------------------------------
00030  *
00031  *************** <auto-copyright.pl END do not edit this line> ***************/
00032 
00033 #ifndef _VRJ_GL_BASIC_SIMULATOR_H_
00034 #define _VRJ_GL_BASIC_SIMULATOR_H_
00035 
00036 #include <vrj/Draw/OGL/Config.h>
00037 
00038 #include <vrj/Draw/OGL/GlSimInterface.h>
00039 #include <vrj/Draw/OGL/GlDrawObjectFunctor.h>
00040 
00041 #ifdef VPR_OS_Darwin
00042 #   include <OpenGL/gl.h>
00043 #   include <OpenGL/glu.h>
00044 #else
00045 #   include <GL/gl.h>
00046 #   include <GL/glu.h>
00047 #endif
00048 
00049 #include <gadget/Type/PositionInterface.h>
00050 
00051 #include <gmtl/Matrix.h>
00052 #include <gmtl/Vec.h>
00053 
00054 
00055 namespace vrj
00056 {
00057 
00063 class GlBasicSimulator : public GlSimInterface
00064 {
00065 public:
00066    GlBasicSimulator();
00067 
00068    virtual ~GlBasicSimulator();
00069 
00076    virtual bool config(jccl::ConfigElementPtr element);
00077 
00078    static std::string getElementType()
00079    {
00080       return std::string("default_simulator");
00081    }
00082 
00087    virtual void draw(const float scaleFactor);
00088 
00089    virtual void initialize(SimViewport* simVp)
00090    {
00091       mSimViewport = simVp;
00092    }
00093 
00098    virtual void setKeyboardMouse(gadget::KeyboardMouseInterface kmInterface);
00099 
00100 public:
00101    const gmtl::Matrix44f& getCameraPos()
00102    {
00103       return mCameraPos;
00104    }
00105 
00106    const gmtl::Matrix44f& getHeadPos()
00107    {
00108       return mHeadPos;
00109    }
00110 
00111    const gmtl::Matrix44f& getWandPos()
00112    {
00113       return mWandPos;
00114    }
00115 
00116    virtual void updateProjectionData(const float positionScale,
00117                                      Projection* leftProj,
00118                                      Projection* rightProj);
00119 
00121    void updateInternalData(float positionScale);
00122 
00123 public:  // Sim Drawing parameters
00124    bool shouldDrawProjections()
00125    {
00126       return mDrawProjections;
00127    }
00128 
00129    gmtl::Vec3f getSurfaceColor()
00130    {
00131       return mSurfaceColor;
00132    }
00133 
00134 protected: // Drawing functions used by library
00139    void drawObjects();
00140 
00142    void drawProjections(bool drawFrustum, gmtl::Vec3f surfColor,
00143                         const float scaleFactor);
00144 
00150    void drawSimulator(const float scaleFactor);
00151 
00153    void setDrawWandFunctor(GlDrawObjectFunctor* functor)
00154    {
00155       mDrawWandFunctor = functor;
00156    }
00157 
00159    void setDrawHeadFunctor(GlDrawObjectFunctor* functor)
00160    {
00161       mDrawHeadFunctor = functor;
00162    }
00163 
00164 protected:     // --- Geom helpers --- //
00165    void initQuadObj();
00166    void drawLine(gmtl::Vec3f& start, gmtl::Vec3f& end);
00167    void drawCone(float base, float height, int slices, int stacks);
00168    void drawBox(float size, GLenum type);
00169    void drawWireCube(float size);
00170    void drawSolidCube(float size);
00171    //void drawGlove(gadget::GloveProxy* gloveProxy);
00172 
00173 protected:
00174    GlDrawObjectFunctor* mDrawWandFunctor;  
00175    GlDrawObjectFunctor* mDrawHeadFunctor;  
00176    GLUquadricObj* mQuadObj;                
00178 protected:
00179    SimViewport*   mSimViewport;
00180 
00181    // Drawing attributes
00182    bool           mDrawProjections;   
00183    gmtl::Vec3f    mSurfaceColor;      
00185    gadget::PositionInterface mCamera; 
00186    gadget::PositionInterface mWand;
00187 
00188    gmtl::Matrix44f    mCameraPos;     
00189    gmtl::Matrix44f    mHeadPos;
00190    gmtl::Matrix44f    mWandPos;
00191 };
00192 
00193 }
00194 
00195 #endif

Generated on Thu Jan 4 10:56:51 2007 for VR Juggler by  doxygen 1.5.1