Hands On DarkBASIC Pro - Digital Skills
Hands On DarkBASIC Pro - Digital Skills
Hands On DarkBASIC Pro - Digital Skills
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
FIG-30.17<br />
Lights<br />
Surface Normals<br />
FIG-30.18<br />
Visible Polygons<br />
We can even use several cameras, switching between each to change what the user<br />
is seeing on the screen. Unlike real life, there's never any chance of seeing a camera<br />
in the view produced by a second camera - all virtual cameras are invisible!<br />
<strong>DarkBASIC</strong> <strong>Pro</strong> creates and positions a single camera automatically at the start of<br />
every program that uses 3D objects. The exact position of the camera depends on<br />
the positioning of the 3D objects, since the camera normally places itself in order<br />
to see the objects that have been created. However, as the programmer, you can take<br />
complete control of the camera and thereby determine just exactly what appears on<br />
the screen.<br />
We can even set up the lights we want to use to illuminate our new world - just like<br />
placing lights on a movie set. By positioning various types of lights in just the<br />
correct positions, we can create any type of atmosphere we want - from dark and<br />
mysterious to bright and sunny. Like cameras in the 3D world, the lights are<br />
invisible, but the effects they create are not!<br />
To help calculate the effect of lights on the individual polygons of a 3D object, a<br />
set of normals are maintained. A surface normal is a vector from the centre of a<br />
polygon perpendicular to the surface of that polygon. Every polygon in an object<br />
has an associated normal (see FIG-30.17).<br />
A normal for<br />
each polygon<br />
Normals are stored as mathematical expressions and are not part of the visible<br />
structure of the model.<br />
In principal every polygon can have two surface normals: one on the top side and<br />
one on the bottom. However, often models only use a single normal - on the side<br />
facing outwards.<br />
When using surface normals to calculate how an object should be lit, we sometimes<br />
get a rather faceted appearance, with an obvious jump in shading from one polygon<br />
to the next (see FIG-30.18).<br />
752 <strong>DarkBASIC</strong> <strong>Pro</strong>: 3D - Concepts and Terminology