SAS Elite Pvt Rakosi I admire your "out of the box" thinking. That solution would never have occured to me. I've spent some time with the idea and discovered many useful effects I'd like to develop further. But getting the texture to rotate seems to require math similar to getting the ball to rotate. So for now I still working on spinning the ball. Many Thanks.
Deep Blue you have a fine grasp of the problem. Your code is beautifully written. The logic is clearly seen with the variable names you choose. You come directly to grips with the math. I didn't expect that. I too used the circumference formula to calculate the linear distance of movement per degree of rotation. But I relied heavily on DB Commands as the code should show. I think my code more imitates rolling than actually explains the math.
`Rolling Ball Final
`Author: Hop A Long
`With thanks to Deep Blue for sharing his
`insight into the Physics of Motion
`Begun June 19, 2004
`*****SET UP*****
Sync On
Sync Rate 30
Autocam Off
radius = 5
Hide Mouse
`*****MAKE A FLOOR*****
Make Object Box 10,40,2,40
Position Object 10,0,-6,0
Color Object 10,RGB(200,200,0)
`*****MAKE PLAYER*****
Make Object Sphere 1,10 : Position Object 1,0,0,0
YRotate Object 1,90 : Fix Object Pivot 1
Make Mesh from Object 1,1
Make Object Cylinder 2,10 : Position Object 2,0,0,0
Make Mesh from Object 2,2 : Delete Object 2
Add Limb 1,1,2 : Scale Limb 1,1,5,200,5
Color Limb 1,1,RGB(250,0,0)
Make Object Cone 3,5 : Position Object 3,0,10,0
Make Mesh from Object 3,3 : Delete Object 3
Add Limb 1,2,3 : Scale Limb 1,2,25,100,25
Color Limb 1,2,RGB(250,0,0)
Make Object Cylinder 4,10 : Position Object 4,0,0,0
Make Mesh from Object 4,4 : Delete Object 4
Add Limb 1,3,4 : Rotate Limb 1,3,90,0,0
Scale Limb 1,3,5,200,5 : Color Limb 1,3,RGB(0,200,0)
Make Object Cone 5,5 : Position Object 5,0,10,0
Make Mesh from Object 5,5 : Delete Object 5
Add Limb 1,4,5 : Rotate Limb 1,4,90,0,0
Scale Limb 1,4,25,100,25 : Color Limb 1,4,RGB(0,200,0)
`*****TEXTURE THE PLAYER*****
Create Bitmap 1,256,256 : cls rgb(0,100,250) :
Set Text Size 24
Center Text 128,80, " The The "
Center Text 128,100," Almost Almost "
Center Text 128,120,"******Rolling Ball********Rolling Ball******"
Get Image 1,0,0,256,256 : Delete Bitmap 1
Texture Limb 1,0,1
ink rgb(250,250,250),0
`***************************** MAIN LOOP ********************************
Do
`*****ARROW KEYS CONTROL ROLLING*****
If LeftKey() = 1
rot_z# = Wrapvalue(rot_z# + 5.0)
Inc cum_rot_z#,5
trav_x# = cum_rot_z# * .0175 * radius * (-1)
Position Object 1,trav_x#,0,trav_z#
ZRotate Object 1,rot_z#
Fix Object Pivot 1
rot_z# = 0.0
Endif
If RightKey() = 1
rot_z# = Wrapvalue(rot_z# - 5.0)
Dec cum_rot_z#,5
trav_x# = cum_rot_z# * .0175 * radius * (-1)
Position Object 1,trav_x#,0,trav_z#
ZRotate Object 1,rot_z#
Fix Object Pivot 1
rot_z# = 0.0
Endif
If UpKey() = 1
rot_x# = Wrapvalue(rot_x# + 5.0)
Inc cum_rot_x#,5
trav_z# = cum_rot_x# * .0175 * radius
Position Object 1,trav_x#,0,trav_z#
XRotate Object 1,rot_x#
Fix Object Pivot 1
rot_x# = 0.0
Endif
If DownKey() = 1
rot_x# = Wrapvalue(rot_x# - 5.0)
Dec cum_rot_x#,5
trav_z# = cum_rot_x# * .0175 * radius
Position Object 1,trav_x#,0,trav_z#
XRotate Object 1,rot_x#
Fix Object Pivot 1
rot_x# = 0.0
Endif
`*****MOUSE CONTROLS ROLLING*****
If MouseMoveX() <> 0
rot_z#= Wrapvalue(rot_z# - MouseMoveX())
cum_rot_z# = cum_rot_z# - MouseMoveX()
trav_x# = cum_rot_z# * .0175 * radius * (-1)
Position Object 1,trav_x#,0,trav_z#
ZRotate Object 1,rot_z#
Fix Object Pivot 1
rot_z# = 0.0
Endif
If MouseMoveY() <> 0
rot_x#= Wrapvalue(rot_x# - MouseMoveY())
cum_rot_x# = cum_rot_x# - Mousemovey()
trav_z# = cum_rot_x# * .0175 * radius
Position Object 1,trav_x#,0,trav_z#
XRotate Object 1,rot_x#
Fix Object Pivot 1
rot_x# = 0.0
Endif
`*****TEXT OUTPUT OF VALUES*****
posx# = Object Position X(1)
posz# = Object Position Z(1)
Set Text Size 10
Text 10,20,"THE ALMOST ROLLING BALL"
Text 10,50,"posx# : "+str$(posx#)
Text 10,70,"posz# : "+str$(posz#)
Text 10,90,"Moves with Mouse or Arrow Keys"
`*****POSITION CAMERA*****
Position Camera 0,0,-30
Point Camera 0,0,40
`*****REFRESH THE SCREEN*****
Sync
Loop
`******************END OF LOOP********************************************
I would like to put the code on my website along with the thank you for your help. If you have a preference one way or the other please let me know.