NEWS *MAJOR CODE UPDATE* ok not really. this is the form my code has been in for the past few days. I have not had much time to work on it. but it does give a little taste of what will be possible shortly. When running press "A" as in (A)nimation editor. So far it just lets you look at the Key frames already set and the interpolation between them. But once I get a nice interface to select limbs the three slider bars on the right will position them. More Power To The "Line" command!!
REM Project: Stick figures
REM Created: 4/23/2006 12:26:00 PM
REM By Coding Fodder
REM ***** Main Source File *****
REM
sync on: sync rate 0
set display mode 1024,768,32
type AnimationKeyFrame
scale as float
Xangle as float
Yangle as float
Zangle as float
explicitScale as boolean
explicitX as boolean
explicitY as boolean
explicitZ as boolean
EndType
#constant pi=3.1415926535898
#constant totalKeyFrames = 30
global dim KeyFrame(totalKeyFrames,21) as AnimationKeyFrame
MakeStickMan()
do
animationFrame#=animationFrame#+0.04
if animationFrame#>=21 then animationFrame#=0
angle#=wrapvalue(angle#+0.05)
animate(int(AnimationFrame#)+10)
yRotate_Limb(FigureCG,angle#)
RenderMan()
sync
cls
Select inkey$()
case "a","A": animationEditor():endcase
EndSelect
loop
Function animationEditor()
number#=0
do
cls
Text 868,60,"X Angle"
Text 888,40,"Y Angle"
Text 908,20,"Z Angle"
Xangle#=sliderBar(920,80,628,Xangle#,-360,360,1,1)
Yangle#=sliderBar(940,60,628,Yangle#,-360,360,1,1)
Zangle#=sliderBar(960,40,628,Zangle#,-360,360,1,1)
frame=sliderBar(40,720,800,frame,0,totalKeyFrames,1,0)
animate(int(Frame))
xRotate_Limb(FigureCG,Xangle#)
yRotate_Limb(FigureCG,Yangle#)
zRotate_Limb(FigureCG,Zangle#)
RenderMan()
sync
loop
EndFunction
Function sliderBar(X,Y,Length#,OldValue#,Minval#,Maxval#,Increment#,Orientation)
if OldValue#<MinVal# then OldValue#=MinVal#
if OldValue#>MaxVal# then OldValue#=MaxVal#
Offset#=0-Minval#
pixelsPERunit#=Length#/(MaxVal#-MinVal#)
if Orientation = 0
line X,Y,X+Length#,Y
box X-5+(Oldvalue#+Offset#)*pixelsPERunit#, Y-5, X+5+(Oldvalue#+Offset#)*pixelsPERunit#, Y+5
if mouseclick() = 1
if mousex() < X+5+(Oldvalue#+Offset#)*pixelsPERunit# and mousex() > X-5+(Oldvalue#+Offset#)*pixelsPERunit# and mousey() < y+5 and mousey() > y-5
OldValue#=OldValue#+mousemovex()*Increment#
if OldValue#<MinVal# then OldValue#=MinVal#
if OldValue#>MaxVal# then OldValue#=MaxVal#
position mouse X+(Oldvalue#+Offset#)*pixelsPERunit#,Y
endif
else
junk=mousemovex()
endif
text x,y+20,TruncateFloat(OldValue#,2)
else
line X,Y,X,Y+Length#
box X-5, Y-5+(Oldvalue#+Offset#)*pixelsPERunit#, X+5, Y+5+(Oldvalue#+Offset#)*pixelsPERunit#
if mouseclick() = 1
if mousex() < X+5 and mousex() > X-5 and mousey() < y+5+(Oldvalue#+Offset#)*pixelsPERunit# and mousey() > y-5+(Oldvalue#+Offset#)*pixelsPERunit#
OldValue#=OldValue#+mousemovey()*Increment#
if OldValue#<MinVal# then OldValue#=MinVal#
if OldValue#>MaxVal# then OldValue#=MaxVal#
position mouse X,Y+(Oldvalue#+Offset#)*pixelsPERunit#
endif
else
junk = mousemovey()
endif
OldValue#=int(OldValue#/Increment#)*Increment#
text x,y+length#+10,TruncateFloat(OldValue#,2)
endif
Endfunction OldValue#
function TruncateFloat(number#,decimalPlaces)
whole=int(number#)
fraction$=right$(left$(str$(number#-whole),4),2)
out$=str$(whole)+"."+fraction$
endfunction out$
Function animate(frame)
for i = 1 to 20
Scale_Limb(i,KeyFrame(frame,i).scale)
zRotate_Limb(i,KeyFrame(frame,i).Zangle)
yRotate_Limb(i,KeyFrame(frame,i).Yangle)
xRotate_Limb(i,KeyFrame(frame,i).Xangle)
next i
print str$(KeyFrame(frame,leftHumurous).Xangle)
EndFunction
Function Setkeyframe(frame as integer, Limb as integer, scale as float, Xangle as float, Yangle as float, Zangle as float)
text 1,1,str$(KeyFrame(frame,Limb).explicitX)
If scale <= 360
KeyFrame(frame,Limb).scale=scale
KeyFrame(frame,Limb).explicitScale=1
endif
If Xangle <= 360
KeyFrame(frame,Limb).Xangle=Xangle
KeyFrame(frame,Limb).explicitX=1
endif
If Yangle <= 360
KeyFrame(frame,Limb).Yangle=Yangle
KeyFrame(frame,Limb).explicitY=1
endif
If Zangle <= 360
KeyFrame(frame,Limb).Zangle=Zangle
KeyFrame(frame,Limb).explicitZ=1
endif
text 50,1,str$(KeyFrame(frame,Limb).Xangle)
`Interpolate scale key frames
i=1
while i <= totalKeyFrames
j = i
explicitFound=0
while j <= totalKeyFrames and explicitFound=0
inc j
if KeyFrame(j,Limb).explicitScale=1 then explicitFound=1
endwhile
for value = i to j
KeyFrame(value,Limb).scale = KeyFrame(i,Limb).scale/(j-i)*(j-value) + KeyFrame(j,Limb).scale/(j-i)*(value-i)
next value
i=j
endwhile
`Interpolate Xrotation keyframes
i=1
while i <= totalKeyFrames
j = i
explicitFound=0
while j <= totalKeyFrames and explicitFound=0
inc j
if KeyFrame(j,Limb).explicitX=1 then explicitFound=1
endwhile
for value = i to j
KeyFrame(value,Limb).Xangle = KeyFrame(i,Limb).Xangle/(j-i)*(j-value) + KeyFrame(j,Limb).Xangle/(j-i)*(value-i)
next value
i=j
endwhile
`Interpolate Yrotation keyframes
i=1
while i <= totalKeyFrames
j = i
explicitFound=0
while j <= totalKeyFrames and explicitFound=0
inc j
if KeyFrame(j,Limb).explicitY=1 then explicitFound=1
endwhile
for value = i to j
KeyFrame(value,Limb).Yangle = KeyFrame(i,Limb).Yangle/(j-i)*(j-value) + KeyFrame(j,Limb).Yangle/(j-i)*(value-i)
next value
i=j
endwhile
`Interpolate Zrotation keyframes
i=1
while i <= totalKeyFrames
j = i
explicitFound=0
while j <= totalKeyFrames and explicitFound=0
inc j
if KeyFrame(j,Limb).explicitZ=1 then explicitFound=1
endwhile
for value = i to j
KeyFrame(value,Limb).Zangle = KeyFrame(i,Limb).Zangle/(j-i)*(j-value) + KeyFrame(j,Limb).Zangle/(j-i)*(value-i)
next value
i=j
endwhile
EndFunction
Function RenderMan()
Set Vector4 101,x Vector4(1),y Vector4(1),z Vector4(1),w Vector4(1)
for i = 2 to 20
Multiply matrix4 200+i,200+i,200+connections(i)
Transform Vector4 100+i,i,200+i
Add Vector4 100+i,100+i,100+connections(i)
if i<>head and i<>RightHand and i<> lefthand and i <> FigureCG
line x Vector4(100+connections(i)),768-y Vector4(100+connections(i)),x Vector4(100+i),768-y Vector4(100+i)
Endif
next i
circle x Vector4(100+Head),768-y Vector4(100+Head),10
circle x Vector4(100+LeftHand),768-y Vector4(100+LeftHand),5
circle x Vector4(100+RightHand),768-y Vector4(100+RightHand),5
for i = 1 to 20
Set Identity Matrix4 200+i
next i
EndFunction
Function Scale_Limb(limb as integer,amount as float)
`scale matrix4 Ident,amount,amount,amount
`Multiply matrix4 200+limb,200+limb,Ident
`Set Identity matrix4 Ident
EndFunction
Function xRotate_Limb(limb as integer,angle as float)
Rotate X Matrix4 Ident,angle*pi/180.0
Multiply matrix4 200+limb,200+limb,Ident
Set Identity matrix4 Ident
EndFunction
Function yRotate_Limb(limb as integer,angle as float)
Rotate Y Matrix4 Ident,angle*pi/180.0
Multiply matrix4 200+limb,200+limb,Ident
Set Identity matrix4 Ident
EndFunction
Function zRotate_Limb(limb as integer,angle as float)
Rotate Z Matrix4 Ident,angle*pi/180.0
Multiply matrix4 200+limb,200+limb,Ident
Set Identity matrix4 Ident
EndFunction
Function MakeStickMan()
#constant FigurePosition = 1
#constant FigureCG = 2
#constant UpperTorso = 3
#constant Neck = 4
#constant Head = 5
#constant LeftShoulder = 6
#constant LeftHumurous = 7
#constant LeftForeArm = 8
#constant LeftHand=9
#constant RightShoulder=10
#constant RightHumurous = 11
#constant RightForeArm = 12
#constant RightHand = 13
#constant LowerBack = 14
#constant LeftThigh = 15
#constant leftShin = 16
#constant leftFoot = 17
#constant RightThigh = 18
#constant RightShin = 19
#constant RightFoot = 20
#constant Ident = 199
nothing = Make Matrix4(Ident)
Set Identity Matrix4 Ident
for i = 1 to 20
nothing = Make Vector4(i)
nothing = Make Vector4(100+i)
nothing = Make Matrix4(200+i)
Set Identity Matrix4 200+i
next i
Set Vector4 FigurePosition,200,200,0,0
Set Vector4 FigureCG,0,135,0,0
Set Vector4 UpperTorso,-2,30,0,0
Set Vector4 Neck,1,12,0,0
Set Vector4 Head,3,10,0,0
Set Vector4 LeftShoulder,0,-5,20,0
Set Vector4 LeftHumurous,0,-40,10,0
Set Vector4 LeftForeArm,10,-35,10,0
Set Vector4 LeftHand,2,-5,3,0
Set Vector4 RightShoulder,0,-5,-20,0
Set Vector4 RightHumurous,0,-40,-10,0
Set Vector4 RightForeArm,10,-35,-10,0
Set Vector4 RightHand,2,-5,-3,0
Set Vector4 LowerBack,-2,-40,0,0
Set Vector4 LeftThigh,0,-50,20,0
Set Vector4 leftShin,0,-45,15,0
Set Vector4 leftFoot,15,0,2,0
Set Vector4 RightThigh,0,-50,-20,0
Set Vector4 RightShin,0,-45,-15,0
Set Vector4 RightFoot,15,0,-2,0
dim connections(20) as integer
connections(FigurePosition)=0
connections(FigureCG)=FigurePosition
connections(UpperTorso)=FigureCG
connections(Neck)=UpperTorso
connections(Head)=Neck
connections(LeftShoulder)=UpperTorso
connections(LeftHumurous)=LeftShoulder
connections(LeftForeArm)=LeftHumurous
connections(LeftHand)=LeftForeArm
connections(RightShoulder)=UpperTorso
connections(RightHumurous)=RightShoulder
connections(RightForeArm)=RightHumurous
connections(RightHand)=RightForeArm
connections(LowerBack)=FigureCG
connections(LeftThigh)=LowerBack
connections(LeftShin)=LeftThigh
connections(LeftFoot)=LeftShin
connections(RightThigh)=LowerBack
connections(RightShin)=RightThigh
connections(RightFoot)=RightShin
`Values over 360 are ingnored set to whatever interpolation value the program sees fit depending on
`other keyframes
SetKeyFrame(10,RightThigh,400,-20,10,50)
SetKeyFrame(10,RightShin,400,400,400,-80)
SetKeyFrame(5,RightFoot,400,400,400,10)
SetKeyFrame(10,RightFoot,400,400,400,-15)
SetKeyFrame(10,LeftThigh,400,20,10,-10)
SetKeyFrame(10,LeftShin,400,400,400,-20)
SetKeyFrame(10,UpperTorso,400,400,400,-10)
SetKeyFrame(10,LeftHumurous,400,400,400,10)
SetKeyFrame(10,RightHumurous,400,400,400,-10)
SetKeyFrame(20,LeftThigh,400,20,10,50)
SetKeyFrame(20,LeftShin,400,400,400,-80)
SetKeyFrame(15,LeftFoot,400,400,400,10)
SetKeyFrame(20,LeftFoot,400,400,400,-15)
SetKeyFrame(20,RightThigh,400,-20,10,-10)
SetKeyFrame(20,RightShin,400,400,400,-20)
SetKeyFrame(20,UpperTorso,400,400,400,-10)
SetKeyFrame(20,RightHumurous,400,400,400,10)
SetKeyFrame(20,LeftHumurous,400,400,400,-10)
SetKeyFrame(30,RightThigh,400,-20,10,50)
SetKeyFrame(30,RightShin,400,400,400,-80)
SetKeyFrame(25,RightFoot,400,400,400,10)
SetKeyFrame(30,RightFoot,400,400,400,-15)
SetKeyFrame(30,LeftThigh,400,20,10,-10)
SetKeyFrame(30,LeftShin,400,400,400,-20)
SetKeyFrame(30,UpperTorso,400,400,400,-10)
SetKeyFrame(30,LeftHumurous,400,400,400,10)
SetKeyFrame(30,RightHumurous,400,400,400,-10)
`SetKeyFrame(20,,400,400,400,400)
`SetKeyFrame(,,400,400,400,400)
Endfunction
~Fodder
Who was that guy? he joined yesturday and today I am reaching for my large trout....
Something really catchy that makes people stop and think about the meaning of life and say to themselves "My but thats clever"