Hi there.
This piece of code was made long ago and translated to AppGameKit . To avoid heart atack, we need to do some physical sport .
// Project: fitness
// Created: 2018-11-30
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "fitness" )
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 maketexture
createobjectsphere(1000,8,7,10)
setobjectimage(1000,1,0)
`making a mesh to animate vertex
mesh = CreateMemblockFromObjectMesh(1000,1)
ob=0
size=0
verts= GetMemblockInt( mesh, 0 )
for i= 0 to verts-1
inc ob,1
`creating vertex objects
createobjectbox(ob,size,size,size)
`getting coords of every vertex
x#=GetMeshMemblockVertexX(mesh,i)
y#=GetMeshMemblockVertexy(mesh,i)
z#=GetMeshMemblockVertexz(mesh,i)
`modeling vertex to get leg shape
if y#>3 then SetMeshMemblockVertexPosition(mesh,i,x#*1.2,y#+7+x#,z#*1.2)
if y#<-0 then SetMeshMemblockVertexPosition(mesh,i,x#*0.2,y#-8,z#*0.2)
if y#<-2.4 then SetMeshMemblockVertexPosition(mesh, i,1.3+x#*0.9,y#-9,z#*0.3)
if y#<-3.4 then SetMeshMemblockVertexPosition(mesh, i,1.3+x#*0.9,y#-7,z#*0.3)
next i
`fixing mesh
SetObjectMeshFromMemblock(1000,1,mesh)
`left leg
InstanceObject(1001,1000)
setobjectposition(1001,0,0,4)
`positioning objects in new vertex coords.
for i= 1 to verts
x#=GetMeshMemblockVertexX(mesh,i)
y#=GetMeshMemblockVertexy(mesh,i)
z#=GetMeshMemblockVertexz(mesh,i)
setobjectposition(i,x#,y#,z#)
next i
`object that animates vertex
createobjectbox(2000,1,1,1)
setcameraposition(1,20,5,-20)
SetCameraLookAt(1,0,0,0,0)
`our Sky
createobjectcylinder(4000,1000,180,40)
SetObjectCullMode(4000,0)
SetObjectColorEmissive(4000,100,100,255)
`Floor
createobjectbox(4001,200,2,200)
setobjectcolor(4001,0,100,0,0)
setobjectposition(4001,0,-12,0)
gosub shadows
do
mv#=0.6
MoveobjectLocalx( 2000,mv# )
if GetObjectWorldx( 2000 )>2 then SetObjectRotation(2000,0,0,180)
if GetObjectWorldx( 2000 )<0 then SetObjectRotation(2000,0,0,0)
mvt#=getobjectx(2000)
`animating vertex
for i= 1 to verts -1
x#=Getobjectworldx(i)
y#=Getobjectworldy(i)
z#=Getobjectworldz(i)
if y#>0 then SetMeshMemblockVertexPosition(mesh,i,x#*0.3+mvt#,y#-mvt#*1.1,z#*0.3)
if y#<0 then SetMeshMemblockVertexPosition(mesh,i,x#*0.3+mvt#,y#-mvt#*1.1,z#*0.3)
if y#>3 then SetMeshMemblockVertexPosition(mesh,i,x#,y#-mvt#,z#)
if y#<-0 then SetMeshMemblockVertexPosition(mesh,i,x#,y#,z#)
if y#<-2.4 then SetMeshMemblockVertexPosition(mesh, i,x#,y#,z#)
if y#<-3.4 then SetMeshMemblockVertexPosition(mesh, i,x#,y#,z#)
next i
`last fixing to the mesh
SetObjectMeshFromMemblock(1000,1,mesh)
Sync()
loop
maketexture:
skin=makecolor(210,110,70)
drawbox(0,0,100,100,skin,skin,skin,skin,1)
red=makecolor(255,0,0)
drawbox(0,58,100,100,red,red,red,red,1)
getimage(1,0,0,100,100)
return
Shadows:
`Shadows setup
shadowMode = 3 // start with cascade shadow mapping which gives the best quality
SetShadowMappingMode( shadowMode )
SetShadowSmoothing( 2 ) // random sampling
SetShadowMapSize( 1024, 1024 )
SetShadowRange( -1 ) // use the full camera range
SetShadowBias( 0.0012 ) // offset shadows slightly to avoid shadow artifacts
`--------------------------------------------------------------------------------------------
`AJUSTES DIRECCION DEL SOL
dx# = -1.3714
dy# = -1.7428
dz# = -1.1571
SetSunDirection( dx#, dy#, dz# )
SetObjectCastShadow( 1000, 1 )
SetObjectCastShadow( 1001, 1 )
return
Cheers.
I'm not a grumpy grandpa