FS2_Open
Open source remastering of the Freespace 2 engine
spline.h
Go to the documentation of this file.
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 the
6  * source.
7  *
8 */
9 
10 
11 
12 #ifndef __FS2_SPLINE_HEADER_FILE
13 #define __FS2_SPLINE_HEADER_FILE
14 
15 #include "math/vecmat.h"
16 
17 // -------------------------------------------------------------------------------------------------
18 // SPLINE DEFINES/VARS
19 //
20 
21 struct color;
22 
23 // max bezier degree - note the # of points directly corresponds to the degree (degree == n_points - 1).
24 // more points means more expensive!
25 #define MAX_BEZ_PTS 3
26 
27 // bezier class. whee
28 class bez_spline {
29 public :
31  int num_pts;
32 
33 public :
34  // constructor
35  bez_spline();
36  bez_spline(int _num_pts, vec3d *_pts[MAX_BEZ_PTS]);
37 
38  // set the points
39  void bez_set_points(int _num_pts, vec3d *_pts[MAX_BEZ_PTS]);
40 
41  // bezier blend function
42  float BEZ(int k, int n, float u);
43 
44  // get a point on the bez curve. u goes from 0.0 to 1.0
45  void bez_get_point(vec3d *out, float u);
46 
47  // render a bezier
48  void bez_render(int divs, color *c);
49 };
50 
51 // hermite splines. cool cubic stuff
52 #define MAX_HERM_PTS 3
53 class herm_spline {
54 public :
55  vec3d pts[MAX_HERM_PTS]; // control points
56  vec3d d_pts[MAX_HERM_PTS]; // derivative of control points (think of as velocity)
57  int num_pts;
58 public :
59  // constructor
60  herm_spline();
61  herm_spline(int _num_pts, vec3d *_pts[MAX_HERM_PTS], vec3d *_d_pts[MAX_HERM_PTS]);
62 
63  // set the points
64  void herm_set_points(int _num_pts, vec3d *_pts[MAX_HERM_PTS], vec3d *_d_pts[MAX_HERM_PTS]);
65 
66  // get a point on the hermite curve.
67  void herm_get_point(vec3d *out, float u, int k);
68 
69  // the derivative of a point on the hermite curve
70  void herm_get_deriv(vec3d *deriv, float u, int k);
71 
72  // render a bezier
73  void herm_render(int divs, color *c);
74 };
75 
76 
77 // -------------------------------------------------------------------------------------------------
78 // SPLINE FUNCTIONS
79 //
80 
81 
82 #endif
void herm_render(int divs, color *c)
Definition: spline.cpp:258
void bez_set_points(int _num_pts, vec3d *_pts[MAX_BEZ_PTS])
Definition: spline.cpp:71
void herm_set_points(int _num_pts, vec3d *_pts[MAX_HERM_PTS], vec3d *_d_pts[MAX_HERM_PTS])
Definition: spline.cpp:189
float BEZ(int k, int n, float u)
Definition: spline.cpp:87
Definition: pstypes.h:88
int num_pts
Definition: spline.h:57
Definition: 2d.h:95
enum_h * u
Definition: lua.cpp:12649
int num_pts
Definition: spline.h:31
#define MAX_BEZ_PTS
Definition: spline.h:25
void herm_get_point(vec3d *out, float u, int k)
Definition: spline.cpp:208
void bez_get_point(vec3d *out, float u)
Definition: spline.cpp:97
vec3d pts[MAX_HERM_PTS]
Definition: spline.h:55
void herm_get_deriv(vec3d *deriv, float u, int k)
Definition: spline.cpp:233
void bez_render(int divs, color *c)
Definition: spline.cpp:127
GLclampd n
Definition: Glext.h:7286
vec3d d_pts[MAX_HERM_PTS]
Definition: spline.h:56
vec3d pts[MAX_BEZ_PTS]
Definition: spline.h:30
#define MAX_HERM_PTS
Definition: spline.h:52
bez_spline()
Definition: spline.cpp:53
const GLubyte * c
Definition: Glext.h:8376