如何在WEBGL中使用maya导入的模型

Convert a model from Maya to WebGL for use with THREE.js

I’ve been a bit busy, but lots of folks have asked for this so here is the quick step by step on how I export from Maya to WebGL for use with three.js.

Within the THREE.js github project, under utils/exporter there is a obj conversion tool called convert_obj_three.py. It’s written in python as a command line script, so a python executable is required to make it work. If you don’t have Python, you can download the version appropriate for your platform from python.org. I drop both the python.exe and convert_obj_three.py in the folder where I save my models, just to avoid typing lengthy paths into the command line.

In Maya, there’s a few things which I do to retain consistancy in translations and scaling before importing the model in THREE.js. I ensure that the model’s xyz translation’s and rotation’s values are 0, and the xyz scaling is at 1. The model also needs to be a child of the world and not under any groups or objects, due to inheritated transformations from the parent group or object. At this point I delete any available history of the model, and select “freeze transformations” from the MODIFY menu.

I export the model as an obj (make sure that the plugin(objExport) is loaded) into the folder I have the python converter script in. “All File Type Specific Options” can be left checked.

Run cmd(command prompt). Go to the directory which the models and “convert_obj_three.py” is located and run the exectution line as such for a basic conversion:

-i for import, -o is output, -x is truncation and scaling. I typically use 1000 so it truncates the vertice values as intergers, and rescaling is easy to remember via 10, 100,1000 etc.

Now the exported model is ready for use in THREE.js. If transformations need to be inherrited from Maya, just multiply by 10, 100 or 1000 depending on your preferred scene scaling.


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值