For DB Classic And DB Pro
When you create a cube with DB, you can texture or colour it as a whole, but not all of the sides individually.
This function creates a cube, but gives it 6 limbs (the DB primitive only has limb 0 by default).
Each of these 6 limbs can then be independently coloured or textured as shown in the demo program below.
The Function:
Function MakeLimbCube(ObjNum,Size#)
Offset#=Size#/2.0: MeshNum=2000: PlainNum=2000
Make Object Cube ObjNum,Size#
Make Object Plain PlainNum,Size#,Size#
Make Mesh From Object MeshNum,PlainNum
ADD LIMB ObjNum,1,2000: Offset Limb ObjNum,1,0,0,0.0-Offset#: Rem Cube Side 1 (Front)
ADD LIMB ObjNum,2,2000: Rotate Limb ObjNum,2,0,90,0: Offset Limb ObjNum,2,0.0-Offset#,0,0: Rem Cube Side 2 (Left)
ADD LIMB ObjNum,3,2000: Rotate Limb ObjNum,3,0,180,0: Offset Limb ObjNum,3,0,0,Offset#: Rem Cube Side 3 (Back)
ADD LIMB ObjNum,4,2000: Rotate Limb ObjNum,4,0,270,0: Offset Limb ObjNum,4,Offset#,0,0: Rem Cube Side 4 (Right)
ADD LIMB ObjNum,5,2000: Rotate Limb ObjNum,5,270,0,0: Offset Limb ObjNum,5,0,0.0-Offset#,0: Rem Cube Side 5 (Bottom)
ADD LIMB ObjNum,6,2000: Rotate Limb ObjNum,6,90,0,0: Offset Limb ObjNum,6,0,Offset#,0: Rem Cube Side 6 (Top)
Delete Mesh MeshNum
Delete Object PlainNum
Hide Limb ObjNum,0
EndFunction
Call it with:
MakeLimbCube(1,2.0)
Note that the first parameter has to be an integer and the second a float!
The Demo:
Rem Cube With Coloured Faces Example By TDK_Man
Sync On: AutoCam Off
Rem Call function with object number (integer) and size (float)
MakeLimbCube(1,2.0): Rem ObjectNumber (Int), Size (Float)
Rem Cube Sides Can Now Be Coloured (Or Textured) Via The 6 Limbs
Rem (You Could Also Use Texture Limb Instead Of Color Limb)
COLOR LIMB 1,1,RGB(0,0,255)
COLOR LIMB 1,2,RGB(255,0,0)
COLOR LIMB 1,3,RGB(0,255,0)
COLOR LIMB 1,4,RGB(0,255,255)
COLOR LIMB 1,5,RGB(255,0,255)
COLOR LIMB 1,6,RGB(255,255,0)
Rem Position Camera
Position Camera 0,5,-5
Point Camera 0,0,0
Do
Rotate Object 1,WrapValue(Object Angle X(1)+1),WrapValue(Object Angle Y(1)+1),WrapValue(Object Angle Z(1)+1)
Sync
Loop
Function MakeLimbCube(ObjNum,Size#)
Offset#=Size#/2.0: MeshNum=2000: PlainNum=2000
Make Object Cube ObjNum,Size#
Make Object Plain PlainNum,Size#,Size#
Make Mesh From Object MeshNum,PlainNum
ADD LIMB ObjNum,1,2000: Offset Limb ObjNum,1,0,0,0.0-Offset#: Rem Cube Side 1 (Front)
ADD LIMB ObjNum,2,2000: Rotate Limb ObjNum,2,0,90,0: Offset Limb ObjNum,2,0.0-Offset#,0,0: Rem Cube Side 2 (Left)
ADD LIMB ObjNum,3,2000: Rotate Limb ObjNum,3,0,180,0: Offset Limb ObjNum,3,0,0,Offset#: Rem Cube Side 3 (Back)
ADD LIMB ObjNum,4,2000: Rotate Limb ObjNum,4,0,270,0: Offset Limb ObjNum,4,Offset#,0,0: Rem Cube Side 4 (Right)
ADD LIMB ObjNum,5,2000: Rotate Limb ObjNum,5,270,0,0: Offset Limb ObjNum,5,0,0.0-Offset#,0: Rem Cube Side 5 (Bottom)
ADD LIMB ObjNum,6,2000: Rotate Limb ObjNum,6,90,0,0: Offset Limb ObjNum,6,0,Offset#,0: Rem Cube Side 6 (Top)
Delete Mesh MeshNum
Delete Object PlainNum
Hide Limb ObjNum,0
EndFunction
Note: Written and tested only in DB Classic. Please report any glitches found running in DBPro (though there shouldn't be any).
TDK_Man