This commit is contained in:
gbrochar 2020-11-22 17:52:57 +01:00
parent 56d52cd8cf
commit d43b1f9747
229 changed files with 17856 additions and 1 deletions

209
Makefile Normal file
View File

@ -0,0 +1,209 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: scebula <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2017/01/09 20:49:49 by scebula #+# #+# #
# Updated: 2017/01/10 21:46:25 by scebula ### ########.fr #
# #
# **************************************************************************** #
NAME = RT
C_FILES = main.c \
color_maths.c \
color_tools.c \
csg_diff.c \
csg_inter.c \
csg_add.c \
display.c \
display_names.c \
display_scene_tmb.c \
events_menu.c \
events_scene.c \
events_scene_look.c \
events_scene_movement.c \
events_scene_movement_up_down.c \
free_functions.c \
ft_error.c\
get_obj_color.c \
get_obj_color_bis.c \
get_obj_normal.c \
get_obj_normal_bis.c \
get_obj_tf_list.c \
get_obj_tf_list_complex.c \
get_list_from_page.c \
init_camera.c \
init_env.c \
init_cut_condition.c \
init_function.c \
init_img.c \
init_light.c \
init_obj_cone.c \
init_obj_cube.c \
init_obj_cylinder.c \
init_obj_hyperboloid.c \
init_obj_paraboloid.c \
init_obj_plane.c \
init_obj_prism.c \
init_obj_sphere.c \
init_obj_triangle.c \
init_obj_triangle_bis.c \
init_scenes.c \
init_obj_csg.c \
init_solid.c \
init_vector.c \
list_light_manage.c \
list_obj_cone.c \
list_obj_cube.c \
list_obj_cylinder.c \
list_obj_hyperboloid.c \
list_obj_paraboloid.c \
list_obj_plane.c \
list_obj_prism.c \
list_obj_sphere.c \
list_obj_triangle.c \
list_obj_csg.c \
list_scene.c \
maths_matrix.c \
maths_matrix_rotation.c \
maths_matrix_scale.c \
maths_matrix_translation.c \
maths_obj_cone.c \
maths_obj_cube.c \
maths_obj_cylinder.c \
maths_obj_hyperboloid.c \
maths_obj_paraboloid.c \
maths_obj_plane.c \
maths_obj_prism.c \
maths_obj_sphere.c \
maths_obj_triangle.c \
maths_vector_calc.c \
maths_vector_op.c \
obj_apply_parameters.c\
light_cam_apply_parameters.c\
obj_apply_parameters_basic.c\
obj_apply_parameters_complex.c\
obj_parameter_parser.c\
light_cam_populators.c\
objects_populators_basic.c\
objects_populators_complex.c\
parameter_input_testers.c \
parser.c\
parser_check.c\
parser_lexer.c \
parser_line_identifier.c\
post_pro_eblouissement.c \
post_pro_hub.c \
post_pro_img_anaglyph.c \
post_pro_recolor.c \
putpixel.c \
init_ray.c \
record_tools.c \
rt_calculate_ray.c \
rt_find_n.c \
rt_get_color_at.c \
rt_get_pixel_color.c \
rt_raytracer.c \
rt_reflection.c \
rt_shadow.c \
specular.c \
texture_getter.c \
texture_modifiers.c \
texture_manager.c \
tf_add.c \
tf_apply.c \
tf_free.c \
tf_push.c \
tools.c\
events_select_scene.c \
cut_object.c \
cut_save.c \
cut_select_negative.c \
cut_select_positive.c \
cut_select_special.c \
cut_select_neg_or_pos.c \
cut_keep.c \
cut_research_in_cone.c \
init_button.c \
events_redirect.c \
maths_obj_csg.c \
INC_NAME = rt.h \
mlx.h \
libft.h \
parser.h\
keys.h
CC = gcc -Wextra -Werror -Wall -o3
MLX_FLAGS = -lft -lmlx -framework OpenGL -framework Appkit
LIBFT = libft.a
LIBMLX = libmlx.a
LIBFT_DIR = libft/
LIB_DIR = lib/
INC_DIR = inc/
EXEC_NAME = RT
INC = $(addprefix inc/,$(INC_NAME))
OBJ = $(addprefix $(O_PATH), $(C_FILES:.c=.o))
SRC = $(addprefix $(C_PATH), $(C_FILES))
######
C_PATH = ./src/
O_PATH = ./obj/
$(addprefix $(O_PATH),%.o): $(addprefix $(C_PATH),%.c)
@mkdir -p $(O_PATH)
@$(CC) -o $@ -c $^ -I inc/
@echo -n .
all: $(NAME)
$(NAME): create_libft obj_comp $(OBJ)
@$(CC) -o $(NAME) $(OBJ) -Llib $(MLX_FLAGS)
@echo "\n\x1b[32m-- COMPILING SUCCESSFULL --"
create_libft:
@echo "\x1b[31mMaking LIBFT ...\033[0m"
@make -s -C $(LIBFT_DIR)
@mkdir -p lib
@cp $(LIBFT_DIR)$(LIBFT) $(LIB_DIR)$(LIBFT)
@cp $(LIBFT_DIR)/includes/libft.h $(INC_DIR)libft.h
obj_comp:
@echo "\x1b[33m-- COMPILING ... --\033[0m"
norminette:
@echo "----------NORMINETTE------------"
@echo "\x1b[37m"
@norminette ./libft/*.h
@norminette ./libft/*.c
@norminette ./inc/*.h
@norminette ./src/*.c
welcome:
@echo "Welcome to our project."
@echo "To launch the program, please use both following commands"
@echo "> make\n> ./RT"
clean:
@make fclean -C $(LIBFT_DIR)
@echo "libft cleaned"
@rm -f $(INC_DIR)libft.h
@rm -f $(INC_DIR)mlx.h
@rm -rf ./obj
@rm -rf ./lib
@echo ".o cleaned"
fclean: clean
@rm -f $(NAME)
@echo "exec deleted"
@echo "Project Cleaned."
re: fclean all
fcleanlibft:
make fclean -C $(LIBFT_DIR)

265
Manual.1 Normal file
View File

@ -0,0 +1,265 @@
.TH RT 6 "January 09, 2017"
.SH NAME
RT - Scene renderer using RayTracing method
.SH SYNOPSIS
RT
.SH DESCRIPTION
RT is a program made to render scenes mades of primitives. the different scenes must be placed in the "./scenes" folder, right next to the compiled program. the scenes must also follow semantics rules, else the behavior of the program is undefined.
.SH SCENE SYNTAX
As mentionned above, a scene must follow a specific syntax, it can contain :
.TP 20
.B Parameters
: Used to define characteristics of the scene, or an object.
.TP 20
.B Declarators
: Create a new object and modify it with parameters.
.P 20
Here is how they are used :
.br
.B Declarator[,declarator arg]
.br
.B {
.br
.B Parameter:arguments
.br
.B }
.br
if a parameter is used outside of any declarator, it is attributed to the scene itself, modifying its properties.
.SH PARAMETERS LIST
Every parameters and their description :
.P
AAlvl:0 - 255 | define the Anti-Aliasing multiplier
.br
reflections:0 - 255 | define the number of reflexions a ray can support
.br
ambient:0 - 1 | define the amount of ambient light the scene apply
.br
translate:X Y Z | define a translation matrix
.br
rotate_[x|y|z]:-360 - 360 | define a rotation matrix along the selected angle
.br
scale:X Y Z | define a scale matrix
.br
color:R G B | define a color
.br
shine:0 - 1 | define the specular property of an object
.br
reflection:0 - 1 | define the reflection level of an object
.br
texture:file.xpm | define the texture to be displayed on an object
.br
bumpmap:file.xpm | define a bumpmap to apply on an object
.br
texmodifier:[1|2|3|4] | define a dynamic texture modifier [SINX|SINY|SINXY|QUAD]
.br
texscale:X Y | define the amount of times the texture is repeated in one unit
.br
texoffset:X Y | define an offset in units of the texture
.br
sheetmode:[0|1] | activate or not the sheet mode for the HYPERBOLOID [off|on]
.br
vertex_[a|b|c|d]:X Y Z | define a vertex as needed by certain objects
.br
absolute:[0|1] | define a cut as absolute, using world coordinates instead of parent [off|on]
.br
orientation:X Y Z | define an orientation vector, should be normalised to prevent undefined behaviors
.br
look_at:X Y Z | define a location to witch the camera will look initially
.SH SUPPORTED DECLARATORS AND PARAMETERS
Here is listed every declarators and their supported parameters :
.P 20
.B ROOT
.br
{
.br
AAlvl:X
.br
reflections:X
.br
ambient:X
.br
}
.P 20
.B [SPHERE|PLANE|CYLINDER|CONE|PARABOLOID]
.br
{
.br
translate:X Y Z
.br
rotate_[x|y|z]:X
.br
scale:X Y Z
.br
color:R G B
.br
shine:X
.br
reflection:X
.br
texture:file.xpm
.br
bumpmap:file.xpm
.br
texmodifier:X
.br
texscale:X Y
.br
texoffset:X Y
.br
}
.P 20
.B HYPERBOLOID
.br
{
.br
translate:X Y Z
.br
rotate_[x|y|z]:X
.br
scale:X Y Z
.br
color:R G B
.br
shine:X
.br
reflection:X
.br
texture:file.xpm
.br
bumpmap:file.xpm
.br
texmodifier:X
.br
texscale:X Y
.br
texoffset:X Y
.br
sheetmode:X
.br
}
.P 20
.B TRIANGLE
.br
{
.br
translate:X Y Z
.br
rotate_[x|y|z]:X
.br
scale:X Y Z
.br
color:R G B
.br
shine:X
.br
reflection:X
.br
vertex_[a|b|c]:X Y Z
.br
}
.P 20
.B PRISM
.br
{
.br
translate:X Y Z
.br
rotate_[x|y|z]:X
.br
scale:X Y Z
.br
color:R G B
.br
shine:X
.br
reflection:X
.br
vertex_[a|b|c|d]:X Y Z
.br
}
.P 20
.B CUBE
.br
{
.br
translate:X Y Z
.br
rotate_[x|y|z]:X
.br
scale:X Y Z
.br
color:R G B
.br
shine:X
.br
reflection:X
.br
vertex_[a|b]:X Y Z
.br
}
.P 20
.B CUT
.br
{
.br
translate:X Y Z
.br
rotate_[x|y|z]:X
.br
scale:X Y Z
.br
color:R G B
.br
shine:X
.br
reflection:X
.br
texture:file.xpm
.br
bumpmap:file.xpm
.br
texmodifier:X
.br
texscale:X Y
.br
texoffset:X Y
.br
absolute:X
.br
}
.P 20
.B CSG,[INTER|UNION|DIFF]
.br
{
.br
[DECLARATOR1]
.br
{...}
.br
[DECLARATOR2]
.br
{...}
.br
}
.P 20
.B CAMERA
.br
{
.br
position:X Y Z
.br
orientation:X Y Z
.br
look_at:X Y Z
.br
}
.P 20
.B LIGHT
.br
{
.br
position:X Y Z
.br
color:R G B
.br
}

View File

@ -1,3 +1,9 @@
# rt
rt : a raytracing engine made using minilibx. Features all quadrics, CSG objects, bumpmapping and texture mapping amongst other features.
rt : a raytracing engine made using minilibx. Features all quadrics, CSG objects, bumpmapping and texture mapping amongst other features.
You need to have to minilibx installed to run it. It will not compile on linux systems.
Most scenes wont work as I've deleted heavy texture files from the original repo.
It's a team project for 4 students.

4
auteur Normal file
View File

@ -0,0 +1,4 @@
scebula
gbrochar
ntrahy
qviguier

93
inc/keys.h Normal file
View File

@ -0,0 +1,93 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* keys.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/07/24 22:34:33 by scebula #+# #+# */
/* Updated: 2017/01/10 12:27:47 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef KEYS_H
# define KEYS_H
# define KEY_Q 12
# define KEY_W 13
# define KEY_E 14
# define KEY_R 15
# define KEY_T 17
# define KEY_Y 16
# define KEY_U 32
# define KEY_I 34
# define KEY_O 31
# define KEY_P 35
# define KEY_A 0
# define KEY_S 1
# define KEY_D 2
# define KEY_F 3
# define KEY_G 5
# define KEY_H 4
# define KEY_J 38
# define KEY_K 40
# define KEY_L 37
# define KEY_Z 6
# define KEY_X 7
# define KEY_C 8
# define KEY_V 9
# define KEY_B 11
# define KEY_N 45
# define KEY_M 46
# define KEY_1 18
# define KEY_2 19
# define KEY_3 20
# define KEY_4 21
# define KEY_5 23
# define KEY_6 22
# define KEY_7 26
# define KEY_8 28
# define KEY_9 25
# define KEY_0 29
# define KEY_F1 122
# define KEY_F2 120
# define KEY_F3 99
# define KEY_F4 118
# define KEY_F5 96
# define KEY_F6 97
# define KEY_F7 98
# define KEY_F8 100
# define KEY_F9 101
# define KEY_F10 109
# define KEY_F11 103
# define KEY_F12 111
# define KEY_LEFT 123
# define KEY_RIGHT 124
# define KEY_UP 126
# define KEY_DOWN 125
# define KEY_TAB 48
# define KEY_SHIFTL 257
# define KEY_FN 279
# define KEY_CTRL 256
# define KEY_ALTL 261
# define KEY_CMDL 259
# define KEY_CMDR 260
# define KEY_SPACE 49
# define KEY_ALTR 262
# define KEY_ENTER 36
# define KEY_MINUS 27
# define KEY_EQUAL 24
# define KEY_BACKSPACE 51
# define KEY_BRACKETL 33
# define KEY_BRACKETR 30
# define KEY_ANTISLASH 42
# define KEY_ESC 53
# define KEY_TILT 50
# define KEY_COMMA 43
# define KEY_DOT 47
# define KEY_SLASH 44
# define KEY_SEMICOLON 41
# define MOUSE_WHEEL_BOTTOM 5
# define MOUSE_WHEEL_UP 4
# define KEY_APO 3
#endif

37
inc/parser.h Normal file
View File

@ -0,0 +1,37 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parser.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ntrahy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 13:41:38 by ntrahy #+# #+# */
/* Updated: 2017/01/10 21:25:02 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef PARSER_H
# define PARSER_H
# define DOUBLE 0
# define STRING 1
# define NOTHING 0
# define CONTEXT_OPENER 1
# define CONTEXT_CLOSER 2
# define DECLARATOR 3
# define PARAMETER 4
# define UNION 1
# define INTER 2
# define DIFF 3
# define TWO_ATOF ft_atof(cache->params[0]), ft_atof(cache->params[1])
# define POS cache->pos
# define FN cache->filename
# define PARAM_NAME cache->param_name
# define PARAMS cache->params
# define CAC cache
# include "rt.h"
#endif

100
inc/rt.h Normal file
View File

@ -0,0 +1,100 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rt.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/10 21:43:48 by scebula #+# #+# */
/* Updated: 2017/01/10 21:43:51 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef RT_H
# define RT_H
# include "libft.h"
# include "mlx.h"
# include "keys.h"
# include "threads.h"
# include "rt_structs.h"
# include "rt_proto.h"
# include "parser.h"
# include <math.h>
# define THREADS 8
# define AA_LVL 1
# define ACC 0.000001
# define REFLECTIONS 2
# define AMBIENT 0.5
# define DIFFUSE 1
# define WIDTH 1000
# define HEIGHT 640
# define FOUND 1
# define NOT_FOUND 0
# define ROTATION_X 0
# define ROTATION_Y 1
# define ROTATION_Z 2
# define TRANSLATION 3
# define SCALE 4
# define ROTATION_XYZ 5
# define SPHERE 0
# define PLANE 1
# define CYLINDER 2
# define CONE 3
# define TRIANGLE 4
# define PRISM 5
# define CUBE 6
# define PARABOLOID 7
# define HYPERBOLOID 8
# define CSG 9
# define OBJECT_NUMBER 10
# define TO_SPHERE obj->solid->sphere
# define TO_PLANE obj->solid->plane
# define TO_CYLINDER obj->solid->cylinder
# define TO_CONE obj->solid->cone
# define TO_TRIANGLE obj->solid->triangle
# define TO_PRISM obj->solid->prism
# define TO_CUBE obj->solid->cube
# define TO_PARABOLOID obj->solid->paraboloid
# define TO_HYPERBOLOID obj->solid->hyperboloid
# define TO_CSG obj->solid->csg
# define COLOR ((t_color (*)(t_obj *))d->func->get_obj_color[info->type])
# define GET_COLOR_MOY(X,Y) moy(img_pull_pixel(X, Y, &tex->img)) / (double)255
# define INITIAL_RAY 0
# define SHADOW_RAY 1
# define REFLECTION_RAY 2
# define TF_NORMAL 0
# define TF_RAY 1
# define TF_INTERSECTION 2
# define ABS(X) (X) < 0 ? -(X) : (X)
# define SINX 1
# define SINY 2
# define QUAD 3
# define SINXY 4
# define DOUBLE 0
# define STRING 1
# define NOTHING 0
# define CONTEXT_OPENER 1
# define CONTEXT_CLOSER 2
# define DECLARATOR 3
# define PARAMETER 4
# define UNION 1
# define INTER 2
# define DIFF 3
# define NEXT 1
#endif

468
inc/rt_proto.h Normal file
View File

@ -0,0 +1,468 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rt_proto.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/09 18:33:58 by scebula #+# #+# */
/* Updated: 2017/01/09 20:37:07 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef RT_PROTO_H
# define RT_PROTO_H
/*
** Tools
*/
void swap_double(double *a, double *b);
/*
** Main function
*/
void raytracer(t_data *d);
/*
** Intersection computing
*/
void get_plane_n(t_ray ray, t_obj *obj,
t_thread *thread, double *dist);
void n_ray_plane(t_ray ray, t_obj *obj,
t_thread *thread, double *dist);
void get_sphere_n(t_ray ray, t_obj *obj,
t_thread *thread, double *dist);
void n_ray_sphere(t_ray ray, t_obj *obj,
t_thread *thread, double *dist);
void get_triangle_n(t_ray ray, t_obj *obj,
t_thread *thread, double *dist);
void n_ray_triangle(t_ray ray, t_obj *obj,
t_thread *thread, double *dist);
void get_cone_n(t_ray ray, t_obj *obj,
t_thread *thread, double *dist);
void n_ray_cone(t_ray ray, t_obj *obj,
t_thread *thread, double *dist);
void get_cylinder_n(t_ray ray, t_obj *obj,
t_thread *thread, double *dist);
void n_ray_cylinder(t_ray ray, t_obj *obj,
t_thread *thread, double *dist);
void get_cube_n(t_ray ray, t_obj *obj,
t_thread *thread, double *dist);
void n_ray_cube(t_ray ray, t_obj *obj,
t_thread *thread, double *dist);
void get_prism_n(t_ray ray, t_obj *obj,
t_thread *thread, double *dist);
void n_ray_prism(t_ray ray, t_obj *obj,
t_thread *thread, double *dist);
void get_paraboloid_n(t_ray ray, t_obj *obj,
t_thread *thread, double *dist);
void n_ray_paraboloid(t_ray ray, t_obj *obj,
t_thread *thread, double *dist);
void get_hyperboloid_n(t_ray ray, t_obj *obj,
t_thread *thread, double *dist);
void n_ray_hyperboloid(t_ray ray, t_obj *obj,
t_thread *thread, double *dist);
void get_csg_n(t_research *r, t_thread *thread, t_data *d);
t_solid *get_csg_solid(void *p);
/*
** Img init
*/
t_img *init_img(void *mlx, int length, int height);
void putpixel(int x, int y, unsigned int color, t_img *img);
t_texture *get_texture_data(t_data *d, char *path);
t_record *find_n(t_ray ray, t_data *d, t_thread *thread);
t_color *get_color_at(t_data *d, t_record *info);
t_color get_pixel_color(t_data *d, t_record *info, int type);
/*
** Free functions
*/
void free_env(t_env *e);
void free_prec_split(t_p_cache *cache);
void free_data(t_data *d);
t_img *free_img(void *mlx, t_img *img);
t_obj *free_obj(t_obj **begin_light_list);
t_sphere *free_sphere(t_sphere *sphere);
t_plane *free_plane(t_plane *plane);
t_triangle *free_triangle(t_triangle *triangle);
t_cylinder *free_cylinder(t_cylinder *cylinder);
t_cone *free_cone(t_cone *cone);
t_csg *free_csg(t_csg *csg);
void free_info(t_record *info);
t_tf_list *free_tf_list(t_tf_list **begin_tf_list);
t_light *free_light_list(t_light **begin_light_list);
t_func *free_functions(t_func *func);
void free_scene_list(t_scene *s);
void free_butt(t_butt *butt_lst);
t_cube *free_cube(t_cube *cube);
t_hyperboloid *free_hyperboloid(t_hyperboloid *hyperboloid);
t_paraboloid *free_paraboloid(t_paraboloid *paraboloid);
t_prism *free_prism(t_prism *prism);
t_csg *free_csg(t_csg *csg);
void free_texture(void *mlx, t_texture *begin_texture);
t_obj *free_cut(t_obj **begin_cut);
void select_free_obj(t_obj *tmp);
/*
** Color functions
*/
unsigned char moy(t_color color);
t_color set_color(int r, int g, int b);
void color_add(t_color *c1, t_color c2);
t_color copy_color(t_color color);
void color_divide(t_color *c, double d);
void color_multiply(t_color *c1, t_color c2);
void color_scale(t_color *color, double scalar);
void color_add_nolimit(t_color *c1, t_color c2);
int get_color(t_color color);
int get_obj_color(t_obj *obj);
t_ray calculate_ray(t_data *d, double x, double y, t_thread *thread);
void calculate_refl_ray(t_record *info);
void add_refls(t_data *d, t_record *info,
t_color *final_color);
void specular_color(t_record *info, t_color *final_color,
t_light *light_list);
void add_diffuse_and_specular(t_record *info, t_data *d,
t_light *light_list, t_color *final_color);
void ft_error(void);
void ft_malloc_error(void);
t_texture *texturegetter(char type, t_obj *obj);
t_texture *bumpmapgetter(char type, t_obj *obj);
char texmodifiergetter(char type, t_obj *obj);
double texscalex(char type, t_obj *obj, double in);
double texscaley(char type, t_obj *obj, double in);
double texoffx(char type, t_obj *obj, double in);
double texoffy(char type, t_obj *obj, double in);
/*
** Scenes create -> Init
*/
t_func *init_function(void);
t_cam init_cam(t_vect pos, t_vect dir);
void create_cam(t_cam *cam, t_data *d);
t_data *init_data(int argc, char **argv);
t_obj *create_default_obj(t_data *d);
void init_info_zero(t_record *info);
t_light *init_light();
void push_light(t_light **begin_light, t_light *light);
void create_default_lights(t_data *d);
t_solid *init_solid(void *obj, char type);
t_ray init_ray(t_vect ori, t_vect dir);
t_sphere *init_sphere(double rad);
void apply_color_sphere(t_sphere *sphere, t_color color,
double reflection, double shine);
t_obj *push_sphere(t_obj **begin_obj, t_sphere *sphere);
t_plane *init_plane(void);
t_obj *add_plane(t_plane *plane);
void apply_color_plane(t_plane *plane, t_color color,
double reflection, double shine);
t_obj *push_plane(t_obj **begin_obj, t_plane *plane);
t_plane *init_plane(void);
t_obj *push_plane(t_obj **begin_obj, t_plane *plane);
void apply_color_plane(t_plane *plane,
t_color color, double reflection, double shine);
t_cone *init_cone(double alpha);
t_obj *push_cone(t_obj **begin_obj, t_cone *cone);
void apply_color_cone(t_cone *cone,
t_color color, double reflection, double shine);
t_cylinder *init_cylinder(void);
t_obj *push_cylinder(t_obj **begin_obj, t_cylinder *cylinder);
void apply_color_cylinder(t_cylinder *cylinder,
t_color color, double reflection, double shine);
t_obj *add_triangle(t_triangle *triangle);
t_triangle *init_triangle(void);
t_triangle *init_tri_w_p(t_vect a, t_vect b, t_vect c);
void apply_color_triangle(t_triangle *triangle,
t_color color, double reflection, double shine);
t_triangle *compute_triangle(t_triangle *triangle);
t_vect compute_triangle_normal(t_triangle *t);
void calculate_sides(t_triangle *triangle);
t_obj *push_triangle(t_obj **begin_obj, t_triangle *triangle);
t_cube *init_cube(void);
t_cube *compute_cube(t_cube *cube);
t_obj *push_cube(t_obj **begin_obj, t_cube *cube);
t_prism *init_prism(void);
t_prism *compute_prism(t_prism *prism);
t_obj *push_prism(t_obj **begin_obj, t_prism *prism);
t_paraboloid *init_paraboloid(void);
t_obj *push_paraboloid(t_obj **begin_obj, t_paraboloid *paraboloid);
t_hyperboloid *init_hyperboloid(int sheets);
t_obj *push_hyperboloid(t_obj **begin_obj, t_hyperboloid *hyper);
t_csg *init_csg();
t_obj *push_csg(t_obj **begin_obj, t_csg *csg);
/*
** Matrix
*/
t_matrix init_xrotation_matrix(double theta);
t_matrix init_yrotation_matrix(double theta);
t_matrix init_zrotation_matrix(double theta);
t_matrix init_translation_matrix(double x, double y, double z);
t_matrix init_scale_matrix(double x, double y, double z);
t_matrix init_xyzrotation_matrix(double theta, double x,
double y, double z);
t_vect get_bumped_vect(t_vect normal, t_vect transformed);
void push_xrot_tf(t_tf_list **blist, double deg);
void push_yrot_tf(t_tf_list **blist, double deg);
void push_zrot_tf(t_tf_list **blist, double deg);
void push_trans_tf(t_tf_list **blist, double x, double y, double z);
void push_scale_tf(t_tf_list **blist, double x, double y, double z);
t_tf_list *add_xrot_tf(double deg);
t_tf_list *add_yrot_tf(double deg);
t_tf_list *add_zrot_tf(double deg);
t_tf_list *add_trans_tf(t_vect t);
t_tf_list *add_scale_tf(double x, double y, double z);
void apply_matrix(t_matrix matrix, t_vect *v);
t_matrix get_inverse_matrix(t_matrix m);
void apply_tf(t_obj *obj, t_vect *v, t_data *d, int type);
void apply_inverse_tf(t_obj *obj, t_vect *v, t_data *d);
/*
** Get object values
*/
void define_obj_color(t_record *info);
t_color get_plane_color(t_obj *obj);
t_color get_cylinder_color(t_obj *obj);
t_color get_sphere_color(t_obj *obj);
t_color get_cone_color(t_obj *obj);
t_color get_triangle_color(t_obj *obj);
t_color get_prism_color(t_obj *obj);
t_color get_cube_color(t_obj *obj);
t_color get_paraboloid_color(t_obj *obj);
t_color get_hyperboloid_color(t_obj *obj);
t_tf_list *get_cylinder_tf_list(t_obj *obj);
t_tf_list *get_sphere_tf_list(t_obj *obj);
t_tf_list *get_plane_tf_list(t_obj *obj);
t_tf_list *get_cone_tf_list(t_obj *obj);
t_tf_list *get_triangle_tf_list(t_obj *obj);
t_tf_list *get_prism_tf_list(t_obj *obj);
t_tf_list *get_cube_tf_list(t_obj *obj);
t_tf_list *get_paraboloid_tf_list(t_obj *obj);
t_tf_list *get_hyperboloid_tf_list(t_obj *obj);
t_vect define_obj_normal(t_record *info, t_data *d, t_thread *thread);
t_vect get_cylinder_normal(t_obj *obj, t_vect n, t_thread *thread);
t_vect get_sphere_normal(t_obj *obj, t_vect n, t_thread *thread);
t_vect get_plane_normal(t_obj *obj, t_vect n, t_thread *thread);
t_vect get_cone_normal(t_obj *obj, t_vect n, t_thread *thread);
t_vect get_triangle_normal(t_obj *obj, t_vect n, t_thread *thread);
t_vect get_prism_normal(t_obj *obj, t_vect n, t_thread *thread);
t_vect get_cube_normal(t_obj *obj, t_vect n, t_thread *thread);
t_vect get_paraboloid_normal(t_obj *obj, t_vect n, t_thread *thread);
t_vect get_hyperboloid_normal(t_obj *obj, t_vect n, t_thread *thread);
t_solid *get_cone_solid(void *p);
t_solid *get_sphere_solid(void *p);
t_solid *get_plane_solid(void *p);
t_solid *get_cylinder_solid(void *p);
t_solid *get_triangle_solid(void *p);
t_solid *get_prism_solid(void *p);
t_solid *get_cube_solid(void *p);
t_solid *get_paraboloid_solid(void *p);
t_solid *get_hyperboloid_solid(void *p);
t_solid *get_csg_solid(void *p);
/*
** Vector
*/
t_vect init_vector(double x, double y, double z, double w);
void negative_vector(t_vect *v);
double vector_magnitude(t_vect v);
void normalize_vector(t_vect *v);
void mult_vector(t_vect *v, double d);
void add_to_vector(t_vect *v1, t_vect v2);
double dot_product_vector(t_vect v1, t_vect v2);
t_vect cross_product_vector(t_vect v1, t_vect v2);
t_vect copy_vector(t_vect v);
void substract_to_vector(t_vect *v1, t_vect v2);
/*
** MLX
*/
int welcome_to_rt(t_env *e);
void remake(t_data *d);
void display_again(t_data *d);
void reload_env(t_env *e);
int ft_close_cross(t_env *e);
int events_key(int keycode, t_env *e);
int events_key_menu(int keycode, t_env *e);
int events_key_scene(int keycode, t_data *d);
int events_mouse(int button, int x, int y, t_env *e);
int events_mouse_menu(int button, int x, int y, t_env *e);
int events_mouse_scene(int button, int x, int y, t_data *d);
void event_mov_fwd(t_data *d);
void event_mov_bwd(t_data *d);
void event_mov_strafe_lft(t_data *d);
void event_mov_strafe_rgt(t_data *d);
void event_mov_dwn(t_data *d);
void event_mov_up(t_data *d);
void event_mov_look_left(t_data *d);
void event_mov_look_right(t_data *d);
void event_mov_look_up(t_data *d);
void event_mov_look_down(t_data *d);
void idostuff(t_data *d);
void add_eblouissement(t_data *d);
t_scene *get_scene_list(void);
void load_scenes(t_env *e);
void foreach_d_thumbnail(t_env *e);
void display_scenes(t_env *e);
void init_data_zero(t_data *d);
t_env *init_env(void);
void init_default_scene(t_env *e);
int select_scene(t_env *e, int k);
t_butt *init_butt(void);
int clic_scene(t_env *e, int x, int y);
void print_page_string(t_env *e);
char *get_scene_name(int nb, char *name);
/*
** POST PRO
*/
void **init_post_pro(void);
t_color img_get_hit(double x, double y, t_texture *tex, char alter);
t_color img_pull_pixel(int x, int y, t_img *img);
t_img *img_map_pixel(t_data *d, int (*f)(t_color));
void img_recolor(t_data *d, int (*f)(t_color));
int img_b_n_w(t_color c);
int img_sepia(t_color c);
int img_negative(t_color c);
void img_anaglyph(t_data *d);
void generate_scene(t_data *d, int argc, char **argv);
void ft_parsing_error(int linenbr, char *line, char *filename);
void lexer(int fd, char *filename);
void cache_init(t_p_cache *cache, char *filename);
/*
** Q
*/
void transform(t_tf_list **lst, char *param_name, char **params,
t_p_cache *cache);
void attributeboth(double *xa, double *ya, float xb, float yb);
int tf(char *lolilol, int line, t_p_cache *cache);
char isempty(char *str);
void parser(int fd, t_data *d, char *filename);
void manage_root_parameters(t_p_cache *cache, t_data *d);
void declarator_redirect(int fd, t_p_cache *cache,
t_obj **lst, t_obj **cut);
char line_identifier(t_p_cache *cache);
void populatesphere(int fd, t_p_cache *c, t_obj **lst);
void manage_sphere_params(t_p_cache *cache, t_sphere *sphere);
void populatecylinder(int fd, t_p_cache *c, t_obj **lst);
void manage_cylinder_params(t_p_cache *cache, t_cylinder *cylinder);
void populatecone(int fd, t_p_cache *cache, t_obj **lst);
void manage_cone_params(t_p_cache *cache, t_cone *cone);
void populateplane(int fd, t_p_cache *cache, t_obj **lst);
void manage_plane_params(t_p_cache *cache, t_plane *plane);
void populatetriangle(int fd, t_p_cache *cache, t_obj **lst);
void manage_triangle_params(t_p_cache *cache, t_triangle *triangle);
void populateprism(int fd, t_p_cache *cache, t_obj **lst);
void manage_prism_params(t_p_cache *cache, t_prism *prism);
void populatecube(int fd, t_p_cache *cache, t_obj **lst);
void manage_cube_params(t_p_cache *cache, t_cube *cube);
void populateparaboloid(int fd, t_p_cache *cache, t_obj **lst);
void manage_paraboloid_params(t_p_cache *cache,
t_paraboloid *paraboloid);
void populatehyperboloid(int fd, t_p_cache *cache, t_obj **lst);
void manage_hyperboloid_params(t_p_cache *cache,
t_hyperboloid *hyperboloid);
void populatelight(int fd, t_p_cache *cache, t_light **lst);
void manage_light_params(t_p_cache *cache, t_light *light);
void populatecsg(int fd, t_p_cache *cache, t_obj **lst,
char booleantype);
void disect_param(char *str, char **param, char ***args);
char chk(char **params, int n,
int (*f)(char *, int, struct s_p_cache *), t_p_cache *cache);
void populatecamera(int fd, t_p_cache *cache);
void manage_camera_params(t_p_cache *cache, t_cam *cam);
int parsetest_vector(char *line, int linenbr, t_p_cache *cache);
t_vect get_bumped_vect(t_vect normal, t_vect transformed);
int one_double_required(char *name);
int three_double_required(char *name);
int accepted_types(char *str, int scope);
/*
** CUT OBJECTS
*/
void save_dist(t_research *r, t_cut *cut, t_thread *thread);
void select_negative_case(t_research *r, t_cut *cut);
void select_positive_case(t_research *r, t_cut *cut);
void select_special_case(t_research *r, t_cut *cut);
void save_negative_plane(t_research *r, t_cut *cut);
void save_positive_plane(t_research *r, t_cut *cut);
void save_cutted_object(t_research *r, t_cut *cut);
void save_nothing(t_research *r, t_cut *cut);
int keep_plane(t_cut *cut);
int keep_nothing(t_research *r, t_cut *cut);
int research_in_cone(t_research *r, t_cut *cut);
int research_in_others(t_research *r, t_cut *cut);
void init_cut_condition_cone(t_research *r, t_cut *cut);
void init_cut_condition_others(t_research *r, t_cut *cut);
void if_plane_cut_an_object(t_data *d, t_record *info,
t_thread *thread);
void init_var(t_research *r, t_ray ray);
t_vect find_n_pos(t_ray ray, t_record *info);
void find_n_dist(t_research *r, t_data *d, t_thread *thread);
void check_cut(t_research *r, t_data *d, t_thread *thread);
void init_csg_data(t_csg_data *c_data, t_research *r);
void init_conditions_diff(t_research *r, double *p, double *n,
int type);
int check_diff(t_research *r, t_research *rp, t_research *rn);
int check_inter(t_research *r, t_research *rp, t_research *rn);
int check_add(t_research *r, t_research *rp, t_research *rn);
/*
** DEBUG
*/
void print_data(t_data *d);
void vector_state(t_vect v, char *s);
void init_default_csg(t_data *d);
void print_objects(t_data *d);
#endif

472
inc/rt_structs.h Normal file
View File

@ -0,0 +1,472 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rt_structs.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/11 12:12:16 by scebula #+# #+# */
/* Updated: 2017/01/11 13:03:04 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef RT_STRUCTS_H
# define RT_STRUCTS_H
typedef struct s_matrix
{
char type;
double m11;
double m12;
double m13;
double m14;
double m21;
double m22;
double m23;
double m24;
double m31;
double m32;
double m33;
double m34;
double m41;
double m42;
double m43;
double m44;
} t_matrix;
typedef struct s_img
{
char *data;
int sl;
int endian;
int bpp;
void *img;
int x;
int y;
} t_img;
typedef struct s_texture
{
t_img img;
struct s_texture *next;
char *path;
} t_texture;
typedef struct s_tf_list
{
t_matrix tf;
struct s_tf_list *previous;
struct s_tf_list *next;
char type;
} t_tf_list;
typedef struct s_vect
{
double x;
double y;
double z;
double w;
} t_vect;
typedef struct s_ray
{
t_vect ori;
t_vect dir;
} t_ray;
typedef struct s_cam
{
t_vect pos;
t_vect dir;
t_vect first_pixel_dir;
double cam_plane_dist;
double plane_height;
double plane_width;
t_vect left;
t_vect up;
} t_cam;
typedef struct s_color
{
int r;
int g;
int b;
} t_color;
typedef struct s_light
{
t_vect pos;
t_color color;
struct s_light *next;
} t_light;
typedef struct s_plane
{
t_color color;
t_tf_list *tf_list;
double reflection;
double shine;
double off_x;
double off_y;
double scale_x;
double scale_y;
double dist;
t_vect normal;
t_texture *texture;
char texmodifier;
t_texture *bumpmap;
struct s_obj *cut;
struct s_obj **cutted_obj;
int cut_type;
} t_plane;
typedef struct s_triangle
{
t_color color;
t_tf_list *tf_list;
double reflection;
double shine;
t_vect normal;
double distance;
t_vect a;
t_vect b;
t_vect c;
t_vect ab;
t_vect ac;
t_vect ba;
t_vect bc;
t_vect cb;
t_vect ca;
t_texture *texture;
t_texture *bumpmap;
struct s_obj *cut;
} t_triangle;
typedef struct s_prism
{
struct s_obj **triangle;
t_vect a;
t_vect b;
t_vect c;
t_vect d;
t_tf_list *tf_list;
int *closest_triangle;
t_color color;
double reflection;
double shine;
t_texture *texture;
t_texture *bumpmap;
struct s_obj *cut;
} t_prism;
typedef struct s_cube
{
struct s_obj **triangle;
t_vect corner1;
t_vect corner2;
t_tf_list *tf_list;
int *closest_triangle;
t_color color;
double reflection;
double shine;
t_texture *texture;
t_texture *bumpmap;
struct s_obj *cut;
} t_cube;
typedef struct s_sphere
{
t_color color;
t_tf_list *tf_list;
double reflection;
double shine;
double off_x;
double off_y;
double scale_x;
double scale_y;
double radius;
t_texture *texture;
char texmodifier;
t_texture *bumpmap;
struct s_obj *cut;
} t_sphere;
typedef struct s_cylinder
{
t_color color;
t_tf_list *tf_list;
double reflection;
double shine;
double off_x;
double off_y;
double scale_x;
double scale_y;
double radius;
t_texture *texture;
char texmodifier;
t_texture *bumpmap;
struct s_obj *cut;
} t_cylinder;
typedef struct s_cone
{
t_color color;
t_tf_list *tf_list;
double reflection;
double shine;
double off_x;
double off_y;
double scale_x;
double scale_y;
double tan_alpha;
t_texture *texture;
char texmodifier;
t_texture *bumpmap;
struct s_obj *cut;
} t_cone;
typedef struct s_paraboloid
{
t_color color;
t_tf_list *tf_list;
double reflection;
double shine;
double off_x;
double off_y;
double scale_x;
double scale_y;
t_texture *texture;
char texmodifier;
t_texture *bumpmap;
struct s_obj *cut;
} t_paraboloid;
typedef struct s_hyperboloid
{
t_color color;
t_tf_list *tf_list;
double reflection;
double shine;
double off_x;
double off_y;
double scale_x;
double scale_y;
int sheets;
t_texture *texture;
char texmodifier;
t_texture *bumpmap;
struct s_obj *cut;
} t_hyperboloid;
typedef struct s_csg
{
struct s_obj *first;
struct s_obj *second;
int operation;
} t_csg;
typedef union u_solid
{
t_sphere *sphere;
t_plane *plane;
t_cylinder *cylinder;
t_cone *cone;
t_triangle *triangle;
t_prism *prism;
t_cube *cube;
t_paraboloid *paraboloid;
t_hyperboloid *hyperboloid;
t_csg *csg;
} t_solid;
typedef struct s_obj
{
int type;
double *reflectionx;
double *shinex;
t_solid *solid;
struct s_obj *cut;
struct s_obj *next;
} t_obj;
typedef struct s_csg_condition
{
int in_neg;
int in_pos;
int neg_behind;
int neg_front;
int out;
int in;
int c1;
int c2;
int c3;
int c4;
int c5;
int c6;
int p1;
int p2;
int p3;
} t_csg_condition;
typedef struct s_csg_data
{
t_obj *one;
t_obj *two;
t_ray default_ray;
t_ray ray_one;
t_ray ray_two;
double p[3];
double n[3];
} t_csg_data;
typedef struct s_research
{
t_csg_condition c;
t_obj *current_obj;
t_obj *closest_obj;
double dist[3];
double final_dist;
t_ray modified_ray;
t_ray final_ray;
} t_research;
typedef struct s_record
{
t_vect n_pos;
t_vect refl_dir;
t_vect to_light_dir;
t_ray refl_ray;
t_ray to_light_ray;
t_ray ray;
t_vect normal;
float dist_to_light;
double cosinus;
double dist;
int type;
t_thread *current_thread;
t_obj *obj;
t_color color;
t_vect oldnorm;
} t_record;
typedef struct s_cut_condition
{
int c1;
int c2;
int c3;
int c4;
int c5;
int c6;
int p1;
int p2;
int p3;
int in;
int f;
int b;
} t_cut_condition;
typedef struct s_cut
{
double plane[3];
double final_dist;
double dot;
t_ray object_ray;
t_ray modified_ray;
t_obj *current_obj;
t_obj *cutted_obj;
double final_dist_p;
t_obj *closest_negative;
t_ray closest_negative_ray;
double final_dist_n;
t_obj *closest_positive;
t_ray closest_positive_ray;
t_cut_condition c;
t_cut_condition c_p;
t_cut_condition c_n;
} t_cut;
typedef struct s_func
{
void **get_obj_tf_list;
void **get_obj_normal;
void **get_obj_color;
void **get_obj_n;
void **post_pro;
} t_func;
typedef struct s_data
{
int height;
int width;
void *mlx;
void *win;
t_img *img;
t_obj *obj;
t_func *func;
t_cam cam;
t_light *light_list;
t_texture *texturelist;
double x;
double y;
double aa_lvl;
double dpp;
char reflections;
int tld;
float ambient;
t_thread th[8];
} t_data;
typedef struct s_p_cache
{
t_data *d;
char scope;
int pos;
int linelen;
char *line;
char prec;
char *filename;
char *param_name;
char **params;
} t_p_cache;
typedef struct s_scene
{
char *name;
t_data *d;
struct s_scene *next;
} t_scene;
typedef struct s_butt
{
int xmin;
int xmax;
int ymin;
int ymax;
int moon;
struct s_butt *next;
} t_butt;
typedef struct s_env
{
void *mlx;
void *win;
void *img_wel;
void *img_bg;
void *img_cmd;
void *img_loading;
void *img_rendering;
t_scene *lst_scene;
t_data *current_scene;
int page;
int page_m;
int lst_size;
int in_menu;
t_butt *butt_lst;
int w;
int h;
int rendering;
int loading;
int cmd;
} t_env;
#endif

26
inc/threads.h Normal file
View File

@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* threads.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ntrahy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/03 02:12:34 by ntrahy #+# #+# */
/* Updated: 2017/01/03 02:12:36 by ntrahy ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef THREADS_H
# define THREADS_H
# include <pthread.h>
typedef struct s_data t_data;
typedef struct s_thread
{
int num;
pthread_t t;
t_data *d;
double x;
double y;
} t_thread;
#endif

119
libft/Makefile Normal file
View File

@ -0,0 +1,119 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: scebula <scebula@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2015/11/27 16:07:00 by scebula #+# #+# #
# Updated: 2016/11/18 14:30:15 by ntrahy ### ########.fr #
# #
# **************************************************************************** #
SRCS = ./ft_atoi.c \
./ft_atof.c \
./ft_bzero.c \
./ft_free_charchar.c \
./get_next_line.c \
./ft_isalnum.c \
./ft_isalpha.c \
./ft_isascii.c \
./ft_isdigit.c \
./ft_isdigits.c \
./ft_isprint.c \
./ft_isspace.c \
./ft_itoa.c \
./ft_itoa_base.c \
./ft_list_clear.c \
./ft_listlen.c \
./ft_lst_pushback.c \
./ft_lstadd.c \
./ft_lstdel.c \
./ft_lstdelone.c \
./ft_lstiter.c \
./ft_lstmap.c \
./ft_lstnew.c \
./ft_memalloc.c \
./ft_memccpy.c \
./ft_memchr.c \
./ft_memcmp.c \
./ft_memcpy.c \
./ft_memdel.c \
./ft_memmove.c \
./ft_memset.c \
./ft_printlst.c \
./ft_putchar.c \
./ft_putchar_fd.c \
./ft_putendl.c \
./ft_putendl_fd.c \
./ft_putnbr.c \
./ft_putnbr_fd.c \
./ft_putstr.c \
./ft_putstr_fd.c \
./ft_strcat.c \
./ft_strcat_new.c \
./ft_strchr.c \
./ft_strclr.c \
./ft_strcmp.c \
./ft_strcpy.c \
./ft_strdel.c \
./ft_strdup.c \
./ft_strequ.c \
./ft_striter.c \
./ft_striteri.c \
./ft_strjoin.c \
./ft_strlcat.c \
./ft_strlen.c \
./ft_strmap.c \
./ft_strmapi.c \
./ft_strncat.c \
./ft_strncmp.c \
./ft_strncpy.c \
./ft_strndup.c \
./ft_strnequ.c \
./ft_strnew.c \
./ft_strnstr.c \
./ft_strrchr.c \
./ft_strrchr_n.c \
./ft_strrev.c \
./ft_strsplit.c \
./ft_strsplit_lst.c \
./ft_strsplit_whitespaces.c \
./ft_strstr.c \
./ft_strsub.c \
./ft_strtrim.c \
./ft_tablen.c \
./ft_tolower.c \
./ft_toupper.c \
./ft_isnumeric.c
CFLAGS = -Wall -Werror -Wextra
CC = gcc
INCLUDES = includes/
O_FILES = $(SRCS:.c=.o)
%.o: %.c
@gcc $(CFLAGS) -I $(INCLUDES) -o $@ -c $^
NAME = libft.a
all: $(NAME)
$(NAME): $(O_FILES)
@ar cr $(NAME) $(O_FILES)
@ranlib $(NAME)
@echo "[libft compiled]"
clean:
@rm -f $(O_FILES)
@echo "libft .o deleted"
fclean: clean
@rm -f $(NAME)
@echo "libft.a deleted"
re: fclean all

42
libft/ft_atof.c Normal file
View File

@ -0,0 +1,42 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atof.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: qviguier <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/03/11 18:10:24 by qviguier #+# #+# */
/* Updated: 2017/01/10 18:26:45 by ntrahy ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
float ft_atof(char *str)
{
float rez[2];
int dot_seen;
rez[0] = 0;
rez[1] = 1;
dot_seen = 0;
while (*str == ' ')
str++;
if (*str == '-' || *str == '+')
rez[1] *= *(str) == '-' ? -1 : 1;
if (*str == '-' || *str == '+')
str++;
while ((ft_isdigit(*str) || *str == '.') && *str != '\0')
{
if (dot_seen == 0 && *str == '.')
dot_seen = 1;
else if (ft_isdigit(*str))
{
if (dot_seen)
rez[1] /= 10.0f;
rez[0] = rez[0] * 10.0f + (float)(*str - '0');
}
str++;
}
return (rez[0] * rez[1]);
}

39
libft/ft_atoi.c Normal file
View File

@ -0,0 +1,39 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atoi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 09:47:14 by scebula #+# #+# */
/* Updated: 2015/12/04 00:21:47 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_atoi(const char *str)
{
int n;
int sign;
sign = 1;
n = 0;
while (ft_isspace(*str))
str++;
if (*str == '-')
{
sign = -1;
str++;
}
else if (*str == '+')
{
str++;
}
while (*str && ft_isdigit(*str))
{
n = n * 10 + (*str - '0');
str++;
}
return (n * sign);
}

18
libft/ft_bzero.c Normal file
View File

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_bzero.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/24 16:34:34 by scebula #+# #+# */
/* Updated: 2015/11/30 01:27:31 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_bzero(void *s, size_t n)
{
ft_memset(s, 0, n);
}

25
libft/ft_free_charchar.c Normal file
View File

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_free_charchar.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/30 02:48:08 by scebula #+# #+# */
/* Updated: 2015/11/30 02:55:41 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_free_charchar(char **tab)
{
size_t i;
i = 0;
while (tab[i] != NULL)
{
free(tab[i]);
i++;
}
}

18
libft/ft_isalnum.c Normal file
View File

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isalnum.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 10:09:08 by scebula #+# #+# */
/* Updated: 2015/11/26 10:12:23 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isalnum(int c)
{
return (ft_isdigit(c) || ft_isalpha(c));
}

18
libft/ft_isalpha.c Normal file
View File

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isalpha.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 09:53:04 by scebula #+# #+# */
/* Updated: 2015/11/26 09:54:06 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isalpha(int c)
{
return (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'));
}

18
libft/ft_isascii.c Normal file
View File

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isascii.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 10:14:02 by scebula #+# #+# */
/* Updated: 2015/11/26 10:15:19 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isascii(int c)
{
return (0 <= c && c <= 127);
}

18
libft/ft_isdigit.c Normal file
View File

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isdigit.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 09:56:25 by scebula #+# #+# */
/* Updated: 2016/04/27 14:19:35 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isdigit(int c)
{
return ('0' <= c && c <= '9');
}

27
libft/ft_isdigits.c Normal file
View File

@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isdigits.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/04/26 21:54:11 by scebula #+# #+# */
/* Updated: 2016/04/26 21:54:38 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char ft_isdigits(char *s)
{
int i;
i = 0;
while (s[i])
{
if (!ft_isdigit(s[i]))
return (0);
i++;
}
return (1);
}

20
libft/ft_isnumeric.c Normal file
View File

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isnumeric.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ntrahy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/09 18:25:11 by ntrahy #+# #+# */
/* Updated: 2017/01/09 18:25:39 by ntrahy ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isnumeric(int c)
{
if (c == '+' || c == '-' || c == '.')
return (1);
return (ft_isdigit(c));
}

18
libft/ft_isprint.c Normal file
View File

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isprint.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 10:15:50 by scebula #+# #+# */
/* Updated: 2015/11/26 10:16:19 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isprint(int c)
{
return (32 <= c && c <= 126);
}

19
libft/ft_isspace.c Normal file
View File

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isspace.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 09:43:41 by scebula #+# #+# */
/* Updated: 2015/11/26 09:45:49 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isspace(int c)
{
return (c == ' ' || c == '\n' || c == '\v'
|| c == '\f' || c == '\r' || c == '\t');
}

22
libft/ft_itoa.c Normal file
View File

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_itoa.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ntrahy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/25 17:56:12 by ntrahy #+# #+# */
/* Updated: 2016/01/28 13:55:55 by ntrahy ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_itoa(int n)
{
char *s;
if (!(s = ft_itoa_base(n, 10)))
return (NULL);
return (s);
}

37
libft/ft_itoa_base.c Normal file
View File

@ -0,0 +1,37 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_itoa_base.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ntrahy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/01/28 13:50:02 by ntrahy #+# #+# */
/* Updated: 2016/11/18 14:35:11 by ntrahy ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_itoa_base(int nb, int base)
{
char *s;
char *mem;
int neg;
if (!(s = ft_strnew(35)) || base < 2 || base > 16)
return (NULL);
mem = s;
neg = (nb < 0);
if (!nb)
*s = '0';
while (nb != 0)
{
*s = "0123456789ABCDEF"[(nb % base) * (neg ? -1 : 1)];
nb /= base;
s++;
}
if (neg)
*s = '-';
ft_strrev(mem);
return (mem);
}

34
libft/ft_list_clear.c Normal file
View File

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_list_clear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/02/16 20:34:53 by scebula #+# #+# */
/* Updated: 2016/02/16 20:34:55 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_list_clear(t_list **begin_list)
{
t_list *tmp;
t_list *list;
list = *begin_list;
tmp = NULL;
while (list)
{
if (list->next)
tmp = list->next;
else
tmp = NULL;
free(list->content);
list->content = NULL;
list->next = NULL;
free(list);
list = tmp;
}
}

28
libft/ft_listlen.c Normal file
View File

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_listlen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/04/26 21:52:57 by scebula #+# #+# */
/* Updated: 2016/04/26 21:53:44 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_listlen(t_list *list)
{
t_list *l;
size_t i;
i = 0;
l = list;
while (l)
{
i++;
l = l->next;
}
return (i);
}

28
libft/ft_lst_pushback.c Normal file
View File

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lst_pushback.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/30 03:51:59 by scebula #+# #+# */
/* Updated: 2015/11/30 03:57:41 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lst_pushback(t_list **begin_list, void *content, size_t content_size)
{
t_list *list;
list = *begin_list;
if (list)
{
while (list->next)
list = list->next;
list->next = ft_lstnew(content, content_size);
}
else
*begin_list = ft_lstnew(content, content_size);
}

19
libft/ft_lstadd.c Normal file
View File

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstadd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 13:13:20 by scebula #+# #+# */
/* Updated: 2015/11/28 02:30:13 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstadd(t_list **alst, t_list *new)
{
new->next = *alst;
*alst = new;
}

28
libft/ft_lstdel.c Normal file
View File

@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstdel.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 13:10:34 by scebula #+# #+# */
/* Updated: 2015/11/26 13:12:44 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstdel(t_list **alst, void (*del)(void*, size_t))
{
t_list *robin;
t_list *batman;
batman = *alst;
while (batman != NULL)
{
robin = batman->next;
ft_lstdelone(&batman, del);
batman = robin;
}
*alst = NULL;
}

20
libft/ft_lstdelone.c Normal file
View File

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstdelone.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 13:08:42 by scebula #+# #+# */
/* Updated: 2015/11/26 13:09:18 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstdelone(t_list **alst, void (*del)(void*, size_t))
{
del((*alst)->content, (*alst)->content_size);
free(*alst);
*alst = NULL;
}

24
libft/ft_lstiter.c Normal file
View File

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstiter.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 13:18:10 by scebula #+# #+# */
/* Updated: 2015/12/03 23:44:37 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstiter(t_list *lst, void (*f)(t_list *))
{
f(lst);
lst = lst->next;
while (lst != NULL)
{
f(lst);
lst = lst->next;
}
}

34
libft/ft_lstmap.c Normal file
View File

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 13:20:43 by scebula #+# #+# */
/* Updated: 2015/12/04 00:07:45 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstmap(t_list *lst, t_list *(*f)(t_list *elem))
{
t_list *first_element;
t_list *next_element;
t_list *previous_element;
first_element = NULL;
first_element = f(lst);
previous_element = first_element;
lst = lst->next;
while (lst)
{
next_element = f(lst);
previous_element->next = next_element;
previous_element = next_element;
lst = lst->next;
}
previous_element->next = NULL;
return (first_element);
}

40
libft/ft_lstnew.c Normal file
View File

@ -0,0 +1,40 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 12:48:01 by scebula #+# #+# */
/* Updated: 2016/04/26 16:07:11 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstnew(void const *content, size_t content_size)
{
t_list *new;
new = (t_list*)malloc(sizeof(t_list));
if (new == NULL)
return (NULL);
if (content == NULL)
{
new->content = NULL;
new->content_size = 0;
}
else
{
new->content = malloc(content_size);
if (new->content == NULL)
{
free(new);
return (NULL);
}
ft_memcpy(new->content, content, content_size);
new->content_size = content_size;
}
new->next = NULL;
return (new);
}

26
libft/ft_memalloc.c Normal file
View File

@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memalloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 10:23:27 by scebula #+# #+# */
/* Updated: 2017/01/09 20:23:38 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memalloc(size_t size)
{
void *p;
p = malloc(size);
if (p == NULL)
{
exit(-1);
}
else
return (ft_memset(p, 0, size));
}

34
libft/ft_memccpy.c Normal file
View File

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/24 17:04:25 by scebula #+# #+# */
/* Updated: 2015/11/27 20:56:04 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *dest, const void *src, int c, size_t n)
{
char *source;
char *desti;
source = (char *)src;
desti = (char *)dest;
while (n > 0 && *source != c)
{
*desti++ = *source++;
n--;
}
if (n > 0)
{
*desti = *source;
desti++;
return ((void*)desti);
}
return (NULL);
}

29
libft/ft_memchr.c Normal file
View File

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/24 19:51:45 by scebula #+# #+# */
/* Updated: 2015/11/30 01:19:27 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *s, int c, size_t n)
{
unsigned char *src;
src = (unsigned char*)s;
while (n > 0 && *src != (unsigned char)c)
{
src++;
n--;
}
if (n == 0)
return (NULL);
else
return ((void*)src);
}

32
libft/ft_memcmp.c Normal file
View File

@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/24 20:13:47 by scebula #+# #+# */
/* Updated: 2015/11/24 20:19:34 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
{
unsigned char *a;
unsigned char *b;
a = (unsigned char *)s1;
b = (unsigned char *)s2;
while (n > 0 && *a == *b)
{
a++;
b++;
n--;
}
if (n == 0)
return (0);
else
return (*a - *b);
}

30
libft/ft_memcpy.c Normal file
View File

@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/24 16:48:35 by scebula #+# #+# */
/* Updated: 2015/12/04 00:25:07 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memcpy(void *dst, const void *src, size_t n)
{
char *source;
char *desti;
source = (char *)src;
desti = (char *)dst;
while (n > 0)
{
*desti = *source;
desti++;
source++;
n--;
}
return (dst);
}

19
libft/ft_memdel.c Normal file
View File

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memdel.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 10:26:10 by scebula #+# #+# */
/* Updated: 2015/11/26 10:26:37 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_memdel(void **ap)
{
free(*ap);
*ap = NULL;
}

33
libft/ft_memmove.c Normal file
View File

@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/24 17:37:47 by scebula #+# #+# */
/* Updated: 2015/12/04 00:26:22 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t len)
{
char *desti;
char *source;
desti = (char*)dst;
source = (char*)src;
if (source <= desti)
{
while (len > 0)
{
*(desti + len - 1) = *(source + len - 1);
len--;
}
}
else
ft_memcpy(desti, source, len);
return (dst);
}

27
libft/ft_memset.c Normal file
View File

@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* memset.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/23 16:17:13 by scebula #+# #+# */
/* Updated: 2015/12/04 00:23:59 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memset(void *b, int c, size_t n)
{
unsigned char *p;
p = (unsigned char *)b;
while (n > 0)
{
*p = (unsigned char)c;
n--;
p++;
}
return (b);
}

26
libft/ft_printlst.c Normal file
View File

@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printlst.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/12/03 20:43:58 by scebula #+# #+# */
/* Updated: 2015/12/03 20:47:27 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_printlst(t_list *list)
{
t_list *l;
l = list;
while (l)
{
ft_putstr(l->content);
ft_putchar('\n');
l = l->next;
}
}

18
libft/ft_putchar.c Normal file
View File

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putchar.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 12:03:12 by scebula #+# #+# */
/* Updated: 2015/11/26 12:06:37 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putchar(char c)
{
write(1, &c, 1);
}

18
libft/ft_putchar_fd.c Normal file
View File

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putchar_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 12:07:59 by scebula #+# #+# */
/* Updated: 2015/11/26 12:08:32 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putchar_fd(char c, int fd)
{
write(fd, &c, 1);
}

19
libft/ft_putendl.c Normal file
View File

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putendl.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 12:13:28 by scebula #+# #+# */
/* Updated: 2015/11/27 22:58:54 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putendl(char const *s)
{
write(1, s, ft_strlen(s));
ft_putchar('\n');
}

19
libft/ft_putendl_fd.c Normal file
View File

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putendl_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 12:40:02 by scebula #+# #+# */
/* Updated: 2015/11/26 12:40:47 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putendl_fd(char const *s, int fd)
{
ft_putstr_fd(s, fd);
ft_putchar_fd('\n', fd);
}

34
libft/ft_putnbr.c Normal file
View File

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 12:42:01 by scebula #+# #+# */
/* Updated: 2015/11/30 01:20:12 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putnbr(int n)
{
if (n == -2147483648)
ft_putstr("-2147483648");
else
{
if (n < 0)
{
ft_putchar('-');
n = -n;
}
if (n >= 10)
{
ft_putnbr(n / 10);
ft_putnbr(n % 10);
}
else
ft_putchar(n + '0');
}
}

34
libft/ft_putnbr_fd.c Normal file
View File

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putnbr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 12:43:46 by scebula #+# #+# */
/* Updated: 2015/11/30 01:20:38 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putnbr_fd(int n, int fd)
{
if (n == -2147483648)
ft_putstr_fd("-2147483648", fd);
else
{
if (n < 0)
{
ft_putchar_fd('-', fd);
n = -n;
}
if (n >= 10)
{
ft_putnbr_fd(n / 10, fd);
ft_putnbr_fd(n % 10, fd);
}
else
ft_putchar_fd(n + '0', fd);
}
}

18
libft/ft_putstr.c Normal file
View File

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 12:09:22 by scebula #+# #+# */
/* Updated: 2015/11/26 12:10:09 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putstr(char const *s)
{
write(1, s, ft_strlen(s));
}

18
libft/ft_putstr_fd.c Normal file
View File

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putstr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 12:11:51 by scebula #+# #+# */
/* Updated: 2015/11/26 13:27:36 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putstr_fd(char const *s, int fd)
{
write(fd, s, ft_strlen(s));
}

34
libft/ft_strcat.c Normal file
View File

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/24 21:33:24 by scebula #+# #+# */
/* Updated: 2015/12/04 00:34:17 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strcat(char *s1, const char *s2)
{
char *dest;
char *src;
dest = s1;
src = (char*)s2;
if (!*src)
return (s1);
while (*dest)
dest++;
while (*src)
{
*dest = *src;
dest++;
src++;
}
*dest = '\0';
return (s1);
}

39
libft/ft_strcat_new.c Normal file
View File

@ -0,0 +1,39 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcat_new.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/07/25 16:30:30 by scebula #+# #+# */
/* Updated: 2016/07/25 16:31:23 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strcat_new(char *s1, const char *s2)
{
char *str;
int a;
int b;
int i;
i = 0;
a = ft_strlen(s1);
b = ft_strlen(s2);
str = (char *)malloc(sizeof(char) * (a + b + 1));
while (s1[i])
{
*(str + i) = s1[i];
i++;
}
i = 0;
while (s2[i])
{
*(str + a + i) = s2[i];
i++;
}
str[a + b] = '\0';
return (str);
}

23
libft/ft_strchr.c Normal file
View File

@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 09:10:36 by scebula #+# #+# */
/* Updated: 2015/11/26 09:22:12 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strchr(const char *s, int c)
{
while (*s && *s != (char)c)
s++;
if (*s == (char)c)
return (char *)s;
else
return (NULL);
}

22
libft/ft_strclr.c Normal file
View File

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strclr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 10:33:01 by scebula #+# #+# */
/* Updated: 2015/12/04 00:56:32 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_strclr(char *s)
{
while (*s)
{
*s = '\0';
s++;
}
}

23
libft/ft_strcmp.c Normal file
View File

@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 09:30:45 by scebula #+# #+# */
/* Updated: 2015/11/27 19:43:01 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strcmp(const char *s1, const char *s2)
{
while (*s1 && *s1 == *s2)
{
s1++;
s2++;
}
return ((unsigned char)*s1 - (unsigned char)*s2);
}

27
libft/ft_strcpy.c Normal file
View File

@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/24 21:05:14 by scebula #+# #+# */
/* Updated: 2015/12/04 00:29:51 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strcpy(char *dst, const char *src)
{
int i;
i = 0;
while (src[i])
{
dst[i] = src[i];
i++;
}
dst[i] = '\0';
return (dst);
}

18
libft/ft_strdel.c Normal file
View File

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdel.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 10:31:16 by scebula #+# #+# */
/* Updated: 2015/12/04 00:56:41 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_strdel(char **as)
{
ft_memdel((void**)as);
}

35
libft/ft_strdup.c Normal file
View File

@ -0,0 +1,35 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/24 20:46:25 by scebula #+# #+# */
/* Updated: 2015/12/04 00:28:12 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s1)
{
int l;
int i;
char *str;
i = 0;
if (!s1)
return (NULL);
l = ft_strlen(s1);
str = (char *)malloc(sizeof(char) * (l + 1));
if (str == NULL)
return (NULL);
while (i < l)
{
str[i] = s1[i];
i++;
}
str[i] = '\0';
return (str);
}

20
libft/ft_strequ.c Normal file
View File

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strequ.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 10:53:27 by scebula #+# #+# */
/* Updated: 2015/11/26 10:54:39 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strequ(char const *s1, char const *s2)
{
if (ft_strcmp(s1, s2) == 0)
return (1);
return (0);
}

22
libft/ft_striter.c Normal file
View File

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_striter.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 10:38:31 by scebula #+# #+# */
/* Updated: 2015/12/03 21:49:48 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_striter(char *s, void (*f)(char *))
{
while (*s)
{
f(s);
s++;
}
}

25
libft/ft_striteri.c Normal file
View File

@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_striteri.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 10:40:23 by scebula #+# #+# */
/* Updated: 2015/11/26 10:41:03 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_striteri(char *s, void (*f)(unsigned int, char *))
{
unsigned int i;
i = 0;
while (s[i])
{
f(i, &s[i]);
i++;
}
}

34
libft/ft_strjoin.c Normal file
View File

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 11:00:52 by scebula #+# #+# */
/* Updated: 2015/12/04 00:57:09 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)
{
char *str;
char *start;
str = ft_strnew(ft_strlen(s1) + ft_strlen(s2));
start = str;
if (str == NULL)
return (NULL);
while (*s1)
{
*str++ = *(char *)s1++;
}
while (*s2)
{
*str++ = *(char *)s2++;
}
*str = '\0';
return (start);
}

41
libft/ft_strlcat.c Normal file
View File

@ -0,0 +1,41 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/24 21:58:06 by scebula #+# #+# */
/* Updated: 2015/12/03 22:20:35 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcat(char *dst, const char *src, size_t size)
{
int i;
size_t dstlen;
size_t srclen;
dstlen = ft_strlen(dst);
srclen = ft_strlen(src);
if (size < dstlen)
return (size + srclen);
i = (int)size;
while (*dst && i >= 0)
{
dst++;
i--;
}
while (*src && i-- > 1)
*dst++ = *src++;
if (i == 1)
*dst++ = '\0';
while (*dst)
{
*dst = '\0';
dst++;
}
return (srclen + dstlen);
}

23
libft/ft_strlen.c Normal file
View File

@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/24 20:28:30 by scebula #+# #+# */
/* Updated: 2015/11/24 20:42:18 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlen(const char *s)
{
size_t i;
i = 0;
while (*s++)
i++;
return (i);
}

30
libft/ft_strmap.c Normal file
View File

@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 10:43:35 by scebula #+# #+# */
/* Updated: 2015/11/26 10:51:04 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmap(char const *s, char (*f)(char))
{
char *str;
unsigned int i;
str = ft_strnew(ft_strlen(s));
if (str == NULL)
return (NULL);
i = 0;
while (s[i])
{
str[i] = f(s[i]);
i++;
}
return (str);
}

30
libft/ft_strmapi.c Normal file
View File

@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmapi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 10:48:03 by scebula #+# #+# */
/* Updated: 2015/11/26 10:51:51 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
{
char *str;
unsigned int i;
str = ft_strnew(ft_strlen(s));
if (str == NULL)
return (NULL);
i = 0;
while (s[i])
{
str[i] = f(i, s[i]);
i++;
}
return (str);
}

35
libft/ft_strncat.c Normal file
View File

@ -0,0 +1,35 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/24 21:49:21 by scebula #+# #+# */
/* Updated: 2015/12/04 00:46:06 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strncat(char *s1, const char *s2, size_t n)
{
char *dest;
char *src;
dest = s1;
src = (char*)s2;
if (!*src)
return (s1);
while (*dest)
dest++;
while (*src && n > 0)
{
*dest = *src;
dest++;
src++;
n--;
}
*dest = '\0';
return (s1);
}

29
libft/ft_strncmp.c Normal file
View File

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 09:36:32 by scebula #+# #+# */
/* Updated: 2015/11/27 21:56:31 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strncmp(const char *s1, const char *s2, size_t n)
{
size_t i;
i = 0;
while (*s1 && *s1 == *s2 && i < n)
{
s1++;
s2++;
i++;
}
if (i == n)
return (0);
return ((unsigned char)*s1 - (unsigned char)*s2);
}

31
libft/ft_strncpy.c Normal file
View File

@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/24 21:13:38 by scebula #+# #+# */
/* Updated: 2015/12/04 00:30:48 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strncpy(char *dst, const char *src, size_t n)
{
size_t i;
i = 0;
while (src[i] && i < n)
{
dst[i] = src[i];
i++;
}
while (i < n)
{
dst[i] = '\0';
i++;
}
return (dst);
}

37
libft/ft_strndup.c Normal file
View File

@ -0,0 +1,37 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strndup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/30 02:19:00 by scebula #+# #+# */
/* Updated: 2015/12/03 16:35:35 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strndup(const char *s, size_t n)
{
int l;
int i;
char *str;
size_t length;
i = 0;
if (!s)
return (NULL);
length = ft_strlen(s);
l = (n < length) ? n : length;
str = (char *)malloc(sizeof(char) * (l + 1));
if (str == NULL)
return (NULL);
while (i < l)
{
str[i] = s[i];
i++;
}
str[i] = '\0';
return (str);
}

20
libft/ft_strnequ.c Normal file
View File

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnequ.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 10:55:16 by scebula #+# #+# */
/* Updated: 2015/11/26 10:56:03 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strnequ(char const *s1, char const *s2, size_t n)
{
if (ft_strncmp(s1, s2, n) == 0)
return (1);
return (0);
}

18
libft/ft_strnew.c Normal file
View File

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 10:27:40 by scebula #+# #+# */
/* Updated: 2015/11/26 10:30:11 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strnew(size_t size)
{
return ((char*)ft_memalloc(size + 1));
}

36
libft/ft_strnstr.c Normal file
View File

@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 17:53:36 by scebula #+# #+# */
/* Updated: 2015/12/04 00:41:10 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strnstr(const char *s1, const char *s2, size_t n)
{
size_t i;
size_t j;
i = 0;
j = 0;
if (!*s2)
return ((char *)s1);
while (s1[i] && i < n)
{
j = 0;
while (s1[i + j] == s2[j] && (i + j) < n)
{
j++;
if (!s2[j])
return ((char *)s1 + i);
}
i++;
}
return (NULL);
}

31
libft/ft_strrchr.c Normal file
View File

@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 09:26:10 by scebula #+# #+# */
/* Updated: 2015/11/27 20:25:48 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *s, int c)
{
char *last;
last = NULL;
while (*s)
{
if (*s == (char)c)
{
last = (char*)s;
}
s++;
}
if (*s == (char)c)
return ((char *)s);
return (last);
}

27
libft/ft_strrchr_n.c Normal file
View File

@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr_n.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/02/16 20:34:24 by scebula #+# #+# */
/* Updated: 2016/02/20 17:04:47 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strrchr_n(char *str, char c)
{
int i;
i = 0;
while (str[i])
{
if (str[i] == c)
return (i + 1);
i++;
}
return (0);
}

29
libft/ft_strrev.c Normal file
View File

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrev.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 11:38:52 by scebula #+# #+# */
/* Updated: 2015/11/28 01:44:40 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_strrev(char *s)
{
char tmp;
char *rev;
rev = s + ft_strlen(s) - 1;
while (s < rev)
{
tmp = *s;
*s = *rev;
*rev = tmp;
s++;
rev--;
}
}

61
libft/ft_strsplit.c Normal file
View File

@ -0,0 +1,61 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strsplit.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/28 02:35:48 by scebula #+# #+# */
/* Updated: 2016/02/25 01:04:23 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static int ft_count(char *s, char c)
{
int i;
int n;
i = 0;
n = 0;
while (s[i] == c)
{
i++;
}
while (s[i])
{
if (s[i] == c && s[i - 1] != c)
n++;
i++;
}
if (s[i - 1] != c && !s[i])
n++;
return (n);
}
char **ft_strsplit(char const *s, char c)
{
char **ss;
int new_word_start;
int i;
int index;
i = 0;
index = 0;
ss = (char **)malloc(sizeof(char *) * (ft_count((char *)s, c) + 1));
while (s[i])
{
while (s[i] == c)
i++;
if (!s[i])
break ;
new_word_start = i;
while (s[i] && s[i] != c)
i++;
ss[index++] = ft_strsub(s, new_word_start, i - new_word_start);
new_word_start = i;
}
ss[index] = NULL;
return (ss);
}

64
libft/ft_strsplit_lst.c Normal file
View File

@ -0,0 +1,64 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strsplit_lst.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/30 03:29:45 by scebula #+# #+# */
/* Updated: 2015/12/03 18:02:48 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static int ft_count(char *s, char c)
{
int i;
int n;
i = 0;
n = 0;
while (s[i] == c)
{
i++;
}
while (s[i])
{
if (s[i] == c && s[i - 1] != c)
n++;
i++;
}
if (s[i - 1] != c && !s[i])
n++;
return (n);
}
t_list *ft_strsplit_lst(char const *s, char c)
{
t_list *ss;
int start;
int i;
ss = NULL;
i = 0;
if (s == (NULL))
return (NULL);
if (ft_count((char *)s, c) > 0)
{
while (s[i])
{
while (s[i] == c)
i++;
if (!s[i])
break ;
start = i;
while (s[i] && s[i] != c)
i++;
ft_lst_pushback(&ss, ft_strsub(s, start, i - start), i - start + 1);
}
return (ss);
}
else
return (ft_lstnew(NULL, 0));
}

View File

@ -0,0 +1,62 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strsplit_whitespace.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/30 02:07:01 by scebula #+# #+# */
/* Updated: 2015/12/03 20:01:05 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static int ft_count(char *s, char c)
{
int i;
int n;
i = 0;
n = 0;
while (s[i] == c)
{
i++;
}
while (s[i])
{
if (s[i] == c && s[i - 1] != c)
n++;
i++;
}
if (s[i - 1] != c && !s[i])
n++;
return (n);
}
char **ft_strsplit_whitespaces(char const *s)
{
char **ss;
int start;
int i;
int index;
i = 0;
index = 0;
if (s == (NULL))
return (NULL);
ss = (char **)malloc(sizeof(char *) * (ft_count((char *)s, ' ') + 1));
while (s[i])
{
while (s[i] == ' ')
i++;
if (!s[i])
break ;
start = i;
while (s[i] && s[i] != ' ')
i++;
ss[index++] = ft_strsub(s, start, i - start);
}
ss[index] = NULL;
return (ss);
}

36
libft/ft_strstr.c Normal file
View File

@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 09:28:21 by scebula #+# #+# */
/* Updated: 2015/11/27 20:12:55 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strstr(const char *s1, const char *s2)
{
size_t i;
size_t j;
i = 0;
j = 0;
if (!*s2)
return ((char *)s1);
while (s1[i])
{
j = 0;
while (s1[i + j] == s2[j])
{
j++;
if (!s2[j])
return ((char *)s1 + i);
}
i++;
}
return (NULL);
}

35
libft/ft_strsub.c Normal file
View File

@ -0,0 +1,35 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strsub.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 10:57:04 by scebula #+# #+# */
/* Updated: 2015/12/04 00:57:45 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strsub(char const *s, unsigned int start, size_t len)
{
char *str;
size_t i;
unsigned int k;
if (len > (ft_strlen(s) - start) || start > ft_strlen(s))
return (NULL);
str = ft_strnew(len);
if (str == NULL)
return (NULL);
k = start;
i = 0;
while (i < len)
{
str[i] = s[k];
i++;
k++;
}
return (str);
}

36
libft/ft_strtrim.c Normal file
View File

@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strtrim.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 11:03:36 by scebula #+# #+# */
/* Updated: 2015/12/03 22:45:16 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strtrim(char const *s)
{
size_t i;
unsigned int begin;
unsigned int end;
i = 0;
begin = 0;
end = 0;
while (s[i] && (s[i] == ' ' || s[i] == '\t' || s[i] == '\n'))
i++;
if (s[i] == '\0')
return (ft_strnew(0));
begin = i;
while (s[i])
{
if (s[i] != ' ' && s[i] != '\t' && s[i] != '\n')
end = i;
i++;
}
return (ft_strsub(s, begin, (size_t)(end - begin + 1)));
}

23
libft/ft_tablen.c Normal file
View File

@ -0,0 +1,23 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_tablen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/04/26 21:54:50 by scebula #+# #+# */
/* Updated: 2016/04/26 21:54:53 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_tablen(char **tab)
{
size_t i;
i = 0;
while (tab[i])
i++;
return (i);
}

21
libft/ft_tolower.c Normal file
View File

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_tolower.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 10:17:25 by scebula #+# #+# */
/* Updated: 2015/11/26 10:18:18 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_tolower(int c)
{
if (65 <= c && c <= 90)
return (c + 32);
else
return (c);
}

21
libft/ft_toupper.c Normal file
View File

@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_toupper.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 10:19:07 by scebula #+# #+# */
/* Updated: 2015/11/26 10:19:31 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_toupper(int c)
{
if (97 <= c && c <= 122)
return (c - 32);
else
return (c);
}

135
libft/get_next_line.c Normal file
View File

@ -0,0 +1,135 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/02/16 19:58:34 by scebula #+# #+# */
/* Updated: 2016/04/26 21:55:11 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include "get_next_line.h"
void ft_init_data(t_data **d, int fd, char **line)
{
if (!*d)
{
if ((*d = (t_data *)malloc(sizeof(t_data))) == NULL)
return ;
(*d)->l = ft_lstnew("", 1);
(*d)->i = 0;
}
(*d)->sp = 0;
(*d)->tmp = ft_strnew(BUFF_SIZE);
(*d)->t = (*d)->tmp;
while (((*d)->ret = read(fd, (*d)->tmp, BUFF_SIZE)) > 0)
{
(*d)->tmp[(*d)->ret] = '\0';
ft_lst_pushback(&((*d)->l), (*d)->tmp, (size_t)(*d)->ret + 1);
(*d)->i += (size_t)(*d)->ret;
if (((*d)->sp = ft_strrchr_n((*d)->tmp, '\n')))
break ;
}
if ((*d)->ret <= 0 && (*d)->i == 0)
return ;
ft_list_to_string(&(*d), (*d)->i, line);
}
void ft_init_data_2(t_data **d, char **line, int fd)
{
(*d)->i = 0;
while ((*d)->tmp[(*d)->i] != '\n' && (*d)->tmp[(*d)->i])
(*d)->i++;
if (!(*d)->tmp[(*d)->i])
{
(*d)->l = ft_lstnew("", 1);
if ((*d)->i != 0)
ft_lst_pushback(&(*d)->l, ft_strndup((*d)->tmp, (*d)->i),
(*d)->i + 1);
free((*d)->t);
(*d)->t = NULL;
ft_init_data(&(*d), fd, line);
}
else
{
*line = ft_strndup((*d)->tmp, (*d)->i);
(*d)->tmp = (*d)->tmp + (*d)->i + 1;
}
}
void ft_list_to_string(t_data **d, size_t i, char **line)
{
t_list *list;
list = (*d)->l->next;
(*d)->t = NULL;
(*d)->s = ft_strnew(i);
while (list->next)
{
ft_strcat((*d)->s, (const char*)list->content);
list = list->next;
}
ft_strncat((*d)->s, (const char*)(list->content), (size_t)(*d)->sp - 1);
free((*d)->tmp);
(*d)->tmp = NULL;
(*d)->tmp = ft_strdup(list->content);
(*d)->t = (*d)->tmp;
list = (*d)->l;
(*d)->tmp += (*d)->sp;
ft_list_clear(&((*d)->l));
(*d)->l = NULL;
*line = ft_strdup((*d)->s);
free((*d)->s);
(*d)->s = NULL;
}
int get_next_line(int const fd, char **line)
{
static t_data *d[256];
if (line == NULL || fd < 0 || BUFF_SIZE < 1 || fd > 255)
return (-1);
if (d[fd] && d[fd]->ret == 0)
{
ft_free_data(&(d[fd]));
return (0);
}
if (!d[fd])
{
ft_init_data(&d[fd], fd, line);
if (!d[fd])
return (-1);
}
else
ft_init_data_2(&d[fd], line, fd);
if (d[fd]->ret <= 0)
{
d[fd]->sp = (d[fd]->l != NULL) ? (d[fd]->sp + 1) : d[fd]->sp;
if ((d[fd]->ret == 0) && (d[fd]->sp == 0))
return (1);
return (ft_free_data(&(d[fd])));
}
return (1);
}
int ft_free_data(t_data **d)
{
int i;
i = (int)(*d)->ret;
if (!(*d) && i < 0)
return (i);
if ((*d)->t != NULL)
{
free((*d)->t);
(*d)->t = NULL;
}
ft_list_clear(&(*d)->l);
if (*d != NULL)
free(*d);
*d = NULL;
return (i);
}

36
libft/get_next_line.h Normal file
View File

@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/02/16 19:58:25 by scebula #+# #+# */
/* Updated: 2016/02/24 19:57:17 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef GET_NEXT_LINE_H
# define GET_NEXT_LINE_H
# define BUFF_SIZE 8
# include <sys/types.h>
# include <sys/stat.h>
# include <fcntl.h>
# include "libft.h"
typedef struct s_data
{
t_list *l;
int sp;
size_t i;
ssize_t ret;
char *s;
char *tmp;
char *t;
} t_data;
int get_next_line(int const fd, char **line);
void ft_list_to_string(t_data **d, size_t i, char **line);
void ft_init_data(t_data **d, int fd, char **line);
void ft_init_data_2(t_data **d, char **line, int fd);
int ft_free_data(t_data **d);
#endif

106
libft/includes/libft.h Normal file
View File

@ -0,0 +1,106 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* libft.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/08 13:23:46 by scebula #+# #+# */
/* Updated: 2017/01/08 13:23:50 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef LIBFT_H
# define LIBFT_H
# include <string.h>
# include <stdlib.h>
# include <unistd.h>
# include <fcntl.h>
typedef struct s_list
{
void *content;
size_t content_size;
struct s_list *next;
} t_list;
void *ft_memset(void *b, int c, size_t n);
void *ft_memcpy(void *dst, const void *src, size_t n);
void *ft_memmove(void *dst, const void *src, size_t len);
void *ft_memccpy(void *dest, const void *src, int c, size_t n);
void ft_bzero(void *s, size_t n);
void *ft_memchr(const void *s, int c, size_t n);
int ft_memcmp(const void *s1, const void *s2, size_t n);
size_t ft_strlen(const char *s);
char *ft_strdup(const char *s1);
char *ft_strcpy(char *dst, const char *src);
char *ft_strncpy(char *dst, const char *src, size_t n);
char *ft_strcat(char *s1, const char *s2);
char *ft_strcat_new(char *s1, const char *s2);
char *ft_strncat(char *s1, const char *s2, size_t n);
size_t ft_strlcat(char *dst, const char *src, size_t size);
char *ft_strchr(const char *s, int c);
char *ft_strrchr(const char *s, int c);
char *ft_strstr(const char *s1, const char *s2);
char *ft_strnstr(const char *s1, const char *s2, size_t n);
int ft_strcmp(const char *s1, const char *s2);
int ft_strncmp(const char *s1, const char *s2, size_t n);
int ft_isspace(int c);
int ft_atoi(const char *str);
int ft_isalpha(int c);
int ft_isdigit(int c);
int ft_isalnum(int c);
int ft_isascii(int c);
int ft_isprint(int c);
int ft_isdigit(int c);
int ft_isnumeric(int c);
int ft_tolower(int c);
int ft_toupper(int c);
void *ft_memalloc(size_t size);
void ft_memdel(void **ap);
char *ft_strnew(size_t size);
void ft_strdel(char **as);
void ft_strclr(char *s);
void ft_striter(char *s, void (*f)(char *));
void ft_striteri(char *s, void (*f)(unsigned int, char *));
char *ft_strmap(char const *s, char (*f)(char));
char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
int ft_strequ(char const *s1, char const *s2);
int ft_strnequ(char const *s1, char const *s2, size_t n);
char *ft_strsub(char const *s, unsigned int start, size_t len);
char *ft_strjoin(char const *s1, char const *s2);
char *ft_strtrim(char const *s);
char *ft_itoa(int n);
void ft_strrev(char *s);
void ft_putchar(char c);
void ft_putchar_fd(char c, int fd);
void ft_putstr(char const *s);
void ft_putstr_fd(char const *s, int fd);
void ft_putendl(char const *s);
void ft_putendl_fd(char const *s, int fd);
void ft_putnbr(int n);
void ft_putnbr_fd(int n, int fd);
char **ft_strsplit(char const *s, char c);
t_list *ft_lstnew(void const *content, size_t content_size);
void ft_lstdelone(t_list **alst, void (*del)(void*, size_t));
void ft_lstdel(t_list **alst, void (*del)(void*, size_t));
void ft_lstadd(t_list **alst, t_list *n);
void ft_lstiter(t_list *lst, void (*f)(t_list *));
t_list *ft_lstmap(t_list *lst, t_list *(*f)(t_list *elem));
char *ft_strndup(const char *s, size_t n);
char **ft_strsplit_whitespaces(char const *s);
void ft_free_charchar(char **tab);
void ft_lst_pushback(t_list **alst, void *c, size_t c_size);
char *ft_itoa_base(int n, int base);
t_list *ft_strsplit_lst(const char *s, char c);
void ft_printlst(t_list *list);
void ft_list_clear(t_list **begin_list);
int ft_strrchr_n(char *str, char c);
int get_next_line(int const fd, char **line);
size_t ft_listlen(t_list *list);
size_t ft_tablen(char **tab);
char ft_isdigits(char *s);
char *ft_itoa_size_t(size_t n);
float ft_atof(char *str);
#endif

66
scenes/A_Base_objects Normal file
View File

@ -0,0 +1,66 @@
CAMERA
{
position:0 2 20
look_at:0 0 0
}
LIGHT
{
position:0 5 3
}
SPHERE
{
translate:-5 1 0
color: 255 255 0
}
SPHERE
{
translate:-7 3 0
color: 0 255 255
}
SPHERE
{
translate:-6 -1 0
color: 255 0 255
}
PLANE
{
translate:0 -3 0
color:0 0 200
reflection:0.1
}
CYLINDER
{
color: 0 0 255
}
CYLINDER
{
rotate_z:30
color: 0 255 0
}
CYLINDER
{
rotate_z:-30
color: 255 0 0
}
CONE
{
translate: 9 0 0
reflection:0.2
color: 60 60 60
}
CONE
{
rotate_z:40
rotate_y:-40
translate: 9 0 0
reflection:0.2
color: 160 160 160
}
CONE
{
rotate_z:-40
rotate_y:-40
translate: 9 0 0
color: 230 230 230
reflection:0.2
}

78
scenes/B_rt_group Normal file
View File

@ -0,0 +1,78 @@
SPHERE
{
scale:2 2 2
translate:9 0 0
reflection:0
shine:0
CUT
{
rotate_y:-90
rotate_x:90
scale:2 2 1
shine:0
texoffset:0.25 0
texture:textures/face/large_scebula.xpm
}
}
SPHERE
{
scale:2 2 2
translate:3 0 0
reflection:0
shine:0
CUT
{
rotate_y:-90
rotate_x:90
scale:2 2 1
shine:0
texoffset:0.75 0
texture:textures/face/large_qviguier.xpm
}
}
SPHERE
{
scale:2 2 2
translate:-3 0 0
reflection:0
shine:0
CUT
{
rotate_y:-90
rotate_x:90
scale:2 2 1
shine:0
texoffset:0.25 0
texture:textures/face/large_ntrahy.xpm
}
}
SPHERE
{
scale:2 2 2
translate:-9 0 0
reflection:0
shine:0
CUT
{
rotate_y:-90
rotate_x:90
scale:2 2 1
shine:0
texoffset:0.75 0
texture:textures/face/large_gbrochar.xpm
}
}
CAMERA
{
position:-1 2 22
look_at:-1 0 0
}
LIGHT
{
position:0 5 40
}

91
scenes/C_Inside_of_cube Normal file
View File

@ -0,0 +1,91 @@
CUBE
{
vertex_a:-30 -30 30
vertex_b:30 30 -30
reflection:0.8
shine:0.15
color:0 0 0
}
SPHERE
{
translate: 1 0 0
shine:0.2
reflection:0.1
texture:textures/multi/t1.xpm
bumpmap:textures/multi/t1.xpm
}
SPHERE
{
translate: -1 0 0
color: 255 255 0
shine:0.2
reflection:0.1
texture:textures/multi/t2.xpm
bumpmap:textures/multi/t2.xpm
}
SPHERE
{
translate: 3 0 0
color:0 255 0
shine:0.2
reflection:0.1
texture:textures/multi/t9.xpm
bumpmap:textures/multi/t9.xpm
}
SPHERE
{
translate: 1 3 0
color:0 0 255
shine:0.2
reflection:0.1
texture:textures/multi/t4.xpm
bumpmap:textures/multi/t4.xpm
}
SPHERE
{
translate: 3 3 0
color:255 0 255
shine:0.2
reflection:0.1
texture:textures/multi/t5.xpm
bumpmap:textures/multi/t5.xpm
}
SPHERE
{
translate: -3 0 0
color:0 0 0
shine:0.2
reflection:0.1
texture:textures/multi/t6.xpm
bumpmap:textures/multi/t6.xpm
}
SPHERE
{
translate: -1 3 0
color: 2 199 230
shine:0.2
reflection:0.1
texture:textures/multi/t7.xpm
bumpmap:textures/multi/t7.xpm
}
SPHERE
{
translate: -3 3 0
color:255 255 255
shine:0.2
texture:textures/multi/t8.xpm
bumpmap:textures/multi/t8.xpm
}
CAMERA
{
position:-4 2 15
look_at:3 0 0
}
LIGHT
{
position:0 5 3
}
reflections:5

47
scenes/D_Triforce Normal file
View File

@ -0,0 +1,47 @@
CAMERA
{
position:-2 4 14
look_at:0 2 0
}
LIGHT
{
position:5 3 5
color:200 200 0
}
CUBE
{
color: 255 255 0
rotate_z:135
reflection:0.1
scale:1 1.3 1
CUT
{
rotate_z:45
}
}
CUBE
{
color: 255 255 0
rotate_z:135
translate:2.8 0 0
scale:1 1.3 1
reflection:0.1
CUT
{
rotate_z:45
}
}
CUBE
{
color: 255 255 0
rotate_z:135
translate:1.4 0 0
scale:1 1.3 1
translate:0 1.8 0
reflection:0.1
CUT
{
rotate_z:45
}
}

54
scenes/E_Tetraedre Normal file
View File

@ -0,0 +1,54 @@
CAMERA
{
position:0 0 15
look_at:0 0 0
}
ambient:0
LIGHT
{
position:0 0 0
color:0 255 0
}
LIGHT
{
position:-4 0 0
color:255 0 0
}
LIGHT
{
position:4 0 0
color:0 0 255
}
CSG,DIFF
{
PRISM
{
scale:5 5 5
color:255 255 255
shine:1
reflection:1
}
CYLINDER
{
rotate_x:90
scale: 2.5 2.5 2.5
color:255 255 255
shine:1
reflection:1
}
}
SPHERE
{
scale:0.6 0.6 0.6
translate: 0 1 0
}
SPHERE
{
scale:0.6 0.6 0.6
translate: -1 -0.5 0
}
SPHERE
{
scale:0.6 0.6 0.6
translate: 1 -0.5 0
}

56
scenes/F_Damier Normal file
View File

@ -0,0 +1,56 @@
CAMERA
{
position:-2 4 10
look_at:0 1 0
}
LIGHT
{
position:1 2 0
color:150 150 150
}
LIGHT
{
position:-1 2 0
color:34 134 255
}
PRISM
{
color: 150 150 150
reflection:1
shine:1
vertex_a: -2 0 0
vertex_b: 2 0 0
vertex_c: 0 0 -2
vertex_d: 0 4 -1
CUT
{
translate: 0 0.5 0
color: 150 150 150
}
}
SPHERE
{
translate: 0 1.5 -1
texture:textures/multi/t3.xpm
CUT
{
color:0 0 0
rotate_z: 30
translate:0 0.5 0
shine:1
}
CUT
{
rotate_z: -30
translate:0 0.5 0
color:0 0 0
shine:1
}
}
PLANE
{
texmodifier:3
color:30 30 30
reflection:0.2
shine:0.4
}

212
scenes/G_Billard Normal file
View File

@ -0,0 +1,212 @@
CAMERA
{
position:-3 14 40
look_at:0 0 -10
}
LIGHT
{
position:0 9 0
}
SPHERE
{
texture:textures/billard/1.xpm
texscale: 1 -1
translate:-2 0 -13
scale:0.5 0.5 0.5
reflection:0.2
}
SPHERE
{
texture:textures/billard/2.xpm
texscale: 1 -1
translate:0 0 -13
scale:0.5 0.5 0.5
reflection:0.2
}
SPHERE
{
texture:textures/billard/3.xpm
texscale: 1 -1
translate:2 0 -13
scale:0.5 0.5 0.5
reflection:0.2
}
SPHERE
{
texture:textures/billard/4.xpm
texscale: 1 -1
translate:4 0 -13
scale:0.5 0.5 0.5
reflection:0.2
}
SPHERE
{
texture:textures/billard/5.xpm
texscale: 1 -1
translate:6 0 -13
scale:0.5 0.5 0.5
reflection:0.2
}
SPHERE
{
texture:textures/billard/6.xpm
texscale: 1 -1
translate:-1 0 -11
scale:0.5 0.5 0.5
reflection:0.2
}
SPHERE
{
texture:textures/billard/7.xpm
texscale: 1 -1
translate:1 0 -11
scale:0.5 0.5 0.5
reflection:0.2
}
SPHERE
{
texture:textures/billard/8.xpm
texscale: 1 -1
translate:3 0 -11
scale:0.5 0.5 0.5
reflection:0.2
}
SPHERE
{
texture:textures/billard/9.xpm
texscale: 1 -1
translate:5 0 -11
scale:0.5 0.5 0.5
reflection:0.2
}
SPHERE
{
texture:textures/billard/10.xpm
texscale: 1 -1
translate:0 0 -9
scale:0.5 0.5 0.5
reflection:0.2
}
SPHERE
{
texture:textures/billard/11.xpm
texscale: 1 -1
translate:2 0 -9
scale:0.5 0.5 0.5
reflection:0.2
}
SPHERE
{
texture:textures/billard/12.xpm
texscale: 1 -1
translate:4 0 -9
scale:0.5 0.5 0.5
reflection:0.2
}
SPHERE
{
texture:textures/billard/13.xpm
texscale: 1 -1
translate:1 0 -7
scale:0.5 0.5 0.5
reflection:0.2
}
SPHERE
{
texture:textures/billard/14.xpm
texscale: 1 -1
translate:3 0 -7
scale:0.5 0.5 0.5
reflection:0.2
}
SPHERE
{
texture:textures/billard/15.xpm
texscale: 1 -1
translate:2 0 -5
scale:0.5 0.5 0.5
reflection:0.2
}
SPHERE
{
texscale: 1 -1
scale:0.5 0.5 0.5
translate:2 0 9
reflection:0
color:255 255 255
}
CYLINDER
{
scale:0.1 1 0.1
rotate_x:85
rotate_y:10
translate:2 0 10
reflection:0
shine:0.1
texture:textures/billard/wood.xpm
CUT
{
rotate_z:180
}
CUT
{
translate:0 15 0
}
}
PLANE
{
texture:textures/billard/table.xpm
bumpmap:textures/billard/table.xpm
translate: 0 -0.5 0
reflection:0.01
CUT
{
rotate_z:90
translate:-7 0 0
}
CUT
{
rotate_z:-90
translate:8 0 0
}
CUT
{
rotate_x:90
translate:0 0 21
}
CUT
{
rotate_x:-90
translate:10 0 -21
}
}
CUBE
{
vertex_a: -8 -1 22
vertex_b: -7 1 -23
color:135 90 47
reflection:0
}
CUBE
{
vertex_a: -8 -1 -23
vertex_b: 9 1 -22
color:135 90 47
reflection:0
}
CUBE
{
vertex_a: 8 -1 22
vertex_b: 9 1 -23
color:135 90 47
reflection:0
}
CUBE
{
vertex_a: -8 -1 21
vertex_b: 9 1 22
color:135 90 47
reflection:0
}

106
scenes/H_Glass Normal file
View File

@ -0,0 +1,106 @@
CAMERA
{
position:-15 5 15
look_at:0 0 0
}
LIGHT
{
position:100 100 100
}
ambient:0.6
CONE
{
scale:3 0.3 3
reflection:0.1
color:30 30 30
texture:textures/bumpmap/glass.xpm
CUT
{
}
CUT
{
rotate_z:180
translate:0 -2 0
}
}
CYLINDER
{
color:30 30 30
scale:0.1 1 0.1
reflection:0.1
color: 150 150 150
texture:textures/bumpmap/glass.xpm
CUT
{
rotate_z:180
translate:0 -0.1 0
}
CUT
{
translate:0 2 0
}
}
CSG,DIFF
{
SPHERE
{
color: 150 150 150
translate:0 2.4 0
scale:0.8 1.2 0.5
reflection:0.1
texture:textures/bumpmap/glass.xpm
}
SPHERE
{
color: 150 150 150
translate:0 4 0
scale:0.5 0.9 0.3
reflection:0.1
texture:textures/bumpmap/glass.xpm
}
}
PLANE
{
scale:7 1 7
texture:textures/bumpmap/table.xpm
bumpmap:textures/bumpmap/table.xpm
translate: 0 -0.5 0
reflection:0.01
shine:0.01
CUT
{
rotate_z:90
translate:-5 0 0
}
CUT
{
rotate_z:-90
translate:5 0 0
}
CUT
{
rotate_x:90
translate:0 0 5
}
CUT
{
rotate_x:-90
translate:10 0 -5
}
}
PLANE
{
translate:0 -0.51 0
texture:textures/bumpmap/grass.xpm
reflection:0
shine:0.1
}
PLANE
{
rotate_x:90
translate:0 0 -100
color: 0 191 255
shine:0
reflection:0
}

42
scenes/I_CSG_Ex Normal file
View File

@ -0,0 +1,42 @@
CAMERA
{
position:0 2 12
look_at:0 0 0
}
LIGHT
{
position:0 3 20
}
CSG,DIFF
{
CUBE
{
vertex_a:-1 -1 1
vertex_b:1 1 -1
color:60 60 60
}
SPHERE
{
translate:0.7 0.7 1
scale:1.3 1.3 1.3
texture:textures/bumpmap/b4.xpm
bumpmap:textures/bumpmap/b4.xpm
}
}
CSG,DIFF
{
SPHERE
{
scale:0.6 0.6 0.6
translate:0.7 0.7 1
texture:textures/bumpmap/b5.xpm
bumpmap:textures/bumpmap/b5.xpm
}
SPHERE
{
scale:0.6 0.6 0.6
translate:1 1 1.5
color:255 0 0
shine: 0.2
}
}

53
scenes/J_Hyperboloid Normal file
View File

@ -0,0 +1,53 @@
CAMERA
{
position:-2 4 10
look_at:0 1 0
}
LIGHT
{
position:10 2 0
}
HYPERBOLOID
{
translate:2 0 0
scale:0.4 1 0.4
color:255 255 255
bumpmap:textures/general/bumpmap.xpm
texture:textures/general/texturetest.xpm
sheetmode:0
}
HYPERBOLOID
{
translate:-6 0 0
scale:0.4 1 0.4
color:255 255 255
bumpmap:textures/general/bumpmap.xpm
texture:textures/general/texturetest.xpm
sheetmode:1
}
PLANE
{
texture:textures/bumpmap/pb.xpm
bumpmap:textures/bumpmap/pb.xpm
reflection:0.3
shine:0.3
}
CUBE
{
rotate_y: -30
translate:4 0 -4
color:200 200 200
CUT
{
color:200 200 200
translate:0 1 0
rotate_z: 24
}
CUT
{
color:200 200 200
rotate_z: -40
translate:1 1 0
rotate_z: -40
}
}

99
scenes/K_All Normal file
View File

@ -0,0 +1,99 @@
SPHERE
{
translate:0 0 0
CUT
{
translate:0 0.5 0
}
bumpmap:textures/general/bumpmap.xpm
}
AAlvl:1
CYLINDER
{
translate:4 0 0
CUT
{
translate:0 5 0
}
CUT
{
bumpmap:textures/general/bumpmap.xpm
translate:0 1 0
rotate_x:75
}
}
CSG,DIFF
{
CYLINDER
{
texture:textures/general/texturetest.xpm
scale:1.2 1 1.2
translate:4 0 0
}
SPHERE
{
translate:4 0.5 0.5
}
}
CONE
{
translate:-4 0 0
CUT
{
translate:0 1 0
rotate_x:75
}
}
PLANE
{
texture:textures/general/bumpmap.xpm
bumpmap:textures/general/bumpmap.xpm
translate:8 0 0
}
TRIANGLE
{
translate:-8 0 0
}
PRISM
{
translate:16 0 0
}
CUBE
{
translate:-16 0 0
}
PARABOLOID
{
translate:24 0 0
}
HYPERBOLOID
{
translate:-24 0 0
}
CAMERA
{
position:0 2 35
look_at:0 0 0
}
LIGHT
{
position:0 5 3
color: 255 0 0
}
LIGHT
{
position:2 5 3
color: 0 120 0
}

Some files were not shown because too many files have changed in this diff Show More