ld33_umonster
diff src/mesh.cc @ 2:35349df5392d
wtf?
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 22 Aug 2015 23:55:21 +0300 |
parents | 4a6683050e29 |
children | 1e8d90aeae34 |
line diff
1.1 --- a/src/mesh.cc Sat Aug 22 23:17:57 2015 +0300 1.2 +++ b/src/mesh.cc Sat Aug 22 23:55:21 2015 +0300 1.3 @@ -472,7 +472,7 @@ 1.4 1.5 void Mesh::apply_xform(const Matrix4x4 &xform) 1.6 { 1.7 - Matrix4x4 dir_xform = xform; 1.8 + Matrix4x4 dir_xform;// = xform.inverse().transposed(); 1.9 dir_xform[0][3] = dir_xform[1][3] = dir_xform[2][3] = 0.0f; 1.10 dir_xform[3][0] = dir_xform[3][1] = dir_xform[3][2] = 0.0f; 1.11 dir_xform[3][3] = 1.0f; 1.12 @@ -982,6 +982,43 @@ 1.13 } 1.14 } 1.15 1.16 +void Mesh::dump(FILE *fp) const 1.17 +{ 1.18 + if(!has_attrib(MESH_ATTR_VERTEX)) { 1.19 + return; 1.20 + } 1.21 + 1.22 + fprintf(fp, "VERTEX ATTRIBUTES\n"); 1.23 + static const char *label[] = { "pos", "nor", "tan", "tex", "col", "bw", "bid" }; 1.24 + static const char *elemfmt[] = { 0, " %s(%g)", " %s(%g, %g)", " %s(%g, %g, %g)", " %s(%g, %g, %g, %g)", 0 }; 1.25 + 1.26 + for(int i=0; i<(int)nverts; i++) { 1.27 + fprintf(fp, "%5u:", i); 1.28 + for(int j=0; j<NUM_MESH_ATTR; j++) { 1.29 + if(has_attrib(j)) { 1.30 + Vector4 v = get_attrib(j, i); 1.31 + int nelem = vattr[j].nelem; 1.32 + fprintf(fp, elemfmt[nelem], label[j], v.x, v.y, v.z, v.w); 1.33 + } 1.34 + } 1.35 + fputc('\n', fp); 1.36 + } 1.37 + 1.38 + if(is_indexed()) { 1.39 + const unsigned int *idx = get_index_data(); 1.40 + int numidx = get_index_count(); 1.41 + int numtri = numidx / 3; 1.42 + assert(numidx % 3 == 0); 1.43 + 1.44 + fprintf(fp, "FACES\n"); 1.45 + 1.46 + for(int i=0; i<numtri; i++) { 1.47 + fprintf(fp, "%5d: %d %d %d\n", i, idx[0], idx[1], idx[2]); 1.48 + idx += 3; 1.49 + } 1.50 + } 1.51 +} 1.52 + 1.53 // ------ private member functions ------ 1.54 1.55 void Mesh::calc_aabb()