Hands On DarkBASIC Pro - Digital Skills
Hands On DarkBASIC Pro - Digital Skills
Hands On DarkBASIC Pro - Digital Skills
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Copying a 3D Object<br />
FIG-31.43<br />
The CLONE OBJECT<br />
Statement<br />
LISTING-31.9<br />
Creating a Copy of a<br />
3D Object<br />
For example, if we needed to delete 10 3D objects with ID values ranging from 8<br />
to 17, then we would use the statement:<br />
DELETE OBJECTS 8,17<br />
We can create a copy of an existing 3D object in one of two ways, as described<br />
below.<br />
The CLONE OBJECT Statement<br />
The CLONE OBJECT statement creates an independent copy of an existing 3D<br />
object. The statement has the format shown in FIG-31.43.<br />
In the diagram:<br />
objno1 is an integer value specifying the ID to be<br />
assigned to the object being created.<br />
objno2 is an integer value specifying the ID of the<br />
existing object to be copied.<br />
The program in LISTING-31.9 uses the CLONE OBJECT statement to create a<br />
duplicate cube.<br />
REM *** Set display resolution ***<br />
SET DISPLAY MODE 1280,1024,32<br />
REM *** Make and position cube ***<br />
MAKE OBJECT CUBE 1,40<br />
POSITION OBJECT 1,-40,0,100<br />
REM *** Rotate cube ***<br />
WAIT KEY<br />
XROTATE OBJECT 1 , -45<br />
REM *** Copy cube ***<br />
WAIT KEY<br />
CLONE OBJECT 2,1<br />
REM *** Position copy ***<br />
POSITION OBJECT 2, 40,0,50<br />
REM *** Delete original cube ***<br />
WAIT KEY<br />
DELETE OBJECT 1<br />
REM *** End program ***<br />
WAIT KEY<br />
END<br />
Activity 31.19<br />
CLONE OBJECT objno1 , objno2<br />
Type in and test the program given in LISTING-31.9 (object3D11.dbpro).<br />
Is the copied cube rotated to the same angle as the original?<br />
Is the copied cube deleted when the original cube is removed?<br />
778 <strong>DarkBASIC</strong> <strong>Pro</strong>: 3D Primitives