2

我想知道,如何获得 ModelInstance-ArrayList 的渲染图片。

public void modelBufferIcon(int i){
    for(int j = 0; j < i; j++){
        frameBuffer = new FrameBuffer(Format.RGB565, Hangar.WindowWidth , Hangar.WindowHeight, false);
        lights = new Lights();
        lights.ambientLight.set(ambientLight);
        lights.add(new PointLight().set(pointLightBack, 0f, -1f, -5f,pointLightBack_INTENSITY));
        lights.add(new PointLight().set(pointLightFront, 0f, -5f, 10f, pointLightFront_INTENSITY));
        perspectiveCamera.lookAt(roboterVector);
        perspectiveCamera.update();
        frameBuffer.begin();

            Gdx.graphics.getGL20().glViewport(0, 0, frameBuffer.getWidth(), frameBuffer.getHeight());
            Gdx.graphics.getGL20().glClearColor(0f, 0f, 0f, 1);
            Gdx.graphics.getGL20().glClear(GL20.GL_COLOR_BUFFER_BIT);
            Gdx.graphics.getGL20().glEnable(GL20.GL_TEXTURE_2D);

            modelBatch.begin(perspectiveCamera);
                modelBatch.render(physique.reBuildModel(Controller.getUser().getPets().get(j)),lights);
            modelBatch.end();

        frameBuffer.end();

        texture = frameBuffer.getColorBufferTexture();
        TextureRegion textureRegion = new TextureRegion(texture);
        textureRegion.flip(false, true);

        image_pet = new Image(textureRegion);
        imageClickHandler(image_pet, j);
        window.add(image_pet).row();
        window.pack();
        perspectiveCamera.lookAt(cameraVector);
        perspectiveCamera.update();
    }
}

在左侧你看到渲染的模型,在图片的右侧:

图片

使用(physique.reBuildModel(Controller.getUser().getPets().get(j)),lights)渲染方法获得五个 3d 模型(头部、手臂、...)的 Modelinstance。

4

0 回答 0