Panda3D
|
00001 // Filename: nurbsSurfaceResult.h 00002 // Created by: drose (10Oct03) 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 NURBSSURFACERESULT_H 00016 #define NURBSSURFACERESULT_H 00017 00018 #include "pandabase.h" 00019 #include "referenceCount.h" 00020 #include "nurbsBasisVector.h" 00021 00022 class NurbsVertex; 00023 00024 //////////////////////////////////////////////////////////////////// 00025 // Class : NurbsSurfaceResult 00026 // Description : The result of a NurbsSurfaceEvaluator. This object 00027 // represents a surface in a particular coordinate space. 00028 // It can return the point and/or normal to the surface 00029 // at any point. 00030 //////////////////////////////////////////////////////////////////// 00031 class EXPCL_PANDA_PARAMETRICS NurbsSurfaceResult : public ReferenceCount { 00032 public: 00033 NurbsSurfaceResult(const NurbsBasisVector &u_basis, 00034 const NurbsBasisVector &v_basis, 00035 const LVecBase4 vecs[], const NurbsVertex *verts, 00036 int num_u_vertices, int num_v_vertices); 00037 00038 PUBLISHED: 00039 INLINE ~NurbsSurfaceResult(); 00040 00041 INLINE PN_stdfloat get_start_u() const; 00042 INLINE PN_stdfloat get_end_u() const; 00043 00044 INLINE PN_stdfloat get_start_v() const; 00045 INLINE PN_stdfloat get_end_v() const; 00046 00047 INLINE bool eval_point(PN_stdfloat u, PN_stdfloat v, LVecBase3 &point); 00048 INLINE bool eval_normal(PN_stdfloat u, PN_stdfloat v, LVecBase3 &normal); 00049 INLINE PN_stdfloat eval_extended_point(PN_stdfloat u, PN_stdfloat v, int d); 00050 INLINE bool eval_extended_points(PN_stdfloat u, PN_stdfloat v, int d, 00051 PN_stdfloat result[], int num_values); 00052 00053 INLINE int get_num_u_segments() const; 00054 INLINE int get_num_v_segments() const; 00055 void eval_segment_point(int ui, int vi, PN_stdfloat u, PN_stdfloat v, LVecBase3 &point) const; 00056 void eval_segment_normal(int ui, int vi, PN_stdfloat u, PN_stdfloat v, LVecBase3 &normal) const; 00057 PN_stdfloat eval_segment_extended_point(int ui, int vi, PN_stdfloat u, PN_stdfloat v, int d) const; 00058 void eval_segment_extended_points(int ui, int vi, PN_stdfloat u, PN_stdfloat v, int d, 00059 PN_stdfloat result[], int num_values) const; 00060 INLINE PN_stdfloat get_segment_u(int ui, PN_stdfloat u) const; 00061 INLINE PN_stdfloat get_segment_v(int vi, PN_stdfloat v) const; 00062 00063 private: 00064 INLINE int verti(int ui, int vi) const; 00065 INLINE int segi(int ui, int vi) const; 00066 00067 int find_u_segment(PN_stdfloat u); 00068 int r_find_u_segment(PN_stdfloat u, int top, int bot) const; 00069 int find_v_segment(PN_stdfloat v); 00070 int r_find_v_segment(PN_stdfloat v, int top, int bot) const; 00071 00072 NurbsBasisVector _u_basis; 00073 NurbsBasisVector _v_basis; 00074 const NurbsVertex *_verts; 00075 int _num_u_vertices; 00076 int _num_v_vertices; 00077 00078 // We pre-compose the basis matrix and the geometry vectors, so we 00079 // have these handy for evaluation. There is one entry in the 00080 // _composed for each entry in u_basis._segments * 00081 // v_basis._segments. 00082 class ComposedMats { 00083 public: 00084 LMatrix4 _x, _y, _z, _w; 00085 }; 00086 typedef epvector<ComposedMats> ComposedGeom; 00087 ComposedGeom _composed; 00088 00089 00090 int _last_u_segment; 00091 PN_stdfloat _last_u_from; 00092 PN_stdfloat _last_u_to; 00093 int _last_v_segment; 00094 PN_stdfloat _last_v_from; 00095 PN_stdfloat _last_v_to; 00096 }; 00097 00098 #include "nurbsSurfaceResult.I" 00099 00100 #endif 00101