Statistics
| Revision:

## root / branches / simulator / projects / simulator / simulator / core / world.h @ 1173

 1 ```/** ``` ``` * @file world.h ``` ``` * @author Colony Project ``` ``` * ``` ``` * @brief THE WHOLE WIDE WORLD ``` ``` * ``` ``` * Contains structures and function prototypes used ``` ``` * for managing the world. ``` ``` **/ ``` ```#ifndef __WORLD_H__ ``` ```#define __WORLD_H__ ``` ```#include ``` ```#include ``` ```#include ``` ```#include ``` ```#define ID_OFFSET -1 ``` ```#define ID_RECTANGLE 3 ``` ```#define ID_CIRCLE 2 ``` ```#define ID_NULL 0 ``` ```#define ID_POLY 1 ``` ```#define POLY_DISCONNECTED 0 ``` ```#define POLY_CONNECTED 1 ``` ```#define POLY_RECT 2 ``` ```#define NUM_SHAPES 3 ``` ```#define RAY_MISS 10000 ``` ```#define CREATE(id, ...) (create_func[id](__VA_ARGS__)) ``` ```#define PBBOX(b) {printf("(%g,%g) --> (%g, %g)\n",(b).p1.x,(b).p1.y,(b).p2.x,\ ``` ``` (b).p2.y);} ``` ```#define PRAY(v) {printf("(%g,%g), %g\n", (v).p.x, (v).p.y,(v).d);} ``` ```#define BUF_SIZE 512 ``` ```typedef struct { ``` ``` double x; ``` ``` double y; ``` ```} point_t; ``` ```typedef struct { ``` ``` point_t p1; /* Lower left point */ ``` ``` point_t p2; /* Upper right point */ ``` ```} bbox_t, rect_t, seg_t; ``` ```typedef struct { ``` ``` point_t p; /* origin */ ``` ``` double d; /* direction */ ``` ```} ray_t; ``` ```typedef struct { ``` ``` int type; ``` ``` int num_pts; ``` ``` point_t *pts; ``` ```} poly_t; ``` ```typedef struct { ``` ``` double radius; ``` ``` point_t center; ``` ```} circle_t; ``` ```typedef struct { ``` ``` int id; ``` ``` bbox_t *bbox; ``` ``` void *props; /* shape-specific properties */ ``` ```} object_t; ``` ```typedef struct { ``` ``` int max_objs; ``` ``` int cur_objs; ``` ``` object_t *objs; ``` ``` bbox_t win; ``` ```} world_t; ``` ```/* Specific collision functions */ ``` ```double collide(ray_t *ray, object_t *obj); ``` ```double collide_circle(ray_t *ray, object_t *obj); ``` ```double collide_rect(ray_t *ray, object_t *obj); ``` ```double collide_poly(ray_t *ray, object_t *obj); ``` ```double collide_world(ray_t *ray); ``` ```/* Array of function pointers to the specific collide functions. ``` ``` * Must be listed in the same order as IDs */ ``` ```extern double (*collide_func[NUM_SHAPES])(ray_t *ray, object_t *obj); ``` ```extern int (*create_func[NUM_SHAPES])(object_t *obj, va_list ap); ``` ```extern int (*destroy_func[NUM_SHAPES])(object_t *obj); ``` ```extern world_t world; ``` ```int init_world(int num_objs, bbox_t b); ``` ```int destroy_world(void); ``` ```int create_poly(object_t *obj, va_list ap); ``` ```int destroy_poly(object_t *obj); ``` ```object_t *create(int id, ...); ``` ```void print_world(void); ``` ```void print_object(object_t *obj); ``` ```/* WORLD 0 0 512 512 ``` ``` * POLYGON 3 CONNECTED 1 2 3 4 5 6 ``` ``` */ ``` ```int load_world (const char* filename, int max_objs); ``` ```int load_object (const char* line); ``` ```#endif ```