object.c
 1  /* ************************************************************************** */
 2  /*                                                                            */
 3  /*                                                        :::      ::::::::   */
 4  /*   object.c                                           :+:      :+:    :+:   */
 5  /*                                                    +:+ +:+         +:+     */
 6  /*   By: gychoi <gychoi@student.42seoul.kr>         +#+  +:+       +#+        */
 7  /*                                                +#+#+#+#+#+   +#+           */
 8  /*   Created: 2023/05/04 17:50:01 by gychoi            #+#    #+#             */
 9  /*   Updated: 2023/05/07 21:27:14 by gychoi           ###   ########.fr       */
10  /*                                                                            */
11  /* ************************************************************************** */
12  
13  #include "header.h"
14  
15  t_object	*object(t_object_type type, void *element, t_color3 albedo)
16  {
17  	t_object	*new;
18  
19  	new = malloc(sizeof(t_object));
20  	if (!new)
21  		return (NULL);
22  	new->type = type;
23  	new->element = element;
24  	new->next = NULL;
25  	new->albedo = albedo;
26  	return (new);
27  }
28  
29  t_sphere	*sphere(t_point3 center, double radius)
30  {
31  	t_sphere	*sphere;
32  
33  	sphere = malloc(sizeof(t_sphere));
34  	if (!sphere)
35  		return (NULL);
36  	sphere->center = center;
37  	sphere->radius = radius;
38  	sphere->radius2 = radius * radius;
39  	return (sphere);
40  }
41  
42  t_light	*light_point(t_point3 light_origin, t_color3 light_color, double bright_ratio)
43  {
44  	t_light	*light;
45  
46  	light = malloc(sizeof(t_light));
47  	if (!light)
48  		return (NULL);
49  	light->origin = light_origin;
50  	light->light_color = light_color;
51  	light->bright_ratio = bright_ratio;
52  	return (light);
53  }