what are you trying to achive ? ...that could be done with vertexdata...memblocks of course
Something like this:
// Project: pyramid hula hoop
// Created: 2018-12-01
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "pyramid hula hoop" )
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
`-----------------------------------------------------------------------------------
//SetRawMouseVisible(0)
createobjectbox(1,10,10,10)
setobjectcolor(1,0,255,0,0)
conic(1,0.05) ` conic(1,0) goes ok ...just playing a bit
mesh = CreateMemblockFromObjectMesh(1,1)
verts= GetMemblockInt( mesh, 0 )
`anim object
createobjectbox(2,0,0,0)
`hula hoop
createobjectcylinder(3,8,15,30)
SetObjectScale(3,1,0.1,1)
SetObjectCullMode(3,0)
setobjectcolor(3,255,255,0,0)
lid_off(3) ` cutting cups to the cylinder
`our Sky
createobjectcylinder(4000,1000,180,40)
SetObjectCullMode(4000,0)
SetObjectColorEmissive(4000,100,100,255)
`floor
createobjectbox(5000,100,1,100)
setobjectcolor(5000,90,60,10,0)
setobjectposition(5000,0,-6,0)
`SHADOWS CONTROL
gosub shadows
SetObjectCastShadow( 1, 1 )
SetObjectCastShadow( 3, 1 )
setcameraposition(1,-10,30,-70)
SetCameraLookAt(1,0,0,0,0)
do
`animating pyramid vertex
setobjectposition(2,0,0,0)
MoveobjectLocalx( 2,0.5 )
tn#=tn#+15
SetObjectRotation (2,0,tn#,0)
nxx#=getobjectworldx(2)
nzz#=getobjectworldz(2)
for i= 0 to verts
x#=GetMeshMemblockVertexX(mesh,i)
y#=GetMeshMemblockVertexy(mesh,i)
z#=GetMeshMemblockVertexz(mesh,i)
if y#>1 and tn#<8200 then SetMeshMemblockVertexPosition(mesh,i, x#+nxx#,y#,z#+nzz#)
next i
SetObjectMeshFromMemblock(1,1,mesh)
if tn#>9000 then rt#=rt#+0.5 :setobjectrotation(1,0,rt#*6,0) :moveobjectlocalz(1,rt#/10)
`animating hula hoop
setobjectposition(3,0,2,0)
MoveobjectLocalx( 3,3.5 )
SetObjectRotation (3,tn#/360,180+tn#,0)
if tn#>8000
mv=mv+1
setobjectrotation(3,5,0,-tn#/5) `trial and error until get correct direction
MoveobjectLocalz( 3,mv )
endif
//print(tn#)
Sync()
loop
function conic(obj,zz#)
`making a mesh to play with
mesh = CreateMemblockFromObjectMesh(obj,1)
//Calcular los vertices que tiene un objeto
verts= GetMemblockInt( mesh, 0 )
for i= 0 to verts
x#=GetMeshMemblockVertexX(mesh,i)
y#=GetMeshMemblockVertexy(mesh,i)
z#=GetMeshMemblockVertexz(mesh,i)
`checking if vertex are higher then center up
if y#>1 then SetMeshMemblockVertexPosition(mesh,i, x#*zz#,y#,z#*zz#)
next i
DeleteMemblock(1)
//fixing mesh
SetObjectMeshFromMemblock(obj,1,mesh)
endfunction
function lid_off(obj)
mesh2 = CreateMemblockFromObjectMesh(obj,1)
verts= GetMemblockInt( mesh2, 0 )
for i= 0 to verts-1
x#=GetMeshMemblockVertexX(mesh2,i)
y#=GetMeshMemblockVertexy(mesh2,i)
z#=GetMeshMemblockVertexz(mesh2,i)
if i<89 then SetMeshMemblockVertexPosition(mesh2,i, 0,0,0)
if i>359-89 then SetMeshMemblockVertexPosition(mesh2,i, 0,0,0)
next i
DeleteMemblock(1)
`fixing mesh
SetObjectMeshFromMemblock(obj,1,mesh2)
endfunction
Shadows:
`shadows setup
shadowMode = 3 // start with cascade shadow mapping which gives the best quality
SetShadowMappingMode( shadowMode )
SetShadowSmoothing( 2 ) // random sampling
SetShadowMapSize( 2024, 1024 )
SetShadowRange( -2 ) // use the full camera range
SetShadowBias( 0.0012 ) // offset shadows slightly to avoid shadow artifacts
`--------------------------------------------------------------------------------------------
`sun coords
dx# = -1.3714
dy# = -0.7428
dz# = 0.5571
SetSunDirection( dx#, dy#, dz# )
return
I'm not a grumpy grandpa