-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscene_types.h
83 lines (71 loc) · 1.97 KB
/
scene_types.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef __SCENE_TYPES_H__
#define __SCENE_TYPES_H__
#include "defines.h"
#include "scene.h"
#include <vector>
struct AABB
{
vec3 min;
vec3 max;
};
//! \file : internal types to describe a scene
typedef struct light_s {
point3 position;
color3 color;
} Light;
typedef struct camera_s {
point3 position; //! eye position
vec3 zdir; //! view direction
vec3 xdir; //! right direction
vec3 ydir; //! up direction
point3 center; //! center of the image plane
float fov; //! field of view
float aspect; //! aspect ratio (typically use WIDTH/HEIGHT of the computed image
} Camera;
typedef struct geometry_s {
Etype type; //! what kind of geometry we have, this value allows to determine which part of the union is valid;
//anonymous union of structures to stores object data
union {
struct {
// sphere
vec3 center;
float radius;
} sphere;
struct {
// plan
vec3 normal;
float dist;
} plane;
struct {
point3 v[3];
vec3 vt[3];
vec3 vn[3];
} triangle;
struct {
point3 C;
vec3 V;
float teta;
} cone;
};
} Geometry;
typedef struct object_s {
/** not used yet, but you should use it to transform ray before
* computing intersection (and thu have a better control on 3D position
*/
mat3 orientation;
/** not used yet, but you should use it to transform ray before
* computing intersection (and thu have a better control on 3D position
*/
vec3 tranlation;
Geometry geom;
Material mat;
} Object;
typedef std::vector<Object*> Objects;
typedef std::vector<Light*> Lights;
typedef struct scene_s {
Lights lights; //! the scene have several lights
Objects objects; //! the scene have several objects
Camera cam; //! the scene have one camera
color3 skyColor; //! the sky color, could be extended to a sky function ;)
} Scene;
#endif