3 ms·
Very cool and very uncool. Cool: that it works in a decent way, and uses a neat trick. Uncool: You can't export the image into a 3D file, making it 99% less u
by antirez 16y ago
Very cool and very uncool.
Cool: that it works in a decent way, and uses a neat trick.
Uncool: You can't export the image into a 3D file, making it 99% less useful that it would be otherwise.
Suggestion: export it as VRML, it's trivial format that you can generate starting from your points. Use this format (from my own code, so use it as you wish):
fprintf(fp,
"#VRML V2.0 utf8\n"
"Shape {\n"
" appearance Appearance {\n"
" material Material {\n"
" diffuseColor .5 .5 .5\n"
" }\n"
" }\n"
" geometry ElevationGrid {\n"
" xDimension %d\n"
" zDimension %d\n"
" xSpacing 0.01\n"
" zSpacing 0.01\n"
" solid FALSE\n"
" creaseAngle 6.28\n"
" height [\n", hgt->width, hgt->height
);
for (y = 0; y < hgt->height ; y++) {
for (x = 0; x < hgt->width; x++) {
height = getheight(x,y);
h *= YOUR_3D_MULT_FACTOR;
fprintf(fp, "%f", h);
if (y != hgt->height-1 && x != hgt->width-1) fprintf(fp,",");
if (x == hgt->width) fprintf(fp,"\n");
}
}
fprintf(fp,
" ]\n"
" }\n"
"}\n"
3d studio and other programs will happily import this stuff.
- zach 16y agoWow, there's been a VRML sighting! As an old dude, VRML reminds me of the worst of 90s web hype. Trying to leave that aside, I also don't think it has a lot going for it to keep it around as a format. I prefer the even simpler Wavefront OBJ format as a scratch format. It's about as printf-compatible as it gets and is supported in many more places than VRML. http://en.wikipedia.org/wiki/Wavefront_.obj_file http://en.wikipedia.org/wiki/Wavefront_.obj_file
- antirez 16y agoGood point, but unfortunately in wavefront .obj there is no "elevation mesh" alike object, so it's a bit more complex than this, but still not too hard. Btw while VRML as a plugin and the idea of a 3D web sounds now 90s, the data format itself is too bad.
- chadaustin 16y agoVRML was the interchange format of choice back when I worked on OpenSG at Iowa State. OBJ was too limiting.
- deleted 16y ago[deleted]