LibGDX 纹理在 g3db 模型中使用错误,但在 uv 贴图上映射正确
LibGDX texture is used wrong for g3db model but was mapped correctly on uv map
我试图在 LibGDX 中渲染我的 g3db 模型,但不幸的是,moder 的纹理不会像我将其映射到对象上那样应用。这是我的代码:
class WauWau : ApplicationAdapter() {
companion object val tag = "WauWau"
private lateinit var camera: PerspectiveCamera
private lateinit var modelBatch: ModelBatch
private lateinit var model: Model
private lateinit var modelInstance: ModelInstance
private lateinit var environment: Environment
override fun create() {
camera = PerspectiveCamera(75f, Gdx.graphics.width.toFloat(), Gdx.graphics.height.toFloat())
camera.position.set(0f,100f,200f)
camera.lookAt(0f, 100f, 0f)
camera.near = 0.1f
camera.far = 300.0f
modelBatch = ModelBatch()
val jsonReader = UBJsonReader()
val modelLoader = G3dModelLoader(jsonReader)
model = modelLoader.loadModel(Gdx.files.getFileHandle("card.g3db", Files.FileType.Internal))
modelInstance = ModelInstance(model)
environment = Environment()
environment.set(ColorAttribute(ColorAttribute.AmbientLight, 0.8f, 0.8f, 0.8f, 1.0f))
}
override fun render() {
Gdx.gl.glViewport(0, 0, Gdx.graphics.width, Gdx.graphics.height)
Gdx.gl.glClearColor(1f, 1f, 1f, 1f)
Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT or GL30.GL_DEPTH_BUFFER_BIT)
camera.update()
modelBatch.begin(camera)
modelBatch.render(modelInstance)
modelBatch.end()
}
override fun dispose() {
modelBatch.dispose()
model.dispose()
}
}
有什么建议是我的模型出了什么问题,或者有什么解决办法吗?
刚刚翻转了纹理,现在可以正常使用了!
我试图在 LibGDX 中渲染我的 g3db 模型,但不幸的是,moder 的纹理不会像我将其映射到对象上那样应用。这是我的代码:
class WauWau : ApplicationAdapter() {
companion object val tag = "WauWau"
private lateinit var camera: PerspectiveCamera
private lateinit var modelBatch: ModelBatch
private lateinit var model: Model
private lateinit var modelInstance: ModelInstance
private lateinit var environment: Environment
override fun create() {
camera = PerspectiveCamera(75f, Gdx.graphics.width.toFloat(), Gdx.graphics.height.toFloat())
camera.position.set(0f,100f,200f)
camera.lookAt(0f, 100f, 0f)
camera.near = 0.1f
camera.far = 300.0f
modelBatch = ModelBatch()
val jsonReader = UBJsonReader()
val modelLoader = G3dModelLoader(jsonReader)
model = modelLoader.loadModel(Gdx.files.getFileHandle("card.g3db", Files.FileType.Internal))
modelInstance = ModelInstance(model)
environment = Environment()
environment.set(ColorAttribute(ColorAttribute.AmbientLight, 0.8f, 0.8f, 0.8f, 1.0f))
}
override fun render() {
Gdx.gl.glViewport(0, 0, Gdx.graphics.width, Gdx.graphics.height)
Gdx.gl.glClearColor(1f, 1f, 1f, 1f)
Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT or GL30.GL_DEPTH_BUFFER_BIT)
camera.update()
modelBatch.begin(camera)
modelBatch.render(modelInstance)
modelBatch.end()
}
override fun dispose() {
modelBatch.dispose()
model.dispose()
}
}
有什么建议是我的模型出了什么问题,或者有什么解决办法吗?
刚刚翻转了纹理,现在可以正常使用了!