first render
[retroray] / src / scene.h
index 7d4cd22..ce11dd5 100644 (file)
@@ -19,6 +19,7 @@ along with this program.  If not, see <https://www.gnu.org/licenses/>.
 #define SCENE_H_
 
 #include "cgmath/cgmath.h"
+#include "material.h"
 
 enum {
        OBJ_NULL,
@@ -32,7 +33,8 @@ enum {
        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;
@@ -49,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 */
@@ -63,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);
 
@@ -72,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_ */