This commit is contained in:
InventorXtreme 2024-07-19 14:44:21 -04:00
parent 97a53e49f7
commit 89ab1281b5
2 changed files with 7 additions and 2 deletions

2
c3d.c
View file

@ -490,7 +490,7 @@ int main() {
bool run3d = true; bool run3d = true;
if (true) { if (true) {
Object3D t = ReadObjectFromFile("cube.obj"); Object3D t = ReadObjectFromFile("mario.obj");
for (int i = 0; i < t.triangles->length; i++) { for (int i = 0; i < t.triangles->length; i++) {
// printf("t: %f\n", t.triangles->arr[i].a.x); // printf("t: %f\n", t.triangles->arr[i].a.x);
TriArrayAppend(&tarr, t.triangles->arr[i]); TriArrayAppend(&tarr, t.triangles->arr[i]);

View file

@ -91,7 +91,7 @@ Object3D ReadObjectFromFile(char *fname) {
tarr.length = 0; tarr.length = 0;
CMaterialArray cmats; CMaterialArray cmats;
cmats.arr = malloc(10 * sizeof(CMaterial)); cmats.arr = malloc(50 * sizeof(CMaterial));
cmats.length = 0; cmats.length = 0;
out.triangles = &tarr; out.triangles = &tarr;
@ -146,6 +146,11 @@ Object3D ReadObjectFromFile(char *fname) {
fclose(f); fclose(f);
printf("Loaded model %s with %d tris\n", fname, tarr.length); printf("Loaded model %s with %d tris\n", fname, tarr.length);
printf("Mats Loaded\n");
for (int i = 0; i < cmats.length; i++) {
printf("%s\n", cmats.arr[i].name);
}
return out; return out;
// TODO: use file object and read each line // TODO: use file object and read each line