Skip to Content

boat.

The Task:

O.k. I took the GI21 module in my second year.  The second coursework was on OpenGL. This was a really good coursework, and one I found very enjoyable (worryingly so, in fact).

The specification said that we had to produce a 3D model of a sailing boat, and make it interactive in several ways.  The sails had to rotate (the main one around the mast, and the head sail around it's anchoring rope), based upon a user's key press.  The sails also had to raise and lower, again, based upon a user key press.  Finally, as the most challenging part of the coursework, wind had to be implemented and the sails had to billow in a reasonably realistic way depending on their angle to the wind.

This coursework was only an introduction to OpenGL, so we didn't have to get too realistic in the physics of the movement or anything, as long as it looked reasonably nice.

So, onto my attempt(s)...

The first iteration:

The submitted boat

This version of the boat is the one I submitted.  It consists of the hull model, with a mast and boom which are represented by an octagonal 'cylinder' (we weren't allowed to use gluCylinder() or any similar library functions). There are also the main and head sails and accompanying ropes, as defined in the specification.  The whole boat is lit, and Gourad shaded (so it looks sexy if you rotate it).  The sails have also got lighting on both sides (which wasn't strictly necessary, but made it look lots nicer).

This version of the boat provides all the interactive-ness that the spec. required.  Both sails rotate (around the correct axes), and raise and lower correctly.  The sails also billow in the wind (when its strength is increased from the default value of 0), which is always behind the boat.

Also, the boat does a few more things too, since I'm cool like that...  Firstly, the whole boat can be rotated around each of the three axis (X,Y and Z).  This was more of a necessity to allow checking of my model than me playing around though.  Also, I stuck a few extra details in.  There's a flag on top of the mast, and I've added extra ropes on the boom (it took so long to work out how to get one end to stay put, and one to move with the head sail I thought I may as well flaunt the effect once I got it to work!).  There's also a sky blue background (it made sense, and was really only changing a few numbers), and 'the sea'.  The water's just a big semi-transparent cube that the boat sits in (you can see this if you go 'underwater' on this version of the model), but it made the whole thing look a lot nicer in my opinion.  Finally, I've made the sails lower in a 'realistic' manner, when the correct key is pressed.  This basically just means that the bottom corner of the mainsail stays put when lowering it, which I think looks a lot more realistic than the specified sail movement (which is the default in this model).  In 'realistic' mode both sails lower in much smaller increments also.  The final addition I made was a reset key - this basically resets any overall rotation, and sail movement (but not sail modes or water on/off selections).

I was pretty happy with this model, and I should hopefully get good marks for it.  However, there were a few things I'd have liked to improve.  Firstly, I'd have liked to make the mast/boom rounder, by repeating a rotation calculation to find 'slices' of the cylinder, instead of simply using a hard coded octagonal cylinder.  I'd also have liked to do something similar with the sails when they billow - if I'd had them curving from a center point back to their anchor points they'd have looked much more realistic.  Also, a minor niggle with this version of the scene was that the water cube was clearly visible as just that, a cube, when the scene was rotated so you were 'underwater'.  This should be relatively easy to fix, as it was simply an effect of lighting on the cube's sides, making them different shades.

Anyway, enough talk, you can get a tar file containing the Linux version of the boat here: Download the boat scene. I've only provided the binary and a readme in this package because I don't really want to post what are in effect coursework solutions on my site.  Especially not this soon after submission, since people might still have extensions etc.  I just don't think it's worth it, considering how many people will actually ever look at this...

The second iteration:

The improved boat

This is an updated version of the boat I created. I did it to fix some of the flaws in my submitted version, since I wanted to see it looking it's nicest. At the moment the only change I've made is that the water is no longer lit, which removes the problem of it looking cube-like.  I think it also keeps it a nicer colour, and there's no longer a flash of light when you rotate the boat (although the water catching the light was quite nice).

Here's the download: Download the improved boat scene

Site created and maintained by Gareth Allan - webmaster<at>sonikblue.co.uk