Panda3D
|
00001 // Filename: nurbsCurveEvaluator.h 00002 // Created by: drose (03Dec02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef NURBSCURVEEVALUATOR_H 00016 #define NURBSCURVEEVALUATOR_H 00017 00018 #include "pandabase.h" 00019 #include "nurbsBasisVector.h" 00020 #include "nurbsCurveResult.h" 00021 #include "nurbsVertex.h" 00022 #include "pointerTo.h" 00023 #include "vector_float.h" 00024 #include "pvector.h" 00025 #include "nodePath.h" 00026 #include "referenceCount.h" 00027 #include "luse.h" 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Class : NurbsCurveEvaluator 00031 // Description : This class is an abstraction for evaluating NURBS 00032 // curves. It accepts an array of vertices, each of 00033 // which may be in a different coordinate space (as 00034 // defined by a NodePath), as well as an optional knot 00035 // vector. 00036 // 00037 // This is not related to NurbsCurve, CubicCurveseg or 00038 // any of the ParametricCurve-derived objects in this 00039 // module. It is a completely parallel implementation 00040 // of NURBS curves, and will probably eventually replace 00041 // the whole ParametricCurve class hierarchy. 00042 //////////////////////////////////////////////////////////////////// 00043 class EXPCL_PANDA_PARAMETRICS NurbsCurveEvaluator : public ReferenceCount { 00044 PUBLISHED: 00045 NurbsCurveEvaluator(); 00046 ~NurbsCurveEvaluator(); 00047 00048 INLINE void set_order(int order); 00049 INLINE int get_order() const; 00050 00051 void reset(int num_vertices); 00052 00053 INLINE int get_num_vertices() const; 00054 INLINE void set_vertex(int i, const LVecBase4f &vertex); 00055 INLINE void set_vertex(int i, const LVecBase3f &vertex, float weight = 1.0); 00056 INLINE const LVecBase4f &get_vertex(int i) const; 00057 INLINE LVecBase4f get_vertex(int i, const NodePath &rel_to) const; 00058 MAKE_SEQ(get_vertices, get_num_vertices, get_vertex); 00059 00060 INLINE void set_vertex_space(int i, const NodePath &space); 00061 INLINE void set_vertex_space(int i, const string &space); 00062 NodePath get_vertex_space(int i, const NodePath &rel_to) const; 00063 00064 INLINE void set_extended_vertex(int i, int d, float value); 00065 INLINE float get_extended_vertex(int i, int d) const; 00066 void set_extended_vertices(int i, int d, 00067 const float values[], int num_values); 00068 00069 INLINE int get_num_knots() const; 00070 void set_knot(int i, float knot); 00071 float get_knot(int i) const; 00072 MAKE_SEQ(get_knots, get_num_knots, get_knot); 00073 void normalize_knots(); 00074 00075 INLINE int get_num_segments() const; 00076 00077 PT(NurbsCurveResult) evaluate(const NodePath &rel_to = NodePath()) const; 00078 PT(NurbsCurveResult) evaluate(const NodePath &rel_to, 00079 const LMatrix4f &mat) const; 00080 00081 void output(ostream &out) const; 00082 00083 public: 00084 void get_vertices(pvector<LVecBase4f> &verts, const NodePath &rel_to) const; 00085 void get_vertices(pvector<LPoint3f> &verts, const NodePath &rel_to) const; 00086 00087 private: 00088 void recompute_knots(); 00089 void recompute_basis(); 00090 00091 int _order; 00092 00093 typedef pvector<NurbsVertex> Vertices; 00094 Vertices _vertices; 00095 00096 bool _knots_dirty; 00097 typedef vector_float Knots; 00098 Knots _knots; 00099 00100 bool _basis_dirty; 00101 NurbsBasisVector _basis; 00102 }; 00103 00104 INLINE ostream &operator << (ostream &out, const NurbsCurveEvaluator &n); 00105 00106 #include "nurbsCurveEvaluator.I" 00107 00108 #endif 00109