viewing source for "objects.h"
last commit
commit 2fcfc3b2e8e18bd4ab667b82d939cc2ba9b6a5d3
Date: Sun Jan 13 09:25:46 2008 -0800
source code
01: #ifndef __OBJECTS__H__
02: #define __OBJECTS__H__
03:
04: #define SPHERE 0
05: #define BOX 1
06: #define PLANE 2
07:
08: #define NOT_LIGHT 0
09: #define POINT_LIGHT 1
10: #define AREA_LIGHT 2
11:
12: #include "vector.h"
13:
14: struct _isect;
15: typedef struct _isect intersection;
16: typedef struct _prim primitive;
17:
18: typedef struct {
19: color col;
20: float diffuse, refl, refr, specular, absorb;
21: int is_refr;
22: } material;
23:
24: struct _prim {
25: primitive *next;
26:
27: char type;
28: char is_light;
29:
30: vector center;
31:
32: material mat;
33:
34: void *data;
35:
36: float *grid;
37: float dx;
38: float dy;
39: float dz;
40:
41: intersection* (*intersect)( primitive*, ray* );
42: void (*normal)( primitive*, vector*, vector* );
43: };
44:
45: struct _isect {
46: primitive *prim;
47: float dist;
48: char inside;
49: };
50:
51: typedef struct {
52: vector point;
53: vector size;
54: } box_data;
55:
56: typedef struct {
57: vector center;
58: float radius;
59: } sphere_data;
60:
61: typedef struct {
62: vector normal;
63: float dist;
64: } plane_data;
65:
66: intersection* box_isect( primitive *prim, ray *r );
67: void box_normal( primitive *box, vector *isect, vector *ret );
68: intersection* sphere_isect( primitive *prim, ray *r );
69: void sphere_normal( primitive *sphere, vector *isect, vector *ret );
70: intersection* plane_isect( primitive *prim, ray *r );
71: void plane_normal( primitive *plane, vector *isect, vector *ret );
72:
73: #endif