]> icculus.org git repositories - taylor/freespace2.git/blob - include/spline.h
Initial revision
[taylor/freespace2.git] / include / spline.h
1 /*
2  * $Logfile: /Freespace2/code/Math/spline.h $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  *
8  * $Log$
9  * Revision 1.1  2002/05/03 03:28:12  root
10  * Initial revision
11  *
12  * 
13  * 3     7/08/99 10:53a Dave
14  * New multiplayer interpolation scheme. Not 100% done yet, but still
15  * better than the old way.
16  * 
17  * 2     7/06/99 4:24p Dave
18  * Mid-level checkin. Starting on some potentially cool multiplayer
19  * smoothness crap.
20  *  
21  *
22  * $NoKeywords: $
23  */
24
25 #ifndef __FS2_SPLINE_HEADER_FILE
26 #define __FS2_SPLINE_HEADER_FILE
27
28 #include "vecmat.h"
29
30 // -------------------------------------------------------------------------------------------------
31 // SPLINE DEFINES/VARS
32 //
33
34 struct color;
35
36 // max bezier degree - note the # of points directly corresponds to the degree (degree == n_points - 1).
37 // more points means more expensive!
38 #define MAX_BEZ_PTS                     3
39
40 // bezier class. whee
41 class bez_spline {
42 public :
43         vector  pts[MAX_BEZ_PTS];
44         int             num_pts;
45
46 public :
47         // constructor
48         bez_spline();
49         bez_spline(int _num_pts, vector *_pts[MAX_BEZ_PTS]);
50
51         // set the points
52         void bez_set_points(int _num_pts, vector *_pts[MAX_BEZ_PTS]);
53
54         // bezier blend function
55         float BEZ(int k, int n, float u);
56         
57         // get a point on the bez curve. u goes from 0.0 to 1.0
58         void bez_get_point(vector *out, float u);
59
60         // render a bezier
61         void bez_render(int divs, color *c);
62 };
63
64 // hermite splines. cool cubic stuff
65 #define MAX_HERM_PTS                    3
66 class herm_spline {
67 public :
68         vector  pts[MAX_HERM_PTS];                      // control points
69         vector  d_pts[MAX_HERM_PTS];                    // derivative of control points (think of as velocity)
70         int             num_pts;
71 public :
72         // constructor
73         herm_spline();
74         herm_spline(int _num_pts, vector *_pts[MAX_HERM_PTS], vector *_d_pts[MAX_HERM_PTS]);
75
76         // set the points
77         void herm_set_points(int _num_pts, vector *_pts[MAX_HERM_PTS], vector *_d_pts[MAX_HERM_PTS]);   
78         
79         // get a point on the hermite curve.
80         void herm_get_point(vector *out, float u, int k);
81
82         // the derivative of a point on the hermite curve
83         void herm_get_deriv(vector *deriv, float u, int k);
84
85         // render a bezier
86         void herm_render(int divs, color *c);
87 };
88
89
90 // -------------------------------------------------------------------------------------------------
91 // SPLINE FUNCTIONS
92 //
93
94
95 #endif
96