Page 1 of 2 12 LastLast
Results 1 to 15 of 22

Thread: Morphs2OBJs - New script for LW to Unity 3D with Megafiers

  1. #1
    Registered User sami's Avatar
    Join Date
    Jul 2003
    Location
    TopLeft Viewport
    Posts
    994

    Post Morphs2OBJs - New script for LW to Unity 3D with Megafiers

    Hey all,

    In case you are using the amazing mesh modifier add-on for Unity 3D, Megafiers, which among its many features adds morphing in the game engine, I've created a new script to aid the workflow between Lightwave and Unity - especially if you are using Mega-Fiers.

    This Modeler script Morphs2OBJs exports morphmaps (Endomorphs) as separate OBJ files in one click. It's not rocket science by any means, however I find it useful since I haven't seen a script that does it.

    Btw Mega-Fiers allows you to use your standard FBX model/scene from LW as usual in Unity but allows you to use external OBJ files as the morph maps (since morphmap data is not obtainable in the LWO to FBX conversion or the FBX import into Unity). So instead of manually exporting each morphmap, this script does it for you. Plus it ensures your General Options settings will export them in a way that works. Once exported from the script, just load the gameobject into Unity and load the exported OBJs. Add the morphing component and voila - morphing works a charm! If you use Unity, I highly recommend Mega-Fiers from the Unity Asset store (I am not related to the company) as it works great with Lightwave - and this free script improves its workflow for LW users.

    However, this script is probably also useful for other reasons as well, possibly including working with Poser or Daz 3D. Or for anyone who wants to export morphs out as OBJs for other applications.

    Here's what my script looks like:


    There's a readme included for more info and some sample objects to test with. Feel free to critique or give feedback if it is useful etc. I've incorporated my MsgBox script in it to make it a bit more responsive and intelligent in various situations - though it may not be 1000% bulletproof.

    Hope it saves someone some time.

  2. #2
    Really Nice! Thanks for sharing!

  3. #3
    Registered User sami's Avatar
    Join Date
    Jul 2003
    Location
    TopLeft Viewport
    Posts
    994
    cool. hope it's useful. Let me know if you have any problems with it and I'll tweak it...

  4. #4
    Registered User
    Join Date
    Oct 2010
    Location
    Dallas, Tx
    Posts
    135
    Heya Sami! This looks like a REALLY useful plugin. But i'm having an issue...

    I'm in 10.1 and whenever it run the plugin to export all my shapes i get an error as foolows...

    line 219, illegal arithmetic operation on data type


    Any clue there?

    BTW i'm on a mac running OSx 10.6
    Last edited by bpritchard; 08-08-2011 at 01:40 PM. Reason: added platform

  5. #5
    Registered User sami's Avatar
    Join Date
    Jul 2003
    Location
    TopLeft Viewport
    Posts
    994
    hi,
    I'm still on 9.6.1 and it works fine. I've tested it in Win 7 32bit and 64bit versions of Modeler and it's fine. I'll test it on the mac in 9.6.1 too if you like, but off the top of my head I'm not sure what that problem is. I plan to upgrade to 10.x between projects sometime in September. I'll also have a look at line 219 and let you know if I see anything obvious I can quick fix without actually having 10 to try it out on. Sorry I can't be of more immediate help. I'll post after I have a look...

  6. #6
    Super Member geo_n's Avatar
    Join Date
    Aug 2007
    Location
    jpn
    Posts
    4,677
    Thanks for this.
    Tested on lw 9.6 and lw 10.1 and works great.

  7. #7
    Registered User sami's Avatar
    Join Date
    Jul 2003
    Location
    TopLeft Viewport
    Posts
    994

    Exclamation What's wrong with this for Lscript v10.x?

    Haven't tested it on Mac Modeler 9.6.1 yet, but I just had a look at the source code. Turns out line 219 was a comment - but line 218 (the line at the end of this code snippet) might be the culprit...

    Code:
     
                // Validate that User hasn't entered a crappy folder name
                var validateSaveFolder;
                var sfDrive;
                var sfPath;
                var sfFile;
                var sfExt;
    
                (sfDrive,sfPath,sfFile,sfExt) = split(saveFolder);
    
                validateSaveFolder = matchdirs(sfDrive + sfPath,"*.*");
    Only it DOES work in LW 9.6.1 Lscript. Is there a link to a v 10.x LScript release notes someone could point me to? Lscripters who use v10.x, is there any reason a simple string concatenation would work in 9.6.1 but fail in 10.1?

    Has matchdirs() changed for LW10? I can try and concatenating that in a separate variable and then passing it in if that may fix the 'illegal arithmetic' issue...?

    If there's a quick fix I'll recompile and reupload the fix. Sorry I can't be of more help without me having LW10 to test it in.

  8. #8
    Registered User sami's Avatar
    Join Date
    Jul 2003
    Location
    TopLeft Viewport
    Posts
    994
    bpritchard, are you still having issues with the script? Could you please try restarting Modeler and ONLY loading JUST the model with the morphs you want to export and then retry the script? It is possible this script is not bulletproof when multiple objects with multiple morphs are loaded at the same time.... I'll keep checking though.

  9. #9
    Hi !

    Thanks for this great tool
    I'm starting to use Unity, and would like to use morphs on bones animated objects inside Unity... Do you know if it's possible, or has some limitations ?

    I'm also planning to do a lwo import script for Unity (and maybe lws), if you are interested to share ideas on this subject, send me a private message

  10. #10
    Registered User
    Join Date
    Oct 2010
    Location
    Dallas, Tx
    Posts
    135
    I haven't had a change to try it like you said.. i'll give it a whirl tonight.

  11. #11
    Registered User sami's Avatar
    Join Date
    Jul 2003
    Location
    TopLeft Viewport
    Posts
    994
    Hi Alexx,
    I use the third-party addon Mega-fiers for morphing within Unity. Unity gives you access to vertices in C#, but instead of "rolling-my-own" I bought Mega-fiers and it is awesome. Morphing with that on my boned FBX rigs exported from LW works fine in Unity. With boned objects I've used the morphing primarily for facial expressions and mouth shapes and it seems to work fine.

  12. #12
    Jonny Gorden jonny's Avatar
    Join Date
    Feb 2003
    Location
    South Australia
    Posts
    77
    Hi Sami,

    Thanks very much for making this available. Do you know what would be involved with importing morph mixer animation data into Mega-Fiers to accompany this script, in the same way that Chris has done for Max?

  13. #13
    Registered User sami's Avatar
    Join Date
    Jul 2003
    Location
    TopLeft Viewport
    Posts
    994
    Quote Originally Posted by jonny View Post
    Hi Sami,

    Thanks very much for making this available. Do you know what would be involved with importing morph mixer animation data into Mega-Fiers to accompany this script, in the same way that Chris has done for Max?
    Hi jonny,

    In Unity, I don't tend to use the editor Animations as I usually do all my animations in code or have them embedded in the FBX. I view the Unity editor Animations much like the timeline in Flash - useful for banner ads or people who don't code, but most of the time I find it more robust and flexible to code the animations or just access them from within the content (the FBX) as opposed to having yet another timeline (on top of the LW channel envelopes and the dynamic tweening using iTween in the C# code in Unity).

    Sorry for the diatribe, just I don't see too much value (for me) for using that editor animations. But to answer your question, I think the pseudo-code/algorithm would be something like this:
    • enumerate the scene's objects
    • enumerate each object's channels
    • determine which were morphmixer channels
    • enumerate that channels keyframes
    • transfer scene/object/keyframes of morphmixer to Unity's animation timeline (or Mega-fiers MorphAnimation Component)


    Without rewriting a new FBX importer for Unity (which would be a big job) and assuming that the existing Unity FBX importer does not import MorphMixer data or at least have access to it (Chris knows much more about the specifics of the Unity FBX importer than I do), then we would need a way to transfer that morph mixer animation from LW to Unity with some intermediate file or LWS reader in Unity.

    Sorry I can't be of more help, and at this stage for me the benefits of me doing that are not great enough to warrant the time it would take me to do it - I just don't have the free time - but if anyone else wanted to do that and needed a hand or if I could assist a little, I'd be happy to do so

    Probably not the answer you wanted, but hope it helps a bit...

  14. #14
    hi,

    Thanks for your reply

  15. #15
    Jonny Gorden jonny's Avatar
    Join Date
    Feb 2003
    Location
    South Australia
    Posts
    77
    Thanks for the reply Sami,

    That's a bit of overkill

    I just meant parsing the text file that Motion Mixer exports (with keyframe/channel data), and recreate the keys in the existing channels in Unity. I was going to ask my coder to look at it, and I thought since you'd been looking at Mega-Fiers that you might have some tips.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •