00001 // Filename: geomNode.I 00002 // Created by: drose (23Feb02) 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 //////////////////////////////////////////////////////////////////// 00021 // Function: GeomNode::GeomEntry::Constructor 00022 // Access: Public 00023 // Description: 00024 //////////////////////////////////////////////////////////////////// 00025 INLINE GeomNode::GeomEntry:: 00026 GeomEntry(Geom *geom, const RenderState *state) : 00027 _geom(geom), 00028 _state(state) 00029 { 00030 } 00031 00032 //////////////////////////////////////////////////////////////////// 00033 // Function: GeomNode::CData::Constructor 00034 // Access: Public 00035 // Description: 00036 //////////////////////////////////////////////////////////////////// 00037 INLINE GeomNode::CData:: 00038 CData() { 00039 } 00040 00041 //////////////////////////////////////////////////////////////////// 00042 // Function: GeomNode::get_num_geoms 00043 // Access: Public 00044 // Description: Returns the number of geoms in the node. 00045 //////////////////////////////////////////////////////////////////// 00046 INLINE int GeomNode:: 00047 get_num_geoms() const { 00048 CDReader cdata(_cycler); 00049 return cdata->_geoms.size(); 00050 } 00051 00052 //////////////////////////////////////////////////////////////////// 00053 // Function: GeomNode::get_geom 00054 // Access: Public 00055 // Description: Returns the nth geom of the node. 00056 //////////////////////////////////////////////////////////////////// 00057 INLINE Geom *GeomNode:: 00058 get_geom(int n) const { 00059 CDReader cdata(_cycler); 00060 nassertr(n >= 0 && n < (int)cdata->_geoms.size(), NULL); 00061 return cdata->_geoms[n]._geom; 00062 } 00063 00064 //////////////////////////////////////////////////////////////////// 00065 // Function: GeomNode::get_geom_state 00066 // Access: Public 00067 // Description: Returns the RenderState associated with the nth geom 00068 // of the node. This is just the RenderState directly 00069 // associated with the Geom; the actual state in which 00070 // the Geom is rendered will also be affected by 00071 // RenderStates that appear on the scene graph in nodes 00072 // above this GeomNode. 00073 //////////////////////////////////////////////////////////////////// 00074 INLINE const RenderState *GeomNode:: 00075 get_geom_state(int n) const { 00076 CDReader cdata(_cycler); 00077 nassertr(n >= 0 && n < (int)cdata->_geoms.size(), NULL); 00078 return cdata->_geoms[n]._state; 00079 } 00080 00081 //////////////////////////////////////////////////////////////////// 00082 // Function: GeomNode::set_geom_state 00083 // Access: Public 00084 // Description: Changes the RenderState associated with the nth geom 00085 // of the node. This is just the RenderState directly 00086 // associated with the Geom; the actual state in which 00087 // the Geom is rendered will also be affected by 00088 // RenderStates that appear on the scene graph in nodes 00089 // above this GeomNode. 00090 //////////////////////////////////////////////////////////////////// 00091 INLINE void GeomNode:: 00092 set_geom_state(int n, const RenderState *state) { 00093 CDWriter cdata(_cycler); 00094 nassertv(n >= 0 && n < (int)cdata->_geoms.size()); 00095 cdata->_geoms[n]._state = state; 00096 } 00097 00098 //////////////////////////////////////////////////////////////////// 00099 // Function: GeomNode::add_geom 00100 // Access: Published 00101 // Description: Adds a new Geom to the node. The geom is given the 00102 // indicated state (which may be 00103 // RenderState::make_empty(), to completely inherit its 00104 // state from the scene graph). 00105 // 00106 // The return value is the index number of the new Geom. 00107 //////////////////////////////////////////////////////////////////// 00108 INLINE int GeomNode:: 00109 add_geom(Geom *geom, const RenderState *state) { 00110 nassertr(geom != (Geom *)NULL, -1); 00111 nassertr(state != (RenderState *)NULL, -1); 00112 CDWriter cdata(_cycler); 00113 00114 cdata->_geoms.push_back(GeomEntry(geom, state)); 00115 mark_bound_stale(); 00116 return cdata->_geoms.size() - 1; 00117 } 00118 00119 //////////////////////////////////////////////////////////////////// 00120 // Function: GeomNode::remove_geom 00121 // Access: Published 00122 // Description: Removes the nth geom from the node. 00123 //////////////////////////////////////////////////////////////////// 00124 INLINE void GeomNode:: 00125 remove_geom(int n) { 00126 CDWriter cdata(_cycler); 00127 nassertv(n >= 0 && n < (int)cdata->_geoms.size()); 00128 00129 cdata->_geoms.erase(cdata->_geoms.begin() + n); 00130 mark_bound_stale(); 00131 } 00132 00133 //////////////////////////////////////////////////////////////////// 00134 // Function: GeomNode::remove_all_geoms 00135 // Access: Published 00136 // Description: Removes all the geoms from the node at once. 00137 //////////////////////////////////////////////////////////////////// 00138 INLINE void GeomNode:: 00139 remove_all_geoms() { 00140 CDWriter cdata(_cycler); 00141 cdata->_geoms.clear(); 00142 mark_bound_stale(); 00143 }