Adapting it for use in BBC BASIC (BBCSDL as it happens, but it could equally well have been BB4W) raised several issues that may be of interest to anybody faced with a similar challenge:
- The model came as one .obj file but 11 separate texture images (some with matching transparency bitmaps). My 3D libraries support only one texture per object, so it was obviously going to be necessary either to split the .obj file into 11 .fvf files, or to combine the 11 textures into a single bitmap. Either would involve a 'custom' version of OBJ2FVF, with a comparable amount of effort, so I chose the latter because the BBC BASIC libraries work more efficiently with fewer objects.
- It soon became apparent that simplistically combining the texture images into a single bitmap wasn't going to work, because the model relies on texture wrapping (that is, the automatic 'tiling' or tessellation of a small texture to cover a larger area by repeating it). One of the textures, for the ground, was tiled in both x- and y-directions so I had no choice but to separate this out as an independent object. Of the other ten textures some were not tiled at all (so weren't a problem) but some were tiled only in the x-direction. To make it possible to combine them into a single bitmap I had to stack them vertically as a strip, so that horizontal wrapping had the desired effect.
- The 3D model's small polygon count is achieved by making extensive use of texture 'transparency' (i.e. an alpha channel). So for example a tree may be composed of a relatively small number of triangles, with the details of the branches and leaves modelled in 2D by means of the transparency mask (you can see this if you look closely). I initially tried to enable the mask with 'alpha blending' (as for example used in 'bbcowl.bbc', 'tower.bbc' and 'brandenburg.bbc'), but the object-ordering restriction - discussed in a separate thread - was impossible to meet with such a complex model. So instead I have enabled simple alpha-based pixel pruning: this does mean that the transparency is 'binary' (either fully opaque or fully transparent) rather than 'linear', which causes some aliasing on edges.
- iOS has a specific restriction, which the other supported platforms don't have, that textures can only be wrapped (tiled) if they have power-of-two dimensions (both width and height being 2^n pixels). Because I wanted the program to run in iOS I chose to make the 'ground' texture 256x256 pixels (GIF-encoded to keep the file size small) and the ten remaining combined textures a single 256 wide by 2048 high bitmap. This bitmap is PNG-encoded because it needs to support an alpha channel (the alternative would have been a 32-bpp BMP but being uncompressed it would have been a lot larger).
- Tweaks to achieve the final animation included separating out the string of Christmas lights into two .fvf files so I could flash the lights in real time (the objects are simply swapped at regular intervals) and generating a separate .fvf file containing the snowflakes (1000 of them in the file) so they could be independently animated.