60 lines
1.2 KiB
C
60 lines
1.2 KiB
C
#include "c3dtypes.h"
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
|
|
int TestFunc(int x) {
|
|
x = x + 1;
|
|
return x;
|
|
}
|
|
|
|
|
|
Object ReadObjectFromFile() {
|
|
Object out;
|
|
out.VertexArray = malloc(10000*sizeof(Vector3));
|
|
out.VertexArrayLength = 0;
|
|
|
|
TriArray tarr;
|
|
tarr.arr = malloc(10000*sizeof(Tri));
|
|
tarr.length = 0;
|
|
|
|
|
|
out.triangles = &tarr;
|
|
|
|
strncpy(out.name, "cube.obj", 100);
|
|
|
|
|
|
FILE * f = fopen("cube.obj", "r");
|
|
|
|
while (true) {
|
|
char t[500];
|
|
char * fgetres = fgets(t, 500, f);
|
|
if (fgetres == NULL) {
|
|
break;
|
|
}
|
|
|
|
char objtype[10];
|
|
double v1;
|
|
double v2;
|
|
double v3;
|
|
sscanf(t, "%s %lf %lf %lf", objtype, &v1,&v2,&v3);
|
|
if ( strcmp(t, "v")) {
|
|
out.VertexArray[out.VertexArrayLength].x = v1;
|
|
out.VertexArray[out.VertexArrayLength].x = v2;
|
|
out.VertexArray[out.VertexArrayLength].x = v3;
|
|
out.VertexArrayLength = out.VertexArrayLength + 1;
|
|
}
|
|
if ( strcmp(t, "f")) {
|
|
//TODO: append face to triarry
|
|
}
|
|
//need to bring in triarray functions into their own file
|
|
|
|
|
|
|
|
}
|
|
|
|
//TODO: use file object and read each line
|
|
// add verticies to the vertex list, +1 ing the length value each time
|
|
// just fucking parse the obj file its not that hard
|
|
|
|
}
|