• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CatmullRomSpline类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.badlogic.gdx.math.CatmullRomSpline的典型用法代码示例。如果您正苦于以下问题:Java CatmullRomSpline类的具体用法?Java CatmullRomSpline怎么用?Java CatmullRomSpline使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CatmullRomSpline类属于com.badlogic.gdx.math包,在下文中一共展示了CatmullRomSpline类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: read

import com.badlogic.gdx.math.CatmullRomSpline; //导入依赖的package包/类
@Override
public CatmullRomSpline read(Kryo kryo, Input input, Class<CatmullRomSpline> type) {
    CatmullRomSpline catmullRomSpline = new CatmullRomSpline();
    Class<? extends Vector> vectorType = kryo.readClass(input).getType();
    int controlPointsLength = input.readInt();
    if (controlPointsLength >= 0){
        Vector<?>[] controlPoints = (Vector<?>[])java.lang.reflect.Array.newInstance(vectorType, controlPointsLength);
        for (int i = 0; i < controlPointsLength; i++) {
            controlPoints[i] = kryo.readObjectOrNull(input, vectorType); // vector type won't be null if control points had a length
        }
        catmullRomSpline.controlPoints = controlPoints;
    }
    catmullRomSpline.continuous = input.readBoolean();
    catmullRomSpline.spanCount = input.readInt(true);
    return catmullRomSpline;
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:17,代码来源:CatmullRomSplineSerializer.java


示例2: render

import com.badlogic.gdx.math.CatmullRomSpline; //导入依赖的package包/类
public void render(Cable cable) {

        Vector2[] dataSet = new Vector2[cable.getBodyList().size()];
        /* fill dataSet with path points */
        for (int i = 0; i < cable.getBodyList().size(); i++) {
            Vector2 cablePosition = cable.getBodyList().get(i).getPosition();
            dataSet[i] = new Vector2(cablePosition.x * conf.UNIT_SIZE, cablePosition.y * conf.UNIT_SIZE);
        }

        CatmullRomSpline<Vector2> romSpline = new CatmullRomSpline<Vector2>(dataSet, false);

        for (int i = 0; i < Constants.CABLE_STEPS; i++) {
            points[i] = new Vector2();
            romSpline.valueAt(points[i], ((float) i) / ((float) Constants.CABLE_STEPS - 1));
        }

        shapeRenderer.setProjectionMatrix(camera.combined);
        shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
        for(int i = 0; i < Constants.CABLE_STEPS - 1; ++i)
        {
            Gdx.gl20.glLineWidth(Constants.CABLE_THICK);
            shapeRenderer.line(points[i], points[i + 1]);
        }
        shapeRenderer.end();
    }
 
开发者ID:cat-in-the-dark,项目名称:old48_30_game,代码行数:26,代码来源:CableRender.java


示例3: write

import com.badlogic.gdx.math.CatmullRomSpline; //导入依赖的package包/类
@Override
public void write(Kryo kryo, Output output, CatmullRomSpline catmullRomSpline) {
    Class<? extends Vector> vectorType = null;
    if (catmullRomSpline.controlPoints != null && catmullRomSpline.controlPoints.length > 0)
        vectorType = catmullRomSpline.controlPoints[0].getClass();
    kryo.writeClass(output, vectorType);
    output.writeInt(catmullRomSpline.controlPoints != null ? catmullRomSpline.controlPoints.length : -1); // -1 for null array
    if (catmullRomSpline.controlPoints != null){
        for (int i = 0; i < catmullRomSpline.controlPoints.length; i++) {
            kryo.writeObjectOrNull(output, catmullRomSpline.controlPoints[i], vectorType);
        }
    }
    output.writeBoolean(catmullRomSpline.continuous);
    output.writeInt(catmullRomSpline.spanCount, true);
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:16,代码来源:CatmullRomSplineSerializer.java


示例4: PathFollowSystem

import com.badlogic.gdx.math.CatmullRomSpline; //导入依赖的package包/类
public PathFollowSystem(){
	super(Family.all(PathFollower.class, Pose.class).get());
	Vector3[] controlPoints = new Vector3[]{new Vector3(0,0,1),
											new Vector3(0,0,-5),
											new Vector3(2,-2.6f,-7.6f),
											new Vector3(3.1f,-1.8f,-15.4f),
											new Vector3(4.2f,-1.3f,-23.8f),
											new Vector3(4.6f,-0.4f,-29.4f),
											new Vector3(4.7f,-0.4f,-29.6f),
											new Vector3(4.7f,-0.4f,-29.7f)};
	spline = new CatmullRomSpline<Vector3>(controlPoints, false);
}
 
开发者ID:urstruktur,项目名称:zierfisch,代码行数:13,代码来源:PathFollowSystem.java


示例5: create

import com.badlogic.gdx.math.CatmullRomSpline; //导入依赖的package包/类
@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);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:32,代码来源:PathTest.java


示例6: initPath

import com.badlogic.gdx.math.CatmullRomSpline; //导入依赖的package包/类
public void initPath(int appWidth, int appHeight){

        //random values
        float xStart = Util.getRandomNumberBetween(0+sprite.getWidth(), appWidth-sprite.getWidth());
        float xEnd =  Util.getRandomNumberBetween(0+sprite.getWidth(), appWidth-sprite.getWidth());

        //ControlPoint1
        float cp1X =  Util.getRandomNumberBetween(0 + sprite.getWidth(), appWidth - sprite.getWidth());
        float cp1Y =  Util.getRandomNumberBetween(0+sprite.getWidth(), appHeight-sprite.getHeight());

        //ControlPoint2
        float cp2X =  Util.getRandomNumberBetween(0+sprite.getWidth(), appWidth-sprite.getWidth());
        float cp2Y =  Util.getRandomNumberBetween(0, cp1Y);

        Vector2 s = new Vector2(xStart, appHeight);
        Vector2 e = new Vector2(xEnd, -sprite.getHeight());
        Vector2 cp1 = new Vector2(cp1X, cp1Y);
        Vector2 cp2 = new Vector2(cp2X, cp2Y);

        dataSet[0] = s;
        dataSet[1] = cp2;
        dataSet[2] = cp1;
        dataSet[3] = e;

        // enemy path
        myCatmull = new CatmullRomSpline<Vector2>(dataSet, true);
    }
 
开发者ID:sscholle,项目名称:top-down-shooter,代码行数:28,代码来源:Enemy.java


示例7: refreshSpline

import com.badlogic.gdx.math.CatmullRomSpline; //导入依赖的package包/类
public void refreshSpline() {
	float[] translated = poly.getTransformedVertices();
	Vector2[] dataSet = new Vector2[numControlls];

	for (int i = 0; i < numControlls; i++) {
		dataSet[i] = new Vector2(translated[i * 2], translated[i * 2 + 1]);
	}

	spline = new CatmullRomSpline<Vector2>(dataSet, false);
}
 
开发者ID:Yasu11,项目名称:aigraphs,代码行数:11,代码来源:CatmulRomSpline.java


示例8: initPath

import com.badlogic.gdx.math.CatmullRomSpline; //导入依赖的package包/类
public void initPath(int appWidth, int appHeight){

        //random values
        float xStart = Util.getRandomNumberBetween(0 + _sprite.getWidth(), appWidth - _sprite.getWidth());
        float xEnd =  Util.getRandomNumberBetween(0 + _sprite.getWidth(), appWidth - _sprite.getWidth());

        //ControlPoint1
        float cp1X =  Util.getRandomNumberBetween(0 + _sprite.getWidth(), appWidth - _sprite.getWidth());
        float cp1Y =  Util.getRandomNumberBetween(0 + _sprite.getWidth(), appHeight - _sprite.getHeight());

        //ControlPoint2
        float cp2X =  Util.getRandomNumberBetween(0 + _sprite.getWidth(), appWidth - _sprite.getWidth());
        float cp2Y =  Util.getRandomNumberBetween(0, cp1Y);

        Vector2 s = new Vector2(xStart, appHeight);
        Vector2 e = new Vector2(xEnd, -_sprite.getHeight());
        Vector2 cp1 = new Vector2(cp1X, cp1Y);
        Vector2 cp2 = new Vector2(cp2X, cp2Y);

        dataSet[0] = s;
        dataSet[1] = cp2;
        dataSet[2] = cp1;
        dataSet[3] = e;

        // enemy path
        myCatmull = new CatmullRomSpline<Vector2>(dataSet, true);
    }
 
开发者ID:sscholle,项目名称:PlanePilot,代码行数:28,代码来源:Enemy.java


示例9: PathSpline

import com.badlogic.gdx.math.CatmullRomSpline; //导入依赖的package包/类
public PathSpline() {
	spline = new CatmullRomSpline();
	controlVertices = new ArrayList<Vector3>();
}
 
开发者ID:steelkiwi,项目名称:libGDX-Path-Editor,代码行数:5,代码来源:PathSpline.java



注:本文中的com.badlogic.gdx.math.CatmullRomSpline类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BinaryResponseWriter类代码示例发布时间:2022-05-23
下一篇:
Java XML11Char类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap