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

sglProbe.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: sglProbe.hpp
00021  *   Author: Scott McMillan
00022  *  Created: 18 April 2001
00023  *  Summary: common base class for sglIntersect and sglPick classes only
00024  *           defines the mode enums
00025  *****************************************************************************/
00026 
00027 #ifndef __SGL_PROBE_HPP
00028 #define __SGL_PROBE_HPP
00029 
00030 #include <sgl.h>
00031 #include <sglTraverser.hpp>
00032 #include <sglMat4.hpp>
00033 #include <sglFrustum.hpp>
00034 
00035 class sglGeode;
00036 class sglDrawable;
00037 
00038 //----------------------------------------------------------------------------
00039 
00046 class SGL_DLL_API sglProbe : public sglTraverser
00047 {
00048 public:
00049    enum ModeEnum
00050    {
00051       ePRIMITIVE      = 0x00000001, // intersect w/ prims (incomplete)
00052       eGEOMETRY       = 0x00000002, // intersect w/ bounding boxes
00053       eGEODE          = 0x00000004, // intersect w/ bounding spheres (default)
00054       eCULL_BACK      = 0x00000008, // cull back faces (default)
00055       eCULL_FRONT     = 0x00000010, // cull front faces
00056       eNORMAL         = 0x00000020, // return the normal of the tri isected w/
00057       eTRANSFORM      = 0x00000040, // return the transform to the geode
00058       ePATH           = 0x00000080, // return the path to intersected node
00059 
00060       eSWITCH_ALL     = 0x00000100, // default is curr switch value
00061       eSWITCH_NONE    = 0x00000200, //
00062 
00063       eLOD_ALL        = 0x00000400, // default is range 0
00064       eLOD_NONE       = 0x00000800, //
00065       eLOD_VIEW       = 0x00001000, //
00066 
00067       // the following requires the current modelview matrix
00068       eBILLBOARD_VIEW = 0x00002000, // default is no billboards
00069 
00070       eANIMATION_ALL  = 0x00004000, // default is curr animation child
00071       eANIMATION_NONE = 0x00008000, //
00072 
00073       eLAYER_NONE     = 0x00010000, // default is all children
00074       eLAYER_BASE     = 0x00020000, // sglLayer::intersect()  not implemented
00075       eLAYER_DECAL    = 0x00040000, // sglLayer::pick()       not implemented
00076 
00077       // the following require the current modelview matrix and the view
00078       // frustum, and view port size in pixels.
00079       eUNSCALE_VIEW   = 0x00080000, // default is no unscale nodes
00080       eUNPROJECT_VIEW = 0x00100000  // default is no unproject nodes
00081    };
00082 
00083    sglProbe() : sglTraverser() {}
00084    virtual ~sglProbe() {}
00085 };
00086 
00087 //----------------------------------------------------------------------------
00088 
00095 template <class T>
00096 class SGL_DLL_API sglProbeTemplate : public sglProbe
00097 {
00098 public: // Sub types
00099    class SGL_DLL_API ProbeResult
00100    {
00101    public:
00102       const sglGeode    *m_geode;     // sglGeode above the picked bbox
00103       const sglDrawable *m_geometry;  // sglDrawable within the picked bbox
00104       sglMat4<T>         m_xform;     // homogeneous transform to picked geode
00105 
00106    public:
00107       ProbeResult() : m_geode(NULL), m_geometry(NULL)
00108          { m_xform.buildIdentity(); }
00109       virtual ~ProbeResult() {}
00110 
00111       virtual void reset() = 0;
00112 
00113    protected:
00114       // called by the subclasses reset() function.  This is a HACK due to
00115       // Windoze stupidity
00116       void resetInternal()
00117          {
00118             m_geode = NULL;
00119             m_geometry = NULL;
00120             m_xform.buildIdentity();
00121          }
00122    };
00123 
00124 public:  // Methods
00125    sglProbeTemplate() : sglProbe(), m_mode(eGEODE|eCULL_BACK) {}
00126    virtual ~sglProbeTemplate() {}
00127 
00128    virtual void reset()
00129       {
00130          m_modelview_matrix.buildIdentity(); // = pick_matrix;
00131       }
00132 
00133    void setMode(unsigned int mode) { m_mode = mode; }
00134    unsigned int getMode() const    { return m_mode; }
00135 
00137    void setViewportSize(unsigned int x, unsigned int y)
00138       { m_viewport_x = x; m_viewport_y = y; }
00140    void getViewportSize(unsigned int &x, unsigned int &y)
00141       { x = m_viewport_x; y = m_viewport_y; }
00142 
00144    void setViewFrustum(const sglFrustum<T> &frustum)
00145       {
00146          m_orig_view_frustum = frustum;
00147          m_current_view_frustum = frustum;
00148       }
00149 
00153    sglFrustum<T> &getOrigViewFrustum() { return m_orig_view_frustum; }
00155    sglFrustum<T> &getViewFrustum() { return m_current_view_frustum; }
00156 
00160    sglMat4<T>& getModelViewMatrix() { return m_modelview_matrix; }
00161 
00164    void setModelViewMatrix(const sglMat4<T> &mat) { m_modelview_matrix = mat; }
00165 
00166 
00167 private: // Methods - NOT IMPLEMENTED
00168    sglProbeTemplate(const sglProbeTemplate &);
00169    sglProbeTemplate &operator=(const sglProbeTemplate &);
00170 
00171 protected: // Variables
00172    unsigned int     m_mode;
00173 
00174    unsigned int     m_viewport_x;
00175    unsigned int     m_viewport_y;
00176    sglFrustum<T>    m_orig_view_frustum;
00177    sglFrustum<T>    m_current_view_frustum;
00178 
00179    sglMat4<T>       m_modelview_matrix;  // current transform matrix
00180 };
00181 
00182 #endif

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