Easy vertex stuff for beginners. Could be used to add frames to a model or even help develop an entire animation system.
It could quickly be modified to call as many meshes as needed to complete an animation.
make object box 1,3,1,5 `(this is our starting shape which we will animate)
`STORE THE VERTEX POSIIONS INTO ARRAYS
lock vertexdata for limb 1,0
vCount=get vertexdata vertex count()
dim x1#(vCount):dim y1#(vCount):dim z1#(vCount)
for v=0 to VCount
x1#(v)=get vertexdata position x(v)
y1#(v)=get vertexdata position y(v)
z1#(v)=get vertexdata position z(v)
next
unlock vertexdata
yrotate object 1,45:set camera range .01,1000:move camera -5:autocam off:sync on:sync rate 60
Polarity=1 `ANIMATION DIRECTION (will oscillate in this example)
gosub NewBox `CREATES A NEW TARGET SHAPE (repeatedly called in this example)
speed#=.01 `SETS THE AMOUNT OF INCREMENT OF ANIMATION MOVEMENT PERCENTAGE PER LOOP (1=100% change)
do
inc percentage#,speed#:p$=str$(percentage#)
if percentage#>1 then Polarity=-Polarity:percentage#=0:if Polarity=1 then color object 1,rgb(rnd(255),rnd(255),rnd(255)):gosub NewBox
if percentage#<=1 then gosub MoveVertices
text 0,0,p$
control camera using arrowkeys 0,.1,3
sync
loop
MoveVertices:
lock vertexdata for limb 1,0
for v=0 to vCount
if Polarity=1 then NewX#=x1#(v)-((x1#(v)-x2#(v))*percentage#):NewY#=y1#(v)-((y1#(v)-y2#(v))*percentage#):NewZ#=z1#(v)-((z1#(v)-z2#(v))*percentage#)
if Polarity=-1 then NewX#=x2#(v)-((x2#(v)-x1#(v))*percentage#):NewY#=y2#(v)-((y2#(v)-y1#(v))*percentage#):NewZ#=z2#(v)-((z2#(v)-z1#(v))*percentage#)
set vertexdata position v,NewX#,NewY#,NewZ#
next
unlock vertexdata
return
NewBox:
if object exist(2)=1 then delete object 2
make object box 2,1+rnd(7),1+rnd(7),1+rnd(7):hide object 2 `randomize and hide our target shape
lock vertexdata for limb 2,0
vCount=get vertexdata vertex count()
dim x2#(vCount):dim y2#(vCount):dim z2#(vCount)
for v=0 to VCount
x2#(v)=get vertexdata position x(v)
y2#(v)=get vertexdata position y(v)
z2#(v)=get vertexdata position z(v)
next
unlock vertexdata
return