Online Tutorial - Introduction to the 3d graphics


Objectives Learning the basic principles working with 3d graphics in Stratum 2000
Operations with graphics 3D objects Three-dimensional objects exist within three-dimensional space and can be visualized in the special two-dimensional object: Projection3D (Graph2d library).
3d011.gif (249 bytes)
The operation objects (handle control of objects) are arranged in the library GRAPH3D.LIB. There is the variable hSpace3d in all objects, which specifies the descriptor (unique number) of three-dimensional space. This variable can be set by linking or be defined in the object by the level above as well
move3d.gif (667 bytes) Move3d - control of the moving graphics object
Resize3d.gif (737 bytes) Resize3d - scale control of the graphics object
Rotate3d.gif (766 bytes) Rotate3d - rotation control of the graphics object

They are much alike and have identical variables:

Name Type Assignment
hSpace3d HANDLE Descriptor of three-dimensional space. If this variable can not be set by linking, take it from the variable of the object, which is in the level above.
hBase HANDLE Object descriptor, in the local coordinate system of which evolution changes of the object take place.
hObject HANDLE Descriptor of the controlled object.
ObjName STRING Name of the controlled object.
BaseName STRING Object descriptor, in the local coordinate system of which evolution changes of the object take place Besides the objects  have special variables.

Some objects also have special variables:

Icon Class Variable name and descriptions
move3d.gif (667 bytes) Move3d x,y,z - objects coordinates . At the moment of the start the object receives the object 3d coordinates and writes them in these variables. In future it displaces 3d object according to its changes
Resize3d.gif (737 bytes) Resize3d x,y,z -  scale coefficients to corresponding axes. Coefficients are initially set in 1. Later the scale is carried out according to their initial values. Therefore as a matter of convenience this variables can be set in other values.
Rotate3d.gif (766 bytes) Rotate3d matrix - matrix number specifying the rotate axis. At the moment when this variable value of objects and space descriptors accuracy remaines equal 0, the matrix is created automatically, by using values of variables AxisX, AxisY, AxisZ.
AxisX, AxisY, AxisZ - vector coordinates lying on the turn axis. If the turning axis is set through values of these variables, the turn is possible only around the axis passing through an origin of coordinates Otherwise it is necessary to set coordinates directly in the matrix.
Angle - turn angle. The object provides the object turn on this corner
Exercise 1 You need the file with the ready three-dimensional scene:

l14_1.gif (18836 bytes)

You can get here. The file should be saved in the project directory.

Create a new project and insert the GraphicSpace object (Unit library). As the window contents will be read out from the 3d.vdr file. You should set the FileName variable in 3d.vdr (or set full path to the file).

Now set the Projection3D object (Graph2d library) on the scheme. The Projection3D object can create a new projection of three-dimensional space, but it can also use already created and drawn one. For this, set in the ObjectName variable the name of already existing projection. In our case this is 3d.
Now let the project run and check up that number of three-dimensional space is not equal 0 (variable hSpace3d for Proection3D object). Set the variable Control (Proection3D object) which equals 0, just to place the whole view of the three - dimensional space in the window. Let the project run.

Set the Move3d object in order to move torus (three-dimensional object TORE01) along the cylinder on the OY axis.

Then link hSpace3d variables of this object and Projection3D object and set the name of the moving object. (ObjName variable)
- TORE01, and of the object, in the coordinate system of which the moving takes place. (BaseName variable) - CYLINDER. Differ the large and small characters while giving names.
Create a new object, which text will set the law of the object moving:

t:=t+0.1
y:=y0+r*sin(t+f)

where y0 - initial position, r - amplitude, f - phase, t - time. Now link variable y of new object and Move3d object.
Then set initial values of variables (y0, r, f). For example (5, 4, 0). Let the project run. The red torus must fulfil translation motion along OY axis of the cylinder. Set the moving for red and blue toruses using operation as stated above. Instead of creating new objects, take the advantage of copying and inserting already created objects. Then set initial values of variables (y0, r, f).

Exercise 2 Rotation of the sphere around the torus. For this set the Move3d object and link hSpace3d variables of this object and of Projection3D object. Set the name of the moving object. (ObjName variable) - SPHERE, and of the object, in coordinate system of which  the moving takes place. (BaseName variable) - CYLINDER.
Create a new object, which text will set the law of the object moving:
Rotation on small radius:
a1:=a1+0.2
y:=0.16*r1*sin(~a1)
_x:=r1*cos(~a1)

Rotation on large radius
a:=a+0.02
z:=(r+~_x)*sin(a)
x:=(r+~_x)*cos(a)

Set initial values of variables r1- 15, r - 40. Then link x, y, z variables of new object and of Move3d object

Additional exercise Try to control any three-dimensional graphics object with the help of VSlider and HSlider objects
to change the colour  of three-dimensional objects take the advantage of ObjectColor3d objects. Change the colour in the external object by the arbitrary law.

Back : Index : Forward

Trademarks & Copyright © 1998 Stratum Modeling Group.  Last modified on 6-January-1999.