raaaaaaa
This commit is contained in:
parent
777140f625
commit
7f9cd7ef7c
2
c3d.c
2
c3d.c
|
@ -488,7 +488,7 @@ int main() {
|
|||
bool run3d = true;
|
||||
|
||||
if (true) {
|
||||
Object3D t = ReadObjectFromFile("teapot.obj");
|
||||
Object3D t = ReadObjectFromFile("mario.obj");
|
||||
for (int i = 0; i < t.triangles->length; i++) {
|
||||
// printf("t: %f\n", t.triangles->arr[i].a.x);
|
||||
TriArrayAppend(&tarr, t.triangles->arr[i]);
|
||||
|
|
19
c3dtypes.h
19
c3dtypes.h
|
@ -22,7 +22,19 @@ struct Tri {
|
|||
Vector3 c;
|
||||
|
||||
Color color;
|
||||
|
||||
|
||||
Vector2 auv;
|
||||
Vector2 buv;
|
||||
Vector2 cuv;
|
||||
|
||||
};
|
||||
|
||||
struct Mat {
|
||||
char * name;
|
||||
char * file;
|
||||
}
|
||||
|
||||
typedef struct Tri Tri;
|
||||
|
||||
struct Tri2D {
|
||||
|
@ -30,11 +42,18 @@ struct Tri2D {
|
|||
Vector2 b;
|
||||
Vector2 c;
|
||||
|
||||
|
||||
|
||||
float adepth;
|
||||
float bdepth;
|
||||
float cdepth;
|
||||
|
||||
Color color;
|
||||
|
||||
|
||||
Vector2 auv;
|
||||
Vector2 buv;
|
||||
Vector2 cuv;
|
||||
};
|
||||
typedef struct Tri2D Tri2D;
|
||||
|
||||
|
|
18
reader.c
18
reader.c
|
@ -9,6 +9,15 @@ int TestFunc(int x) {
|
|||
return x;
|
||||
}
|
||||
|
||||
Vector3 BreakDownObjTriElement(char * vert) {
|
||||
int vertex = 0;
|
||||
int vertextexture = 0;
|
||||
int normal = 0;
|
||||
|
||||
sscanf(vert, "%i/%i/%i", &vertex, &vertextexture, &normal);
|
||||
return (Vector3) {vertex, vertextexture, normal};
|
||||
}
|
||||
|
||||
Object3D ReadObjectFromFile(char * fname) {
|
||||
Object3D out;
|
||||
Vector3 *VertexArray = malloc(10000 * sizeof(Vector3));
|
||||
|
@ -42,6 +51,9 @@ Object3D ReadObjectFromFile(char * fname) {
|
|||
VertexArray[VertexArrayLength].z = atof(v3)*100;
|
||||
VertexArrayLength = VertexArrayLength + 1;
|
||||
}
|
||||
if (strcmp(objtype, "vt") == 0) {
|
||||
|
||||
}
|
||||
if (strcmp(objtype, "f") == 0 ) {
|
||||
// TODO: append face to triarry
|
||||
Tri temptri;
|
||||
|
@ -51,15 +63,15 @@ Object3D ReadObjectFromFile(char * fname) {
|
|||
temptri.b = VertexArray[ atoi(v2) - 1];
|
||||
temptri.c = VertexArray[ atoi(v3) - 1];
|
||||
|
||||
printf("OLINE: %s\n", t);
|
||||
printf("adding tri A: %d, B: %d, C: %d\n", atoi(v1), atoi(v2) , atoi(v3) );
|
||||
//printf("OLINE: %s\n", t);
|
||||
//printf("adding tri A: %d, B: %d, C: %d\n", atoi(v1), atoi(v2) , atoi(v3) );
|
||||
|
||||
temptri.color = GREEN;
|
||||
TriArrayAppend(&tarr, temptri);
|
||||
}
|
||||
// need to bring in triarray functions into their own file
|
||||
}
|
||||
|
||||
printf("Loaded model %s with %d tris\n", fname, tarr.length);
|
||||
return out;
|
||||
|
||||
// TODO: use file object and read each line
|
||||
|
|
Loading…
Reference in a new issue