OK, here's the snippet.
As usual, it's written in DB Classic - I'm going to install DBPro now to test it out - I believe the MakeLimbCube() function needs a little tweaking fir DBPro.
Even so, it should work enough as it is to see if what I
think you are trying to do is what you
are trying to do...
DB Classic Version:
Rem Rotating Cube Example For Phantom 2590
Rem DBC Version By TDK_Man
Gosub Setup
Do
If ScanCode() <> 0 then Gosub MoveSphere
Position Object 2,SpherePosX#,SpherePosY#,SpherePosZ#
Sync
Loop
End
Rem * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Rem PROCEDURES
Rem * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
MoveSphere:
If Leftkey() = 1 Then Dec SpherePosX#,0.4: If SpherePosX# < CubeLeftEdgeX# Then Gosub CubeRotate
If Rightkey() = 1 Then Inc SpherePosX#,0.4: If SpherePosX# > CubeRightEdgeX# Then Gosub CubeRotate
If Upkey() = 1 Then Inc SpherePosZ#,.4: If SpherePosZ# > CubeTopEdgeZ# Then Gosub CubeRotate
If Downkey() = 1 Then Dec SpherePosZ#,.4: If SpherePosZ# < CubeBottomEdgeZ# Then Gosub CubeRotate
Return
CubeRotate:
If SpherePosX# < CubeLeftEdgeX#
Rem Hit Left Edge
Hide Object 2
For N=1 To 30
ZRotate Object 1,WrapValue(Object Angle Z(1)-3)
Sync
Next N
Fix Object Pivot 1
SpherePosX# = CubeRightEdgeX#: Rem Jump Sphere To Opposite Side (Right)
Show Object 2
Endif
If SpherePosX# > CubeRightEdgeX#
Rem Hit Right Edge
Hide Object 2
For N=1 To 30
ZRotate Object 1,WrapValue(Object Angle Z(1)+3)
Sync
Next N
Fix Object Pivot 1
SpherePosX# = CubeLeftEdgeX#: Rem Jump Sphere To Opposite Side (Left)
Show Object 2
Endif
If SpherePosZ# > CubeTopEdgeZ#
Rem Hit Top Edge
Hide Object 2
For N=1 To 30
XRotate Object 1,WrapValue(Object Angle X(1)-3)
Sync
Next N
Fix Object Pivot 1
SpherePosZ# = CubeBottomEdgeZ#: Rem Jump Sphere To Opposite Side (Bottom)
Show Object 2
Endif
If SpherePosZ# < CubeBottomEdgeZ#
Rem Hit Bottom Edge
Hide Object 2
For N=1 To 30
XRotate Object 1,WrapValue(Object Angle X(1)+3)
Sync
Next N
Fix Object Pivot 1
SpherePosZ# = CubeTopEdgeZ#: Rem Jump Sphere To Opposite Side (Top)
Show Object 2
Endif
Return
CreateObjects:
MakeLimbCube(1,CubeSize#): Rem Create Cube
Rem Now Colour The Six Sides
COLOR LIMB 1,1,RGB(0,0,255)
COLOR LIMB 1,2,RGB(255,0,0)
COLOR LIMB 1,3,RGB(250,100,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)
Make Object Sphere 2,SphereSize#: Color Object 2,RGB(0,255,0): Rem Create Green Sphere
Return
Setup:
Set Display Mode 800,600,32
Sync On: Sync Rate 0: CLS 0
AutoCam Off
BackDrop On: Color BackDrop 0
CubeSize# = 20.0: SphereSize# = 1.0
CubeLeftEdgeX# = 0-(CubeSize#/2.0)
CubeRightEdgeX# = CubeSize#/2.0
CubeTopEdgeZ# = CubeSize#/2.0
CubeBottomEdgeZ# = 0-(CubeSize#/2.0)
SpherePosX# = 0.0
SpherePosY# = (CubeSize#/2.0)+(SphereSize#/2.0)
SpherePosZ# = 0.0
Gosub CreateObjects
Position Camera 0,40,-40
Point Camera 0,0,0
Return
Rem * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Rem FUNCTIONS
Rem * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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
[Edit] DB Pro Version:
Rem Rotating Cube Example For Phantom 2590
Rem DB Pro Version By TDK_Man
Gosub Setup
Do
If ScanCode() <> 0 then Gosub MoveSphere
Position Object 2,SpherePosX#,SpherePosY#,SpherePosZ#
rem Text 0,0,"X: "+Str$(Object Angle X(1))+" Y: "+Str$(Object Angle Y(1))+" Z: "+Str$(Object Angle Z(1))+" "
Sync
Loop
End
Rem * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Rem PROCEDURES
Rem * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
MoveSphere:
If Leftkey() = 1 Then Dec SpherePosX#,0.4: If SpherePosX# < CubeLeftEdgeX# Then Gosub CubeRotate
If Rightkey() = 1 Then Inc SpherePosX#,0.4: If SpherePosX# > CubeRightEdgeX# Then Gosub CubeRotate
If Upkey() = 1 Then Inc SpherePosZ#,.4: If SpherePosZ# > CubeTopEdgeZ# Then Gosub CubeRotate
If Downkey() = 1 Then Dec SpherePosZ#,.4: If SpherePosZ# < CubeBottomEdgeZ# Then Gosub CubeRotate
Return
CubeRotate:
If SpherePosX# < CubeLeftEdgeX#
Rem Hit Left Edge So Rotate On Z Axis
Hide Object 2
For N=1 To 30
ZRotate Object 1,WrapValue(Object Angle Z(1)-3)
Sync
Next N
SpherePosX# = CubeRightEdgeX#: Rem Jump Sphere To Opposite Side (Right)
Show Object 2
Endif
If SpherePosX# > CubeRightEdgeX#
Rem Hit Right Edge
Hide Object 2
For N=1 To 30
ZRotate Object 1,WrapValue(Object Angle Z(1)+3)
Sync
Next N
SpherePosX# = CubeLeftEdgeX#: Rem Jump Sphere To Opposite Side (Left)
Show Object 2
Endif
If SpherePosZ# > CubeTopEdgeZ#
Rem Hit Top Edge
Hide Object 2
For N=1 To 30
XRotate Object 1,WrapValue(Object Angle X(1)-3)
Sync
Next N
SpherePosZ# = CubeBottomEdgeZ#: Rem Jump Sphere To Opposite Side (Bottom)
Show Object 2
Endif
If SpherePosZ# < CubeBottomEdgeZ#
Rem Hit Bottom Edge
Hide Object 2
For N=1 To 30
XRotate Object 1,WrapValue(Object Angle X(1)+3)
Sync
Next N
SpherePosZ# = CubeTopEdgeZ#: Rem Jump Sphere To Opposite Side (Top)
Show Object 2
Endif
Return
CreateObjects:
MakeLimbCube(1,CubeSize#): Rem Create Cube
Rem Now Colour The Six Sides
COLOR LIMB 1,1,RGB(0,0,255)
COLOR LIMB 1,2,RGB(255,0,0)
COLOR LIMB 1,3,RGB(250,100,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)
Make Object Sphere 2,SphereSize#: Color Object 2,RGB(0,255,0): Rem Create Green Sphere
Return
Setup:
Set Display Mode 800,600,32
Sync On: Sync Rate 60: CLS 0
AutoCam Off
BackDrop On: Color BackDrop 0
CubeSize# = 20.0: SphereSize# = 1.0
CubeLeftEdgeX# = 0-(CubeSize#/2.0)
CubeRightEdgeX# = CubeSize#/2.0
CubeTopEdgeZ# = CubeSize#/2.0
CubeBottomEdgeZ# = 0-(CubeSize#/2.0)
SpherePosX# = 0.0
SpherePosY# = (CubeSize#/2.0)+(SphereSize#/2.0)
SpherePosZ# = 0.0
Gosub CreateObjects
Position Camera 0,40,-40
Point Camera 0,0,0
Return
Rem * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Rem FUNCTIONS
Rem * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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)
Set Object Cull ObjNum,0
Delete Mesh MeshNum
Delete Object PlainNum
Hide Limb ObjNum,0
EndFunction
Note: At some cube angles, rotation is incorrect but I didn't have time to look into it in any great detail. It might be better to use Pitch and Roll instead of the Rotate commands, but I'll leave that for you.
TDK_Man