00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef ROPENODE_H
00020 #define ROPENODE_H
00021
00022 #include "pandabase.h"
00023 #include "nurbsCurveEvaluator.h"
00024 #include "pandaNode.h"
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 class EXPCL_PANDA RopeNode : public PandaNode {
00040 PUBLISHED:
00041 RopeNode(const string &name);
00042
00043 protected:
00044 RopeNode(const RopeNode ©);
00045 public:
00046 virtual void output(ostream &out) const;
00047 virtual void write(ostream &out, int indent_level = 0) const;
00048
00049 virtual PandaNode *make_copy() const;
00050
00051 virtual bool safe_to_transform() const;
00052 virtual bool has_cull_callback() const;
00053 virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
00054
00055 PUBLISHED:
00056 enum RenderMode {
00057
00058 RM_thread,
00059
00060
00061
00062 RM_billboard
00063 };
00064
00065 enum UVMode {
00066
00067 UV_none,
00068
00069
00070
00071 UV_parametric,
00072
00073
00074
00075
00076 UV_distance,
00077
00078
00079
00080
00081
00082
00083 UV_distance2,
00084 };
00085
00086 INLINE void set_curve(NurbsCurveEvaluator *curve);
00087 INLINE NurbsCurveEvaluator *get_curve() const;
00088
00089 INLINE void set_render_mode(RenderMode render_mode);
00090 INLINE RenderMode get_render_mode() const;
00091
00092 INLINE void set_uv_mode(UVMode uv_mode);
00093 INLINE UVMode get_uv_mode() const;
00094
00095 INLINE void set_uv_scale(const LVecBase2f &uv_scale);
00096 INLINE const LVecBase2f &get_uv_scale() const;
00097
00098 INLINE void set_num_segs(int num_segs);
00099 INLINE int get_num_segs() const;
00100
00101 INLINE void set_thickness(float thickness);
00102 INLINE float get_thickness() const;
00103
00104 void reset_bound(const NodePath &rel_to);
00105
00106 protected:
00107 virtual BoundingVolume *recompute_internal_bound();
00108
00109 private:
00110 BoundingVolume *do_recompute_bound(const NodePath &rel_to);
00111 void render_thread(CullTraverser *trav, CullTraverserData &data,
00112 NurbsCurveResult *result);
00113 void render_billboard(CullTraverser *trav, CullTraverserData &data,
00114 NurbsCurveResult *result);
00115
00116 private:
00117
00118 class EXPCL_PANDA CData : public CycleData {
00119 public:
00120 INLINE CData();
00121 INLINE CData(const CData ©);
00122 virtual CycleData *make_copy() const;
00123 virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
00124 virtual void fillin(DatagramIterator &scan, BamReader *manager);
00125
00126 PT(NurbsCurveEvaluator) _curve;
00127 RenderMode _render_mode;
00128 UVMode _uv_mode;
00129 LVecBase2f _uv_scale;
00130 int _num_segs;
00131 float _thickness;
00132 };
00133
00134 PipelineCycler<CData> _cycler;
00135 typedef CycleDataReader<CData> CDReader;
00136 typedef CycleDataWriter<CData> CDWriter;
00137
00138 public:
00139 static void register_with_read_factory();
00140 virtual void write_datagram(BamWriter *manager, Datagram &dg);
00141
00142 protected:
00143 static TypedWritable *make_from_bam(const FactoryParams ¶ms);
00144 void fillin(DatagramIterator &scan, BamReader *manager);
00145
00146 public:
00147 static TypeHandle get_class_type() {
00148 return _type_handle;
00149 }
00150 static void init_type() {
00151 PandaNode::init_type();
00152 register_type(_type_handle, "RopeNode",
00153 PandaNode::get_class_type());
00154 }
00155 virtual TypeHandle get_type() const {
00156 return get_class_type();
00157 }
00158 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00159
00160 private:
00161 static TypeHandle _type_handle;
00162 };
00163
00164 #include "ropeNode.I"
00165
00166 #endif