3dtoys/camera.h
2024-08-12 21:47:01 -04:00

32 lines
734 B
C

#ifndef __3DTOYS_CAMERA
#define __3DTOYS_CAMERA
#include "haloo3d/haloo3d.h"
typedef struct {
mfloat_t xofs;
mfloat_t yofs;
mfloat_t zofs;
mfloat_t yaw;
mfloat_t pitch;
} camset;
static inline int readcam(camset *set, int max, char *filename) {
FILE *f = fopen(filename, "r");
if (f == NULL) {
dieerr("Can't open %s for reading cam\n", filename);
}
int num = 0;
while (5 == fscanf(f, "%f %f %f %f %f", &set[num].xofs, &set[num].yofs,
&set[num].zofs, &set[num].yaw, &set[num].pitch)) {
num++;
if (num >= max) {
eprintf("Camera file too big! Ignoring rest\n");
break;
}
}
fclose(f);
printf("Read %d camlines from %s\n", num, filename);
return num;
}
#endif