MiniRT
My MiniRT notes.
MiniRT
MiniRT
Design
Scene Hierarchy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Scene
│
├── Ambient (unique)
│ ├─ ratio: float
│ └─ color: Color
│
├── Camera (unique)
│ ├─ position: Vector3
│ ├─ orientation: Vector3 (normalized)
│ └─ fov: float
│
├── Lights (list, one or more)
│ └─ Light
│ ├─ position: Vector3
│ ├─ brightness: float
│ └─ color: Color
│
└── Objects (list, one or more)
└─ Object (versatile template)
├─ type: enum {SPHERE, PLANE, CYLINDER, ...}
├─ data: void* → points to Sphere/Plane/Cylinder
└─ function pointers (optional):
• intersect(ray, obj)
• normal_at(point, obj)
Shared Building Blocks
1
2
3
4
5
6
7
8
9
Vector3
├─ x: float
├─ y: float
└─ z: float
Color
├─ r: float (0–1 normalized)
├─ g: float
└─ b: float
Specific Objects
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Sphere
├─ center: Vector3
├─ diameter: float
└─ color: Color
Plane
├─ point: Vector3
├─ normal: Vector3 (normalized)
└─ color: Color
Cylinder
├─ center: Vector3
├─ axis: Vector3 (normalized)
├─ diameter: float
├─ height: float
└─ color: Color
This post is licensed under CC BY 4.0 by the author.