wifi boombox android,android filament入门,GLB和GLTF模型查看器

本文介绍了使用Android Filament库创建3D模型查看器和AR查看器的过程,通过链接提供详细教程。同时展示了如何加载GLB和GLTF模型,并在AR场景中应用。代码示例中包括了动画管理和模型渲染。
摘要由CSDN通过智能技术生成

filament入门挺难的,主要是因为受干扰的信息太多了,有arCore的干扰,也有scenceform的干扰。这里通过制作3D模型查看器的方式,理清他们之间的关系。

有用的信息来源主要有3个:

1,https://medium.com/@philiprideout/getting-started-with-filament-on-android-d10b16f0ec67

Android上的Filament入门

2,https://github.com/thomasgorisse/sceneform-android-sdk

适用于Android的Sceneform SDK-维护

3,https://github.com/Sergiioh/android-model-viewer

适用于Android的GLB和GLTF模型查看器

整体表现为:1实现了页面查看3D模型,2实现了ar查看3D模型,3提供了将1和2集成到你应用的一种思路。依照他们说的一步步来做,就可以实现这样的效果。

fa0e45d3c967

球状元素周期表

为了防止页面走丢,这里把他们的内容复制进来。

class gltfActivity : Activity()

companion object {

init {

Utils.init()

}

}

private lateinit var surfaceView: SurfaceView

private lateinit var choreographer: Choreographer

private lateinit var modelViewer: ModelViewer

override fun onCreate(savedInstanceState: Bundle?) {

super.onCreate(savedInstanceState)

surfaceView = SurfaceView(this).apply { setContentView(this) }

choreographer = Choreographer.getInstance()

modelViewer = ModelViewer(surfaceView)

surfaceView.setOnTouchListener(modelViewer)

loadGltf("BoomBox")

loadEnvironment("courtyard_8k")

}

private fun loadGltf(name: String) {

val buffer = readAsset("models/BoomBox/${name}.gltf")

modelViewer.loadModelGltf(buffer) { uri -> readAsset("models/BoomBox/$uri") }

modelViewer.transformToUnitCube()

}

private fun readAsset(assetName: String): ByteBuffer {

val input = assets.open(assetName)

val bytes = ByteArray(input.available())

input.read(bytes)

return ByteBuffer.wrap(bytes)

}

private val frameCallback = object : Choreographer.FrameCallback

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值