|  | 
 
 When I used to hear terms like "primitives" I had no idea what people were talking about. Well, it's not as bad as you might think. Basically, a primitive is something that is a building block for more advanced graphics. For example, in order to draw a line, you must use pixels. To draw a cube (box) you use lines. To draw a ship you use a bunch of things, like cubes, spheres, cylinders, and cones...and those are all made using triangles. So picture primitives as the building blocks and you'll be okay. 
 There are a few primary tools used to draw shapes in B3D: cubes, spheres, cones, and cylinders. They are all very similar in how you set them up and how you use them, so you'll really only need to worry about which to use in the various scenes you'll be creating. Personally, I prefer to use a rending program to create stuff and just load it in as opposed to the trial and error method of creating on the fly. This way it's easy to adjust, mold, and build new stuff into your mesh. As an aside, a "mesh" is simply a bunch of triangles placed together to build an image. Regardless, primitives are still important to know because they'll help you to understand how the B3D world works, and there are numerous uses for them where you won't have pre-created meshes. 
 First off, let's just create one of each element and plop it onto the screen. Here's the code: 
 You'll notice that all of the entities (the term used for each item in a B3D world) are created almost the same, with the exception of the cube. The cube is different because cube's don't need to have smooth edges. As you'll recall in the last tutorial, segments are triangles. The more segments you have, the smoother your entities will be. Well, a box is square, so smooth edges aren't needed. However, spheres, cones, and cylinders without smoothed edges will look really blocky, which is why segment control is important there. 
 Now, let's just create a sphere and have it appear to bounce on the screen (there's no physics in this, just moving the sphere far away and bring it back up close): 
 One of the things that should be explained is the values used for directional control. As you probably are aware, changes to X values will move the entity from left-to-right (or right-to-left) on the screen. Positive values will move the entity to the right, and negative will move it to the left. Zero (0) is the center X position. Likewise, Y's center is 0. Changing Y's values will move the image up and down. Positive values will move it up and negative will move it down. Z is a little different. Setting Z to a value of 0 will mean that it's litterally on the camera. If you set the value of Z to 0, you won't see the image at all. Actually, I've found you'll need at least a value of 1 to see it. To make the entity move farther away, you'll need to update this value by positive numbers. To bring it closer (and then move it behind the camera), you would use negative numbers. When you look at the MoveEntity line, though, you'll notice that the value in Z is either going to be 1 or a negative 1 (-1) ...there's no subtracting or addition going on. That's true to a point. There's none going on by us. B3D, on the otherhand, is saying "okay, from my current position, I will update the Z by 1 (or -1)." So, we just tell it how many units, and it what direction, it should move that entity and it takes care of the particulars. One last thing on this is the command EntityZ(entity). This command simply returns where in the B3D world a particular entity is at, in particular on the Z-axis. So, in the above program I just keep checking to see if it's greater than 50 units away. If so, I tell it to start coming back. There are complimentary functions to this for X and Y as well, they are called EntityX and EntityY, respecitively. 
 Although this was already touched on in the prior tutorial, I'm going to make stuff spin whilst moving in this one. It's not much different, but there is a very important distinction that you'll see here: 
 When you run that you'll notice that the cone doesn't go straight out and straight back as the sphere did in the previous example. This is because we have turned the front of the entity. When you use the TurnEntity command, it not only turns the direction the entity is facing but also the direction it will move when MoveEntity is called. This is cool because when you have a jet flying around you won't have to worry about how to make it go a particular direction, you simply use the TurnEntity command and keep things moving. Replace the "Offset" with a 0 in some of the TurnEntity arguments and you'll see the different ways it controls movement. 
 Again, there's a lot more this stuff then is shown here, but this should help to keep you moving with B3D and to see how things are made up. In the next article, "Lights, Camera, Action!", I'll start incorporating lighting effects and camera movement. Until next time...cya! 
 For a printable copy of this article, please click HERE. 
 This site is Copyright© 2000-2004, BlitzCoder. All rights reserved.   |