Creating Cubes, Cylinders, and Spheres

There are several other shapes that you can create using Blitz3D, all of which are created in the exact same manner as you created the cone earlier. The only difference is that the create command you use will be different for each shape.

  • CreateSphere()—This will create a sphere.

  • CreateCube()—This will create a cube.

  • CreateCylinder()—This will create a cylinder.

Don’t forget that, when using any of these commands, you’ll need to specify a name for the shape you are creating as well as a location. Here is an example of how you would create a cube within a program.

; This is the code for creating a cube
cube=CreateCube()
PositionEntity cube,0,0,5

Note: Now You Try

Take a look at Figure 5.10. Try to replicate what you see here on your own. Once you are done, compare your code to the actual code used to create it.

Figure 5.10. The demo05-03.bb program.



; demo05-03.bb - Creating a bunch of shapes
; ------------------
Graphics3D 640,480
SetBuffer BackBuffer()

Const ESC_KEY = 1
; Create camera
camera = CreateCamera()
; Create a light
light = CreateLight()
;Create and position four different shapes
cone=CreateCone()
PositionEntity cone,-3.5,0,5
cube=CreateCube()
PositionEntity cube,3,0,5
sphere=CreateSphere()
PositionEntity sphere,-1.6,0,5
cylinder=CreateCylinder()
PositionEntity cylinder,0.5,0,5


; This following code makes our program run
While Not KeyDown(ESC_KEY)
      RenderWorld
      Flip
Wend
End

We have managed to create four different 3D shapes! Check out Figure 5.10 to see what we made!

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

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