2

BSpline と ShapeRenderer を使用して曲線を描画しようとしています。遠近法カメラを使用すると、それができることに気づきました。代わりに OrthographicCamera を使用しようとすると、画面に何もレンダリングされません。私の目標は、Shape と同じデザインに従う ShapeRenderer と Sprite を使用して BSPline を描画することです。これを修正する方法/私が間違っていることを誰か教えてもらえますか? どうもありがとう

public class MyGdxGame extends GdxTest implements ApplicationListener {
    private SpriteBatch spriteBatch;
    ParticleEffect effect;
    int emitterIndex;
    Array<ParticleEmitter> emitters;
    int particleCount = 10;
    float fpsCounter;
    InputProcessor inputProcessor;

    int CAMERA_WIDTH = 640; //Gdx.graphics.getWidth(); if use this function an exception is arose
    int CAMERA_HEIGHT = 480; //Gdx.graphics.getHeight(); if use this function an exception is arose

    BspHbCached hb;
    ShapeRenderer renderer;
    int nPoints;
    private OrthographicCamera camera;

    @Override
    public void create () {
    hb = new BspHbCached(CAMERA_WIDTH/4, CAMERA_WIDTH/4); // caching points for curve to draw
    renderer = new ShapeRenderer();
    nPoints = hb.getNumSamplePoints();

    camera = new OrthographicCamera(CAMERA_WIDTH, CAMERA_HEIGHT);

    camera.position.set(CAMERA_WIDTH / 2f, CAMERA_HEIGHT / 2f, 0);  
    camera.update();    

    spriteBatch = new SpriteBatch();

    effect = new ParticleEffect();
    effect.load(Gdx.files.internal("data/test.p"), Gdx.files.internal("data"));
    effect.setPosition(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2);
    // Of course, a ParticleEffect is normally just used, without messing around with its emitters.
    emitters = new Array(effect.getEmitters());
    effect.getEmitters().clear();
    effect.getEmitters().add(emitters.get(0));

    inputProcessor = new InputProcessor() {
    public boolean touchUp (int x, int y, int pointer, int button) {
    return false;
    }

ここに私の他の重要な方法があります:

    public void render () {

    float delta = Gdx.graphics.getDeltaTime();
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);


    renderer.setProjectionMatrix(camera.combined);
    spriteBatch.setProjectionMatrix(camera.combined);
    for(int i = 0; i < nPoints - 1; i++) // all points contained in bspline to draw
    {

    renderer.begin(ShapeType.Line);
    renderer.setColor(Color.RED);
    renderer.line(p1,p2);
    renderer.end();
    }


    spriteBatch.begin();
    effect.draw(spriteBatch, delta);
    spriteBatch.end();

    fpsCounter += delta;
    if (fpsCounter > 3) {
    fpsCounter = 0;
    int activeCount = emitters.get(emitterIndex).getActiveCount();
    Gdx.app.log("libgdx", activeCount + "/" + particleCount + " particles, FPS: " + Gdx.graphics.getFramesPerSecond());
    }

    }   
}

NB: 私の出発点はパス インターフェース スプラインでした

4

0 に答える 0