我正在尝试在从 Blender 导出的球体周围映射单个纹理。该模型在 Blender 中看起来很棒,但是当我在我的 Android 应用程序中使用它时,纹理似乎映射到几乎每个面,而不是整个球体。有任何想法吗?我在 Android 上使用 libGDX。
设置代码:
model = G3dtLoader.loadStillModel(Gdx.files.internal("models/planet.g3dt"), true);
for(StillSubMesh mesh: model.subMeshes) {
mesh.mesh.scale(0.1f, 0.1f, 0.1f);
}
G3dExporter.export(model, Gdx.files.local("models/planet.g3d"));
model = G3dLoader.loadStillModel(Gdx.files.local("models/planet.g3d"));
texture = new Texture(Gdx.files.internal("textures/planet1_pot.png"), true);
bounds = new BoundingBox();
model.getBoundingBox(bounds);
float len = bounds.getDimensions().len();
cam = new PerspectiveCamera(60, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.position.set(bounds.getCenter().cpy().add(len / 2, len / 2, len / 2));
cam.lookAt(bounds.getCenter().x, bounds.getCenter().y, bounds.getCenter().z);
cam.near = 0.1f;
cam.far = 1000;
renderer = new ImmediateModeRenderer10();
渲染代码:
@Override
public void renderScreen(float delta) {
Gdx.gl.glClearColor(0, 0, 0, 1.0f);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
Gdx.gl.glEnable(GL10.GL_DEPTH_TEST);
cam.update();
cam.apply(Gdx.gl10);
if(texture != null) {
Gdx.gl.glActiveTexture(GL10.GL_TEXTURE);
Gdx.gl.glEnable(GL10.GL_TEXTURE_2D);
texture.bind();
}
model.render();
if(texture != null) {
Gdx.gl.glActiveTexture(GL10.GL_TEXTURE);
Gdx.gl.glDisable(GL10.GL_TEXTURE_2D);
}
}
编辑:这是演示我的问题的屏幕截图: