eray,
3D can be truly challenging, especially without any prior knowledge in programming. I would love to help you get a good start in deep ground. So, let's start with something simple. But first, I do ask that you take your time to study the tutorials which come with DarkBasic. They will help you get good ground, even into the topic of 3 dimensions.
I want to help you get started in 3D programming within DarkBasic. Let's make a simple cube that you can move around on the
x and
z axises. Now, 3D stands for 3 dimensions, so there are 3 axises within a 3D world. There is the
x,
y and
z axises. Look at
figure 1 below.
This is how the dimensions in DarkBasic are set up. However, this may change from program to program. Now, the z axis is fowards and backwards movement. The x axis is side to side, and the y axis is up and down. For this program, we need to go fowards, backwards and side to side. Let me have you to know that every programmer has his own method to writing code. So, how I teach you may not be the way someone else codes.
Let's start with the writing now. I will be showing you the code in sections, starting with the topmost lines.
set display mode 800,600,32
sync on
sync rate 60
set display mode 800,600,32 is not a necessary piece of code. However, it does allow you to have control over the size of the area of the screen, which you may find quite handy sometime. The syntax for this line is
SET DISPLAY MODE Height,Width,Depth. Height and width refer to the number of pixels across and from top to bottom of your screen. Depth refers to the amount of color. This command is limited to your machine. If you would like to find the available display modes your computer can handle, just right-click on your desktop and select 'properties'. Then go to the 'settings' tab.
sync stands for
synchronize, and is what happens when the program refreshes the screen with all current information from the program. In typing
sync on, I am telling DarkBasic that I want to manually handle the syncronization of the program. It is not necessary to manually control it, but it does come in handy when you need to update the screen at specific points within a program. I will explain how to further use this command later in this tutorial.
Next, is
sync rate 60, which limits the amount of times the screen can be refreshed to 60 times per second. 1 = 1 second. This command comes in handy when you would like a game to run at the same speed on all computers. Now, not all computers will be able to run a game as fast as some, so there is no way to set a
minimum speed of refresh. If the number is set to 0, the program will refresh the screen as many a time it can per second.
make object cube 1,10
position camera 0,10,-30
xrotate camera 30
make object cube 1,10 will make a single 3D cube at the size of 10 units in width,height and depth. The syntax for this command is
MAKE OBJECT CUBE Object Number,Size. Since this is our first object to create, object number will be a 1. You will want to increase this value by 1 everytime you create another object. The cube will be positioned at 0 on all coordinates initially. See figure 2.
position camera 0,10,-30 will place the camera 10 units up(y axis), and 30 units back(z axis), as the syntax is
POSITION CAMERA X,Y,Z.
x rotate camera 30 will rotate the camera, on the x axis, downward a bit to see the cube. To understand rotation, think about the bar of the axis being rotated on, as being the 'hinge' of the rotation. Even as a door rotates on it's hinges. If we were to place a door into 3D technicalities, we would say that it rotates on its
Y axis. See figure 3.
More to come, I've run short of time...
+NanoBrain+