Graphics on the ARM
Roger Amos

Three Dimensions

As we have seen in the previous chapters, the images in vector graphics are stored as a sequence of co-ordinate data which the software handles in a stack. In the software considered so far, these co-ordinate data have always related to two dimensions, the x-axis (horizontal) and the y-axis (vertical). Two dimensions are sufficient for most purposes because ultimately the graphics will be displayed on a two-dimensional monitor screen or printed on a two-dimensional sheet of paper. It is true that, as the software redraws its way through the stack, objects at the bottom of the stack (back of the drawing) may become obscured by those higher up (further forward), giving an illusion of depth. But illusion is the operative word, for ultimately all the objects lie in one plane - that of the screen or printout.

Since computers are by definition data processing machines, it is not a wildly extravagant extension of the principles of vector graphics to modify the format of the co-ordinate data so that they relate to not two but three dimensions. Obviously the new third axis will be perpendicular to the plane of the screen or printout.

Of course, some compromise is inevitable in any attempt to reproduce three-dimensional graphics on a two dimensional monitor screen. But in one sense this does not really matter, for we accommodate ourselves to the same compromise whenever we watch television, video or cinema film. Of course, those three media are all animated; the pictures they present are, for most of the time, moving. Movement i.s a particularly powerful tool in the representation of three dimensional graphics. If a man walks in front of a chair and temporarily conceals it we know that he is in front of it, even if we could not have gleaned that from the perspective in the scene. And even if the objects depicted are static - as in a still life - by changing the viewpoint, e.g. by zooming the camera in on some point of interest, the change in perspective will reinforce our perception of the spatial relationships of the objects depicted, fostering the illusion that the monitor screen is a window into a three dimensional world and not a two dimensional one. For this reason, three dimensional graphics and animation often go hand-in-hand.

Euclid

Several three dimensional graphics packages have been written for the ARM machines, but probably the best known and certainly the oldest is Euclid from Ace Computing. Euclid claims to be a three-dimensional equivalent of Draw. In fact in some senses Euclid is much more than that, for it lies at the hub of a network of packages which offer a comprehensive range of linked facilities and is supported by an active user group called Elements. For instance, whenever you load Euclid you may find that Mogul has automatically been loaded as well. Mogul creates animations from Euclid and animation, as mentioned, is a potent force in the quest for three-dimensional realism.

A Euclid screen closely resembles any two dimensional vector graphics screen except that the pointer co-ordinate display reveals three axes. Euclid is object-based; the objects themselves are usually three-dimensional and their relative positions are defined in three dimensions. It is perhaps easiest to think of the cluster of three-dimensional objects as being drawn at the centre of a sphere. The image in the editing window is the view through a mobile window which can be moved to any point on the sphere's surface using the 'move' tool identified by the hand icon. This allows you to view the objects from any side or from any angle above ground level or even beneath it, the ground being conveniently transparent! The zoom tool controls the size of the sphere; it can be contracted so that the window zooms in for close-up work or it can be expanded so that more of the scene can be viewed in the window. However, the view in the editing window is always isometric and therefore devoid of perspective. Views with perspective can lie obtained using the camera facility described later.

All objects can be selected; in the editing window each object carries a marker, normally a blue rectangle. Clicking SELECT on a marker changes it to red showing the object to be selected; multiple selections are possible by clicking ADJUST on other objects' markers. Selected objects can be moved, rotated or scaled using drag operations which are reassuringly conventional. To eliminate the ambiguity that would otherwise result from attempting to define moves in three dimensional space using a two dimensional screen, only two of the three axes are available simultaneously; the axis tool allows you to choose the pair of axes with which you wish to work. The x- and y-axes are in the plane of the floor or ground of the scene; the z-axis is perpendicular to the floor plane and so relates to altitude above the floor, or depth beneath it. Euclid knows none of those conflicts of time and space which in die real world place restraints on our manipulation of solid objects; so you can make two objects share the same space - with bizarre or comic results.

Normally objects are viewed with their styles (mainly colour) in place. The wire-frame tool, however, eliminates colours so that objects are viewed as 'skeletons' of black lines. This can be useful as it allows you to see through solid objects to what lies behind.

Object types

Euclid recognises three types of objects: solids, which consist of a collection of flat, coloured surfaces; meshes, which consist of arrays of four- sided shapes; and sheets which are the product of two paths. It also recognises groups which may lie made up of collections of any combination of object types including other groups. Interestingly, an object may belong to more than one group and consequently may appear in more than one place simultaneously and so is a clone or replication, edits to any instance being reflected in all instances.

Scenes in Euclid are built up using a hierarchical structure rather like that of the disc filing system. The whole scene is often named $ like a disc's root directory. This may contain a mixture of objects and groups, like a root directory containing both files and subdirectories. The groups may contain objects and other groups, and so on.

Tools are provided which allow the quick creation of some frequently used shapes such as cuboids, cylinders and spheres. The building up of solids, meshes and sheets demands the same drawing skills as Draw, although Euclid conveniently compensates for minor inaccuracies by assuming that a click within a certain radius of an existing point was intended to be coincident with that point, Bezier curves are provided, although their rendering and control are a little crude and, since the manipulation of curved solids is very time consuming, many normally curved surfaces are drawn as a succession of plane surfaces, the uplighter being an example. Colours are chosen using a standard 16 colour palette supplemented by a colour wheel which provides access to 256 colours in 256 colour modes; colours are stored internally by their RGB values and colours not in the current palette are simulated using dither patterns. Where an object is made up of separate components each may be given its own colour.

Euclid also provides 'system objects' which behave in special ways. A camera can be moved and rotated just like any other object, but clicking select on the camera tool changes the view in the picture window to the image 'seen' by the camera-this time with full perspective and with the markers invisible. A choice of lenses allows for special effects. You may have several cameras in the scene, offering a choice of views. Each camera is invisible to the others.

Lights allow the effects of shade to add interest to the scene. The 'front lit' option assumes the light is on the viewer's head (recalling a miner's helmet) so that as the move tool is used to change the view, the patterns of light and shade change in a realistic manner. User-defined lighting effects allow the experimenter almost limitless freedom to create special effects.

File exchange

Euclid allows you to save any scene as a sprite; it also allows the saving of Draw files. Note, however, that complex scenes may not leave the Euclid editor enough workspace to create a Draw file; also many Euclid scenes do not produce satisfactory Draw files.

Draw files can also be dragged on to the Euclid icon. Only path objects in them will be recognised and, subject to certain limitations, can be used as objects within Euclid, A dialogue box will ask for the depth of separation between successive objects. Subject to memory avail- ability, a sprite file can be loaded as a background scene.

Incidentally Euclid's !RunImage file is written in BASIC and so, if you are competent in BASIC programming, you may adapt it to suit your own purposes. The possibilities are endless...

Mogul

Mogul is loaded automatically with Euclid, provided that its application directory has been 'seen' by die computer. It allows for animated sequences to Ix; built up from scenes prepared in Euclid easily and without programming skills.

The technique is very simple. You arrange the objects (including cameras) as you wish them to be at certain critical stages in the film - these are called key frames. A Show motion option in the Miscellaneous submenu opens a 'motion' window which consists essentially of a chart or program. Down the left-hand side are listed the objects which will change or move within the film. Across the top are the frame numbers, the limit being 250 (giving 10 seconds of action at normal speed). In the key frames the three dimensional co-ordinates of die mobile objects are stored. There is no need to work out the intermediate positions of the objects: Mogul does the 'in-betweening' itself. A Preview option allows you to watch the action, but almost certainly in slow motion, since the positions of mobile objects must be calculated before each frame is set up.

There is a separate option to save the film. This sets up each frame as before but then saves that frame as a sprite. Each sprite is saved in a compressed format and an additional compression system (delta-compression) offers further memory savings in sprite-based animations by eliminating those parts of successive frames which remain unchanged. The need for such memory saving techniques is obvious when you consider that, without compression, if you wished to fit a sequence of 250 256-colour sprites on an 800-Kbyte floppy, you would be limited to a sprite size of just 3200 pixels, e.g. 75 x 43 pixels.

The resulting sprite-based film will be in Ace film format and can be played at its intended speed using a public-domain application called Projector which gives a useful range of facilities including freeze-frame, reverse and slow motion. We shall meet the Ace film format again later. Since the projector application is public domain and the film is your own creation, you may freely distribute copies of both without infringing copyrights.

3-D Construction Kit

'Build your own virtual reality' is how Domark have advertised their package. 3-D Construction Kit. The package, however, uses the regular monitor display, not a personal stereoscopic display unit as usually associated with virtual reality. Like Euclid it is an object-based three- dimensional graphics package which includes an animation system. It also incorporates a BASIC- like programming language which allows you to write your own adventure games in which you interact with the three-dimensional world you have created. Not only can you explore the world, but you can collect objects, shoot at objects and score points. A thoroughly entertaining demonstration game is included. The games you create are saved in a stand-alone format which you may freely distribute to third parties.

That the software was originally developed for another machine and has been converted for the Acorn 32-hit machines is immediately apparent. It uses a pull-down menu system recalling much PC practice and fails to observe the niceties of the RISC OS desktop. It will not multi-task with other RISC OS applications and files are not interchangeable with them. In fact you cannot even use a screen grabbing module to save a screen since its presence causes the computer to crash. You are advised to switch off the computer before running the software to ensure that all other applications are cleared from the system first. For this reason it is sadly not possible to show any screens from the package in this book. Moreover, running the software reconfigurs the system - the font cache, for instance, is reset to zero (to 32 Kbytes on an A5000) as you will quickly - or do I mean slowly? - discover when next you try to use a DTP package,

A comprehensive user manual and a tutorial video are very helpful. The video makes one appreciate the sophistication of the Acorn machines.

All the action takes place in the 'view window' which occupies the top half of the mode 15 screen. At first this wide and shallow window may seem somewhat restrictive, but you quickly get used to it. The lower half of the screen is used for messages, icons and menus.

Objects are created using the pull-down menu structure. A Create menu allows you to create two types of three-dimensional objects - pyramids and cubes - and five types of two dimensional objects - triangles, rectangles, quadrilaterals, pentagons and hexagons - besides (straight) lines. There are also special objects such as sensors which detect your presence. Groups are also supported. 1here are no true curves in the application, presumably because they would make the redrawing unacceptably slow. Remember that the program must redraw the scene interactively and interactive vector graphics are very demanding of computing power. Nearly all virtual reality systems are similarly devoid of curves.

The created object is an arbitrary size and colour and suspended rather menacingly above the ground. You can then colour it (each face of a cuboid can be assigned a different colour) and you can move it, turn it, stretch it and squash it. So what was created 'as a cuboid can become tall and thin, like the leg of a table, or short, deep and wide like a table top. With a little imagination most shapes can be constructed from the two three-dimensional primitives, pyramids and cubes. 'Hie two-dimensional shapes can be used to ornament the three- dimensional ones, e.g. to add windows to houses. Each new object is given a default name (such as 'cuboid002') which you can change to something more informative if you wish. Besides objects, you can have different areas or zones with doorways or passageways between them. In fact, each area is itself a cuboid (cuboid00l) which explains wily die first cuboid object you create is always 002 and not 001. Facilities are provided to edit areas and to create and edit animated sequences within areas.

The Freescape Command Language allows you to program certain functions to occur under specific circumstances. For example, your score is incremented when you collect a certain object, a door opens when you shoot at it or the game ends when you collide with a certain object. The language will pose no difficulties to anyone familiar with BASIC. A built-in editor allows you to construct the necessary routines. Even sound effects using sampled sound are also supported. Six sounds are provided and up to 26 more samples, in a suitable format, can be added.

previousmain indexnext

 
© 3QD Developments Ltd & Roger Amos 2015