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

panda/src/pgraph/lodNode.I

Go to the documentation of this file.
00001 // Filename: lodNode.I
00002 // Created by:  drose (06Mar02)
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 ////////////////////////////////////////////////////////////////////
00020 //     Function: LODNode::CData::Constructor
00021 //       Access: Public
00022 //  Description:
00023 ////////////////////////////////////////////////////////////////////
00024 INLINE LODNode::CData::
00025 CData() {
00026 }
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //     Function: LODNode::CData::Copy Constructor
00030 //       Access: Public
00031 //  Description:
00032 ////////////////////////////////////////////////////////////////////
00033 INLINE LODNode::CData::
00034 CData(const LODNode::CData &copy) :
00035   _lod(copy._lod)
00036 {
00037 }
00038 
00039 ////////////////////////////////////////////////////////////////////
00040 //     Function: LODNode::Constructor
00041 //       Access: Published
00042 //  Description:
00043 ////////////////////////////////////////////////////////////////////
00044 INLINE LODNode::
00045 LODNode(const string &name) :
00046   SelectiveChildNode(name)
00047 {
00048 }
00049 
00050 ////////////////////////////////////////////////////////////////////
00051 //     Function: LODNode::Copy Constructor
00052 //       Access: Protected
00053 //  Description:
00054 ////////////////////////////////////////////////////////////////////
00055 INLINE LODNode::
00056 LODNode(const LODNode &copy) :
00057   SelectiveChildNode(copy),
00058   _cycler(copy._cycler)
00059 {
00060 }
00061 
00062 ////////////////////////////////////////////////////////////////////
00063 //     Function: LODNode::add_switch
00064 //       Access: Published
00065 //  Description: Adds a switch range to the LODNode.  This implies
00066 //               that the corresponding child node has been parented
00067 //               to the node.
00068 //
00069 //               The sense of in vs. out distances is as if the object
00070 //               were coming towards you from far away: it switches
00071 //               "in" at the far distance, and switches "out" at the
00072 //               close distance.  Thus, "in" should be larger than
00073 //               "out".
00074 ////////////////////////////////////////////////////////////////////
00075 INLINE void LODNode::
00076 add_switch(float in, float out) {
00077   CDWriter cdata(_cycler);
00078   cdata->_lod._switch_vector.push_back(LODSwitch(in, out));
00079 }
00080 
00081 ////////////////////////////////////////////////////////////////////
00082 //     Function: LODNode::set_switch
00083 //       Access: Published
00084 //  Description: Changes the switching range of a particular child of
00085 //               the LODNode.  See add_switch().
00086 ////////////////////////////////////////////////////////////////////
00087 INLINE bool LODNode::
00088 set_switch(int index, float in, float out) {
00089   CDWriter cdata(_cycler);
00090   nassertr(index >= 0 && index < (int)cdata->_lod._switch_vector.size(), false);
00091   cdata->_lod._switch_vector[index].set_range(in, out);
00092   return true;
00093 }
00094 
00095 ////////////////////////////////////////////////////////////////////
00096 //     Function: LODNode::clear_switches
00097 //       Access: Published
00098 //  Description: Removes the set of switching ranges for the LODNode,
00099 //               presumably in conjunction with removing all of its
00100 //               children.  See add_switch().
00101 ////////////////////////////////////////////////////////////////////
00102 INLINE void LODNode::
00103 clear_switches(void) {
00104   CDWriter cdata(_cycler);
00105   cdata->_lod._switch_vector.erase(cdata->_lod._switch_vector.begin(),
00106                                    cdata->_lod._switch_vector.end());
00107 }
00108 
00109 ////////////////////////////////////////////////////////////////////
00110 //     Function: LODNode::get_num_switches
00111 //       Access: Published
00112 //  Description: Returns the number of switch ranges added to the
00113 //               LODNode.  This should correspond to the number of
00114 //               children of the node in order for the LODNode to
00115 //               function correctly.
00116 ////////////////////////////////////////////////////////////////////
00117 INLINE int LODNode::
00118 get_num_switches() const {
00119   CDReader cdata(_cycler);
00120   return cdata->_lod._switch_vector.size();
00121 }
00122 
00123 ////////////////////////////////////////////////////////////////////
00124 //     Function: LODNode::get_in
00125 //       Access: Published
00126 //  Description: Returns the "in" distance of the indicated switch
00127 //               range.  This should be larger than the "out" distance
00128 //               of the same range.
00129 ////////////////////////////////////////////////////////////////////
00130 INLINE float LODNode::
00131 get_in(int index) const {
00132   CDReader cdata(_cycler);
00133   nassertr(index >= 0 && index < (int)cdata->_lod._switch_vector.size(), 0.0);
00134   return cdata->_lod._switch_vector[index].get_in();
00135 }
00136 
00137 ////////////////////////////////////////////////////////////////////
00138 //     Function: LODNode::get_out
00139 //       Access: Published
00140 //  Description: Returns the "out" distance of the indicated switch
00141 //               range.  This should be smaller than the "in" distance
00142 //               of the same range.
00143 ////////////////////////////////////////////////////////////////////
00144 INLINE float LODNode::
00145 get_out(int index) const {
00146   CDReader cdata(_cycler);
00147   nassertr(index >= 0 && index < (int)cdata->_lod._switch_vector.size(), 0.0);
00148   return cdata->_lod._switch_vector[index].get_out();
00149 }
00150 
00151 ////////////////////////////////////////////////////////////////////
00152 //     Function: LODNode::set_center
00153 //       Access: Published
00154 //  Description: Specifies the center of the LOD.  This is the point
00155 //               that is compared to the camera (in camera space) to
00156 //               determine the particular LOD that should be chosen.
00157 ////////////////////////////////////////////////////////////////////
00158 INLINE void LODNode::
00159 set_center(const LPoint3f &center) {
00160   CDWriter cdata(_cycler);
00161   cdata->_lod._center = center;
00162 }
00163 
00164 ////////////////////////////////////////////////////////////////////
00165 //     Function: LODNode::get_center
00166 //       Access: Published
00167 //  Description: Returns the center of the LOD.  This is the point
00168 //               that is compared to the camera (in camera space) to
00169 //               determine the particular LOD that should be chosen.
00170 ////////////////////////////////////////////////////////////////////
00171 INLINE const LPoint3f &LODNode::
00172 get_center() const {
00173   CDReader cdata(_cycler);
00174   return cdata->_lod._center;
00175 }

Generated on Fri May 2 00:41:51 2003 for Panda by doxygen1.3