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

panda/src/gobj/LOD.h

Go to the documentation of this file.
00001 // Filename: LOD.h
00002 // Created by:  mike (09Jan97)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef LOD_H
00020 #define LOD_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "luse.h"
00025 #include "typedReferenceCount.h"
00026 
00027 class Datagram;
00028 class DatagramIterator;
00029 
00030 ////////////////////////////////////////////////////////////////////
00031 //       Class : LODSwitch
00032 // Description : Defines a switching region for an LOD.  An object
00033 //               will be visible when it is closer than "in" units,
00034 //               but further than "out" units from the camera.
00035 //
00036 //               The sense of in vs. out distances is as if the object
00037 //               were coming towards you from far away: it switches
00038 //               "in" at the far distance, and switches "out" at the
00039 //               close distance.  Thus, "in" should be larger than
00040 //               "out".
00041 ////////////////////////////////////////////////////////////////////
00042 class EXPCL_PANDA LODSwitch {
00043 public:
00044   INLINE LODSwitch();
00045   INLINE LODSwitch(float in, float out);
00046   INLINE LODSwitch(const LODSwitch &copy);
00047   INLINE void operator = (const LODSwitch &copy);
00048 
00049   INLINE void get_range(float &in, float &out) const;
00050   INLINE float get_in() const;
00051   INLINE float get_out() const;
00052   INLINE void set_range(float in, float out);
00053   INLINE bool in_range(float dist_squared) const;
00054 
00055   INLINE void rescale(float factor_squared);
00056 
00057   // We must declare these operators to allow VC++ to explicitly
00058   // export pvector<LODSwitch>, below.  They don't do anything useful.
00059   INLINE bool operator == (const LODSwitch &other) const;
00060   INLINE bool operator != (const LODSwitch &other) const;
00061   INLINE bool operator < (const LODSwitch &other) const;
00062 
00063   INLINE void write_datagram(Datagram &destination) const;
00064   INLINE void read_datagram(DatagramIterator &source);
00065 
00066 protected:
00067   float _in;
00068   float _out;
00069 };
00070 
00071 #define EXPCL EXPCL_PANDA
00072 #define EXPTP EXPTP_PANDA
00073 #define TYPE LODSwitch
00074 #define NAME LODSwitchVector
00075 
00076 #include <vector_src.h>
00077 
00078 ////////////////////////////////////////////////////////////////////
00079 //       Class : LOD
00080 // Description : Computes whether a level-of-detail should be rendered
00081 //               or not based on distance from the rendering camera.
00082 ////////////////////////////////////////////////////////////////////
00083 class EXPCL_PANDA LOD {
00084 public:
00085   LOD();
00086   LOD(const LOD &copy);
00087   ~LOD();
00088 
00089   void xform(const LMatrix4f &mat);
00090 
00091   int compute_child(const LPoint3f &cam_pos,
00092                     const LPoint3f &center) const;
00093 
00094   void write_datagram(Datagram &destination) const;
00095   void read_datagram(DatagramIterator &source);
00096 
00097   void output(ostream &out) const;
00098   void write(ostream &out, int indent_level = 0) const;
00099 
00100 PUBLISHED:
00101   static void set_stress_factor(float stress_factor);
00102   static float get_stress_factor();
00103 
00104 public:
00105   LPoint3f _center;
00106   LODSwitchVector _switch_vector;
00107 
00108 private:
00109   static float _stress_factor;
00110 };
00111 
00112 INLINE ostream &operator << (ostream &out, const LOD &lod) {
00113   lod.output(out);
00114   return out;
00115 }
00116 
00117 #include "LOD.I"
00118 
00119 #endif

Generated on Fri May 2 00:39:36 2003 for Panda by doxygen1.3