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