Ejemplo n.º 1
0
#include <core/cxEngine.h>
#include <core/cxNumber.h>
#include <core/cxActionRoot.h>
#include "cxSpline.h"

static void cxSplineInit(cxAny pav)
{
    cxSpline this = pav;
    CX_ASSERT(this->super.view != NULL, "view not set");
    this->delta = 1.0f/((cxFloat)cxArrayLength(this->points) - 1.0f);
}

static cxVec2f cxSplinePointAt(cxSpline this,cxInt idx)
{
    idx = CX_MIN(cxArrayLength(this->points) - 1, CX_MAX(idx, 0));
    cxNumber num = cxArrayAtIndex(this->points, idx);
    CX_ASSERT(num != NULL, "num error");
    return cxNumberToVec2f(num);
}

static void cxSplineStep(cxAny pav,cxFloat dt,cxFloat time)
{
    cxInt index = 0;
    cxSpline this = pav;
    cxFloat lt = 0;
    if (time >= 1.0f){
        index = cxArrayLength(this->points) - 1;
        lt = 1.0f;
    }else{
        index = time / this->delta;
Ejemplo n.º 2
0
cxVec2f cxSplinePointAt(cxAny pav,cxInt idx)
{
    CX_ASSERT_THIS(pav, cxSpline);
    idx = CX_MIN(cxAnyArrayLength(this->points) - 1, CX_MAX(idx, 0));
    return *cxAnyArrayAt(this->points, idx, cxVec2f);
}