Added lua interface for using bezier curves.

This commit is contained in:
Kyzentun Keeslala
2015-06-22 21:08:55 -06:00
parent ac3ecfd034
commit 87d0687457
4 changed files with 191 additions and 0 deletions
+17
View File
@@ -1361,6 +1361,14 @@
<Class name='RadarValues'>
<Function name='GetValue'/>
</Class>
<Class name='RageBezier2D'>
<Function name='destroy'/>
<Function name='evaluate'/>
<Function name='evaluate_y_from_x'/>
<Function name='get_x'/>
<Function name='get_y'/>
<Function name='set_from_bezier'/>
</Class>
<Class name='RageDisplay'>
<Function name='GetCumFPS'/>
<Function name='GetDisplayHeight'/>
@@ -1393,6 +1401,15 @@
<Class name='RageInput'>
<Function name='GetDescriptions'/>
</Class>
<Class name='RageQuadratic'>
<Function name='evaluate'/>
<Function name='get_bezier'/>
<Function name='get_bezier_end'/>
<Function name='get_bezier_start'/>
<Function name='get_slope'/>
<Function name='set_from_bezier'/>
<Function name='set_from_cubic'/>
</Class>
<Class name='RageSound'>
<Function name='get_length'/>
<Function name='SetParam'/>
+56
View File
@@ -126,6 +126,9 @@ save yourself some time, copy this for undocumented things:
converts them to equivalent lua files. See Docs/Themerdocs/XmlToLua.txt
for details.
</Function>
<Function name='create_bezier' return='RageBezier2D' arguments=''>
Creates a RageBezier2D for you to use. Make sure you destroy the RageBezier2D when you're done with it, or you will have a memory leak.
</Function>
<Function name='create_spline' return='CubicSplineN' arguments=''>
Creates a CubicSplineN for you to use. Make sure you destroy the CubicSplineN when you're done with it, or you will have a memory leak.
</Function>
@@ -4027,6 +4030,32 @@ save yourself some time, copy this for undocumented things:
Returns the value of <code>rc</code> from <Link class='Steps' function='GetRadarValues' />.
</Function>
</Class>
<Class name='RageBezier2D'>
<Description>
You must call create_bezier to create a RageBezier2D to use any of these functions. When you are done with the object, destroy it with its destroy function to avoid a memory leak.<br />
A RageBezier2D is two RageQuadratics, one for the x coordinate and one for the y.<br />
This class is provided as a tool for designers working with bezier tweens who need a tool that displays the tween curve visually.<br />
If you use Actor:tween(time, "TweenType_Bezier", {xa, ya, xb, yb, xc, yc, xd, yd}) to tween an actor, the actor creates a RageBezier2D internally and calls evaluate_y_from_x each frame to set where it is in the tween.
</Description>
<Function name='destroy' return='' arguments=''>
Destroys the RageBezier2D. Do not attempt to use it after it has been destroyed.
</Function>
<Function name='evaluate' return='float,float' arguments='float t'>
Evaluates the bezier curve at the given t and returns the x and y values. This is equivalent to using get_x and get_y to fetch the quadratic parts and calling evaluate on them directly.
</Function>
<Function name='evaluate_y_from_x' return='float' arguments='float x'>
Takes the x given and converts it to a t value, then evaluates the y quadratic with the t value and returns the result.
</Function>
<Function name='get_x' return='RageQuadratic' arguments=''>
Returns the RageQuadratic used for the x component.
</Function>
<Function name='get_y' return='RageQuadratic' arguments=''>
Returns the RageQuadratic used for the y component.
</Function>
<Function name='set_from_bezier' return='' arguments='float xa, float ya, float xb, float yb, float xc, float yc, float xd, float yd'>
Sets the values used by the two quadratics. This is equivalent to using get_x and get_y to get the quadratics and setting them directly. Note that the components for the x quadratic and the y quadratic are interleaved.
</Function>
</Class>
<Class name='RageDisplay'>
<Function name='GetDisplayHeight' return='int' arguments=''>
Return the height of the display.
@@ -4113,6 +4142,33 @@ save yourself some time, copy this for undocumented things:
Return an array of connected input device descriptions.
</Function>
</Class>
<Class name='RageQuadratic'>
<Description>
If you use Actor:tween(time, "TweenType_Bezier", {a, b, c, d}) to tween an actor, the actor creates a RageQuadratic internally and calls evaluate each frame to set where it is in the tween.
</Description>
<Function name='evaluate' return='float' arguments='float t'>
Evaluates the quadratic at the given t value and returns the result.
</Function>
<Function name='get_bezier' return='float,float,float,float' arguments=''>
Returns the four values that form the quadratic equation. This function returns multiple values, so you must do something like this to get them:<br />
a, b, c, d= quadratic:get_bezier()
</Function>
<Function name='get_bezier_end' return='float' arguments=''>
Equivalent to evaluate(1), but faster.
</Function>
<Function name='get_bezier_start' return='float' arguments=''>
Equivalent to evaluate(0), but faster.
</Function>
<Function name='get_slope' return='float' arguments='float t'>
Returns the slope of the curve at the given t value.
</Function>
<Function name='set_from_bezier' return='' arguments='float a, float b, float c, float d'>
Sets the four values that form the quadratic equation.
</Function>
<Function name='set_from_cubic' return='' arguments='float a, float b, float c, float d'>
Sets the four values that form the quadratic equation, treating the arguments as from a cubic equation instead of as from a bezier curve.
</Function>
</Class>
<Class name='RageSound'>
<Description>
See <Link class='ActorSound' /> for loading a sound.