00001 // Filename: parametricCurveDrawer.h 00002 // Created by: drose (14Mar97) 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 #ifndef PARAMETRICCURVEDRAWER_H 00020 #define PARAMETRICCURVEDRAWER_H 00021 00022 #include "parametricCurveCollection.h" 00023 00024 #include "lineSegs.h" 00025 #include "pandaNode.h" 00026 00027 #include "typedObject.h" 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Class : ParametricCurveDrawer 00031 // Description : Draws a 3-d parametric curve in the scene by creating 00032 // a series of line segments to approximate the curve. 00033 //////////////////////////////////////////////////////////////////// 00034 class EXPCL_PANDA ParametricCurveDrawer : public TypedObject { 00035 PUBLISHED: 00036 ParametricCurveDrawer(); 00037 virtual ~ParametricCurveDrawer(); 00038 00039 void set_curve(ParametricCurve *curve); 00040 void set_curves(ParametricCurveCollection *curves); 00041 void clear_curves(); 00042 ParametricCurveCollection *get_curves(); 00043 00044 GeomNode *get_geom_node(); 00045 PT(GeomNode) detach_geom_node(); 00046 00047 void set_num_segs(float num_segs); 00048 float get_num_segs() const; 00049 00050 void set_num_ticks(float num_ticks); 00051 float get_num_ticks() const; 00052 00053 void set_color(float r, float g, float b); 00054 void set_tick_color(float r, float g, float b); 00055 00056 void set_frame_accurate(bool frame_accurate); 00057 bool get_frame_accurate() const; 00058 00059 virtual bool draw(); 00060 void hide(); 00061 00062 void set_tick_scale(float scale); 00063 float get_tick_scale() const; 00064 00065 public: 00066 INLINE float get_max_t() const; 00067 INLINE void redraw(); 00068 00069 private: 00070 static void get_tick_marks(const LVecBase3f &tangent, LVecBase3f &t1, LVecBase3f &t2); 00071 00072 protected: 00073 PT(GeomNode) _geom_node; 00074 PT(ParametricCurveCollection) _curves; 00075 bool _frame_accurate; 00076 00077 private: 00078 float _num_segs; 00079 LineSegs _lines, _ticks; 00080 bool _drawn; 00081 float _num_ticks; 00082 float _tick_scale; 00083 00084 public: 00085 static TypeHandle get_class_type() { 00086 return _type_handle; 00087 } 00088 static void init_type() { 00089 register_type(_type_handle, "ParametricCurveDrawer", 00090 TypedObject::get_class_type()); 00091 } 00092 virtual TypeHandle get_type() const { 00093 return get_class_type(); 00094 } 00095 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00096 00097 private: 00098 static TypeHandle _type_handle; 00099 }; 00100 00101 #include "parametricCurveDrawer.I" 00102 00103 #endif