Hi there. Today I come up with not exactly morphing but pretty much like...This is a sphere that becomes a box . I hope you like it
// Project: Morphing Sphere
// Created: 2018-12-23
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Morphing Sphere" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
`
gosub texture
CreateObjectSphere(1,30,30,30)
setobjectimage(1,1,0)
createobjectbox(2,20,20,20)
setobjectposition(2,30,0,0)
setobjectimage(2,1,0)
`our Sky
createobjectcylinder(4000,1000,180,40)
SetObjectCullMode(4000,0)
SetObjectColorEmissive(4000,100,100,255)
SetCameraPosition(1,0,20,-80)
SetCameraLookAt(1,0,0,0,0)
r=0
do
mesh = CreateMemblockFromObjectMesh(1,1)
`get vertex quantity
verts= GetMemblockInt( mesh, 0 )
for i= 0 to verts-1
x#=GetMeshMemblockVertexX(mesh,i)
y#=GetMeshMemblockVertexy(mesh,i)
z#=GetMeshMemblockVertexz(mesh,i)
if y#> 8 then SetMeshMemblockVertexPosition(mesh,i,x#,y#-scale#,z#)
if y#<-8 then SetMeshMemblockVertexPosition(mesh,i,x#,y#+scale#,z#)
if x#<-8 then SetMeshMemblockVertexPosition(mesh,i,x#+scale#,y#,z#)
if x#> 8 then SetMeshMemblockVertexPosition(mesh,i,x#-scale#,y#,z#)
if z#> 8 then SetMeshMemblockVertexPosition(mesh,i,x#,y#,z#-scale#)
if z#<-8 then SetMeshMemblockVertexPosition(mesh,i,x#,y#,z#+scale#)
next
SetObjectMeshFromMemblock(1,1,mesh)
`Animation
if ( GetRawKeyState( 32 ) )
scale#=scale#+0.001
r=1
endif
if r=1 then a=a+1
if a>100 then g#=g#+2
setobjectrotation(1,g#,g#,g#)
setobjectrotation(2,0,-g#,0)
Print( "Press Spacebar" )
Sync()
loop
Texture:
red=makecolor(155,155,0)
drawbox(0,0,640,480,red,red,red,red,1)
x=300
y=200
g=0
c=0
for i= 1 to 600
inc g,5 `jugar con estos valores
inc c,1 `jugar con estos valores
if c>255 then c=50
x=x+(cos(g/10)*i/110)
y=Y+(sin(g)*i/50)
col=makecolor(c*3,c,0)
drawbox(x,y,x+i/20,y+i/20,col,col,col,col,1)
next i
getimage(1,220,120,170,170)
return
Cheers.
I'm not a grumpy grandpa