00001 // Filename: ropeNode.I 00002 // Created by: drose (04Dec02) 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: RopeNode::CData::Constructor 00022 // Access: Public 00023 // Description: 00024 //////////////////////////////////////////////////////////////////// 00025 INLINE RopeNode::CData:: 00026 CData() { 00027 _curve = new NurbsCurveEvaluator; 00028 _render_mode = RopeNode::RM_thread; 00029 _uv_mode = RopeNode::UV_none; 00030 _uv_scale.set(1.0f, 1.0f); 00031 _num_segs = 10; 00032 _thickness = 1.0f; 00033 } 00034 00035 //////////////////////////////////////////////////////////////////// 00036 // Function: RopeNode::CData::Copy Constructor 00037 // Access: Public 00038 // Description: 00039 //////////////////////////////////////////////////////////////////// 00040 INLINE RopeNode::CData:: 00041 CData(const RopeNode::CData ©) : 00042 _curve(copy._curve), 00043 _render_mode(copy._render_mode), 00044 _uv_mode(copy._uv_mode), 00045 _uv_scale(copy._uv_scale), 00046 _num_segs(copy._num_segs), 00047 _thickness(copy._thickness) 00048 { 00049 } 00050 00051 //////////////////////////////////////////////////////////////////// 00052 // Function: set_curve 00053 // Access: Public 00054 // Description: Sets the particular curve represented by the 00055 // RopeNode. 00056 //////////////////////////////////////////////////////////////////// 00057 INLINE void RopeNode:: 00058 set_curve(NurbsCurveEvaluator *curve) { 00059 CDWriter cdata(_cycler); 00060 cdata->_curve = curve; 00061 } 00062 00063 //////////////////////////////////////////////////////////////////// 00064 // Function: get_curve 00065 // Access: Public 00066 // Description: Returns the curve represented by the RopeNode. 00067 //////////////////////////////////////////////////////////////////// 00068 INLINE NurbsCurveEvaluator *RopeNode:: 00069 get_curve() const { 00070 CDReader cdata(_cycler); 00071 return cdata->_curve; 00072 } 00073 00074 //////////////////////////////////////////////////////////////////// 00075 // Function: set_render_mode 00076 // Access: Public 00077 // Description: Specifies the method used to render the rope. The 00078 // simplest is RM_thread, which just draws a one-pixel 00079 // line segment. 00080 //////////////////////////////////////////////////////////////////// 00081 INLINE void RopeNode:: 00082 set_render_mode(RopeNode::RenderMode render_mode) { 00083 CDWriter cdata(_cycler); 00084 cdata->_render_mode = render_mode; 00085 } 00086 00087 //////////////////////////////////////////////////////////////////// 00088 // Function: get_render_mode 00089 // Access: Public 00090 // Description: Returns the method used to render the rope. See 00091 // set_render_mode(). 00092 //////////////////////////////////////////////////////////////////// 00093 INLINE RopeNode::RenderMode RopeNode:: 00094 get_render_mode() const { 00095 CDReader cdata(_cycler); 00096 return cdata->_render_mode; 00097 } 00098 00099 //////////////////////////////////////////////////////////////////// 00100 // Function: set_uv_mode 00101 // Access: Public 00102 // Description: Specifies the algorithm to use to generate UV's for 00103 // the rope. 00104 //////////////////////////////////////////////////////////////////// 00105 INLINE void RopeNode:: 00106 set_uv_mode(RopeNode::UVMode uv_mode) { 00107 CDWriter cdata(_cycler); 00108 cdata->_uv_mode = uv_mode; 00109 } 00110 00111 //////////////////////////////////////////////////////////////////// 00112 // Function: get_uv_mode 00113 // Access: Public 00114 // Description: Returns the algorithm to use to generate UV's for the 00115 // rope. 00116 //////////////////////////////////////////////////////////////////// 00117 INLINE RopeNode::UVMode RopeNode:: 00118 get_uv_mode() const { 00119 CDReader cdata(_cycler); 00120 return cdata->_uv_mode; 00121 } 00122 00123 //////////////////////////////////////////////////////////////////// 00124 // Function: set_uv_scale 00125 // Access: Public 00126 // Description: Specifies an additional scaling factor to apply to 00127 // generated UV's for the rope. 00128 //////////////////////////////////////////////////////////////////// 00129 INLINE void RopeNode:: 00130 set_uv_scale(const LVecBase2f &uv_scale) { 00131 CDWriter cdata(_cycler); 00132 cdata->_uv_scale = uv_scale; 00133 } 00134 00135 //////////////////////////////////////////////////////////////////// 00136 // Function: get_uv_scale 00137 // Access: Public 00138 // Description: Returns the scaling factor to apply to generated UV's 00139 // for the rope. 00140 //////////////////////////////////////////////////////////////////// 00141 INLINE const LVecBase2f &RopeNode:: 00142 get_uv_scale() const { 00143 CDReader cdata(_cycler); 00144 return cdata->_uv_scale; 00145 } 00146 00147 //////////////////////////////////////////////////////////////////// 00148 // Function: set_num_segs 00149 // Access: Public 00150 // Description: Specifies the number of segments per cubic segment 00151 // (that is, per unique knot value) to draw in a fixed 00152 // uniform tesselation of the curve. 00153 //////////////////////////////////////////////////////////////////// 00154 INLINE void RopeNode:: 00155 set_num_segs(int num_segs) { 00156 nassertv(num_segs >= 0); 00157 CDWriter cdata(_cycler); 00158 cdata->_num_segs = num_segs; 00159 } 00160 00161 //////////////////////////////////////////////////////////////////// 00162 // Function: get_num_segs 00163 // Access: Public 00164 // Description: Returns the number of segments per cubic segment to 00165 // draw. See set_num_segs(). 00166 //////////////////////////////////////////////////////////////////// 00167 INLINE int RopeNode:: 00168 get_num_segs() const { 00169 CDReader cdata(_cycler); 00170 return cdata->_num_segs; 00171 } 00172 00173 //////////////////////////////////////////////////////////////////// 00174 // Function: set_thickness 00175 // Access: Public 00176 // Description: Specifies the thickness of the rope, in pixels or in 00177 // spatial units, depending on the render mode. See 00178 // set_render_mode(). 00179 //////////////////////////////////////////////////////////////////// 00180 INLINE void RopeNode:: 00181 set_thickness(float thickness) { 00182 nassertv(thickness >= 0); 00183 CDWriter cdata(_cycler); 00184 cdata->_thickness = thickness; 00185 } 00186 00187 //////////////////////////////////////////////////////////////////// 00188 // Function: get_thickness 00189 // Access: Public 00190 // Description: Returns the thickness of the rope. See 00191 // set_thickness(). 00192 //////////////////////////////////////////////////////////////////// 00193 INLINE float RopeNode:: 00194 get_thickness() const { 00195 CDReader cdata(_cycler); 00196 return cdata->_thickness; 00197 }