将模型从 3dStudioMax 导入 THREE.js [英] Import model from 3dStudioMax into THREE.js
本文介绍了将模型从 3dStudioMax 导入 THREE.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道 THREE.js 有来自各种 3d 图形格式的导入器.
I know that THREE.js has importers from various 3d graphics formats.
是否有适合显示在 3dStudioMax 中创建的模型的导入器?如果没有,有没有办法将 3dStudioMax 模型转换为可以在 THREE.js 中导入的东西?
Is there an importer suitable to display a model created in 3dStudioMax? And if there is not one, is there a way to convert a 3dStudioMax model in something that can be imported in THREE.js?
推荐答案
下面是一个 MAXScript 脚本,可将选定对象的网格转换为 JSON.在撰写本文时,它在 3ds Max 开发者社区的 SVN 中位于 Google 代码托管处.>
Below is a MAXScript script that will convert a selected object's mesh into JSON. At the time of this post, it was available in the SVN of the 3ds Max developer community at Google code hosting.
tmesh = snapshotAsMesh selection[1]
out_file = createfile "$scripts\output.json
num_faces = tmesh.numfaces
num_verts = tmesh.numverts
fn PrintPoint pt = (
format "%, %, %, " pt.x pt.y pt.z to:out_file
)
fn PrintPointUV pt = (
format "%, %, " pt.x pt.y to:out_file
)
fn PrintPointInt pt = (
x = int(pt.x) - 1
y = int(pt.y) - 1
z = int(pt.z) - 1
format "%, %, %, " x y z to:out_file
)
format "{
" to:out_file
-- Vertex Positions
-- format " "vertexPositions" : [" to:out_file
format " positions : [" to:out_file
for i = 1 to num_verts do
(
vert = getVert tmesh i
PrintPoint vert
)
format "],
" to:out_file
-- Vertex Normals
-- format " "vertexNormals" : [" to:out_file
format " normals : [" to:out_file
for i = 1 to num_verts do
(
vert = getNormal tmesh i
PrintPoint vert
)
format "],
" to:out_file
-- Vertex Texture Coordinates
-- format " "vertexTextureCoords" : [" to:out_file
format " uv : [" to:out_file
for i = 1 to num_faces do
(
-- Iterate over faces
tvface = getTVFace tmesh i
for j = 1 to 3 do (
-- Get a specific texture vertex
tvert = getTVert tmesh tvface[j]
PrintPointUV tvert
)
)
format "],
" to:out_file
-- Face Indexes
-- format " "indices" : [" to:out_file
format " indices : [" to:out_file
for f = 1 to num_faces do
(
face = getFace tmesh f
PrintPointInt face
)
format "],
" to:out_file
format "}" to:out_file
close out_file
delete tmesh
edit out_name
这篇关于将模型从 3dStudioMax 导入 THREE.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文