2011-10-28 14 views
12

THREE.js'nin çeşitli 3 boyutlu grafik biçimlerinden ithalatçı olduğunu biliyorum.Modele 3dStudioMax'dan THREE.js'ye alma

3dStudioMax'da oluşturulan bir modeli görüntülemek için uygun bir ithalatçı var mı? Ve değilse, bir 3BStudioMax modelini THREE.js'ye aktarılabilecek bir şeye dönüştürmenin bir yolu var mı?

+0

, bu http://area51.stackexchange.com/proposals/5022/3d-graphics-modeling-applications teklif edilen 3d Stack Exchange için mükemmel bir soru olurdu. – cdiggins

cevap

6

Aşağıda JSON içine Seçilen bir nesnenin örgü dönüştürecek olan bir MAXScript yazısıdır. Bu gönderi sırasında, Google kod barındırmada 3ds Max developer community'un SVN'sinde kullanılabilir.

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 
2

Bir süredir üç.js kullanmadım, ancak 3dsmax'ın kolayca dışa aktarılabildiği OBJ'yi içe aktardığını ve bir .obj dosyasını bir three.js .json mesh'e dönüştüren bir python betiği olduğunu biliyorum.

Ben son revizyonunda json formatına bir MaxScript Exporter düz olduğunu fark, böylece başlar. Seçilen ağa bağlı bir .js dosyası oluşturmalı, ancak test edilecek anda bir PC'ye erişemez.

17

İki seçeneğiniz vardır:

1) Kullanım ThreeJSExporter.ms ama artık mantained olduğunu dikkate almak:

https://github.com/mrdoob/three.js/tree/master/utils/exporters/max

2) (Önerilen) Kullanım OBJ 3DS Max'da ihracatçı seçeneği. Three.js en Github benim sayısında

https://github.com/mrdoob/three.js/blob/master/utils/converters/obj/convert_obj_three.py

Daha detaylı bilgi: Sonra burada mevcut convert_obj_three.py komut dosyasını kullanabilirsiniz

https://github.com/mrdoob/three.js/issues/893

1

Sen 3ds dosya biçimini kullanarak maksimum dosya kaydedebilirsiniz. A3dsViewer ile 3ds model 'u açın. Araç çubuğunda HTML5'e Aktar seçeneğini tıklayın ve modelini tarayıcıda önizleyebilirsiniz. Bu arada