Category Archives: 3d

I have been using Wings3d recently to construct a 3d model of something I would like to print on a 3d printer. It is very interesting.

I have nearly finished my model, and one of the things I realize now is that I spent a long time working on one part of the model early on, only to see now that it represents maybe 10% of the volume of the finished whole. But when I started, I was focused on this one piece, and put a lot of detail into it. Now that detail is hardly visible in the final model. Worse, the extra detail results in a very large number of polygons for that one piece, with a number of negative consequences. I should have done a rough sketch of the whole model at the beginning, then I would have understood where I should focus my time.

It’s a bit like software development, accelerated. Some important themes in common are:

Employ rapid prototyping at the beginning to understand the problem and what the important elements of a solution should be (see previous paragraph).

Big components can require a lot of maintenance. If you put a lot of work into a part of the system, you can make it beautiful and reusable. But you can also make it bloated, full of unseen problems, and hard to fix or adapt to new uses. For example, part of my model is a hand. When I originally constructed the hand, I made it too thin, but I also added a lot of extra faces to get a smooth surface. Later, I realized I had made it too thin. Then all those extra faces bit me, I had to take care to move them all to make the hand wider.

Maintain modularity and decoupling. I have had some problems with Wings3d incorrectly applying transformations to selections containing multiple bodies. To get around that, I merged the separate parts of my model into a single body fairly early in the construction process. That helps the transformation problem, but now it will be hard to reuse the separate parts of the model.

Wings3d is a surprisingly excellent 3d modeling package, written in Erlang. I have been playing with it for a few weeks, using a prebuilt .dmg. I now need to be able to build from source so I can tinker.

I hit some rocks following the build instructions on the wings3d site.

First problem: the build of ESDL which the ESDL website claims is the latest is esdl-0.94.0615. This is outdated and not compatible with current Wings3d source code – there seem to be big differences in the OpenGL libraries. Get the actual latest version instead from ESDL [sourceforge]. I got 1.0.1 and that seems to work.

After building ESDL, ESDL_PATH needs to be set correctly to compile Wings3d. I achieved that with:

export ESDL_PATH=/usr/local/lib/erlang/lib/esdl-1.0.1

Another problem with ESDL – somehow, the library files had been installed with the wrong permissions: they were owned by root and had permissions -rwx——– and so could not be read by erlang. I fixed the permissions.

Final ESDL problem – when I had built Wings3d and started it from the command line, I got an error:
Driver failed: dlopen(/usr/local/lib/erlang/lib/esdl-1.0.1/priv/sdl_driver.so, 2): no suitable image found. Did find:
/usr/local/lib/erlang/lib/esdl-1.0.1/priv/sdl_driver.so: mach-o, but wrong architecture

I added ‘-arch i386’ to the LDFLAGS and CFLAGS in the Makefile in the c_src directory of the ESDL sources and got an i386 .so library out as needed.

Another problem is that the Mac specific Makefiles and the XCode project needed to build a .dmg specify MacOS 10.4. I am running 10.6.6 and do not have the 10.4 frameworks installed on this machine, so to build I needed to specify 10.6 or latest versions of the frameworks. This was achieved by deleting -isysroot /Developer/SDKs/MacOSX10.4u.sdk where it appears in various Makefiles, and editing the XCode project in macosx/Wings3d.xcodeproj/ to change the target to 10.6 or latest from 10.4.

That was enough to get the build to work, and to yield a .dmg containing an application bundle to install.

My first piece of fiddling has been to allow a mousepress while holding down the CMD modifier to fake a right button click if a single button mouse is being used. I changed the first clause of handle_event_0 in wings.erl to this: