将3D模型转换为SceneJS JSON,包括纹理 [英] Convert 3D model to SceneJS JSON, including texture

查看:367
本文介绍了将3D模型转换为SceneJS JSON,包括纹理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

动机
我正在尝试使用WebGL创建一个小型演示应用程序.我选择使用SceneJS,因为它看起来很简单,并且足以满足此目的.

Motive
I'm trying to create a small demo application using WebGL. I chose to use SceneJS, because it seemed an easy framework and would more than suffice for this purpose.

我已经下载了几个.blend模型(

I have downloaded a couple of .blend models (Amy Rose, amongst others) and exported them as a Collada (.dae) file using Blender. Then I used scenejs-pycollada to convert them to a json model.

我花了几个小时才使 scenejs-pycollada 转换器正常工作.如果您以前从未使用过Python,显然要让这些Python依赖关系在Windows中工作并不容易. ;)

I just spent a couple of hours getting the scenejs-pycollada convertor to work. Apparently getting those Python dependencies to work in Windows isn't that easy if you've never used Python before. ;)

问题
但是现在(再次)我被卡住了.我的问题是模型没有任何纹理或材料.

Problem
But now I'm stuck (again). My problem is that the models don't have any textures or materials.

我使用了SceneJS的西摩飞机示例 .我转换后的模型几乎看不到.它是黑色的,似乎对场景的照明没有反应.如果将平面和模型一起加载,则可以看到模型已加载,因为模型的手臂和腿都伸出了平面.

I used the Seymour Plane Example of SceneJS. The model I converted is hardly visible. It is black and doesn't seem to respond to the lighting in the scene. If I load the plane and the model together, I can see the model is loaded, because its arms and legs are sticking out of the plane.

现在,我遵循了一些教程,可以将纹理导出为PNG图像.然后,我在JSON模型中修改了纹理文件名以匹配该文件名,但这无济于事.

Now I followed a couple of tutorials that would let me export the texture as a PNG image. I then modified the texture file name in the JSON model to match the file name, but it doesn't help.

所以我希望有人能帮助我找到一种方法,将Blender模型(或其他常见的3D模型)导出为SceneJS使用的JSON格式,包括纹理.

So I hope someone can help me to find a way to export Blender models (or other common 3D models) to the JSON format used by SceneJS, including the textures.

只要能工作,任何其他在SceneJS中加载模型的方法都可以.

Any other method of loading models in SceneJS will do too, as long as it works.

如果有人链接到body/figure JSON模型的免费下载,那将对目前有所帮助,但我宁愿了解其工作原理. :)

If one 's got a link to free downloads of body/figure JSON models, that would help for now, but I rather learn how this works. :)

我正在使用

  • Windows 7 Home Premium 64位
  • Python 2.7(Windows 32位)
    之所以选择32位版本,是因为它似乎对库的支持更好,并且安装程序更多.最初,我将32位和64位混合使用,这给我带来了麻烦,但是现在一切似乎都可以正常工作(除了纹理).
  • 搅拌器2.59
  • SceneJS 0.8.0
  • Windows 7 Home Premium 64bit
  • Python 2.7 (Windows 32bit)
    I chose the 32 bit version, because of seemingly better support for libraries, and more available installers. At first I mixed up 32 and 64 bit and it caused me trouble, but now everything seems to work (except for the textures, that is).
  • Blender 2.59
  • SceneJS 0.8.0

我的工作流程
在Blender中,我将模型导出到Collada(* .dae)文件,然后使用scenejs-pycollada将其转换为Raw JSON.这给了我一个带有两个对象的JSON文件.第一个似乎是场景,第二个是模型.我保留第二个参数并将其放在SceneJS示例代码中使用的Javascript变量中.该模型以属性, "type": "library", "parent": "Scene"结尾,我需要从代码中删除该属性以使其完全加载.

My workflow
In Blender I export the models to Collada (*.dae) files, and then convert them to Raw JSON using scenejs-pycollada. This gives me a JSON file with two objects in it. The first seems to be the scene, the second the model. I keep the second and put it in a Javascript variable that is used in the code of the SceneJS example. The model ends with the properties , "type": "library", "parent": "Scene" which I need to remove from the code to make it load at all.

推荐答案

我实际上是scenejs-pycollada的作者.让我看看是否能为您提供帮助:)

I'm actually the author of scenejs-pycollada. Let me see if I can help you :)

我看到您正在使用SceneJS的0.8版...情况一直在变化,因此实际上可能最容易拉个人仓库.我基本上将SceneJS-pycollada的第一个发行版定位为SceneJS 0.9,但是该版本从未得到正式发行.而且,从长远来看,如果您现在就切换,就不必重写所有内容...

I see you're using version 0.8 of SceneJS... Things have been rather in flux, so it might actually easiest to pull the 2.0 branch of SceneJS from github and scenejs-pycollada from my personal repo. I was basically targeting SceneJS 0.9 for the first release of scenejs-pycollada, but that version never got officially released. Also, in the long run you won't have to rewrite everything if you just switch over now...

有问题的Windows编译也是一个很大的麻烦,我真的希望麻木的开发人员为您解决Windows民间问题. SceneJS 2.0发布后,我将发布Scenejs-pycollada的正式版本,该版本随附Windows的所有必需依赖项.

The problematic windows compile is also a big thorn, I really wish the numpy devs would fix this up for you windows folk. Once SceneJS 2.0 is released I'll release an official version of scenejs-pycollada that comes packaged with all the necessary dependencies for windows.

因此,请随时对此答案发表评论或更新您的问题.我会尽量注意的.

So, feel free to comment on this answer or update your question. I'll try to keep an eye on it.

P.S.另外,如果您真的很沮丧,我实际上在 https://github上有第二个搅拌器出口商.com/rehno-lindeque/Blender-WebGL-exporter ,但我不建议您使用此工具-它已经过时了.很久以前,不推荐使用其他场景collada collada导出器.

P.S. Alternatively, if you're really frustrated I actually have a second blender exporter at https://github.com/rehno-lindeque/Blender-WebGL-exporter, but I don't recommend using this one - it's very outdated. The only other scenejs collada exporter was deprecated a long time ago.

P.P.S. scenejs-pycollada本身中也有一个示例和一些测试模型.如果您只想使用快速模型,请查看 https://github.com/rehno-lindeque/scenejs-pycollada/tree/master/example ,尽管公认它不是最漂亮的模型.

P.P.S. There's also and example and some test models in scenejs-pycollada itself. If you just want a quick model to play with, check out https://github.com/rehno-lindeque/scenejs-pycollada/tree/master/example although admittedly it's not the prettiest model ever.

P.P.P.S.实际上,为什么Amy Rose模型不能很好地为您工作的原因之一是因为scenejs-pycollada还不支持多种材料.今晚我将为此提供一些支持.

P.P.P.S. Actually one of the reasons why the Amy Rose model wasn't working well for you is because scenejs-pycollada didn't support multiple materials yet. I'm quickly adding some support for this tonight.

这篇关于将3D模型转换为SceneJS JSON,包括纹理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆