Hands On DarkBASIC Pro - Digital Skills
Hands On DarkBASIC Pro - Digital Skills
Hands On DarkBASIC Pro - Digital Skills
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
FIG-31.32<br />
The POINT OBJECT<br />
Statement<br />
LISTING-31.5<br />
Using the POINT<br />
OBJECT Statement<br />
FIG-31.33<br />
Turning an Object to Face<br />
a Specified Point<br />
In the diagram:<br />
objno is an integer value giving the ID of the object to<br />
be affected.<br />
x,y,z are the coordinates of the point in space at which<br />
the main polygon of the 3D object is to face.<br />
In the program shown in LISTING-31.5 a cube is made to face the point (45,45,0)<br />
using the statement:<br />
POINT OBJECT 1,45,45,0<br />
REM *** Set display resolution and backdrop ***<br />
SET DISPLAY MODE 1280,1024,32<br />
COLOR BACKDROP 0<br />
BACKDROP ON<br />
REM *** Make the set of objects ***<br />
MAKE OBJECT CUBE 1,40<br />
REM *** Move cube to (0,0,100) after key press ***<br />
WAIT KEY<br />
POSITION OBJECT 1,0,0,100<br />
REM *** point cube at (45,45,0)***<br />
WAIT KEY<br />
POINT OBJECT 1,45,45,0<br />
REM *** End program ***<br />
WAIT KEY<br />
END<br />
The result is shown in FIG-31.33.<br />
Initially, the cube’s main polygon faces the<br />
viewer.<br />
Activity 31.13<br />
POINT OBJECT objno<br />
x y z<br />
Type in and test the program given in LISTING-31.5 (object3D07.dbpro).<br />
Modify the program to make the cube face the point (-20,17,-10).<br />
The MOVE OBJECT distance Statement<br />
, , ,<br />
After the POINT OBJECT statement is<br />
executed, the main polygon faces (45,45,0).<br />
We've already encountered a MOVE OBJECT statement which allows an object to<br />
be moved up, down, left, or right, but a second version of MOVE OBJECT exists<br />
which will move an object in the direction its main polygon is facing. This statement<br />
has the format shown in FIG-31.34.<br />
772 <strong>DarkBASIC</strong> <strong>Pro</strong>: 3D Primitives