-
Notifications
You must be signed in to change notification settings - Fork 0
/
Clipping.h
36 lines (28 loc) · 832 Bytes
/
Clipping.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef CLIPPING_H
#define CLIPPING_H
#include "Triangle.h"
#include "Vector.h"
#define MAX_NUM_POLY_VERTICES 10
#define MAX_NUM_POLY_TRIANGLES 10
enum {
LEFT_FRUSTUM_PLANE,
RIGHT_FRUSTUM_PLANE,
TOP_FRUSTUM_PLANE,
BOTTOM_FRUSTUM_PLANE,
NEAR_FRUSTUM_PLANE,
FAR_FRUSTUM_PLANE
};
typedef struct {
vec3_t point;
vec3_t normal;
} plane_t;
void init_frustum_planes(float fov_x, float fov_y, float z_near, float z_far);
typedef struct {
vec3_t vertices[MAX_NUM_POLY_VERTICES];
tex2_t texcoords[MAX_NUM_POLY_VERTICES];
int num_vertices;
} polygon_t;
polygon_t polygon_from_triangle(vec3_t v0, vec3_t v1, vec3_t v2, tex2_t t0, tex2_t t1, tex2_t t2);
void triangles_from_polygon(polygon_t* polygon, triangle_t triangles[], int* num_triangles);
void clip_polygon(polygon_t* polygon);
#endif