如何使用 uploadFromByteArray(...) 写入 IndexBuffer3D
我真的不明白我做错了什么,但根据 Adobe 的说法,这就是在 IndexBuffer3D 对象上使用 uploadFromByteArray(...)
的方式:
我不明白的是我必须使用哪种写入方法来写入我的顶点索引的整数?我尝试过 writeFloat、writeUnsignedInt、writeInt,甚至 writeShort,但都失败了。我已将 ByteArray 实例设置为 ba.endian = Endian.LITTLE_ENDIAN ,但仍然不行。
在尝试将 ByteArray 位置上传到索引缓冲区之前,我已确保将其重置为 0,但是什么也没有显示!
如果我上传 Vector。
有什么想法吗?
I really don't understand what I'm doing wrong, but according to Adobe, this is how you use uploadFromByteArray(...)
on an IndexBuffer3D object:
What I don't understand is which writing-method do I have to use to write the integers of my vertex-indexes? I've tried writeFloat
, writeUnsignedInt
, writeInt
, even writeShort
and all fails. I've set my ByteArray instance to ba.endian = Endian.LITTLE_ENDIAN
, still no go.
I've made sure to reset my ByteArray position to 0 before I attempt to upload it to my index-buffer, but nothing shows up!
If I upload a Vector.<uint>
instead, that works! So I know the problem is not with the AGAL shader.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没关系,只是发现我做错了什么:
错误:
我一开始除以 4(按位移位两次是相同的),因为我认为每个索引的字节数是 4 个字节长。不啊啊!不正确!
用于 IndexBuffer3D 的 ByteArray 应使用 writeShort() 写入,因为它使用 16 位数字而不是 32 位。因此,每个索引仅使用 2 个字节。
正确:
希望能为其他 Stage3D 用户澄清这一点! :)
Nevermind, just found what I was doing wrong:
WRONG:
I was dividing by 4 at first (bitwise-shift twice is the same) because I though the number of bytes per index was 4 bytes long. Nah ah! Incorrect!
ByteArrays for IndexBuffer3D purposes should be written with
writeShort()
, since it utilizes 16-bit numbers instead of 32-bit. Therefore, it only uses 2 bytes per indexes.CORRECT:
Hope that clarifies it up for other Stage3D users! :)