Understanding the 3D World

Before we begin, it’s important that you understand the concept of a 3D world. Start by looking at your monitor. Your monitor screen is actually two-dimensional; you can’t reach in and grab an object on your computer’s screen. So 3D games aren’t really 3D, they just pretend to be 3D by using a variety of lighting and positioning techniques. Take a look at Figure 5.1. Just like the monitor on your computer, the pages of this book are in two dimensions, but we can create the illusion of three dimensions by cleverly using lighting and positioning. Both objects are simple circles, but the one on the right looks three-dimensional because of the lighting applied to it.

Figure 5.1. These two circles started off the same but now look distinctly different. The circle on the left looks two-dimensional but the one on the right looks three-dimensional because of the lighting applied to it.


A 2D world is made of up two axes: an x axis, which represents the horizontal part of your game, and a y axis, which represents the vertical part of your game. Think of the x and y axes as two rulers going across your monitor—one (the x axis) goes left and right, and the other (the y axis) goes up and down (see Figure 5.2).

Figure 5.2. The x axis runs left to right across your screen and the y axis goes up and down.


Objects that you create in a two-dimensional game are positioned along the x and y axes. Their positions on the screen are called coordinates. Take a look at

Figure 5.3, which has an object in the top-right corner. The coordinates for this object would be (2,3). The first number represents the object’s position on the x axis—in this case, two units to the right. The second number, 3, represents the object’s position on the y axis—in this case, three units up.

Figure 5.3. This object has the coordinate (2,3) because it is two units to the right of the center point and 3 units up.


On the x axis, positive numbers represent objects that are to the right of the center point, and objects to the left are represented by negative numbers. On the y axis, positive numbers represent objects that are above the center point, and negative numbers are those objects below the center point. Take a look at Figure 5.4, which shows several objects in different positions with their coordinates in brackets.

Figure 5.4. Each object is positioned at different coordinates.


To create the illusion of near or far in a 3D world, the size of the object will change. Take a look at Figure 5.5, which has two objects: one that seems close and one that seems far away. We can tell that they are near or far because one is bigger than the other. In a 3D world, there is one more axis, the z axis, which represents objects that are near or far on the screen. On the z axis you can control how near or far an object is.

Figure 5.5. The z axis controls how near or far an object is.


The position of an object in a 3D program is represented by three coordinates: an x axis, a y axis, and a z axis number. Positive numbers on the z axis represent how far away the object is. For example, if the z axis number is 2, the object will be relatively close to the center point while a z axis value of 100 would mean that it is far away. A negative number will mean that the object will be on the close side of the center point, while a positive number represents a position on the far side of the center point. An example of coordinates of an object in a 3D world would be (–3,–,4,–4), which means the object would be at position –3 on the x axis, –4 on the y axis, and –4 on the z axis, as seen in Figure 5.6.

Figure 5.6. This object is positioned at location (–3, –4, –4).


Note: Near or Far?

Keep in mind that terms like near, far, up, down, and left and right are all relative terms in Blitz3D because your “eyes” are the camera. Although the camera starts at position 0, 0, 0, it can be moved to any position in the 3D universe.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.239.182