2011-10-28 9 views
12

में मॉडल आयात करें मुझे पता है कि THREE.js में विभिन्न 3 डी ग्राफिक्स प्रारूपों के आयातक हैं।3 डी स्टूडियो मैक्स से THREE.js

क्या 3 डी स्टूडियो मैक्स में बनाए गए मॉडल को प्रदर्शित करने के लिए उपयुक्त एक आयातक है? और यदि कोई नहीं है, तो क्या 3 डी स्टूडियो मैक्स मॉडल को किसी चीज़ में कनवर्ट करने का कोई तरीका है जिसे THREE.js में आयात किया जा सकता है?

+0

वैसे, यह http://area51.stackexchange.com/proposals/5022/3d-graphics-modeling-plplications पर प्रस्तावित 3 डी स्टैकएक्सचेंज के लिए एक उत्कृष्ट सवाल होगा। – cdiggins

उत्तर

6

नीचे एक MAXScript स्क्रिप्ट है जो किसी चयनित ऑब्जेक्ट के जाल को JSON में परिवर्तित कर देगी। इस पोस्ट के समय, यह Google कोड होस्टिंग पर 3ds Max developer community के एसवीएन में उपलब्ध था।

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

मैंने थोड़ी देर में तीन.जेएस का उपयोग नहीं किया है, लेकिन मुझे पता है कि यह ओबीजे आयात करता है जो 3dsmax आसानी से निर्यात कर सकता है और एक पाइथन लिपि है जो एक .obj को तीन.जेएस। जेसन जाल में परिवर्तित करती है।

मैंने देखा कि नवीनतम संशोधन में MaxScript Exporter सीधे जेसन प्रारूप में है, इसलिए इसके साथ शुरू करें। इसे चयनित जाल के आधार पर एक .js फ़ाइल उत्पन्न करनी चाहिए, लेकिन परीक्षण के लिए इस समय एक पीसी तक नहीं पहुंच सकता है।

17

आपके पास दो विकल्प:

1) का प्रयोग करें ThreeJSExporter.ms लेकिन वह नहीं रह गया है mantained है को ध्यान में रखना:

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

2) (अनुशंसित) उपयोग OBJ 3 डी एस मैक्स में निर्यातक विकल्प। Three.js के Github पर अपने अंक में

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

अधिक विस्तृत जानकारी:: फिर convert_obj_three.py स्क्रिप्ट यहाँ उपलब्ध का उपयोग

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

1

आप 3DS फ़ाइल स्वरूप का उपयोग कर अधिकतम फ़ाइल बचा सकता है। A3dsViewer के साथ 3 डी मॉडल खोलें। टूलबार में HTML5 पर निर्यात करें और आप ब्राउज़र में मॉडल का पूर्वावलोकन करने में सक्षम होंगे।