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

sglLOD.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: sglLOD.hpp
00021  *  Created: 14 November 1998
00022  *  Summary: select (or not) the children to be traversed based on range
00023  *****************************************************************************/
00024 
00025 #ifndef __SGL_LOD_HPP
00026 #define __SGL_LOD_HPP
00027 
00028 #include <sgl.h>
00029 #include <vector>
00030 
00031 #include <sglVector.hpp>
00032 #include <sglGroup.hpp>
00033 #include <sglLODState.hpp>
00034 
00035 //----------------------------------------------------------------------------
00036 
00163 class SGL_DLL_API sglLOD : public sglGroup
00164 {
00165 public:
00167    sglLOD();
00169    virtual ~sglLOD();
00170 
00174    unsigned int getNumRanges() const { return m_ranges.size(); }
00175 
00181    void  setRange(unsigned int index, float range);
00182 
00189    float getRange(unsigned int index) const;
00190 
00195    void setCenter(const sglVec3f &center) { m_center = center; }
00196 
00200    const sglVec3f &getCenter() const { return m_center; }
00201 
00206    static void setScaleFactor(float scale) { s_range_scale = scale; }
00207 
00211    static float getScaleFactor() { return s_range_scale; }
00212 
00223    void setLODState(sglLODState *lod_state);
00224 
00229    sglLODState *getLODState() const { return m_lod_state; }
00230 
00231    // see sglNode::intersect(f) for details.
00232    virtual sglBound::IntersectResultEnum intersect(
00233       sglIntersectf &isector) const;
00234 
00235    // see sglNode::intersect(d) for details.
00236    virtual sglBound::IntersectResultEnum intersect(
00237       sglIntersectd &isector) const;
00238 
00239    // see sglNode::pick(f) for details.
00240    virtual void pick(sglPickf &pick_state, unsigned int cull_flags) const;
00241 
00242    // see sglNode::pick(d) for details.
00243    virtual void pick(sglPickd &pick_state, unsigned int cull_flags) const;
00244 
00245    // See sglNode::clone() for details.
00246    virtual sglNode *clone(unsigned int mode) const;
00247 
00248    // See sglObject::printInfo() for details.
00249    virtual void printInfo(ostream &ostrm, const char *indent_string) const;
00250 
00251 protected:
00252    // See sglNode::cull(f) for details
00253    virtual void cull(sglCull<float> &trav_state,
00254                      unsigned int cull_flags) const;
00255 
00256    // See sglNode::cull(d) for details
00257    virtual void cull(sglCull<double> &trav_state,
00258                      unsigned int cull_flags) const;
00259 
00260    // If a user wants to subclass this node and replace the equation used for
00261    // determining the range used in child selection, the following function
00262    // should be reimplemented in the subclass (one each for single and double
00263    // precision traversals.
00264    virtual float computeRange(float trav_lod_scale,
00265                               float trav_lod_offset,
00266                               const sglMat4f &view_matrix) const;
00267    virtual float computeRange(float trav_lod_scale,
00268                               float trav_lod_offset,
00269                               const sglMat4d &view_matrix) const;
00270 
00271    void copyTo(sglLOD *dst, unsigned int mode) const;
00272 
00273 private: // not implemented
00274    sglLOD(const sglLOD &);
00275    sglLOD &operator=(const sglLOD &);
00276 
00277 protected:
00278    static float s_range_scale;
00279 
00280    sglVec3f m_center;
00281    vector<float> m_ranges;
00282 
00283    sglLODState *m_lod_state;
00284 };
00285 
00286 #endif

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