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

sglDistanceSwitch.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: sglDistanceSwitch.hpp
00021  *  Created: 24 January 2002
00022  *  Summary: select (or not) all the children to be traversed based on a single
00023  *           range value (a very specialized LOD node).
00024  *****************************************************************************/
00025 
00026 #ifndef __SGL_DISTANCE_SWITCH_HPP
00027 #define __SGL_DISTANCE_SWITCH_HPP
00028 
00029 #include <sgl.h>
00030 #include <vector>
00031 
00032 #include <sglVector.hpp>
00033 #include <sglGroup.hpp>
00034 #include <sglLODState.hpp>
00035 
00036 //----------------------------------------------------------------------------
00037 
00145 class SGL_DLL_API sglLOD : public sglGroup
00146 {
00147 public:
00149    sglLOD();
00151    virtual ~sglLOD();
00152 
00156    unsigned int getNumRanges() const { return m_ranges.size(); }
00157 
00163    void  setRange(unsigned int index, float range);
00164 
00171    float getRange(unsigned int index) const;
00172 
00177    void setCenter(const sglVec3f &center) { m_center = center; }
00178 
00182    const sglVec3f &getCenter() const { return m_center; }
00183 
00188    static void setScaleFactor(float scale) { s_range_scale = scale; }
00189 
00193    static float getScaleFactor() { return s_range_scale; }
00194 
00205    void setLODState(sglLODState *lod_state);
00206 
00211    sglLODState *getLODState() const { return m_lod_state; }
00212 
00213    // see sglNode::intersect(f) for details.
00214    virtual sglBound::IntersectResultEnum intersect(
00215       sglIntersectf &isector) const;
00216 
00217    // see sglNode::intersect(d) for details.
00218    virtual sglBound::IntersectResultEnum intersect(
00219       sglIntersectd &isector) const;
00220 
00221    // see sglNode::pick(f) for details.
00222    virtual void pick(sglPickf &pick_state, unsigned int cull_flags) const;
00223 
00224    // see sglNode::pick(d) for details.
00225    virtual void pick(sglPickd &pick_state, unsigned int cull_flags) const;
00226 
00227    // See sglNode::clone() for details.
00228    virtual sglNode *clone(unsigned int mode) const;
00229 
00230    // See sglObject::printInfo() for details.
00231    virtual void printInfo(ostream &ostrm, const char *indent_string) const;
00232 
00233 protected:
00234    // See sglNode::cull(f) for details
00235    virtual void cull(sglCull<float> &trav_state,
00236                      unsigned int cull_flags) const;
00237 
00238    // See sglNode::cull(d) for details
00239    virtual void cull(sglCull<double> &trav_state,
00240                      unsigned int cull_flags) const;
00241 
00242    // If a user wants to subclass this node and replace the equation used for
00243    // determining the range used in child selection, the following function
00244    // should be reimplemented in the subclass (one each for single and double
00245    // precision traversals.
00246    virtual float computeRange(float trav_lod_scale,
00247                               float trav_lod_offset,
00248                               const sglMat4f &view_matrix) const;
00249    virtual float computeRange(float trav_lod_scale,
00250                               float trav_lod_offset,
00251                               const sglMat4d &view_matrix) const;
00252 
00253    void copyTo(sglLOD *dst, unsigned int mode) const;
00254 
00255 private: // not implemented
00256    sglLOD(const sglLOD &);
00257    sglLOD &operator=(const sglLOD &);
00258 
00259 protected:
00260    static float s_range_scale;
00261 
00262    sglVec3f m_center;
00263    vector<float> m_ranges;
00264 
00265    sglLODState *m_lod_state;
00266 };
00267 
00268 #endif

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