Recently I began to learn the ins and outs of C++ programming. I decided to create an update
to my 3D code by writing the whole thing using Data Abstraction (an important Object Oriented
principle) as such I now have a program built entirely on class structures. Although at present
it is written for use with BGI, all that needs to be done is update the Tgraph class with non
BGI, OpenGL or DirectX perhaps, code and the rest will work. The modules do not care how the
image is drawn all they do is call functions such as SetForeColour and DrawLine, Initialisation
of the graphics mode is also performed through the Tgraph class.

Again this image is nothing special, it shows a cube made up of triangular shaped faces. It does,
however, demonstrate a few good principles. The back faces are not drawn for example. This
performed by using the way the face is constructed to produce a normal vector for the face. If
this vector is negative then the face is pointing away and hence the face is invisible. The other
important factor, in fact something that is not in either of the above programs is the triangular
faces. I have always been told this is a much faster way of displaying images. I believe (and do
forgive me if I am wrong) that the reason triangular faces are faster is that all trigonometry is
based on triangular shapes. Seeing as 3D is all spherical trigonometry it makes no sense to
overload the system with performing more calculations than it might otherwise have to. At best the
system would need to break a face down into triangles anyway.
To see the C++ code click here.
To download the executable click here.