00001 // Filename: nurbsCurveEvaluator.I 00002 // Created by: drose (05Dec02) 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: NurbsCurveEvaluator::set_order 00022 // Access: Published 00023 // Description: Sets the order of the curve. This resets the knot 00024 // vector to the default knot vector for the number of 00025 // vertices. 00026 // 00027 // The order must be 1, 2, 3, or 4, and the value is one 00028 // more than the degree of the curve. 00029 //////////////////////////////////////////////////////////////////// 00030 INLINE void NurbsCurveEvaluator:: 00031 set_order(int order) { 00032 _order = order; 00033 _knots_dirty = true; 00034 _basis_dirty = true; 00035 } 00036 00037 //////////////////////////////////////////////////////////////////// 00038 // Function: NurbsCurveEvaluator::get_order 00039 // Access: Published 00040 // Description: Returns the order of the curve as set by a previous 00041 // call to set_order(). 00042 //////////////////////////////////////////////////////////////////// 00043 INLINE int NurbsCurveEvaluator:: 00044 get_order() const { 00045 return _order; 00046 } 00047 00048 //////////////////////////////////////////////////////////////////// 00049 // Function: NurbsCurveEvaluator::get_num_vertices 00050 // Access: Published 00051 // Description: Returns the number of control vertices in the curve. 00052 // This is the number passed to the last call to 00053 // reset(). 00054 //////////////////////////////////////////////////////////////////// 00055 INLINE int NurbsCurveEvaluator:: 00056 get_num_vertices() const { 00057 return (int)_vertices.size(); 00058 } 00059 00060 //////////////////////////////////////////////////////////////////// 00061 // Function: NurbsCurveEvaluator::set_vertex 00062 // Access: Published 00063 // Description: Sets the nth control vertex of the curve. 00064 //////////////////////////////////////////////////////////////////// 00065 INLINE void NurbsCurveEvaluator:: 00066 set_vertex(int i, const LVecBase4f &vertex) { 00067 nassertv(i >= 0 && i < (int)_vertices.size()); 00068 _vertices[i].set_vertex(vertex); 00069 } 00070 00071 //////////////////////////////////////////////////////////////////// 00072 // Function: NurbsCurveEvaluator::set_vertex 00073 // Access: Published 00074 // Description: Sets the nth control vertex of the curve. 00075 //////////////////////////////////////////////////////////////////// 00076 INLINE void NurbsCurveEvaluator:: 00077 set_vertex(int i, const LVecBase3f &vertex, float weight) { 00078 nassertv(i >= 0 && i < (int)_vertices.size()); 00079 _vertices[i].set_vertex(LVecBase4f(vertex[0] * weight, vertex[1] * weight, vertex[2] * weight, weight)); 00080 } 00081 00082 //////////////////////////////////////////////////////////////////// 00083 // Function: NurbsCurveEvaluator::get_vertex 00084 // Access: Published 00085 // Description: Returns the nth control vertex of the curve, relative 00086 // to its indicated coordinate space. 00087 //////////////////////////////////////////////////////////////////// 00088 INLINE const LVecBase4f &NurbsCurveEvaluator:: 00089 get_vertex(int i) const { 00090 nassertr(i >= 0 && i < (int)_vertices.size(), LVecBase4f::zero()); 00091 return _vertices[i].get_vertex(); 00092 } 00093 00094 //////////////////////////////////////////////////////////////////// 00095 // Function: NurbsCurveEvaluator::set_vertex_space 00096 // Access: Published 00097 // Description: Sets the coordinate space of the nth control vertex. 00098 // If this is not specified, or is set to an empty 00099 // NodePath, the nth control vertex is deemed to be in 00100 // the coordinate space passed to evaluate(). 00101 // 00102 // This specifies the space as a fixed NodePath, which 00103 // is always the same NodePath. Also see setting the 00104 // space as a path string, which can specify a different 00105 // NodePath for different instances of the curve. 00106 //////////////////////////////////////////////////////////////////// 00107 INLINE void NurbsCurveEvaluator:: 00108 set_vertex_space(int i, const NodePath &space) { 00109 nassertv(i >= 0 && i < (int)_vertices.size()); 00110 _vertices[i].set_space(space); 00111 } 00112 00113 //////////////////////////////////////////////////////////////////// 00114 // Function: NurbsCurveEvaluator::set_vertex_space 00115 // Access: Published 00116 // Description: Sets the coordinate space of the nth control vertex. 00117 // If this is not specified, or is set to an empty 00118 // string, the nth control vertex is deemed to be in 00119 // the coordinate space passed to evaluate(). 00120 // 00121 // This specifies the space as a string, which describes 00122 // the path to find the node relative to the rel_to 00123 // NodePath when the curve is evaluated. 00124 //////////////////////////////////////////////////////////////////// 00125 INLINE void NurbsCurveEvaluator:: 00126 set_vertex_space(int i, const string &space) { 00127 nassertv(i >= 0 && i < (int)_vertices.size()); 00128 _vertices[i].set_space(space); 00129 } 00130 00131 //////////////////////////////////////////////////////////////////// 00132 // Function: NurbsCurveEvaluator::get_num_knots 00133 // Access: Published 00134 // Description: Returns the number of knot values in the curve. This 00135 // is based on the number of vertices and the order. 00136 //////////////////////////////////////////////////////////////////// 00137 INLINE int NurbsCurveEvaluator:: 00138 get_num_knots() const { 00139 return (int)_vertices.size() + _order; 00140 }