Alex3DTools

-- aleXtra -- ©08 Alex da Franca -- alex@farbflash.de
Version 1.1.5, Release date: 08/02/02

x

  • Use this Director Tool Xtra to sav and restore the current state of a shockwave3d scene as a list.

  • For use with the Macromedia Director.

  • I was sick of not being able to save the changes I make to my 3-D members, so I wrote some utility scripts to wade through all objects in the 3-D member and store them in a list.

    Especially in conjunction with ullalas great 3dpi (http://www.ullala.at/3DPI) you may now build and save 3-D worlds without any line of lingo.
    Of course it can also be done with a 3-d modelling app, but it results in big movies, since the data is stored in the shockwave3-D member.
    With this script you can empty your 3-D member and build the world at runtime on the fly, resulting in small filesize, which is especially useful for tiny .dcrs.

    The idea is simple (it was only much 'typing work') The approach to save the huge lists in scriptmembers results in little filesize after publishing the movie to dcr or dxr since the scripttext which actually makes the .dir file big, is stripped after precompiling.
    Thus only the 'compiled' list is stored in the published file.
    Also the access of the data is much faster, than saving it to a field member and rebuilding the list via value().

    The drawback is: that huge scriptmembers are loaded into memory when the castlib is loaded and can't be purged.

    I think pims propsave xtra (http://www.pimz.com/xtras/free/propsave.html) might do a better job on this.
    And it is supposed to be shockwave save in the near future.

    Just one more thing:
    If you want to call the restore function from within a script just do the following:

    tell window "Alex3-DTools"
      saveObj = new(script "SaveW3DScript")
    end tell
    saveObj.mRestoreSW3Dworld(memberref, whichScriptname)
    	                               
    

    Make sure the miaw is already open, or write your own code to open it invisible.



  • "Alex3-DTools1_1_5.dcr"
  • ... and Macromedia Director 8.5 and higher.
  • Quit Director
  • Copy the file 'Alex3-DTools1_1_5.dcr' into the Xtras Folder of Director
  • Launch Director
  • Choose 'Alex3-DTools1_1_5' from the Xtras menu

  • To use a saved state, which was previously saved with Alex3-DTool, at runtime, open the director castlib 'RuntimeRestore.cst' and copy both scriptmembers to your castlib. Drag the 'RestoreBehavior' behavior onto the sprite with the #shockwave3d member. (at authortime you can instead simply use the provided button in the xtra interface to restore a saved state)

  • Then in the appearing GPDL dialog do the following: following options:

  • Select the saved state you wish to restore from the popup menu

  • Select "Restore on Beginsprite?", if the saved state shall be restored every time the sprite is first displayed. If you leave this checkbox blank you'll need to call the restore handler yourself with lingo. (e.g. if you have a #shockwave3d member in sprite 1, with the RestoreBehavior attached, you can simply call: sendsprite(1, #mReset) or sprite(1).mReset() at any time.)

  • Select "Reset World before Restoring?", if the #shockwave3d member shall be reset to its default. If you leave it unchecked, only the values stored in the saved state will be reset and missing objects will be recreated, leaving all additional objects in the #shockwave3d member untouched.

  • If you want to use different saved states at runtime for a single #shockwave3d member at different times, you may also call the restore script directly without the need of the RestoreBehavior. To do so call the following function with lingo:
    new(script "OnlyRestoreScript").restoreWorld(, )
    
    where <SWMember> is a reference to the #shockwave3d member in question (e.g. SWMember = member("myWorld") ) and <savedStateName> is a string holding the name of a saved state (the name of the script castmember, which was created with 'Alex3-DTools')

  • Like most of my other director tool miaws, this tool uses the "on idle sleep 1" trick to prevent the CPU from maxing to 100% and the fan of my computer running like mad. This means, that as long as the tool is open you movie won't run at the maximum speed. So to test performance of your movie make sure to close the tool miaw before.
  • Attention must be paid, where your own scripts refer to objects or create new ones. The save tool shouldn't throw errors regardless when the restore function is called, because it only creates objects if it doesn't find the required objects when restoring. In this case it would only set the properties to the previous saved state. Thus your changes won't be touched by the restore command, unless the objects already existed, when the state was saved or you by bad chance use the same name for a newly created object, that was used by a deleted object. In the case of the new object being of other type it will be deleted and a new object with the correct type will be created instead.

  • Models of type #extruder can't be saved, since there is no access to the original textmember, respectively the textmember may have been changed meanwhile. So if you have created an #extruder model by lingo you will have to create it again after the restoreworld command or you convert it before saving the world to a lingo mesh, using the 'Convert' or 'Convert All' function.

  • The same is true for models #fromFile since they may reside in the shockwave3d member (I do not convert them automatically to lingo meshes when saving to not blow up your castlib with a big scriptmember, if it isn't needed) and which is more important: The models #fromFile are superior to lingomeshes, since at this moment I do not store all of the informations of the meshes AND the lingo meshes have no LOD function :-(). On the other hand, since I give you the choice of skipping the normallist if it's enough to use generateNormals() (generateNormals() does a great job by the way, good work Macromedia/Intel! Most of the models imported from 3-D modelling programms look pretty the same without saving the normallist.) For filesize reason I skipped the colorlist and texturecoordinatelist also. I am working on giving the choice to maintain them. The main goal when converting to lingo meshes was to reduce filesize and it reduced the filesize of the dcr up to 30 % vs. using 3-DMax exported members. The lack of LOD in lingo meshes makes them inferior, however. BTW. when converting to lingo-meshes you can determine the number of vertices, by altering the lod level of the original resource. I built in a slider to determine the lod level. (you may enter 0 if the lod level should not be forced and the actual lod level should be used).

  • If the models where imported at runtime into the 3D member by lingo, you will have to import them again after the restoreWorld command or convert them to lingo meshes using 'Convert' before saving the member state with 'save'.

  • Members from type #text with displaymode #mode3d are not supported currently.

  • Sprite properties like DTS, targetframerate, camera.count, camera[x].rect etc. are not saved, because the saved state refers to member properties. In this case you also might set these properties by lingo after restoring the world.

  • Read the comments at the top of the Behaviors
  • Drop me a line: Alex da Franca

  • Version 1.15 02/02/08
    • Fixed a bug where overlay and backdrop shader and models were saved. Since overlays and backdrops are saved and restored by the tool, it doesn't need to mess with the models and shaders of the overlays/backdrops. Instead doind so even causes a bug to happen, where if you use the reserved names "OverlayShader-copy"/"BackdropShader-copy" with any number, wil result in funny things to happen, when Director creates the overlays or backdrops (shaders with the same name), which result in reference woes.
      Credits for spotting this bug go to Jonathan Lyerly
    • Added ability to save and restore bones and keyfram animation settings. Please keep in mind, that the motions themselves are #fromFile and can't be savd themselves. So you will need to use the w3d files with the corresponding motions, just like for modelresources #fromFile.
    • Save and restore of userdata now is suppoirted for all nodetypes, but only userdata values which are NOT objects are saved. That means values of type string or integer are saved, wehreas for example lists, transforms points, vectors, colors etc are skipped. So if you want userdata to be saved and restored make sure you use strings or numbers.
    • Fixed a bug where querying the texture of a particle will set the texture type to #fromFile, if it was #fromcastMember, so that later the reference to the member is lost.

  • Version 1.04 27/11/01
    • added resources of type #plane to the types which can be converted or merged to a single lingo mesh

  • Version 1.03beta 22/08/01
    • added the ability to provide bitmaps which are named after the textures #importedFromFile, to create textures #fromCastMember using the provided bitmaps, when a bitmap member with the matching name was found in the movie casts, while restoring the saved state. since I have no access to textures #importedFromFile. the according bitmaps can be created with the following steps (maybe one day I'll build these steps into the tool...)
      • make the 'defaultmodel' modelresource (#plane) of the same dimension (on resource level: length and width) like the texture you want to grab.
      • rotate it to vector(-90,0,0)
      • create a model with the modelresource 'defaultmodel'
      • apply a shader with the texture you want to grab to the model
      • set the camera to the default transform camera.transform = transform() camera.translate(0,0,250)
      • set the defaultrect of the sw3d member to the same dimension as the texture is adjust the camera z position that the viewport is completely covered by the model
      • now grab the image of the sw3d member: new(#bitmap).image = member("world").image
    • fixed a bug with the normallist when restoring a modelresource with normallist data

  • Version 1.02beta 15/08/01
    • fixed a bug, where resources of the type #mesh wouldn't be merged to one single mesh, by adding another radio button (#mesh) to the mui dialog, which appears when converting all models to one single mesh.
    • when 'converting All' to one single mesh, now only the models which are inWorld() will be merged to one mesh. by grouping all models you don't want to convert to one single mesh to a temporary group and remove this group temporarely from world, you can select the models you want to merge, even if they are of the same resource type as the ones you don't want to merge.
    • reduced the filesize of the saved state (a little bit) by replacing standard values for the texture list of shaders.

  • Version 1.01beta 04/08/01
    • saves the texturecoordinatelist for meshes, if any

  • Version 1.0 beta 08/01/01
    • I added a castlib with the restore handlers and a behavior, to use the saved states at runtime
    • I added the functinality to 'Convert All' which now provides the option to convert all models found in the world to one single mesh. this is useful to convert several primitives and other resource types into one single mesh/model. thus you can compose a mesh with a number of models. the problem was specifying a 'list' of models through the mui interface. when I do it on my own, I just pass a list of mopdels I want to convert to the handler, but that's difficult to ask the user, especially since I would need to build a completely new interface... and so lazy me decided to give the option to convert ALL models found in the 3-D member. so you can simply build the single mesh in a empty 3-D member containing only the models you want to merge, or you save the current state of the 3-D member using the 'save' function, then delete all models you dont want to merge and then 'convert All'. now restore the saved state (the restore function leaves the new model untouched) and save again to save the newly created mesh along.
    • if you want to 'mix up' preserve mesh count (to obtain different shaders) you'll have to do the steps for each different mesh count setting for example: you have two boxes and want to convert them to one single mesh. if you choose preserve mesh count you'll end up with 12 shaders, one for each face of the box. if you want each box to have one single shader for each face, but different shaders for the both boxes, you will have to convert the both boxes in different steps. first the first box with preserve mesh count = 0, then the second with the same setting and then make two models with the two meshresources and convert them using preserve mesh count. so you end up with a mesh which shows the two boxes and has two shaders, one for each box.
    • fixed several bugs in the convert to mesh function, where the shaderlist was void and the process failed when specifying quality level for primitives
    • fixed a bug with shaders other then #standard

  • This tool is free of charge, however you are not allowed to remove the copyright marks in the scripts. All rights on the scripts are reserved.

    If you use it for a paid job and it saved you some time and you feel generous, you are welcome to support my work by donating via
    PayPal Donation
    (PayPal), whatever you think is appropriate.

  • Use the tool and the scripts at your own risk.