[Opal-commits] opal/tools/3dsmax opalExporter.ms,1.1,1.2 readme.txt,1.1,1.2
Status: Inactive
Brought to you by:
tylerstreeter
|
From: tylerstreeter <tyl...@us...> - 2005-04-18 22:21:52
|
Update of /cvsroot/opal/opal/tools/3dsmax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32731/tools/3dsmax Modified Files: opalExporter.ms readme.txt Log Message: made destructor protected for objects instantiated by OPAL; cleaned up a lot of things to prepare for 0.3.0 release Index: opalExporter.ms =================================================================== RCS file: /cvsroot/opal/opal/tools/3dsmax/opalExporter.ms,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** opalExporter.ms 8 Apr 2005 15:49:35 -0000 1.1 --- opalExporter.ms 18 Apr 2005 22:21:06 -0000 1.2 *************** *** 1,201 **** ! global D_TRUE = 1 ! global D_FALSE = 0 ! global D_BOX_ID = #(16,0) ! global D_SPHERE_ID = #(17,0) ! --global D_CYLINDER_ID = #(18,0) ! global D_CAPSULE_ID = #(1832744876, 2043230633) ! ! -- Path for output files. ! global savePath ! ! -- Global handle for the output file. ! global outFile ! ! -- Checks if the scene is in the proper format for exporting. ! function checkScene = ! ( ! -- is something selected? ! if selection.count == 0 then ! ( ! displayTempPrompt "Opal Error: nothing is selected!" 5000 ! return D_FALSE ! ) ! ! -- if saving is canceled return false ! savePath = getSaveFileName caption:"Export Solid To..." filename:"untitled" types:"Opal Blueprint(*.xml)|*.xml|All|*.*" ! if savePath == undefined then return D_FALSE ! ! return D_TRUE ! ) ! ! -- Prints an offset element for Solid. ! function printSolidOffset trans angle axis = ! ( ! format "\t\t<Offset>\n" to:outFile ! ! format "\t\t\t<Transform type=\"translate\" x=\"%\" y=\"%\" z=\"%\"/>\n" trans.x trans.y trans.z to:outFile ! ! -- Only save the rotation if it's significant. ! if abs(angle) > 0.001 then ! ( ! format "\t\t\t<Transform type=\"rotate\" angle=\"%\" x=\"%\" y=\"%\" z=\"%\"/>\n" angle axis.x axis.y axis.z to:outFile ! ) ! ! format "\t\t</Offset>\n" to:outFile ! ) ! ! -- Prints an offset element for Shapes. ! function printShapeOffset trans angle axis = ! ( ! format "\t\t\t<Offset>\n" to:outFile ! ! format "\t\t\t\t<Transform type=\"translate\" x=\"%\" y=\"%\" z=\"%\"/>\n" trans.x trans.y trans.z to:outFile ! ! -- Only save the rotation if it's significant. ! if abs(angle) > 0.001 then ! ( ! format "\t\t\t\t<Transform type=\"rotate\" angle=\"%\" x=\"%\" y=\"%\" z=\"%\"/>\n" angle axis.x axis.y axis.z to:outFile ! ) ! ! format "\t\t\t</Offset>\n" to:outFile ! ) ! ! -- Prints a Shape element for the given object. ! function printShape object printOffset = ! ( ! if object.classID[1] == D_SPHERE_ID[1] then ! ( ! format "\t\t<Shape type=\"sphere\">\n" to:outFile ! format "\t\t\t<Dimensions radius=\"%\"/>\n" (abs(object.scale[1] * object.radius)) to:outFile ! ! ) ! else if object.classID[1] == D_CAPSULE_ID[1] then ! ( ! format "\t\t<Shape type=\"capsule\">\n" to:outFile ! format "\t\t\t<Dimensions radius=\"%\" length=\"%\"/>\n" (abs(object.scale[1] * object.radius)) (abs(object.scale[1] * object.height)) to:outFile ! ) ! -- Default to boxes for everything else. ! else ! ( ! -- We need to find the extents of the object's locally-aligned bounding box. ! -- The MAXScript bounding box extents are wrong for the local coordsys, ! -- so we'll just move the object to the global origin, gets its extents, ! -- and then move it back. ! ! -- First, store the object's original transform. ! originalTransform = object.transform ! ! -- Set its transform to the identity. ! object.transform = Matrix3(1) ! ! -- Calculate the bounding box's extents. ! dimensions = object.max - object.min ! ! -- Restore the object's original transform. ! object.transform = originalTransform ! ! format "\t\t<Shape type=\"box\">\n" to:outFile ! format "\t\t\t<Dimensions x=\"%\" y=\"%\" z=\"%\"/>\n" dimensions.x dimensions.y dimensions.z to:outFile ! ) ! ! -- If requested, print the Shape's offset from its parent. ! if (true == printOffset) then ! ( ! in coordsys parent offsetTranslation = object.center ! in coordsys parent offsetRotation = object.rotation ! printShapeOffset offsetTranslation offsetRotation.angle offsetRotation.axis ! ) ! ! format "\t\t</Shape>\n" to:outFile ! ) ! ! -- Check if the scene is valid. ! readyToGo = checkScene() ! ! if(readyToGo == D_TRUE) then ! ( ! -- Create the output file. ! outFile = createfile savePath ! ! -- Add the XML version and initial Blueprint tags. ! format "<?xml version=\"1.0\"?>\n" to:outFile ! format "<OpalBlueprint>\n" to:outFile ! ! -- Handle Solids. ! --i = 0 ! for object in selection do ! ( ! -- Only print a Solid element for group heads and non-group members. ! if isGroupHead object or false == isGroupMember object then ! ( ! format "\t<Solid>\n" to:outFile ! ! -- Use the object name for the Solid name. ! format "\t\t<Name value=\"%\"/>\n" object.name to:outFile ! ! -- If the group has the "static" user property defined, add an element for it. ! -- Otherwise, the Solid will just use the default OPAL setting. ! isStatic = getUserProp object "static" ! if isStatic != undefined then ! ( ! if "true" == isStatic then ! ( ! format "\t\t<Static value=\"true\"/>\n" to:outFile ! ) ! else if "false" == isStatic then ! ( ! format "\t\t<Static value=\"false\"/>\n" to:outFile ! ) ! else ! ( ! displayTempPrompt "Opal Warning: invalid value for \"static\" user property" 2000 ! ) ! ) ! ! -- Handle group objects. ! if isGroupHead object then ! ( ! -- Create a Shape for each group member. ! ! -- Loop over the group members. ! for member in object do ! ( ! -- The group head "is" the Solid; use its transform as the Solid's transform. ! if true == isGroupHead member then ! ( ! in coordsys world worldTranslation = member.center ! in coordsys world worldRotation = member.rotation ! printSolidOffset worldTranslation worldRotation.angle worldRotation.axis ! ) ! -- Create a Shape for each group member. Their transforms represent offsets from ! -- the group head. ! else ! ( ! printShape member true ! ) ! ) ! ) ! -- Handle "normal" (non-group) objects. Just create a single Shape. ! else if false == isGroupMember object then ! ( ! -- Print the Solid's transform. ! in coordsys world worldTranslation = object.center ! in coordsys world worldRotation = object.rotation ! printSolidOffset worldTranslation worldRotation.angle worldRotation.axis ! ! -- Print the Shape with no offset from its Solid. ! printShape object false ! ) ! ! format "\t</Solid>\n" to:outFile ! ) ! ) ! ! -- Add the closing Blueprint tag. ! format "</OpalBlueprint>\n" to:outFile ! ! -- Close the output file. ! close outFile ! ! displayTempPrompt "Finished exporting OPAL Blueprint" 10000 ! ) --- 1,182 ---- ! global D_TRUE = 1 ! global D_FALSE = 0 ! global D_BOX_ID = #(16,0) ! global D_SPHERE_ID = #(17,0) ! --global D_CYLINDER_ID = #(18,0) ! global D_CAPSULE_ID = #(1832744876, 2043230633) ! ! -- Path for output files. ! global savePath ! ! -- Global handle for the output file. ! global outFile ! ! -- Checks if the scene is in the proper format for exporting. ! function checkScene = ! ( ! -- is something selected? ! if selection.count == 0 then ! ( ! displayTempPrompt "Opal Error: nothing is selected!" 5000 ! return D_FALSE ! ) ! ! -- if saving is canceled return false ! savePath = getSaveFileName caption:"Export Solid To..." filename:"untitled" types:"Opal Blueprint(*.xml)|*.xml|All|*.*" ! if savePath == undefined then return D_FALSE ! ! return D_TRUE ! ) ! ! -- Prints an offset element for Solid. ! function printSolidOffset trans angle axis = ! ( ! format "\t\t<Offset>\n" to:outFile ! ! format "\t\t\t<Transform type=\"translate\" x=\"%\" y=\"%\" z=\"%\"/>\n" trans.x trans.y trans.z to:outFile ! ! -- Only save the rotation if it's significant. ! if abs(angle) > 0.001 then ! ( ! format "\t\t\t<Transform type=\"rotate\" angle=\"%\" x=\"%\" y=\"%\" z=\"%\"/>\n" angle axis.x axis.y axis.z to:outFile ! ) ! ! format "\t\t</Offset>\n" to:outFile ! ) ! ! -- Prints an offset element for Shapes. ! function printShapeOffset trans angle axis = ! ( ! format "\t\t\t<Offset>\n" to:outFile ! ! format "\t\t\t\t<Transform type=\"translate\" x=\"%\" y=\"%\" z=\"%\"/>\n" trans.x trans.y trans.z to:outFile ! ! -- Only save the rotation if it's significant. ! if abs(angle) > 0.001 then ! ( ! format "\t\t\t\t<Transform type=\"rotate\" angle=\"%\" x=\"%\" y=\"%\" z=\"%\"/>\n" angle axis.x axis.y axis.z to:outFile ! ) ! ! format "\t\t\t</Offset>\n" to:outFile ! ) ! ! -- Prints a Shape element for the given object. ! function printShape object printOffset = ! ( ! if object.classID[1] == D_SPHERE_ID[1] then ! ( ! format "\t\t<Shape type=\"sphere\">\n" to:outFile ! format "\t\t\t<Dimensions radius=\"%\"/>\n" (abs(object.scale[1] * object.radius)) to:outFile ! ! ) ! else if object.classID[1] == D_CAPSULE_ID[1] then ! ( ! format "\t\t<Shape type=\"capsule\">\n" to:outFile ! format "\t\t\t<Dimensions radius=\"%\" length=\"%\"/>\n" (abs(object.scale[1] * object.radius)) (abs(object.scale[1] * object.height)) to:outFile ! ) ! -- Default to boxes for everything else. ! else ! ( ! -- We need to find the extents of the object's locally-aligned bounding box. ! -- The MAXScript bounding box extents are wrong for the local coordsys, ! -- so we'll just move the object to the global origin, gets its extents, ! -- and then move it back. ! ! -- First, store the object's original transform. ! originalTransform = object.transform ! ! -- Set its transform to the identity. ! object.transform = Matrix3(1) ! ! -- Calculate the bounding box's extents. ! dimensions = object.max - object.min ! ! -- Restore the object's original transform. ! object.transform = originalTransform ! ! format "\t\t<Shape type=\"box\">\n" to:outFile ! format "\t\t\t<Dimensions x=\"%\" y=\"%\" z=\"%\"/>\n" dimensions.x dimensions.y dimensions.z to:outFile ! ) ! ! -- If requested, print the Shape's offset from its parent. ! if (true == printOffset) then ! ( ! in coordsys parent offsetTranslation = object.center ! in coordsys parent offsetRotation = object.rotation ! printShapeOffset offsetTranslation offsetRotation.angle offsetRotation.axis ! ) ! ! format "\t\t</Shape>\n" to:outFile ! ) ! ! -- Check if the scene is valid. ! readyToGo = checkScene() ! ! if(readyToGo == D_TRUE) then ! ( ! -- Create the output file. ! outFile = createfile savePath ! ! -- Add the XML version and initial Blueprint tags. ! format "<?xml version=\"1.0\"?>\n" to:outFile ! format "<OpalBlueprint>\n" to:outFile ! ! -- Handle Solids. ! --i = 0 ! for object in selection do ! ( ! -- Only print a Solid element for group heads and non-group members. ! if isGroupHead object or false == isGroupMember object then ! ( ! format "\t<Solid>\n" to:outFile ! ! -- Use the object name for the Solid name. ! format "\t\t<Name value=\"%\"/>\n" object.name to:outFile ! ! -- Handle group objects. ! if isGroupHead object then ! ( ! -- Create a Shape for each group member. ! ! -- Loop over the group members. ! for member in object do ! ( ! -- The group head "is" the Solid; use its transform as the Solid's transform. ! if true == isGroupHead member then ! ( ! in coordsys world worldTranslation = member.center ! in coordsys world worldRotation = member.rotation ! printSolidOffset worldTranslation worldRotation.angle worldRotation.axis ! ) ! -- Create a Shape for each group member. Their transforms represent offsets from ! -- the group head. ! else ! ( ! printShape member true ! ) ! ) ! ) ! -- Handle "normal" (non-group) objects. Just create a single Shape. ! else if false == isGroupMember object then ! ( ! -- Print the Solid's transform. ! in coordsys world worldTranslation = object.center ! in coordsys world worldRotation = object.rotation ! printSolidOffset worldTranslation worldRotation.angle worldRotation.axis ! ! -- Print the Shape with no offset from its Solid. ! printShape object false ! ) ! ! format "\t</Solid>\n" to:outFile ! ) ! ) ! ! -- Add the closing Blueprint tag. ! format "</OpalBlueprint>\n" to:outFile ! ! -- Close the output file. ! close outFile ! ! displayTempPrompt "Finished exporting OPAL Blueprint" 10000 ! ) \ No newline at end of file Index: readme.txt =================================================================== RCS file: /cvsroot/opal/opal/tools/3dsmax/readme.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** readme.txt 8 Apr 2005 15:49:36 -0000 1.1 --- readme.txt 18 Apr 2005 22:21:06 -0000 1.2 *************** *** 1,28 **** ! OPAL 3ds max Exporter ! --------------------- ! ! This exporter for 3ds max generates an OPAL XML file. It is currently limited to a subset of the possible OPAL XML elements. The current feature list includes: ! ! * Single-Shape Solids ! - Ungrouped objects in 3dsmax ! * Multi-Shape Solids ! - Grouped objects are automatically added to a single Solid ! * Shapes ! - Box (3dsmax "box" primitive) ! - Sphere (3dsmax "sphere" primitive) ! - Capsule (3dsmax "capsule" primitive) ! - All other object types are exported as boxes, using the objects' locally-aligned bounding boxes ! * Static/dynamic ! - Solids' static/dynamic property defaults to OPAL's default setting ! - To explicitly set a Solid as static or dynamic, set a "static" user-defined property for the object/group (right-click on the object/group, go to "Properties", then "User Defined"). For example, static=true or static=false. ! ! Note: All objects' local transforms refer to the center of their bounding boxes. For Solids with a single Shape, this refers to the Shape's bounding box center. For grouped objects (multi-Shape Solids), this refers to the group's bounding box center. ! ! ! Planned Features ! ---------------- ! ! * Joints ! - Joint type ! - anchor point ! - axes --- 1,27 ---- ! OPAL 3ds max Exporter ! --------------------- ! ! This exporter for 3ds max generates an OPAL XML file. It is currently limited to a subset of the possible OPAL XML elements. The current feature list includes: ! ! * Single-Shape Solids ! - Ungrouped objects in 3dsmax ! * Multi-Shape Solids ! - Grouped objects are automatically added to a single Solid ! * Shapes ! - Box (3dsmax "box" primitive) ! - Sphere (3dsmax "sphere" primitive) ! - Capsule (3dsmax "capsule" primitive) ! - All other object types are exported as boxes, using the objects' locally-aligned bounding boxes ! ! Note: All properties not supported by the exporter will use OPAL's default settings upon instantiation. ! ! Note: All objects' local transforms refer to the center of their bounding boxes. For Solids with a single Shape, this refers to the Shape's bounding box center. For grouped objects (multi-Shape Solids), this refers to the group's bounding box center. ! ! ! Planned Features ! ---------------- ! ! * Joints ! - Joint type ! - anchor point ! - axes \ No newline at end of file |