我想知道,我如何获得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模型(头部,手臂,......)的模型实例。