|
|
|
|
+VarnishedOtter
Admin

|
Heres a script I wrote to export objects to my 3D engine (Gumball).
Will export all selected objects at their current frame.
All materials must be multi/sub with a bitmap in the diffuse slot and all faces must have a valid material ID.
if selection.count > 0 then( output_name = getSaveFileName caption:"Gumball Model" types:"Gumball Model (*.gbm)|*.gbm|All Files (*.*)|*.*|" if output_name != undefined then( output_file = createfile output_name num_objects = 0 for obj in selection do( num_objects = num_objects + 1 ) format "%\n" num_objects to:output_file for obj in selection do( dump1 = undefined dump1 = copy obj dump1.name = obj.name snapshotasmesh dump1 convertToMesh dump1 num_verts = dump1.numverts num_faces = dump1.numfaces num_tverts = dump1.numtverts at time animationrange.start format "% % % % %\n" obj.name dump1.material.numsubs num_faces num_verts num_tverts to:output_file for v = 1 to dump1.material.numsubs do( matid = dump1.material.materialIDList[v] mat = dump1.material.materialList[v].diffuseMap if mat != undefined then( mat = filenameFromPath mat.filename format "% %\n" matid mat to:output_file ) else ( format "% NULL\n" matid to:output_file ) ) for v = 1 to num_faces do( mat = getFaceMatID dump1 v p = getFace dump1 v; x = p.x as Integer -1; y = p.y as Integer -1; z = p.z as Integer -1; tvert = getTVFace dump1 v tx = tvert[1] as integer -1; ty = tvert[2] as integer -1; tz = tvert[3] as integer -1; format "% % % % % % %\n" x y z tx ty tz mat to:output_file ) for v = 1 to num_verts do( p = getVert dump1 v; x = p.x as Float; y = p.y as Float; z = p.z as Float;
format "% % %\n" x y z to:output_file ) for v = 1 to num_tverts do( p = getTVert dump1 v; u = p.x as Float; v = p.y as Float;
format "% %\n" u v to:output_file ) delete dump1 ) close output_file edit output_name ) )
Please support us and post a [Link to www.digitalartsfront.com] on your website.
--Matt
    
|
|
|
|
|
|
Admin
Please support us and post a [Link to www.digitalartsfront.com] on your website.
--Matt