Project

General

Profile

Statistics
| Revision:

root / branches / simulator / projects / simulator / simulator / core / world.h @ 1022

History | View | Annotate | Download (1.06 KB)

1
/**
2
 * @file world.h
3
 * @author Colony Project
4
 *
5
 * @brief THE WHOLE WIDE WORLD
6
 *
7
 * Contains structures and function prototypes used
8
 * for managing the world.
9
 **/
10

    
11
#ifndef __WORLD_H__
12
#define __WORLD_H__
13

    
14
#define ID_RECTANGLE 0
15
#define ID_CIRCLE 1
16
#define NUM_SHAPES 2
17

    
18
typedef struct {
19
    double x;
20
    double y;
21
} point_t;
22

    
23
typedef struct {
24
    point_t p1; /* Lower left point */
25
    point_t p2; /* Upper right point */
26
} bbox_t;
27

    
28
typedef struct {
29
    point_t p; /* origin */
30
    double d; /* direction */
31
} ray_t;
32

    
33
typedef struct {
34
    int id;
35
    bbox_t *bbox;
36
    void *props; /* shape-specific properties */
37
} object_t;
38

    
39
typedef struct {
40
    int num_objs;
41
    object_t *objs;
42
    bbox_t world;
43
} world_t;
44

    
45
/* Specific collision functions */
46
double collide_circle(ray_t *ray, object_t *obj);
47
double collide_rect(ray_t *ray, object_t *obj);
48

    
49
/*  Array of function pointers to the specific collide functions.
50
 *  Must be listed in the same order as IDs */
51
double  (*collide_func[NUM_SHAPES])(ray_t *ray, object_t *obj) = 
52
    {
53
        collide_rect,
54
        collide_circle 
55
    };
56

    
57
#endif
58