diff options
author | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-07-30 23:40:38 +0000 |
---|---|---|
committer | taw27 <taw27@84d2e878-0bd5-11dd-ad15-13eda11d74c5> | 2008-07-30 23:40:38 +0000 |
commit | c566f87fe5853e4f1596792652f203c7386c8699 (patch) | |
tree | 9dfcec4bb6449d528ede9d56c638b04d5d2c48b1 /src | |
parent | 8b6eba5edd92fcdf1ec3e2fc129f78c452abf903 (diff) |
Plumbing :)
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@199 84d2e878-0bd5-11dd-ad15-13eda11d74c5
Diffstat (limited to 'src')
-rw-r--r-- | src/game.c | 2 | ||||
-rw-r--r-- | src/obj2model.c | 29 |
2 files changed, 25 insertions, 6 deletions
@@ -26,7 +26,7 @@ #define MAX_OBJECTS 100 /* Maximum indicies of the rooms - remember they start at zero */ -#define MAX_ROOM_X 0 +#define MAX_ROOM_X 1 #define MAX_ROOM_Y 2 #define MAX_ROOM_Z 4 diff --git a/src/obj2model.c b/src/obj2model.c index 4bf6d48..d58786e 100644 --- a/src/obj2model.c +++ b/src/obj2model.c @@ -27,11 +27,13 @@ int main(int argc, char *argv[]) { FILE *out; float vtmp[3*MAX_VERTICES]; float vntmp[3*MAX_VERTICES]; + float textmp[2*MAX_VERTICES]; int v_used[MAX_VERTICES]; int vn_used[MAX_VERTICES]; - int n_vtmp, n_vntmp; + int tex_used[MAX_VERTICES]; + int n_vtmp, n_vntmp, n_textmp; int nprev; - int i, v_unused, vn_unused; + int i, v_unused, vn_unused, tex_unused; fh = fopen(argv[1], "r"); if ( fh == NULL ) { @@ -42,10 +44,12 @@ int main(int argc, char *argv[]) { for ( i=0; i<MAX_VERTICES; i++ ) { v_used[i] = 5; vn_used[i] = 5; + tex_used[i] = 5; } /* Zip through and find all the vertices */ n_vtmp = 0; + n_textmp = 0; n_vntmp = 0; while ( !feof(fh) ) { @@ -80,6 +84,14 @@ int main(int argc, char *argv[]) { n_vntmp++; continue; } + + if ( sscanf(line+s, "vt %f %f %f\n", &x, &y, &z) == 3 ) { + textmp[2*n_textmp+0] = x; + textmp[2*n_textmp+1] = y; + tex_used[n_textmp] = 0; + n_textmp++; + continue; + } } @@ -123,7 +135,7 @@ int main(int argc, char *argv[]) { for ( i=1; i<n; i++ ) { char **sp; - int np, nnum, j, nslash; + int np, j, nslash; nslash = 0; for ( j=0; j<strlen(bits[i]); j++ ) { @@ -131,7 +143,7 @@ int main(int argc, char *argv[]) { } if ( nslash == 2 ) { - int vnum; + int vnum, tnum, nnum; np = assplode(bits[i], "/", &sp, ASSPLODE_DUPS); if ( np != 3 ) { @@ -139,6 +151,7 @@ int main(int argc, char *argv[]) { continue; } vnum = atoi(sp[0])-1; + tnum = atoi(sp[1])-1; nnum = atoi(sp[2])-1; if ( vnum >= n_vtmp ) { fprintf(stderr, "Vertex index is too high (%i/%i)\n", vnum, n_vtmp); @@ -150,10 +163,11 @@ int main(int argc, char *argv[]) { } fprintf(out, "%+8.3f %+8.3f %+8.3f %8.3f %8.3f %+8.3f %+8.3f %+8.3f\n", vtmp[3*vnum+0], vtmp[3*vnum+1], vtmp[3*vnum+2], - 0.0, 0.0, + textmp[2*tnum+0], textmp[2*tnum+1], vntmp[3*nnum+0], vntmp[3*nnum+1], vntmp[3*nnum+2]); v_used[vnum] = 1; vn_used[nnum] = 1; + tex_used[tnum] = 1; free(sp[0]); free(sp[1]); free(sp[2]); @@ -185,6 +199,7 @@ int main(int argc, char *argv[]) { v_unused = 0; vn_unused = 0; + tex_unused = 0; for ( i=0; i<MAX_VERTICES; i++ ) { if ( v_used[i] == 0 ) { v_unused++; @@ -192,9 +207,13 @@ int main(int argc, char *argv[]) { if ( vn_used[i] == 0 ) { vn_unused++; } + if ( tex_used[i] == 0 ) { + tex_unused++; + } } printf("%i vertices (%i unused)\n", n_vtmp, v_unused); printf("%i normals (%i unused)\n", n_vntmp, vn_unused); + printf("%i texcoords (%i unused)\n", n_textmp, tex_unused); return 0; |