OpenGL 3D渲染技术:渲染glTF模型,2021Android大厂面试经验分享

本文介绍了如何利用tinygltf库解析glTF模型,详细讲解了从数据加载到场景创建的过程,包括模型、纹理、缓冲区和纹理的加载,并展示了在Android平台上实现3D渲染的关键步骤。
摘要由CSDN通过智能技术生成

我们以一个简单的模型BoxTextured为例,它的效果很简单,一个带纹理的立方体,效果是这样的:

企业微信20210328-154411@2x.png

我们来看一下它的配置:

{
“asset”: {
“generator”: “COLLADA2GLTF”,
“version”: “2.0”
},
“scene”: 0,
“scenes”: [
{
“nodes”: [
0
]
}
],
“nodes”: [
{
“children”: [
1
],
“matrix”: [
1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
-1.0,
0.
0,
0.0,
1.0,
0.0,
0.0,
0.0,
0.0,
0.0,
1.0
]
},
{
“mesh”: 0
}
],
“meshes”: [
{
“primitives”: [
{
“attributes”: {
“NORMAL”: 1,
“POSITION”: 2,
“TEXCOORD_0”: 3
},
“indices”: 0,
“mode”: 4,
“material”: 0
}
],
“name”: “Mesh”
}
],
“accessors”: [
{
“bufferView”: 0,
“byteOffset”: 0,
“componentType”: 5123,
“count”: 36,
“max”: [
23
],
“min”: [
0
],
“type”: “SCALAR”
},
{
“bufferView”: 1,
“byteOffset”: 0,
“componentType”: 5126,
“count”: 24,
“max”: [
1.0,
1.0,
1.0
],
“min”: [
-1.0,
-1.0,
-1.0
],
“type”: “VEC3”
},
{
“bufferView”: 1,
“byteOffset”: 288,
“componentType”: 5126,
“count”: 24,
“max”: [
0.5,
0.5,
0.5
],
“min”: [
-0.5,
-0.5,
-0.5
],
“type”: “VEC3”
},
{
“bufferView”: 2,
“byteOffset”: 0,
“componentType”: 5126,
“count”: 24,
“max”: [
6.0,
1.0
],
“min”: [
0.0,
0.0
],
“type”: “VEC2”
}
],
“materials”: [
{
“pbrMetallicRoughness”: {
“baseColorTexture”: {
“index”: 0
},
“metallicFactor”: 0.0
},
“name”: “Texture”
}
],
“textures”: [
{
“sampler”: 0,
“source”: 0
}
],
“images”: [
{
“uri”: “CesiumLogoFlat.png”
}
],
“samplers”: [
{
“magFilter”: 9729,
“minFilter”: 9986,
“wrapS”: 10497,
“wrapT”: 10497
}
],
“bufferViews”: [
{
“buffer”: 0,
“byteOffset”: 768,
“byteLength”: 72,
“target”: 34963
},
{
“buffer”: 0,
“byteOffset”: 0,
“byteLength”: 576,
“byteStride”: 12,
“target”: 34962
},
{
“buffer”: 0,
“byteOffset”: 576,
“byteLength”: 192,
“byteStride”: 8,
“target”: 34962
}
],
“buffers”: [

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值