Java 类com.badlogic.gdx.math.Bezier 实例源码

项目:Vloxlands    文件:Generator.java   
public static Vector2 getHighestBezierValue(float[] c) {
    Vector2 p0 = new Vector2(c[0], c[1]);
    Vector2 p1 = new Vector2(c[2], c[3]);
    Vector2 p2 = new Vector2(c[4], c[5]);
    Vector2 p3 = new Vector2(c[6], c[7]);
    float y = 0;
    float x = 0;
    for (float i = 0; i < 1; i += 0.01f) {
        Vector2 v = Bezier.cubic(new Vector2(), i, p0, p1, p2, p3, new Vector2());
        if (v.y > y) {
            x = i;
            y = v.y;
        }
    }

    return new Vector2(x, y);
}
项目:Alien-Ark    文件:EnterPlanetAnimation.java   
public EnterPlanetAnimation(PerspectiveCamera camera, Rocket rocket, OverlayRenderer overlayRenderer, AnimationFinishedListener listener) {
    super(3000, listener);
    this.camera = camera;
    this.rocket = rocket;
    this.overlayRenderer = overlayRenderer;

    camera.up.set(Vector3.Z);

    exitPath = new Bezier<Vector3>();
    exitPath.set(
            new Vector3(-300, 0, 280),
            new Vector3(-30, 0, 140),
            new Vector3(20, 0, 110));
}
项目:Alien-Ark    文件:ExitPlanetAnimation.java   
public ExitPlanetAnimation(PerspectiveCamera camera, Rocket rocket, OverlayRenderer overlayRenderer, AnimationFinishedListener listener) {
    super(3000, listener);
    this.camera = camera;
    this.rocket = rocket;
    this.overlayRenderer = overlayRenderer;
    this.baseFieldOfView = camera.fieldOfView;
    rocket.setThirdPersonCam(null);
    exitPath = new Bezier<Vector3>();
    exitPath.set(
            new Vector3(20, 0, 110),
            new Vector3(-30, 0, 140),
            new Vector3(-300, 0, 280));
}
项目:CodeBase    文件:TextChar.java   
private void renderChar(BitmapFont font, Color color, Vector2 offset, float t, float alpha) {
    color.a = alpha;
    Bezier.quadratic(temp2, t, start, control, end, temp1);
    temp2.add(offset);
    font.setColor(color);
    font.setScale(0.5f + t * 0.5f);
    font.draw(DrawUtil.batch, text, temp2.x, temp2.y);
}
项目:libgdxcn    文件:PathTest.java   
@Override
public void create () {
    renderer = new ImmediateModeRenderer20(false, false, 0);
    spriteBatch = new SpriteBatch();
    obj = new Sprite(new Texture(Gdx.files.internal("data/badlogicsmall.jpg")));
    obj.setSize(40, 40);
    obj.setOriginCenter();
    obj2 = new Sprite(new Texture(Gdx.files.internal("data/bobrgb888-32x32.png")));
    obj2.setSize(40, 40);
    obj2.setOriginCenter();
    ZIGZAG_SCALE = Gdx.graphics.getDensity() * 96; // 96DP

    float w = Gdx.graphics.getWidth() - obj.getWidth();
    float h = Gdx.graphics.getHeight() - obj.getHeight();

    paths.add(new Bezier<Vector2>(new Vector2(0, 0), new Vector2(w, h)));
    paths.add(new Bezier<Vector2>(new Vector2(0, 0), new Vector2(0, h), new Vector2(w, h)));
    paths.add(new Bezier<Vector2>(new Vector2(0, 0), new Vector2(w, 0), new Vector2(0, h), new Vector2(w, h)));

    Vector2 cp[] = new Vector2[] {new Vector2(0, 0), new Vector2(w * 0.25f, h * 0.5f), new Vector2(0, h),
        new Vector2(w * 0.5f, h * 0.75f), new Vector2(w, h), new Vector2(w * 0.75f, h * 0.5f), new Vector2(w, 0),
        new Vector2(w * 0.5f, h * 0.25f)};
    paths.add(new BSpline<Vector2>(cp, 3, true));

    paths.add(new CatmullRomSpline<Vector2>(cp, true));

    pathLength = paths.get(currentPath).approxLength(500);
    avg_speed = speed * pathLength;

    Gdx.input.setInputProcessor(this);
}
项目:Vloxlands    文件:BezierEditor.java   
@Override
public void create() {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        e.printStackTrace();
    }
    stage = new Stage(new ScreenViewport());
    fontBatch = new SpriteBatch();

    font = new BitmapFont();
    assets = new AssetManager();
    assets.load("img/gui/knob.png", Texture.class);
    assets.finishLoading();

    skin = new Skin(Gdx.files.internal("skin/default/uiskin.json"));
    skin.add("knob", assets.get("img/gui/knob.png", Texture.class));

    knobs = new Image[4];
    renderer = new ImmediateModeRenderer20(false, false, 0);

    Vector2[] v = new Vector2[4];
    Vector2[] w = new Vector2[4];

    for (int i = 0; i < knobs.length; i++) {
        knobs[i] = new Image(skin.getDrawable("knob"));
        knobs[i].setPosition(startPos[i].x, startPos[i].y);
        stage.addActor(knobs[i]);
        v[i] = new Vector2(startPos[i].x, startPos[i].y);
        w[i] = new Vector2((startPos[i].x - X) / SIZE, (startPos[i].y - X) / SIZE);
    }

    bezier = new Bezier<Vector2>(v);
    bezierLogic = new Bezier<Vector2>(w);

    stage.addListener(this);
    stage.getCamera().rotate(Vector3.Z, -270);

    Gdx.input.setInputProcessor(stage);
}
项目:Vloxlands    文件:Generator.java   
public static void generateBezier(Island island, float[] c, int x, int z, int radius, int off, int h, byte[] b, boolean force) {
    Vector2 p0 = new Vector2(c[0], c[1]);
    Vector2 p1 = new Vector2(c[2], c[3]);
    Vector2 p2 = new Vector2(c[4], c[5]);
    Vector2 p3 = new Vector2(c[6], c[7]);
    for (int i = 0; i < h; i++) {
        float t = i / (float) h;

        float rad = (float) Math.floor(radius * Bezier.cubic(new Vector2(), t, p0, p1, p2, p3, new Vector2()).y);
        fillHorizontalCircle(island, x, off - i, z, rad, b, force);
    }
}
项目:Vloxlands    文件:Generator.java   
/**
 * [0 - 1]
 */
public static float getBezierValue(float[] c, float x) {
    Vector2 p0 = new Vector2(c[0], c[1]);
    Vector2 p1 = new Vector2(c[2], c[3]);
    Vector2 p2 = new Vector2(c[4], c[5]);
    Vector2 p3 = new Vector2(c[6], c[7]);

    return Bezier.cubic(new Vector2(), x, p0, p1, p2, p3, new Vector2()).y;
}
项目:gdx-cclibs    文件:BezierSerializer.java   
@Override
public void write(Kryo kryo, Output output, Bezier bezier) {
    kryo.writeObjectOrNull(output, bezier.points, Array.class);
}
项目:gdx-cclibs    文件:BezierSerializer.java   
@Override
public Bezier read(Kryo kryo, Input input, Class<Bezier> type) {
    Bezier bezier = new Bezier();
    bezier.points = kryo.readObjectOrNull(input, Array.class);
    return bezier;
}
项目:zierfisch    文件:RulePathFollow.java   
public RulePathFollow(Bezier<Vector3> curve){
    this(curve, 1.0f);
}