#define SCENE_H_
#include "cgmath/cgmath.h"
+#include "material.h"
enum {
OBJ_NULL,
cgm_vec3 pos, scale, pivot; \
cgm_quat rot; \
float xform[16], inv_xform[16]; \
- int xform_valid
+ int xform_valid; \
+ struct material *mtl
struct object {
OBJ_COMMON_ATTR;
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 */
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);
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_ */