So I've been working on a bunch of different stuff and haven't touched this much directly but I am re-writing the JSON reader to be more portable for other projects. Other than that I have been getting some useful bezier functions together so that I can get the curve values working in my Spine library.
For fun I did this in AGK.Net (C#) and then ported it to AppGameKit Basic:
EDIT: Here's the code I translated for beziers (and the cut down function I'll be testing in my Spine library):
rem full function for getting a bezier curve x component
rem where points x1,y1 and x2,y2 are the start/end points
rem and c1x,c1y and c2x,c2y are the control points
function getPointXOnBezier(x1#, y1#, x2#, y2#, c1x#, c1y#, c2x#, c2y#, v#)
cx# = 3 * (c1x# - x1#)
bx# = 3 * (c2x# - c1x#) - cx#
ax# = x2# - x1# - cx# - bx#
x# = ((ax# * v# + bx#) * v# + cx#) * v# + x1#
endfunction x#
rem full function for getting a bezier curve y component
function getPointYOnBezier(x1#, y1#, x2#, y2#, c1x#, c1y#, c2x#, c2y#, v#)
cy# = 3 * (c1y# - y1#)
by# = 3 * (c2y# - c1y#) - cy#
ay# = y2# - y1# - cy# - by#
y# = ((ay# * v# + by#) * v# + cy#) * v# + y1#
endfunction y#
rem developed for Tier 1 Spine library
rem takes a time value (t#) between 0 and 1 and returns
rem a curve value (v# is Y) for the given bezier curve
function getCurveValue(c1x#, c1y#, c2x#, c2y#, t#)
c# = 3 * c1y#
b# = 3 * (c2y# - c1y#) - c#
a# = 1 - c# - b#
v# = ((a# * t# + b#) * t# + c#) * t#
endfunction v#
"Here I am trying to do some good for the world..." - Fluffy Rabbit