calacirya

changeset 0:df9e0bc7685a

starting calacirya project
author John Tsiombikas <nuclear@mutantstargoat.com>
date Sun, 18 Sep 2011 11:46:55 +0300
parents
children 1a831650f59a
files README src/attr.h src/camera.h src/object.h src/prim.h src/scene.h
diffstat 6 files changed, 120 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/README	Sun Sep 18 11:46:55 2011 +0300
     1.3 @@ -0,0 +1,1 @@
     1.4 +calacirya: 	n. cleft of light
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/attr.h	Sun Sep 18 11:46:55 2011 +0300
     2.3 @@ -0,0 +1,27 @@
     2.4 +#ifndef ATTR_H_
     2.5 +#define ATTR_H_
     2.6 +
     2.7 +#include <anim.h>
     2.8 +
     2.9 +struct attribute {
    2.10 +	struct anm_node *node;
    2.11 +	char *name;
    2.12 +
    2.13 +	struct attribute *left, *right;
    2.14 +};
    2.15 +
    2.16 +
    2.17 +struct attrdb {
    2.18 +	struct attribute *root;
    2.19 +};
    2.20 +
    2.21 +struct attribute *create_attrib(const char *name);
    2.22 +void free_attrib(struct attribute *attr);
    2.23 +
    2.24 +struct attrdb *create_attrdb(void);
    2.25 +void free_attrib(struct attrdb *db);
    2.26 +
    2.27 +void add_attrib(struct attrdb *db, struct attribute *attr);
    2.28 +struct attribute *find_attrib(struct attrdb *db, const char *name);
    2.29 +
    2.30 +#endif	/* ATTR_H_ */
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/camera.h	Sun Sep 18 11:46:55 2011 +0300
     3.3 @@ -0,0 +1,17 @@
     3.4 +#ifndef CAMERA_H_
     3.5 +#define CAMERA_H_
     3.6 +
     3.7 +#include <vmath.h>
     3.8 +#include <anim.h>
     3.9 +
    3.10 +struct camera {
    3.11 +	struct anm_node *node;
    3.12 +	float vfov;
    3.13 +	float shutter, aperture;
    3.14 +
    3.15 +	struct camera *next;
    3.16 +};
    3.17 +
    3.18 +ray_t get_prim_ray(struct camera *cam, vec2_t ppos, float tm);
    3.19 +
    3.20 +#endif	/* CAMERA_H_ */
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/object.h	Sun Sep 18 11:46:55 2011 +0300
     4.3 @@ -0,0 +1,10 @@
     4.4 +#ifndef OBJECT_H_
     4.5 +#define OBJECT_H_
     4.6 +
     4.7 +#include <anim.h>
     4.8 +
     4.9 +struct object {
    4.10 +	struct anm_node *node;
    4.11 +};
    4.12 +
    4.13 +#endif	/* OBJECT_H_ */
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/prim.h	Sun Sep 18 11:46:55 2011 +0300
     5.3 @@ -0,0 +1,51 @@
     5.4 +#ifndef PRIM_H_
     5.5 +#define PRIM_H_
     5.6 +
     5.7 +#include <vmath.h>
     5.8 +
     5.9 +struct object;
    5.10 +
    5.11 +typedef struct vertex isect_info_t;
    5.12 +
    5.13 +typedef float (*isect_func_t)(struct primitive*, ray_t, isect_info_t*);
    5.14 +
    5.15 +enum {
    5.16 +	PRIM_SPHERE,
    5.17 +	PRIM_PLANE,
    5.18 +	PRIM_TRIANGLE
    5.19 +};
    5.20 +
    5.21 +#define PRIM_COMMON_VARS \
    5.22 +	int type; \
    5.23 +	struct object *obj; \
    5.24 +	isect_func_t intersect; \
    5.25 +	struct primitive *next
    5.26 +
    5.27 +struct prim_sphere {
    5.28 +	PRIM_COMMON_VARS;
    5.29 +
    5.30 +	float radius;
    5.31 +};
    5.32 +
    5.33 +struct prim_plane {
    5.34 +	PRIM_COMMON_VARS;
    5.35 +};
    5.36 +
    5.37 +struct vertex {
    5.38 +	vec3_t pos, norm, tang;
    5.39 +	vec2_t texcoord;
    5.40 +};
    5.41 +
    5.42 +struct prim_triangle {
    5.43 +	PRIM_COMMON_VARS;
    5.44 +
    5.45 +	struct vertex v[3];
    5.46 +};
    5.47 +
    5.48 +union primitive {
    5.49 +	struct prim_sphere sph;
    5.50 +	struct prim_plane plane;
    5.51 +	struct prim_triangle tri;
    5.52 +};
    5.53 +
    5.54 +#endif	/* PRIM_H_ */
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/scene.h	Sun Sep 18 11:46:55 2011 +0300
     6.3 @@ -0,0 +1,14 @@
     6.4 +#ifndef SCENE_H_
     6.5 +#define SCENE_H_
     6.6 +
     6.7 +#include "object.h"
     6.8 +#include "prim.h"
     6.9 +#include "kdtree.h"
    6.10 +
    6.11 +struct scene {
    6.12 +	struct object *objlist;
    6.13 +	struct primitive *primlist;
    6.14 +	struct kdtree *tree;
    6.15 +};
    6.16 +
    6.17 +#endif	/* SCENE_H_ */