多纹理 OBJ->JSON 转换文件如何跟踪面部纹理映射?
我正在尝试手动(没有诸如 Three.js 之类的库)将 JSON 3D 模型加载到我的 webGL 代码中,只是为了好玩,但当我的模型具有超过 1 个纹理时,我遇到了困难。 在 OBJ->JSON 转换的文件中,我如何知道哪个纹理对于后面的面是“活动的”? OBJ 文件使用“usemtl”标签来标识正在使用的纹理/材质,但在使用 JSON 时我似乎找不到这种指针。 随着时间的推移,我正在使用 alteredq 编写的 OBJ->JSON 转换器,
非常感谢, 杆
I'm trying to manually (no libs such as Three.js) load a JSON 3D model into my webGL code just for fun but I'm having a hard time when my models have more than 1 texture.
In a OBJ->JSON converted file, how do I know which texture is the "active" for the faces that follow? OBJ files use 'usemtl' tag to identify the texture/material in use but I can't seem to find that kind of pointer when working with JSONs.
In time, I'm using the OBJ->JSON converter written by alteredq
Thanks a bunch,
Rod
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看一下这个文件:
two.js/src/extras/loaders/JSONLoader.js
。JSON 文件的
faces
数组中每个面的第一个元素是一个位字段。第一个位表示该面是否有三到四个索引。第二位表示该面是否分配了材质。材料索引(如果有)出现在索引之后。示例:
面:[2, 46, 44, 42, 0, 1, 45, 46, 48, 3, ...
第一个面(有材质的三角形):
第二个面(没有材质的四边形) :
第三面(带有材料的四边形):
检查源代码以了解该位字段的完整含义。
Take a look at this file:
three.js / src / extras / loaders / JSONLoader.js
.The first element of each face in the
faces
array of the JSON file is a bit field. The first bit says if that face have three o four indices. And the second bit says if that face has a material assigned. Material index, if any, appears after indices.Example:
faces: [2, 46, 44, 42, 0, 1, 45, 46, 48, 3, ...
First face (triangle with material):
Second face (quad without material):
Third face (quad with material):
Check source code for full meaning of that bit field.
在我为 KickJS 游戏引擎编写的 OBJ->JSON 转换器中,每种材质都有自己的索引范围。
这意味着一个简单的 OBJ 模型,如
将被翻译成这样(有两个索引;每种材料一个):
使用在线模型查看器进行转换:
http://www.kickjs.org/example/model_viewer/model_viewer.html
In the OBJ->JSON converter I have written for the KickJS game engine, each material has its own range of indices.
This means a simple OBJ model such as
Would be translated into this (With two indices; one for each material):
Use the online model viewer for the convertion:
http://www.kickjs.org/example/model_viewer/model_viewer.html