Revision 1022 branches/simulator/projects/simulator/simulator/core/world.h
| world.h (revision 1022) | ||
|---|---|---|
| 2 | 2 |
* @file world.h |
| 3 | 3 |
* @author Colony Project |
| 4 | 4 |
* |
| 5 |
* @brief Manages simulated robots. |
|
| 5 |
* @brief THE WHOLE WIDE WORLD |
|
| 6 | 6 |
* |
| 7 | 7 |
* Contains structures and function prototypes used |
| 8 |
* for managing robots in the simulator. |
|
| 8 |
* for managing the world. |
|
| 9 | 9 |
**/ |
| 10 | 10 |
|
| 11 | 11 |
#ifndef __WORLD_H__ |
| 12 | 12 |
#define __WORLD_H__ |
| 13 | 13 |
|
| 14 |
#define ID_RECTANGLE 1 |
|
| 15 |
#define ID_CIRCLE 2 |
|
| 14 |
#define ID_RECTANGLE 0 |
|
| 15 |
#define ID_CIRCLE 1 |
|
| 16 |
#define NUM_SHAPES 2 |
|
| 16 | 17 |
|
| 17 | 18 |
typedef struct {
|
| 18 | 19 |
double x; |
| ... | ... | |
| 25 | 26 |
} bbox_t; |
| 26 | 27 |
|
| 27 | 28 |
typedef struct {
|
| 29 |
point_t p; /* origin */ |
|
| 30 |
double d; /* direction */ |
|
| 31 |
} ray_t; |
|
| 32 |
|
|
| 33 |
typedef struct {
|
|
| 28 | 34 |
int id; |
| 29 | 35 |
bbox_t *bbox; |
| 30 | 36 |
void *props; /* shape-specific properties */ |
| ... | ... | |
| 33 | 39 |
typedef struct {
|
| 34 | 40 |
int num_objs; |
| 35 | 41 |
object_t *objs; |
| 36 |
bbox world; |
|
| 42 |
bbox_t world; |
|
| 37 | 43 |
} world_t; |
| 38 | 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 |
|
|
| 39 | 57 |
#endif |
| 40 | 58 |
|
Also available in: Unified diff