Hi there . I wrote an example in puzzler2018 "Sprite modeler and animation System" thread but I open a new one to show a little update . We can make differents copys of the object while we transform it pressing Ctrl key . At the moment we can't save the object but this is the concept idea.
// Project: 3D Morfing
// Created: 2018-12-24
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "3D Morfing" )
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
createobjectbox(100,10,30,10) `first pose
setobjectrotation(100,20,20,20)
fixobjectpivot(100)
createobjectbox(200,40,5,40) `second pose
createobjectbox(300,5,5,5) `last pose
setobjectvisible(200,0)
setobjectcolor(300,255,255,0,0)
mesh = CreateMemblockFromObjectMesh(100,1)
`getting object vertex quantity
verts= GetMemblockInt( mesh, 0 )
ob=0
for i = 0 to verts-1
inc ob
x#=GetMeshMemblockVertexX(mesh,i)
y#=GetMeshMemblockVertexy(mesh,i)
z#=GetMeshMemblockVertexz(mesh,i)
createobjectbox(ob,1,1,1)
setobjectcolor(ob,255,0,0,0)
setobjectposition(ob,x#,y#,z#)
next
se=ob
mesh = CreateMemblockFromObjectMesh(200,1)
verts= GetMemblockInt( mesh, 0 )
for i = 0 to verts-1
inc se
x#=GetMeshMemblockVertexX(mesh,i)
y#=GetMeshMemblockVertexy(mesh,i)
z#=GetMeshMemblockVertexz(mesh,i)
createobjectbox(se,1,1,1)
setobjectcolor(se,0,0,255,0)
setobjectposition(se ,x#,y#,z#)
next
setcameraposition(1,60,70,-150)
SetCameraLookAt(1,30,0,0,0)
copy=300
jump=0
do
gosub camara
for i= 1 to 24
x#=getobjectx(i)
y#=getobjecty(i)
z#=getobjectz(i)
nx#=getobjectx(i+24)
ny#=getobjecty(i+24)
nz#=getobjectz(i+24)
if ( GetRawKeyState( 32 ) )
if x#>nx# then moveobjectlocalx( i+24,0.1)
if x#<nx# then moveobjectlocalx( i+24,-0.1 )
if y#>ny# then moveobjectlocaly(i+24,0.1)
if y#<ny# then moveobjectlocaly(i+24,-0.1)
if z#>nz# then moveobjectlocalz( i+24,0.1)
if z#<nz# then moveobjectlocalz( i+24,-0.1)
endif
next
mesh = CreateMemblockFromObjectMesh(300,1)
`getting object vertex quantity
verts= GetMemblockInt( mesh, 0 )
for i = 0 to verts-1
x#=Getobjectx(i+25)
y#=getobjecty(i+25)
z#=getobjectz(i+25)
SetMeshMemblockVertexPosition(mesh,i,x#,y#,z#+60)
next
//fixing mesh
SetObjectMeshFromMemblock(300,1,mesh)
print ("Press Sapcebar to see the morphing")
Print ("Pres Ctrl to create different poses")
print ("Fly with cursor and mouse ")
Sync()
loop
camara:
if ( GetRawKeyState( 38 ) ) then MoveCameraLocalZ( 1, 1 )
if ( GetRawKeyState( 40 ) ) then MoveCameraLocalZ( 1, -1 )
if ( GetRawKeyState( 37 ) ) then MoveCameraLocalX( 1, -1 )
if ( GetRawKeyState( 39 ) ) then MoveCameraLocalX( 1, 1 ) // cursor derecha
if ( GetRawKeyState( 17) )
r=r+1
if r=2
inc copy,1
inc jump,40
SetObjectMeshFromMemblock(300,1,mesh)
cloneobject(copy,300)
setobjectposition(copy,jump,0,0)
endif
else
r=0
endif
if ( GetPointerPressed() )
startx# = GetPointerX()
starty# = GetPointerY()
angx# = GetCameraAngleX(1)
angy# = GetCameraAngleY(1)
pressed = 1
endif
if ( GetPointerState() = 1 )
fDiffX# = (GetPointerX() - startx#)/1.0
fDiffY# = (GetPointerY() - starty#)/1.0
newX# = angx# + fDiffY#
if ( newX# > 89 ) then newX# = 89
if ( newX# < -89 ) then newX# = -89
SetCameraRotation( 1, newX#, angy# + fDiffX#, 0 )
endif
return
Cheers.
I'm not a grumpy grandpa