从3dStudioMax导入模型到THREE.js [英] Import model from 3dStudioMax into THREE.js

查看:341
本文介绍了从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可用C $Ç托管。

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 "{\n" 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 "],\n" 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 "],\n" 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 "],\n" 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 "],\n" to:out_file

format "}" to:out_file

close out_file
delete tmesh
edit out_name

这篇关于从3dStudioMax导入模型到THREE.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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