2011-10-28 12 views
12

So che THREE.js ha importatori da vari formati grafici 3D.Importa il modello da 3dStudioMax in THREE.js

Esiste un importatore adatto a visualizzare un modello creato in 3dStudioMax? E se non ce n'è uno, c'è un modo per convertire un modello 3dStudioMax in qualcosa che può essere importato in THREE.js?

+0

A proposito, questa sarebbe una domanda eccellente per il 3d stackexchange proposto all'indirizzo http://area51.stackexchange.com/proposals/5022/3d-graphics-modeling-applications. – cdiggins

risposta

6

Di seguito è riportato uno script MAXScript che converte la mesh di un oggetto selezionato in JSON. Al momento di questo post, era disponibile nell'SVN dello 3ds Max developer community all'hosting del codice Google.

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

Non ho usato three.js in un attimo, ma so che importa OBJ che 3dsmax può esportare facilmente e c'è uno script python che converte un file .obj in una rete di tre js .json.

Ho notato che nell'ultima revisione c'è un MaxScript Exporter direttamente nel formato JSON, quindi comincia da quello. Dovrebbe generare un file .js basato sulla mesh selezionata, ma al momento non può accedere ad un PC per testare.

17

si hanno due opzioni:

1) Utilizzare ThreeJSExporter.ms ma tener conto che non è più mantenuto:

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

2) (consigliata) Usa OBJ opzione di esportazione in 3DS Max. Quindi utilizzare lo script convert_obj_three.py disponibile qui:

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

informazioni più dettagliate nel mio problema su Github di Three.js:

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

1

È possibile salvare file di max utilizzando il formato di file 3ds. Aprire il modello 3ds con lo A3dsViewer. Fai clic su Esporta in HTML5 nella barra degli strumenti e sarai in grado di visualizzare l'anteprima del modello nel browser.