This repository has been archived by the owner on Jun 12, 2023. It is now read-only.
forked from gael-bigot/raytracing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
57 lines (45 loc) · 1.34 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <math.h>
#include "geometry.h"
#include "raytracing.h"
// On lance test nomFichier.obj ray_density max_reflextions nb_mesures
int main(int argc, char *argv[]){
int ray_density, max_reflexions, nb_mesures;
sscanf(argv[2], "%d", &ray_density);
sscanf(argv[3], "%d", &max_reflexions);
sscanf(argv[4], "%d", &nb_mesures);
// Les coordonnées du fichier obj sont dans l'ordre y z x
vector tx;
double txX, txY, txZ;
//Adaptation au modèle étudié
tx.x = 98;
tx.y = 5;
tx.z = -900;
vector dir;
double dirX, dirY, dirZ;
dir.x = -1/8;
dir.y = 0;
dir.z = 1;
// Mise en place de la scène
FILE* obj_file = fopen(argv[1], "r");
scene* s = load_scene(obj_file, true, true, tx);
fclose(obj_file);
// Création du fichier de sortie
char* path = malloc(128*sizeof(char));
time_t t;
time(&t);
sprintf(path, "renders/mesures_%s.csv", ctime(&t));
FILE* csv_write = fopen(path, "w");
fprintf(csv_write, "Distance (mètres), Puissance (mW)\n");
raytrace(s, csv_write, ray_density, max_reflexions, dir, nb_mesures);
fclose(csv_write);
free(path);
free(s->triangles);
free(s);
return EXIT_SUCCESS;
}