Panda3D
Loading...
Searching...
No Matches
piecewiseCurve.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file piecewiseCurve.h
10 * @author drose
11 * @date 2001-03-04
12 */
13
14#ifndef PIECEWISECURVE_H
15#define PIECEWISECURVE_H
16
17#include "pandabase.h"
18
19#include "parametricCurve.h"
20#include "pointerTo.h"
21
22/**
23 * A PiecewiseCurve is a curve made up of several curve segments, connected in
24 * a head-to-tail fashion. The length of each curve segment in parametric
25 * space is definable.
26 */
27class EXPCL_PANDA_PARAMETRICS PiecewiseCurve : public ParametricCurve {
28PUBLISHED:
31
32public:
33 // These functions are all inherited from ParametricCurve, and need not be
34 // re-published.
35 virtual bool is_valid() const;
36 virtual PN_stdfloat get_max_t() const;
37
38 virtual bool get_point(PN_stdfloat t, LVecBase3 &point) const;
39 virtual bool get_tangent(PN_stdfloat t, LVecBase3 &tangent) const;
40 virtual bool get_pt(PN_stdfloat t, LVecBase3 &point, LVecBase3 &tangent) const;
41 virtual bool get_2ndtangent(PN_stdfloat t, LVecBase3 &tangent2) const;
42
43 virtual bool adjust_point(PN_stdfloat t, PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz);
44 virtual bool adjust_tangent(PN_stdfloat t, PN_stdfloat tx, PN_stdfloat ty, PN_stdfloat tz);
45 virtual bool adjust_pt(PN_stdfloat t,
46 PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz,
47 PN_stdfloat tx, PN_stdfloat ty, PN_stdfloat tz);
48
49public:
50 int get_num_segs() const;
51
52 ParametricCurve *get_curveseg(int ti);
53 bool insert_curveseg(int ti, ParametricCurve *seg, PN_stdfloat tlength);
54
55 bool remove_curveseg(int ti);
56 void remove_all_curvesegs();
57
58 PN_stdfloat get_tlength(int ti) const;
59 PN_stdfloat get_tstart(int ti) const;
60 PN_stdfloat get_tend(int ti) const;
61 bool set_tlength(int ti, PN_stdfloat tlength);
62
63 void make_nurbs(int order, int num_cvs,
64 const PN_stdfloat knots[], const LVecBase4 cvs[]);
65
66 virtual bool get_bezier_segs(BezierSegs &bz_segs) const;
67
68 virtual bool
69 rebuild_curveseg(int rtype0, PN_stdfloat t0, const LVecBase4 &v0,
70 int rtype1, PN_stdfloat t1, const LVecBase4 &v1,
71 int rtype2, PN_stdfloat t2, const LVecBase4 &v2,
72 int rtype3, PN_stdfloat t3, const LVecBase4 &v3);
73
74protected:
75 bool find_curve(const ParametricCurve *&curve, PN_stdfloat &t) const;
76 PN_stdfloat current_seg_range(PN_stdfloat t) const;
77
78 class Curveseg {
79 public:
80 Curveseg() {}
81 Curveseg(ParametricCurve *c, PN_stdfloat t) : _curve(c), _tend(t) {}
82
83 PT(ParametricCurve) _curve;
84 PN_stdfloat _tend;
85 };
86
88 int _last_ti;
89
90
91// TypedWritable stuff
92protected:
93 virtual void write_datagram(BamWriter *manager, Datagram &me);
94 void fillin(DatagramIterator &scan, BamReader *manager);
96 BamReader *manager);
97
98public:
99 static TypeHandle get_class_type() {
100 return _type_handle;
101 }
102 static void init_type() {
103 ParametricCurve::init_type();
104 register_type(_type_handle, "PiecewiseCurve",
105 ParametricCurve::get_class_type());
106 }
107 virtual TypeHandle get_type() const {
108 return get_class_type();
109 }
110 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
111
112private:
113 static TypeHandle _type_handle;
114};
115
116
117#endif
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition bamWriter.h:63
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
A virtual base class for parametric curves.
virtual bool adjust_pt(PN_stdfloat t, PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat tx, PN_stdfloat ty, PN_stdfloat tz)
Recomputes the curve such that it passes through the point (px, py, pz) with the tangent (tx,...
virtual bool adjust_tangent(PN_stdfloat t, PN_stdfloat tx, PN_stdfloat ty, PN_stdfloat tz)
Recomputes the curve such that it has the tangent (tx, ty, tz) at time t, but keeps the same position...
virtual bool get_bezier_segs(BezierSegs &) const
Fills up the indicated vector with a list of BezierSeg structs that describe the curve.
virtual bool adjust_point(PN_stdfloat t, PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz)
Recomputes the curve such that it passes through the point (px, py, pz) at time t,...
virtual PN_stdfloat get_max_t() const
Returns the upper bound of t for the entire curve.
virtual bool is_valid() const
Returns true if the curve is defined.
A PiecewiseCurve is a curve made up of several curve segments, connected in a head-to-tail fashion.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
Base class for objects that can be written to and read from Bam files.
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
This is our own Panda specialization on the default STL list.
Definition plist.h:35
This is our own Panda specialization on the default STL vector.
Definition pvector.h:42
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...