miniRT
By Marcelo Magalhães and Ygor G. Sena, 2023.
world.h
Go to the documentation of this file.
1 /* ************************************************************************** */
2 /* */
3 /* ::: :::::::: */
4 /* world.h :+: :+: :+: */
5 /* +:+ +:+ +:+ */
6 /* By: yde-goes <yde-goes@student.42sp.org.br> +#+ +:+ +#+ */
7 /* +#+#+#+#+#+ +#+ */
8 /* Created: 2023/04/13 14:17:44 by mdias-ma #+# #+# */
9 /* Updated: 2023/06/16 13:40:27 by yde-goes ### ########.fr */
10 /* */
11 /* ************************************************************************** */
12 
14 #ifndef WORLD_H
15 # define WORLD_H
16 
17 # include "lights.h"
18 # include "shapes.h"
19 
36 typedef struct s_world
37 {
38  t_hit *xs;
39  int object_count;
40  t_shape *objects;
41  int light_count;
42  t_light *lights;
43  t_color ambient;
45 
65 typedef struct s_comps
66 {
67  float t;
68  t_shape *object;
69  t_point point;
70  t_sight sight;
71  t_bool inside;
72  t_tuple over_point;
74 
75 /* ************************************************************************** */
76 /* WORLD.C */
77 /* ************************************************************************** */
78 
88 t_hit *intersect_world(t_world *world, t_ray ray);
89 
107 
121 t_color shade_hit(t_world world, t_comps comps);
122 
140 t_color color_at(t_world world, t_ray ray);
141 
142 /* ************************************************************************** */
143 /* SHADOWS.C */
144 /* ************************************************************************** */
145 
165 t_bool is_shadowed(t_world *world, t_point point, int index);
166 
167 #endif
t_hit * intersection(float t, t_shape *shape)
Creates a hit record for an intersection.
Definition: intersections.c:18
The struct s_color stores the color values of ray tracing. It contains a field for red,...
Definition: tuples.h:63
This structure of type t_comps stores some precomputed values that are useful when working intersecti...
Definition: world.h:66
The structure t_hit stores a linked list of ray-shape intersections' values.
Definition: shapes.h:134
The struct s_light represents a light's source. This source has a position in space and an intensity ...
Definition: lights.h:44
The struct of type t_ray represents a ray, which is the foundation for ray casting....
Definition: rays.h:28
The struct s_sight represents the human eye looking forwards.
Definition: lights.h:62
Tuple means a list of ordered things. The struct t_tuple stores coordinates for a left-handed coordin...
Definition: tuples.h:33
This struct contains everything related to the building of a ray tracing's world. The world has objec...
Definition: world.h:37
Represents a shape in a scene.
t_tuple point(double x, double y, double z)
This function is a simplification of the function tuple(). It will create a point with the given coor...
Definition: models.c:20
t_hit * intersect_world(t_world *world, t_ray ray)
Finds all intersections between a ray and all objects in the world.
Definition: world.c:15
t_bool is_shadowed(t_world *world, t_point point, int index)
Determines whether a point in a world is in shadow or not.
Definition: shadows.c:15
t_comps prepare_computations(t_hit *intersection, t_ray ray)
Precomputes information related to an intersection.
Definition: world.c:31
struct s_world t_world
This struct contains everything related to the building of a ray tracing's world. The world has objec...
t_color color_at(t_world world, t_ray ray)
Computes the color at the intersection of a given ray with a world.
Definition: world.c:73
struct s_comps t_comps
This structure of type t_comps stores some precomputed values that are useful when working intersecti...
t_color shade_hit(t_world world, t_comps comps)
Computes the color at an intersection in the given world.
Definition: world.c:50