X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fscene.h;h=ce11dd5a5ccd84ae3d8ca53d9af533ffbea68750;hb=86aa9bdd85243207bbd7e888d73c2b865d805265;hp=d12dae6a1e1fe99d9fa0ae487a37c9ab2b1c7d37;hpb=15a4548ff09afb37dd33786cafd50b060a64f840;p=retroray diff --git a/src/scene.h b/src/scene.h index d12dae6..ce11dd5 100644 --- a/src/scene.h +++ b/src/scene.h @@ -19,6 +19,7 @@ along with this program. If not, see . #define SCENE_H_ #include "cgmath/cgmath.h" +#include "material.h" enum { OBJ_NULL, @@ -31,7 +32,9 @@ enum { char *name; \ cgm_vec3 pos, scale, pivot; \ cgm_quat rot; \ - float xform[16], inv_xform[16] + float xform[16], inv_xform[16]; \ + int xform_valid; \ + struct material *mtl struct object { OBJ_COMMON_ATTR; @@ -48,8 +51,17 @@ struct csgnode { struct object *subobj; /* darr */ }; +struct light { + char *name; + cgm_vec3 pos; + cgm_vec3 color, orig_color; + float energy; +}; + struct scene { struct object **objects; /* darr */ + struct light **lights; + struct material **mtl; /* darr */ }; struct rayhit; /* declared in rt.h */ @@ -62,8 +74,21 @@ int scn_rm_object(struct scene *scn, int idx); int scn_num_objects(const struct scene *scn); int scn_object_index(const struct scene *scn, const struct object *obj); +int scn_add_material(struct scene *scn, struct material *mtl); +int scn_rm_material(struct scene *scn, struct material *mtl); +int scn_num_materials(const struct scene *scn); +int scn_material_index(const struct scene *scn, const struct material *mtl); +struct material *scn_find_material(const struct scene *scn, const char *mname); + +int scn_add_light(struct scene *scn, struct light *mtl); +int scn_rm_light(struct scene *scn, struct light *mtl); +int scn_num_lights(const struct scene *scn); +int scn_light_index(const struct scene *scn, const struct light *mtl); +struct light *scn_find_light(const struct scene *scn, const char *mname); + int scn_intersect(const struct scene *scn, const cgm_ray *ray, struct rayhit *hit); +/* --- objects --- */ struct object *create_object(int type); void free_object(struct object *obj); @@ -71,4 +96,12 @@ int set_object_name(struct object *obj, const char *name); void calc_object_matrix(struct object *obj); +/* --- lights --- */ +struct light *create_light(void); +void free_light(struct light *lt); + +int set_light_name(struct light *lt, const char *name); +void set_light_color(struct light *lt, float r, float g, float b); +void set_light_energy(struct light *lt, float e); + #endif /* SCENE_H_ */