To resize a shape, you use the ScaleEntity command and use the same number for the x, y, and z values. For this exercise, we are going to use the “cone” file that you saved earlier, so go ahead and open it. If, for some reason, you didn’t save the file or you skipped the earlier section on creating a cone, you can find the file on the accompanying CD.
Let’s say we want to double the size of the cone we created. To do this we’d add the ScaleEntity command as follows:
; This is the code for creating the cone cone = CreateCone() PositionEntity cone,0,0,5 ScaleEntity cone, 2,2,2
Notice that the only line we added to double the size of our cone was the Scale-Entity cone, 2,2,2 command. ScaleEntity tells Blitz3D that there is an object whose size we want to change, cone tells Blitz3D the name of the object we’d like to resize, and the 2,2,2 informs Blitz3D that we want the size to double on the x, y, and z axes.
What if we wanted to reduce the size of the cone instead of increasing it? In that case, we would enter an integer for the x, y, and z values. For example, if you wanted to scale the cone in half (see Figure 5.12), you would use the following code:
cone = CreateCone() PositionEntity cone,0,0,5 ScaleEntity cone, 0.5,0.5,0.5
Here’s a quick reference for some size changes:
1/10 the size = 0.1
1/2 the size = 0.5
Double the size = 2
Triple the size = 3
Ten times the size = 10
Note: ScaleEntity for All!
The ScaleEntity command can be used on more than just basic shapes that you create. Other objects that you create or import can be scaled using this command.
13.59.232.9