转载于:https://blog.csdn.net/jcq521045349/article/details/52526117
以下内容引用自README.md ,大家请首先参照这个配置
convert-to-threejs
Utility for converting model files to the Three.js JSON format
Supported Formats
- Fbx (.fbx)
- Collada (.dae)
- Wavefront/Alias (.obj)
- 3D Studio Max (.3ds)
Usage
convert_to_threejs.py [source_file] [output_file] [options]
Options:
-t, --triangulate force non-triangle geometry into triangles
-x, --ignore-textures don't include texture references in output file
-u, --force-prefix prefix all object names in output file to ensure uniqueness
-f, --flatten-scene merge all geometries and apply node transforms
-c, --add-camera include default camera in output scene
-l, --add-light include default light in output scene
-p, --pretty-print prefix all object names in output file
Current Limitations
- No animation support
- Only Lambert and Phong materials are supported
- Some camera properties are not converted correctly
- Some light properties are not converted correctly
- Some material properties are not converted correctly
- Textures must be put in asset’s folder, and use relative path in the material
Dependencies
FBX SDK
- Requires Autodesk FBX SDK Python 2013.3 bindings.
You can download the python bindings from the Autodesk website:
http://usa.autodesk.com/fbx/
Don't forget the visit the FBX SDK documentation website:
http://docs.autodesk.com/FBX/2013/ENU/FBX-SDK-Documentation/cpp_ref/index.html
Note: If you use the OSX installer, it will install the Python packages into the following folder.
/Applications/Autodesk/FBX Python SDK/[VERSION]/lib/
If the tool still can’t find the FBX SDK, you may need to copy the fbx.so
, FbxCommon.py
and sip.so
files into your site_packages folder.
If you don’t know your site_packages folder, run python
from shell and paste this:
import site; site.getsitepackages()
Python
- Requires Python 2.6, 2.7 or 3.1 (The FBX SDK requires one of these versions)
sudo apt-get install build-essential
wget http://www.python.org/ftp/python/2.6.8/Python-2.6.8.tar.bz2
tar jxf ./Python-2.6.8.tar.bz2
cd ./Python-2.6.8
./configure --prefix=/opt/python2.6.8 && make && make install
实际使用时我碰到的问题
找不到FBX SDK
这个错误郁闷了我好久,下载了数个版本的python和fbx sdk 依然没有得到解决
就在刚刚,我突然发现自己翻了个很坑的错误,我下载的python到底是什么版本的?
我也不清楚呀,我记得就是官网上随便下载了个windows 平台的安装包而已……
于是问题就明确了,我一直以为我用的是64位版本的python,但实际上我下载的几个都是32位版本的。
描述下配置方法吧
- 安装python ,根据readme的建议,我们可以选择2.6,2.7,3.1。
- 选择FBX SDK 要与自己的python 版本相一致(我这里使用的是2.7版本的python 和2015.1的FBX SDK)
- 打开FBX SDK的安装目录,…\Autodesk\FBX\FBX Python SDK\2015.1\lib 将自己对应版的的文件夹内的内容复制出来,我这里需要复制的是Python27_x86 文件夹内的内容
- 打开你的python 目录,找到site-packages文件夹 例 …\Python27\Lib\site-packages , 然后将刚才的三个文件复制在这里
- 测试下fbx sdk 配置是否已经成功
可以运行 Autodesk\FBX\FBX Python SDK\2015.1\samples 目录下的一些例子py文件进行测试,如果不报错,则表示FBX SDK配置成功
小贴士
打开cmd 一点点输入路径太慢了,可以先输入python 然后用鼠标点住将文件拖拽到cmd窗口上,文件的路径就会直接打在上面,挺方便的。