Skip to main content

Module threeds

Module threeds 

Source
Expand description

Autodesk 3D Studio .3ds files (binary, little-endian chunks).

Read: the editor chunk with its named triangle-mesh objects (vertex list, face list, per-material face groups, smoothing groups) and its materials (name, diffuse colour in the 8-bit or float, linear or gamma-corrected forms, transparency, and the diffuse texture map: its file name, scale, offset and rotation; when that image sits next to the model its average colour stands in for the diffuse colour and the mesh keeps the picture as its texture). The mapping coordinates (0x4140) are kept, with the material’s map scale, offset and rotation baked in and v flipped into picture space. One mesh is made per (object, material) pair; faces in no material group go to a mesh without a material. With smoothing groups, each triangle gets its own three vertices and normals averaged over the faces that meet at the same place and share a smoothing bit; without them the vertices stay shared and the viewer shades flat.

A material with transparency draws see-through. Only the diffuse map and the transparency are read, as in Eagle’s viewer: the bump, opacity and other map chunks are skipped, so no mesh gets a bump or normal map.

Skipped: the keyframer (animation), lights, cameras, the master scale, and everything else unknown (bump, opacity and other maps among it). The vertices of a 3DS mesh are already stored in world space, so the local axis matrix (0x4160) is parsed and ignored, not applied. Coordinates are kept as stored (Z up).

Functions§

parse
Reads a 3DS file; side fetches a texture image next to it by name.