Jump to content
  • Advertisement
Sign in to follow this  

3dsmax export scripts, any tutorials?

This topic is 4827 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
if you have the MaxScript reference (part of the SDK) there are a couple tutorials on how to output geometry to a file. Just search for Output Geometry. That should start you off at least.

hth

Share this post


Link to post
Share on other sites
here is an old script I some time ago. The script handles geometry, physique mod, biped and some normal materials.

hope it will help you somewhat, the code should be rather straightforward


global exportLastFilename=""
global selectedObject=undefined
global logFile="pa_exp.txt"
global logFp
global opt


struct pa_options
(
-- set of booleans:
exp_mesh,
exp_colors,
exp_motion,
exp_physique,

is_textured,
is_material,
is_physique,
is_skin
)

--
-- Some properties of the object
--
fn getProperties obj=
(
format "Finding object properties:\n" to: logFp
opt = pa_options exp_colors:false exp_motion:false exp_physique:false is_physique:false is_textured:false is_material:false

format " - Class of: %\n" (classof obj as string) to: logFp
-- modifiers?
if obj.modifiers[#physique] != undefined do (
opt.is_physique = true
format " - Found physique modifier.\n" to: logFp
)
if obj.modifiers[#skin] != undefined do (
opt.is_skin = true
format " - Found skin modifier.\n" to:logFp
)
if obj.material != undefined do(
opt.is_material = true
format " - Material is defined on object.\n" to:logFp
try (
getTVFace obj 1
format " - Texture coordinates is defined on object.\n" to:logFp
opt.is_textured = true
) catch (
)

)




)

fn errorCheck cb=
(
if classof cb==string do
messagebox cb title:"Pa Export Error"
)
fn fatalError err=
(
errorCheck err
format err to: logFp
return undefined
)
--
--
-- STRUCTURE DEF
--
--


-- HEADER
-- CHUNK: NONE
struct pa_header
(
magic, -- 666

nMeshes, -- Number of subsequent meshes (Id in order)
nSkinControllers, -- Number of subsequent skincontrollers (Id in order)
nSkeletons, -- Number of subsequent skeletons(Id in order)
nMotions
)
--
-- Write header function
--
fn writeHeader fp header=
(
writeshort fp header.magic
writebyte fp header.nMeshes
writebyte fp header.nSkinControllers
writebyte fp header.nSkeletons
writebyte fp header.nMotions
)
-- __END HEADER__________
--
--

-- MATERIAL
-- CHUNK: MATERIAL
-- bitmaptexture:
struct pa_texturemap (
filename, -- name of bitmap
offsetU, -- self expl.
offsetV,
tileU,
tileV
)
fn writeTextureMap fp text =
(
writeString fp text.filename
writefloat fp text.offsetU
writefloat fp text.offsetV
writefloat fp text.tileU
writefloat fp text.tileV
)

struct pa_material ( -- idx in list == ID
-- nMaterials,
-- latter is repeated nMaterials times
name, -- string
ambient, --= point3
diffuse, --= point3
specular, --= point3

selfIlluminate, -- = point3
opacity, --= float
isWire, --= byte
isFaceMap, --= byte

-- if texture then
texturemap -- or null
)
fn writeMaterial fp mat=
(

writestring fp mat.name
writeColorRGBList fp #(mat.ambient)
writeColorRGBList fp #(mat.diffuse)
writeColorRGBList fp #(mat.specular)
writeColorRGBList fp #(mat.selfilluminate)
writebyte fp mat.opacity
writebyte fp mat.isWire
writebyte fp mat.isFaceMap
if mat.texturemap == undefined then
writebyte fp 0
else
writeTextureMap fp mat.texturemap
)

--
-- Geometry structure
--
-- set of lists indexed from a meshpart.
struct pa_geometry (
nGeomPoints,
vertexList,
normalList,
textureList
)

fn writeGeometry fp geom =
(
writelong fp geom.nGeomPoints

writepoint3floatlist fp geom.vertexList
writepoint3floatlist fp geom.normalList
writepoint2floatlist fp geom.textureList
)
--
-- Mesh part structure aka. submesh
--
struct pa_meshpart (
nFaceIdx,
faceIdxList, -- point3
matId -- int
)
fn writeMeshPart fp part=
(
writelong fp part.nFaces
for f in part.faces do
writePoint3Long fp f.face

writeshort fp part.matId
)
-- MESH
-- CHUNK: MESHTOPOLOGY
struct pa_meshtopology
(
nParts,
geometry,
meshPartList
)
fn writeMeshTopology fp top=
(
writelong fp top.nParts
writeGeometry fp top.geometry
for part in top.meshPartList do
writeMeshPart fp part
)
-- __ END MESH _____
--
--

-- SKIN
-- SKIN COLLECTION STRUCT
struct pa_skin
(
skinController,
skeleton
)

-- CHUNK: SKIN
-- SKIN CONTROLLER STRUCT
struct pa_skinController
(
skeletonName, -- identifier

nSkinvertex,
nSkinvertexLinks, -- Sum_i=0^numverts vert.bonelinks
skinvertexList, -- [prevoffs + skinvertexBoneIdList]
skinvertexNLinkList, -- number of links from vertex
skinvertexWeightList, -- [prevoffs + skinvertexBoneIdList]
skinvertexBoneIdList --
)
--
-- Write the skin controller struct to disk
--
fn writeSkinController fp sc=
(
writestring fp sc.skeletonName
writelong fp sc.nSkinvertex
writelong fp sc.nskinvertexLinks
writePoint3FloatList fp sc.skinvertexList

writelongList fp sc.skinvertexNLinkList
writefloatList fp sc.skinvertexWeightList
writelongList fp sc.skinvertexBoneIdList
)
-- hierarchical structure of the bones (used in skin controller)
-- CHUNK: SKELETON
struct pa_bone
(
id, -- Store: byte
parentId -- Store: byte

)
struct pa_skeleton
(
name, -- name of root bone (in case of multiple roots)
nBones,
boneList -- pa_bone struct list
)
fn writeSkeleton fp sk=
(
writestring fp sk.name
writelong fp sk.nBones
for i=1 to sk.boneList.count do (
writebyte fp sk.boneList.id
writebyte fp sk.boneList.parentid
)

)
-- __END SKIN______

--
-- CHUNK: MOTION
--

--
-- Each bone have unique timeList
--
struct pa_motion
(
nNodes,
nTimerecords,-- dword

timeList, -- .count == number of transformations etc. 0 < timeList < 100
rotList, -- (float) quaternion x,y,z,w
posList, -- (point3) x,y,z (float)
scaleList -- (point3) scale x, scale y, scale z (float)


)
fn writeMotion fp motion=
(
writelong fp motion.nTimerecords
writefloatlist fp motion.timeList
writeQuatList fp motion.rotList
writePoint3FloatList fp motion.posList
writePoint3FloatList fp motion.scaleList

)
---
--- Misc writing functino
---
fn writeLongList fp list=
(
for i=1 to list.count do (
writelong fp list
)
)
fn writeFloatList fp list=
(
for i=1 to list.count do (
writefloat fp list
)
)
fn writeQuatList fp list=
(
for i=1 to list.count do (
writefloat fp list.w
writefloat fp list.x
writefloat fp list.y
writefloat fp list.z

)
)
fn writePoint3Long fp p=
(
writelong fp p.x
writelong fp p.y
writelong fp p.z
)
fn writePoint3Float fp p=
(
writefloat fp p.x
writefloat fp p.y
writefloat fp p.z
)
fn writePoint3FloatList fp list=
(

for i=1 to list.count do (
writefloat fp list.x
writefloat fp list.y
writefloat fp list.z
)

)
fn writePoint2FloatList fp list=
(

for i=1 to list.count do (


writefloat fp list.x
writefloat fp list.y
)

)
fn writePoint3LongList fp list=
(
for i=1 to list.count do (
writelong fp list.x
writelong fp list.y
writelong fp list.z
)
)
fn writeColorRGBList fp list=
(
for i=1 to list.count do (
writefloat fp list.r
writefloat fp list.g
writefloat fp list.b
)

)

--
-- Create header object
--
fn createHeader obj=
(
format "createHeader()\n" to: logFp
header = pa_header magic:666 nMeshes:0 nSkinControllers:0 nMotions:0 nSkeletons:0

format " - magic: %\n" header.magic to:logFp

return header

)

fn isValidBone b=
(
if ((superclassof b != helper) or (classof b == bone)) and
(b != undefined) do
return 1

format " - discarded bone: %\n" b to:logFp

return 0

)

fn createTimeList boneObj firsttime lasttime=
(

timelist = #()

format " - createTimeList()\n" to:logFp

-- Biped
if classOf boneObj == Biped_Object do (
keys=boneObj.controller.keys
-- create list

for j=1 to keys.count do (
t = keys[j].time
if t >= firsttime and t <= lasttime do (
append timelist t
)
)
)
-- Bones
if classOf boneObj == BoneGeometry or classOf boneObj == Bone do (
-- Merge rotation keys with position keys and scale keys
if (classOf boneObj.controller == IK_ControllerMatrix3Controller) then
keysList = #(boneObj.rotation.controller.keys, boneObj.pos.controller.keys)
else
keysList = #(boneObj.rotation.controller.keys, boneObj.pos.controller.keys, boneObj.scale.controller.keys)


-- create list
for k=1 to keysList.count do (
keys = keysList[k]
for j=1 to keys.count do (
-- only insert keys in intervalss
t = keys[j].time
if t >= firsttime and t <= lasttime do (
if findItem timelist t == 0 do
append timelist t
)
)
)
)
return timelist
)
fn createBoneMotion boneObj timeList firstTime lastTime length=
(

motion = pa_motion nTimerecords:0 timeList:#() rotList:#() posList:#() scaleList:#()

-- set timelist
motion.nTimerecords = timeList.count
if(timeList.count == 0) do (
append timeList 0f
)

format " - Bone motion for %\n" boneObj.name to:logFp
format " - Number of time records: %\n" motion.nTimerecords to:logFp


-- set default parent to identity
for t in timeList do (
at time t (

ptrans = matrix3 1
trans = boneObj.transform
if(boneObj.parent != undefined) do
ptrans = boneObj.parent.transform

-- Get own time
paTime = float((t - firstTime)) / float((lastTime - firstTime))*float(length)

transrot = trans*inverse(ptrans)
transpos = trans*inverse(ptrans)


if(motion.nTimerecords > 0) then (
append motion.timeList paTime
) else (
format " - Not writing any motion\n" to:logFp
)

append motion.rotList (inverse transrot.rotation)
append motion.posList transpos.pos
append motion.scaleList transpos.scale

) -- end at time
) -- end for




return motion
)
fn createMotion obj=
(
format "createMotion()\n" to: logFp

motionList = #() -- List of all bone motion [id]


-- Get bone list
-- {boneNode = boneList[id]}
boneList = createBoneList (physiqueops.getVertexBone obj 1 1)

-- TODO: fix so 0, 100 ... are variable.
for i=1 to boneList.count do (
timeList = createTimeList boneList 0 1000

if timeList.count > 0 then (
firstTime = timeList[1]
lastTime = timeList[timeList.count]
)
else (
lastTime = 0
firstTime = 0
)


length = 1.0f
append motionList (createBoneMotion boneList timeList firstTime lastTime length)
)

return motionList


)


--
-- takes a bonelist created by createBoneList
--
fn createSkeleton boneList=
(
skel = pa_skeleton name:boneList[1].name boneList:#() nBones:0
format "createSkeleton()\n" to:logFp
format " - Creating a skeleton with % bones.\n" boneList.count to:logFp

-- Set number of bones
skel.nBones = boneList.count

-- Here, i = id of bone
for i=1 to boneList.count do (
boneObj = pa_bone id:-1 parentId:-1
boneObj.id = i-1
format " - bone name: %\n" boneList.name to:logFp
if (isValidBone boneList.parent == 1) then (
boneObj.parentId = (findItem boneList boneList.parent) - 1
if(boneObj.parentId == -1) do fatalError("Not a complete boneList given to createSkeleton")
)
else (
-- no parent, set to -1
boneObj.parentId = -1
)

append skel.boneList boneObj
)

format " - name: %\n" skel.name to:logFp


return skel

)


-- Create list of all bones in a system of parent-child relations
-- Using breadth first search to generate the list
--
-- if only bones attached to the mesh is needed use physiqueOps.getBones obj
fn createBoneList n=
(
-- propogate to root node
tmpnode=n
while( (isValidBone tmpnode.parent)==1) do
tmpnode=tmpnode.parent

-- breadth first
st = #() -- stack for search
boneList = #()

-- counter id
id=-1 -- start with invalid node ==(-1)
append st tmpnode
while (st.count!=0) do (

--visit node
tmpnode = st[1]
deleteItem st 1

-- only append valid nodes
if (isValidBone tmpnode) == 1 do (
-- only attach
if (findItem boneList tmpnode) == 0 then
append boneList tmpnode
else (
return fatalError("No circular bone structures allowed")
)

)

-- add childern to stack
for i=1 to tmpnode.children.count do (
append st tmpnode.children
)
)

--nothing found
return boneList
)

--
-- export skin controller
-- (physique modifier)
-- assume controller exist on object
fn createPhysiqueSkin obj=
(

format "exportSkin()\n" to:logFp
skinc = pa_skinController nSkinvertex:0 skinvertexNLinkList:#() skinvertexList:#() skeletonName:#() skinvertexWeightList:#() skinvertexBoneIdList:#()

skinc.nSkinvertex = physiqueops.getVertexCount obj
format " - nVerts: %\n" nVerts to:logFp


totalBoneLinkCount = 0

boneList = createBoneList (physiqueops.getVertexBone obj 1 1)
skinc.skeletonName = boneList[1].name
format " - skinc.skeletonName: %\n" skinc.skeletonName to:logFp

for i=1 to skinc.nSkinvertex do (

boneCount = physiqueops.getVertexBoneCount obj i
totalBoneLinkCount = totalBoneLinkCount + boneCount

-- this vertex has boneCount links
append skinc.skinvertexNLinkList boneCount


for j=1 to boneCount do (
-- get attached bone[j]
boneNode = physiqueops.getVertexBone obj i j -- solve id?

append skinc.skinvertexList (physiqueops.getVertexOffset obj i j)
boneId = findItem boneList boneNode
if(boneId != 0) then
append skinc.skinvertexBoneIdList (BoneId-1)
else
fatalError("two root system is attached to the selected mesh, not supported")

append skinc.skinvertexWeightList (physiqueops.getVertexWeight obj i j)
)

)

skinc.nSkinvertexLinks = totalBoneLinkCount
format " - Total number of bone links: %\n" skinc.nSkinvertexLinks to:logFp



skel = createSkeleton boneList


--
-- Return the skin (skincontroller + skin)
--
return (pa_skin skeleton:skel skinController:skinc)

)



fn createMaterial mat =
(
format " - createMaterial()\n" to:logFp

text = undefined
format " - Adding material: %\n" mat.name to:logFp

-- Currently only diffuse map/bitmaptexture is supported
if mat.diffuseMap != undefined and classOf mat.diffuseMap == BitmapTexture do (
format " - Adding diffuse map: %\n" mat.diffuseMap to:logFp
tm = mat.diffuseMap
-- filter filename:
t = filterstring tm.filename "\\"
filename = t[t.count]
-- uvgenclass
text = (pa_texturemap filename tm.coords.u_offset tm.coords.v_offset tm.coords.u_tiling tm.coords.v_tiling)
)

-- wire?
wi = 0
if mat.wire do
wi = 1
-- faceted?
fa = 0
if mat.faceted do
fa = 1

pa_material name:mat.name ambient:mat.ambient diffuse:mat.diffuse specular:mat.specular opacity:mat.opacity selfIlluminate:mat.selfIllumColor isWire:wi isFaceMap:fa texturemap:text
)

-- Assume at least one material is defined on object!
fn createMaterials obj =
(
format " - createMaterials()\n" to:logFp
matList = #()
try (
-- if ok then multiple materials
for mat in obj.material do (
append matList (createMaterial mat)
)

) catch (
-- only one material defined
append matList (createMaterial obj.material)
)

-- Return list of materials
matlist

)


--
-- Creates the topology of the mesh -->(to be hardware friendly )
--

-- Needed structures:
-- structure of the vertex buffer elements (unique normal/material)
struct vertexInfo (vert, tvert, normal, matId) -- (point3, point3, point3, int)

-- structure of the vertex lookup elements
struct vertexLookup(vIdx, tvIdx, smGrp, matId)
-- structure of the faces array elements
struct faceInfo (face, matId) -- (point3, int)

-- meshPart (homogene part of mesh (same smoothing group, same material, unique
-- - texture vertices.
struct meshPart (nFaces, faces, matId) -- (point3idx int)

struct topology (vertexBuffer, meshPartList)

-- topology: list of meshParts!
-- quicksort function
-- return -1,1,0
fn qsortFaceFn f1 f2=
(
if f1.matId < f2.matId do
return -1
if f1.matId > f2.matId do
return 1

return 0
)
--
--
-- :TODO: smoothing groups optional
--
--
fn createMeshTopology obj =
(

format " - Creating mesh topology.\n" to:logFp
-- the temp lookup table
lookup = #()
vertBuffer = #()
faces = #()
snap = snapshotasmesh obj

-- define: cloneStartIndex: duplicated vertices will have index start
-- -- at cloneStartIndex!
cloneStartIndex = (getnumverts snap) + 1
nClones = 0;

-- when only one standard material is defined, max has problem with
-- keeping unique ids for all faces. (if true then set all id=0)
collapseMatId = false;
hasMaterials = true;
hasTextureVerts = true;

try (
if classOf obj.material == StandardMaterial do
collapseMatId = true
) catch(
)

-- PSEUDO:
-- define: faceIndex
-- define: vertList: indexed set of (v,tv,normal,faceId)
-- define: lookup list: set of unique (v,tv,matId) tuple
-- 3) newfaceidx = obj.numverts
-- for all faces in face List
-- for vert in face
-- if vert in lookup
-- faceidx.i = oldfaceidx.i
-- do nothing
-- elseif not found
-- add to lookuplist
-- faceidx.i = newfaceidx++.i
-- 4) Sort faceidx list according to material
-- 5) Create mesh parts (unique materials)
-- 6) Convert to pa_meshtopology and return


-------------
-- 3) Traverse faceList
-------------
for i = 1 to obj.numFaces do
(
face = getFace snap i
tvface = undefined
if hasTextureVerts then tvface = getTVFace snap i

-- figure out what to put for the mat id
if not collapseMatId then
faceMatId = (getFaceMatId snap i) - 1
else
faceMatId = 0

-- get the smoothing group
smGrp = getFaceSmoothGroup snap i

-- init the face info struct and set the mat id
faces = (faceInfo [0, 0, 0] faceMatId)

-- do each of the three vertices of the face
for j = 1 to 3 do
(
v = face[j]
tv = undefined
if opt.is_textured then tv = tvface[j]

-- if it doesn't already exist, then add a new rec
if lookup[v] == undefined then
(
-- add new lookup
lookup[v] = #(vertexLookup v tv smGrp faceMatId)

-- grab the pieces
vert = getVert snap v
normal = getNormal snap v
tvert = undefined
if opt.is_textured then tvert = getTVert snap tv

-- add the vert to the vert buf
vertBuffer[v] = (vertexInfo vert tvert normal faceMatId)

-- add to the faces array
faces.face[j] = v - 1
)
-- else, duplicate the vert
else
(

-- define cloneIdx: the added index corresponding to a "cloned" vertex
cloneIdx = -1
-- is the vertex already in lookup table?
for vertLookup in lookup[v] do (
if vertLookup.tvIdx == tv and
vertLookup.matId == faceMatId and
vertLookup.smGrp == smGrp do (
cloneIdx = vertLookup.vIdx
)
)

-- if we can't find it, then we add it
if (cloneIdx == -1) then
(

cloneIdx = cloneStartIndex + nClones
-- add the the lookup
append lookup[v] (vertexLookup cloneIdx tv smGrp faceMatId)

-- grab the pieces
vert = getVert snap v
normal = getNormal snap v
tvert = undefined
if opt.is_textured then tvert = getTVert snap tv

-- add the vert to the vert buf
vertBuffer[cloneIdx] = (vertexInfo vert tvert normal faceMatId)

-- Increase number of clones made
nClones += 1
)
else if (cloneIdx == 0) then
(
cloneIdx = v
)
faces.face[j] = cloneIdx - 1
)
)
)
format " - Vertex buffer was increased to %\n" (vertBuffer.count) to:logFp
format " - Creating Mesh parts.\n" to:logFp



-----------
-- 4) Sort the list of faces according to their material
-----------
qsort faces qsortFaceFn
format "%\n" faces



-------------
-- 5) Create mesh parts with unique materials.
-------------
-- currMatId = -1 (INVALID)
-- on change currMatId
-- create new mesh part
currMatId = -1
top = (topology vertexBuffer:vertBuffer meshPartList:#())
currFaceList = #()
for face in faces do (
-- convert to righthand system:
temp = face.face.x
face.face.x = face.face.z
face.face.z = temp

if face.matId != currMatId do ( -- add prev. meshpart
-- if currmatid not invalid then add meshpart
if currMatId != -1 then (
format " - Adding meshpart (matId: %)\n" currMatId to:logFp
append top.meshPartList (meshPart currFaceList.count currFaceList currMatId)
currFaceList = #()
)
-- and/else update current matId
currMatId = face.matId

)
append currFaceList face
)
-- the last meshpart wasn't added above (addit!)
if currFaceList.count != 0 do (
format " - Adding meshpart (matId: %)\n" currMatId to:logFp
append top.meshPartList (meshPart currFaceList.count currFaceList currMatId)
currFaceList = #()
)

format " - Number of meshparts created: %\n" top.meshPartList.count to:logFp

-- Convert to local topology to exportable pa_meshtopology:
--

-------------
-- 6) Convert to exportable pa_meshtopology
-------------

-- if not geometry then export skin here?
pageom = pa_geometry vertexList:#() normalList:#() textureList:#()
patop = pa_meshtopology nParts:top.meshPartList.count geometry:pageom meshPartList:top.meshPartList


for vinfo in top.vertexBuffer do (
append patop.geometry.vertexList vinfo.vert
append patop.geometry.textureList vinfo.tvert
append patop.geometry.normalList vinfo.normal
)
patop.geometry.nGeomPoints = top.vertexBuffer.count

-- Return exportable topology:
patop


)
--
-- create the mesh
--
fn createMesh obj =
(
format "exportMesh()\n" to: logFp

mesh = snapshotasmesh obj
format " - Native information:\n" to:logFp
format " - Vertex count: %\n" mesh.numverts to:logFp
format " - Texture vert count: %\n" mesh.numtverts to:logFp
format " - Faces count: %\n" mesh.numfaces to:logFp
delete mesh
-- Create meshparts / topology
patop = createMeshTopology obj
)


--
-- create file as either txt or binary
--
fn createExportfile exportFilename=
(
try (
format "Creating binary file for export (%).\n" exportFilename to: logFp
return fopen exportFilename "wb"
) catch (
format "- Error: createExportfile() failed, closing file!" to:logFp
close fp
)

)

--
-- Export function
--
fn exportPAFile obj exportFilename=
(

-------
-- Valid export object?
-------
if obj == undefined do (
err = "No object selected for export."
format err to: logFp
) -- end if obj undefined

format "Starting exporting: %\n" obj.name to: logFp


---------
-- Create exportfile
---------
fp = createExportfile exportFilename

----------
-- Get properties/options
----------
prop = getProperties(obj)

----------
-- Create header
----------
header = createHeader obj

--------
-- Create physique
--------
if opt.exp_physique and opt.is_physique do (
format " - Exporting physique.\n" to:logFp
skin = createPhysiqueSkin obj
)

--------
-- Create motion
--------
if opt.exp_motion do (
motionList = createMotion obj
)

--------
-- Create mesh
--------
meshtop = createMesh obj

--------
-- Create material
--------
matList = createMaterials obj

-----------------------
------- TO FILE -------
-----------------------
writeHeader fp header


if meshtop != undefined do (
writestring fp "MESHTOPOLOGY"
writeMeshTopology fp meshtop
)


if matList.count != 0 do (
writestring fp "MATERIAL"
-- Write number of materials:
writelong fp matList.count
for mat in matList do (
format "%\n" mat
writeMaterial fp mat
)
)

if skin != undefined do (
writestring fp "SKIN"
writeSkincontroller fp skin.skinController
writestring fp "SKELETON"
writeSkeleton fp skin.skeleton
)
if motionList != undefined do (
writestring fp "MOTION"
writelong fp motionList.count
for i=1 to motionList.count do
writeMotion fp motionList
)

-----------------------
-----------------------
-----------------------

format "Finished exporting.\n" to: logFp
-- return
fclose fp


)


--
-- Utility main function
--
utility pa_export "Mutant script" width:162 height:300
(
-- Variable definitions

-- Rollout

GroupBox grpExport "Export" pos:[2,1] width:158 height:238
button exportButton "Export" pos:[49,216] width:60 height:18
button selectValidButton "Select" pos:[106,32] width:38 height:18
checkbox colorChk "Export Vertex Colors" pos:[8,194] width:139 height:16
GroupBox grp3 "Selected" pos:[4,15] width:154 height:57
label selectedLabel "Nothing selected" pos:[9,34] width:85 height:34
checkbox motionChk "Export Motion" pos:[8,178] width:114 height:17 checked:false


-- On <thing> <event> <arg> do ...

-- Check buttons
checkbox physiqueChk "Export Physique" pos:[8,164] width:104 height:15

on pa_export close do
(

)
on pa_export okToClose do
(

)
on exportButton pressed do
(
if selectedObject != undefined do (

exportFilename = getsavefilename caption:"Save As" filename:exportLastFilename types:"planetalpha (*.pa)|*.pa|All Files (*.*)|*.*|"

logFp = createfile logFile
if isValidNode selectedObject and exportFilename != undefined then (
-- try (
exportPAFile selectedObject exportFilename
-- ) catch (
--format "!! Fatal error !!" to:logFp
close logFp

-- )
)

)
)
on selectValidButton pressed do
(
fn check o = (superclassOf o == Geometryclass and
classof o != TargetObject)

obj = obj = pickobject filter:check

if isValidNode obj then (
selectedObject = obj
selectedLabel.caption = "Selected: " + obj.name
)
else (
selectedLabel.caption = "Nothing selected."
selectedObject = undefined
)

)

on physiqueChk changed state do opt.exp_physique = state
on motionChk changed state do opt.exp_motion = state
on colorChk changed state do opt.exp_colors = state


)


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!