Парсинг файла в массив структур

Нужно прочитать файл и в массив структур загнать значения со сцены типа файла "sphere" Тип фигуры, центр, радиус, направление, цвет.

В файле sphere:

cam: [position_vector]
sphere: [position_vector] [rotation_vector] [radius] [color]
light: [position_vector]

и вернуть массив структур.

#ifndef RTV_H
#define RTV_H
// #include "../libft/libft.h"
# include <math.h>
# include <stdlib.h>
# include <unistd.h>
# include <fcntl.h>
# include <stdio.h>

typedef struct s_vec3
{
    double x;
    double y;
    double z;
}               t_vec3;

typedef struct s_object
{
    int type;
    t_vec3 origin;
    t_vec3 direction;
    double radius;
    int angle;
    int color;
}              t_object;
typedef struct s_camera
{
    t_vec3 position;
    double fov;
    double imageAspectRotation;
}               t_camera;

#endif

сам файл: между значениями табы, а не пробелы.

camera: 0.0,0.0,200.0       none        none        none
sphere: 0.0,0.0,3.0         0,0,0       1.0         0xff0000
ligth:  80.0,100.0,200.0    none        none        none
        

Ответы (0 шт):