-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscene.h
57 lines (40 loc) · 1.68 KB
/
scene.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef __SCENE_H__
#define __SCENE_H__
#include "defines.h"
#include <vector>
// SCENE
typedef struct scene_s Scene;
typedef struct object_s Object;
typedef struct light_s Light;
typedef struct camera_s Camera;
typedef struct material_s {
float IOR; //! Index of refraction (for dielectric)
float roughness; //! 0.001 - 0.01 : very smooth finish with slight imperfections. 0.1 : relatively rough. 0.3-0.7 extremely rough
color3 specularColor; //! Specular "albedo"
color3 diffuseColor; //! Base color
color3* image = nullptr;
size_t width = 0;
size_t height = 0;
} Material;
enum Etype {SPHERE=1, PLANE, TRIANGLE, CONE};
//! create a new sphere structure
Object* initSphere(point3 center, float radius, Material mat);
Object* initPlane(vec3 normal, float d, Material mat);
Object *initTriangle(point3 v[3], point3 vt[3], point3 vn[3], Material mat);
Object *initCone(point3 C, vec3 V, float teta, Material mat);
//! release memory for the object obj
void freeObject(Object *obj);
//! init a new light at position with a give color (no special unit here for the moment)
Light* initLight(point3 position, color3 color);
//! release memory for the light
void freeLight(Light *);
// allocate the momery for the scene
Scene *initScene();
void freeScene(Scene *scene);
void setCamera(Scene *scene, point3 position, vec3 at, vec3 up, float fov, float aspect);
//! take ownership of obj freeScene will free obj) ... typically use addObject(scene, initPlane()
void addObject(Scene *scene, Object *obj);
//! take ownership of light : freeScene will free light) ... typically use addObject(scene, initLight()
void addLight(Scene *scene, Light *light);
void setSkyColor(Scene *scene, color3 c);
#endif