Search Unity

[Released] Mega-Fiers. A mesh deformation system - RELEASE

Discussion in 'Assets and Asset Store' started by SpookyCat, May 18, 2011.

  1. wimeck

    wimeck

    Joined:
    May 26, 2008
    Posts:
    50
    Ah, saw your pm!
     
  2. ecurtz

    ecurtz

    Joined:
    May 13, 2009
    Posts:
    640
    Heh, that's pretty cool, but shouldn't you be busy working on my particular pet feature (mesh booleans) rather than all these new toys?
     
  3. bigSky

    bigSky

    Joined:
    Jan 31, 2011
    Posts:
    114
    Awesome Chris. Awesome. @24pfilms, your creature is full of charm.
     
  4. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    Hi All
    I have updated the MegaFiers exporter for Maya to now also export the BlendShape animation data. This now allows Maya users to take full advantage of Mayas animation systems to build their BlendShape animations and quickly and easily get those into Unity.
    Chris

     
    Last edited: Mar 1, 2013
  5. Foam Sleeve

    Foam Sleeve

    Joined:
    Oct 5, 2010
    Posts:
    14
    You Rule!
     
  6. droderick

    droderick

    Joined:
    Aug 25, 2008
    Posts:
    169
    Hi Chris,
    First off - megafiers truly rocks and far and above the most awesomest thing on the asset store! Now onto my problem ;)
    We use c4d for a lot of technical animations and are currently exploring the possibility of moving over to max. Mainly because of the spline/animation export features that work with Megafiers. Do you envision creating additional functionality with c4d megafiers or would you recommend that we give max a shot. Only hesitation is due to our knowledge of c4d vs. max.
    Also, if there's anything we can help with regarding c4d testing or providing sample files, etc. PM me and we'd be happy to help out if we can.

    thanks much,

    daniel
     
  7. ecurtz

    ecurtz

    Joined:
    May 13, 2009
    Posts:
    640
    Hey Chris, I'm trying to write a few of my own MegaFiers to work within the system and I was wondering if there is some documentation I've missed or you'd be willing to explain briefly what the interaction of the different calls is. I could walk through all the code and figure it out, but I'm sure it would help others as well.

    My mod has a chunk of expensive startup code that is currently in the Prepare() call, but that gets hit way more than I want. ModStart() would seem like the obvious place to try, but I'm not clear I can rely on things being initialized by then? Also, should I be trying to keep track of whether updates are required? I can't see anywhere that ChannelsReq() isn't hard-coded, but maybe I return nothing from that if I haven't updated since the last call to Modify()?

    I'd be very happy to just post this small amount of code if you were willing to answer questions here or wanted it for the currently missing write a simple mod tutorial. It's a "wire deformer" that offsets from a source towards a target spline (well, currently MegaShape, because that was simpler for dev.)
     
  8. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    @droderick - It is on my list to do an exporter for C4D but currently I need to get MegaShapes out then MegaMesh and work on our game so if you need something quick then it maybe an idea to look at Max, other users of 3d packages with no direct exporter have used Max, Blender or now Maya to just export the morph info by exporting from their main 3d package to FBX and then importing that into Max, the morph data comes across and can then be exported. If you know of any example source code for C4D for exporters, especially dealing with morphs that I can look at that would help.

    @ecurtz - Yes I do really need to work on a proper tutorial for adding custom modifiers as it would great to see what others come up with. If you want you can email me the code at chris@west-racing.com or post it here and I will get it working for you (if I can understand what you are trying to do :) )
     
  9. S0ULART

    S0ULART

    Joined:
    Jun 14, 2011
    Posts:
    131
    Hello Chris,

    lets say I want to stretch an object from its current position to an object B that is moving and so has different positions at time and now my modified object shall stretch itself towards this object B every 5 seconds or so. In iTween there is an "move to" option for that but I don't know how to get the same result with modifiers..
     
  10. ecurtz

    ecurtz

    Joined:
    May 13, 2009
    Posts:
    640
    Well the current code does "work" so there's some hope, but there were several things where I just copied what one of the originals did rather than trying tracing back and seeing why things worked that way.

    Some questions:
    The code that's currently in the Prepare() method really only needs to be run if the source spline has changed. Some mods seem to keep track of whether they've been initialized, is that the "correct" thing to do here, or does that code belong somewhere else?

    Prepare() returns a bool which seems to indicate the mod is ready to have Modify() called. Is that the same for the other bool methods like ModLateUpdate()? I'm not clear what determines which calls have this result.

    Can you explain the cases / order in which ModStart(), InitMod(), Prepare(), and ModUpdate() / ModLateUpdate() are called?

    Here's the code:
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.IO;
    4. using System.Collections.Generic;
    5.  
    6. public struct MegaWireVert
    7. {
    8.     public int      vert;
    9.     public int      u;
    10.     public float    w;
    11. }
    12.  
    13. [AddComponentMenu("Modifiers/Wire Deform")]
    14. public class MegaWireDeform : MegaModifier
    15. {
    16.     //public MegaSpline     source      = null;
    17.     //public MegaSpline     target      = null;
    18.     public MegaShape        source      = null;
    19.     public MegaShape        target      = null;
    20.     public int              resolution  = 50;
    21.     public float            falloff     = 1f;
    22.    
    23.     public override string ModName()    { return "WireDeform"; }
    24.  
    25.     Vector3[]       sourcePositions;
    26.     Vector3[]       targetOffsets;
    27.    
    28.     MegaWireVert[]  wireVerts;
    29.    
    30.     public override void ModStart(MegaModifiers mc)
    31.     {
    32. Debug.Log("ModStart");
    33.     }
    34.  
    35.     public override bool ModLateUpdate(MegaModContext mc)
    36.     {
    37. Debug.Log("ModLateUpdate");
    38.        
    39.         return Prepare(mc);
    40.     }
    41.  
    42.     public override bool Prepare(MegaModContext mc)
    43.     {
    44. Debug.Log("Prepare");
    45.        
    46.         if (source == null)
    47.             return false;
    48.         if (target == null)
    49.             return false;
    50.        
    51.         sourcePositions = new Vector3[resolution];
    52.         targetOffsets = new Vector3[resolution];
    53.        
    54.         // Find [resolution] steps along the source shape
    55.         bool type = false;
    56.         int knot = 0;
    57.         float alpha = 0f;
    58.         float step = 1f / (resolution - 1);
    59.         Matrix4x4 trans = transform.worldToLocalMatrix * source.transform.localToWorldMatrix;
    60.         for (int i = 0; i < resolution; i++) {
    61.             //sourcePositions[i] = trans.MultiplyPoint3x4(source.Interpolate(alpha, type, ref knot));
    62.             sourcePositions[i] = trans.MultiplyPoint3x4(source.InterpCurve3D(0, alpha, type));
    63.             alpha += step;
    64.         }
    65.        
    66.         // Where does this go?
    67.         List<MegaWireVert> vertList = new List<MegaWireVert>();
    68.         int vertCount = verts.Length;
    69.         for (int i = 0; i < vertCount; i++) {
    70.             float dist = Mathf.Infinity;
    71.             int closest = 0;
    72.             for (int j = 0; j < resolution; j++) {
    73.                 float sourceDist = Vector3.Distance(verts[i], sourcePositions[j]);
    74.                 if (sourceDist < dist) {
    75.                     dist = sourceDist;
    76.                     closest = j;
    77.                 }
    78.             }
    79.            
    80.             if (dist < falloff) {
    81.                 MegaWireVert wireVert;
    82.                 wireVert.vert = i;
    83.                 wireVert.u = closest;
    84.                 float portion = dist / falloff;
    85.                 wireVert.w = (1f - portion * portion) * (1f - portion * portion);
    86.                 vertList.Add(wireVert);
    87.             }
    88.         }
    89.        
    90.         wireVerts = vertList.ToArray();
    91. Debug.Log("found " + wireVerts.Length + " verts within falloff.");
    92.  
    93.         return true;
    94.     }
    95.    
    96.     public override void Modify(MegaModifiers mc)
    97.     {
    98.         // Copy the verts to start
    99.         verts.CopyTo(sverts, 0);
    100.         /*
    101.         int vertCount = verts.Length;
    102.         for (int i = 0; i < vertCount; i++) {
    103.             sverts[i] = verts[i];
    104.         }
    105.         */
    106.  
    107.         // Find [resolution] offsets from source to target shape
    108.         bool type = false;
    109.         int knot = 0;
    110.         float alpha = 0f;
    111.         float step = 1f / (resolution - 1);
    112.         Matrix4x4 trans = transform.worldToLocalMatrix * target.transform.localToWorldMatrix;
    113.         for (int i = 0; i < resolution; i++) {
    114.             //targetOffsets[i] = trans.MultiplyPoint3x4(target.Interpolate(alpha, type, ref knot)) - sourcePositions[i];
    115.             targetOffsets[i] = trans.MultiplyPoint3x4(target.InterpCurve3D(0, alpha, type)) - sourcePositions[i];
    116.             alpha += step;
    117.         }
    118.        
    119.         int wireVertCount = wireVerts.Length;
    120. Debug.Log("Modify() moving " + wireVertCount + " verts.");
    121.         for (int i = 0; i < wireVertCount; i++) {
    122.             sverts[wireVerts[i].vert] += targetOffsets[wireVerts[i].u] * wireVerts[i].w;
    123.         }
    124.     }
    125. }
    126.  
    I'm assuming the spline code will be updated with the new MegaShapes, so I haven't done anything with trying to optimize that. It's also why the weights are kind of rough I'm not getting the real distance from the spline.

    Here's the editor class as well:
    Code (csharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3.  
    4. [CustomEditor(typeof(MegaWireDeform))]
    5. public class MegaWireDeformEditor : MegaModifierEditor
    6. {
    7.     public override string GetHelpString() { return "Wire Deformer by Eli Curtz"; }
    8.     public override Texture LoadImage() { return (Texture)EditorGUIUtility.LoadRequired("MegaFiers\\bend_help.png"); }
    9.  
    10.     public override bool Inspector()
    11.     {
    12.         MegaWireDeform mod = (MegaWireDeform)target;
    13.  
    14.         EditorGUIUtility.LookLikeControls();
    15.         mod.resolution = EditorGUILayout.IntField("Resolution", mod.resolution);
    16.         mod.falloff = EditorGUILayout.FloatField("FallOff", mod.falloff);
    17.         mod.source = (MegaShape)EditorGUILayout.ObjectField("Source Spline", mod.source, typeof(MegaShape), true);
    18.         mod.target = (MegaShape)EditorGUILayout.ObjectField("Target Spline", mod.target, typeof(MegaShape), true);
    19.         return false;
    20.     }
    21. }
     
  11. wimeck

    wimeck

    Joined:
    May 26, 2008
    Posts:
    50
    Nice work again on the Maya plugin, myself I would love to have one for Cinema 4d too. You should clone yourself :)...

    I have a question, I'm working with the displacement deformer and want to have the color of a model change according to the height of the model (so for example blue at the base, yellow in the middle and red on top, see image). Normally I make a gradient texture with those colors, give it a 90 degree rotated planar uv-map in my 3d-package and it works great. I can't do this now because the displacement modifier needs the uv-map too and it can't be rotated. Anyone has an idea how to solve this? Megafiers has uv-modifiers but they don't seem to do what I need... I have been searching the forum to see how you can color each seperate vertex but with no succes till now... Thanks in advance!

     
  12. macspeedee

    macspeedee

    Joined:
    Feb 12, 2011
    Posts:
    31
    @wimeck - Could you not use 2 map channels, one for the displacement map on channel 1 and a second for the colour rotated 9 degrees on channel 2? Well that is how I would do it in max I cannto say whether megafiers allows more than one map channel, need Chris to answer that.
     
  13. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    @wimeck - As Macspeedee said you could always make use of the second uv set in Unity. How are you generating your height data as it wouldn't be hard to add a custom modifier that doesn't use uv coords.

    @ecurtz - I will hopefully be getting onto your modifier today sometime :)

    @soulart - Not sure exacly what you needing to do but it seems a lookat controller on the object and then a stretch computed as a ratio of the object rest height to the distance between the two objects would work.
     
  14. wimeck

    wimeck

    Joined:
    May 26, 2008
    Posts:
    50
    Hi there,

    I was trying to use a second uv-map (from Cinema 4d), maybe I'm doing something wrong. I will experiment some more. My height data is a webcam-feed. Thanks for your replies!
     
  15. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    Version 1.85 is getting close to release. This version will include the Webcam version of the displacement modifier and also the Beta version of the Dynamic Water system. I have also extended the Morph and Point Cache Animator systems so they can be told to link to the main Unity animation. So if you change the Unity animation clip playing the morph and point cache animations will automatically match, so now you dont need to script any changes to get morphs and point caches playing back. You just need to create the clips as before and setup the timings and check the Linked Update box.

    I have also added a Mega Copy Mesh menu item to the Game Object menu, this will allow you to duplicate a mesh in the scene and break the instance connection so you can add different modifiers to it and not have it change the original.

    List of current changes to Version 1.85:

    • Added a public LoadFile() method to point cache editor to allow for files to be loaded via scripts.

    • Added a point cache instance script to allow for easy instancing of point cache objects without overheads of data storage.

    • Knot handles etc orientation bug fixed.

    • Physical UV generation works for shape meshes now

    • Added linked update option to Morph Animator so can link morph animation playback to current animation.

    • Added Play on Start option to Morph Animator

    • Added beta version of dynamic Water modifier

    • Added webcam version displacement modifier

    • Added linked update option to Point Cache Animator so can link morph animation playback to current animation.

    • Added Play on Start option to Point Cache Animator

    • Added a Mega Copy Mesh so you can use a mesh with different modifiers on without interference.
     
  16. wimeck

    wimeck

    Joined:
    May 26, 2008
    Posts:
    50
    Got the export from Cinema 4d correct now but the double uv trick doesn't seem to work. The mapping is correct (on a plane you only see the bottom color of the gradient), but when I add displacement to the object it doesn't show the other colors of the gradient, the bottom color 'sticks' to it. Anybody has an other idea? Thanks again.
     
  17. niosop2

    niosop2

    Joined:
    Jul 23, 2009
    Posts:
    1,059
    Do it in a shader? Use the worldspace Y coordinate as the U or V coordinate and a gradient map. You could add a floor value so it knows where to start and a scale factor to adjust the rate of change. You'll want to make sure the gradient image is set to clamp.
     
  18. wimeck

    wimeck

    Joined:
    May 26, 2008
    Posts:
    50
  19. anadin

    anadin

    Joined:
    Oct 28, 2005
    Posts:
    98
    Hey Chris was just playing with FFD - any change of a mirror function on that?, choose the plane and turn it on?
     
  20. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    That wouldn't be hard to add, when I get a spare moment I will have a play.
     
  21. JimW

    JimW

    Joined:
    Mar 12, 2009
    Posts:
    4
    Hi, I'm trying to use a megashape cicle to define a path and have my cube object move along that path. Is there any way to do that, but without modifying the mesh of the object moving on that path. The cube appears to get squeezed into the shape of that circular ring. Is there anyway to tell Mega-fiers not to alter the mesh?

    Thanks
    Jim
     
  22. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    Hi Jim
    Yes, I included a helper script called PathFollow.cs in the system which allows you to do just that, add it to an object and select a shape and the object will move along it based on the Percent value you supply.
    Chris
     
  23. JimW

    JimW

    Joined:
    Mar 12, 2009
    Posts:
    4
    Works great, thanks. Seems like that script should go in that Megafiers panel.?

    Also, I'm trying to figure out how to best integrate Megafiers easy path manipulation into an NGui's panel animation (which uses Unity's animation system). I'm hoping I can make a script that can use Megafier's aimation data instead of NGui's. Then, rather than specify a specific animation clip that could happen upon a mouse click of a button, I could specify a directed segment along a Megafier shape path. Just thought I'd share my goal with you in case you know it is impossible or something (or you've already done it..)

    And thanks for the coolest tool.
    Jim
     
  24. bigSky

    bigSky

    Joined:
    Jan 31, 2011
    Posts:
    114
    Awesome, Chris!
     
  25. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    Just did a better demo to show of the water. The shader is from the amazing Hard Surface shader pack.

     
    Last edited: Mar 1, 2013
  26. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Woooo !!!!
     
  27. bigSky

    bigSky

    Joined:
    Jan 31, 2011
    Posts:
    114
    Hi Chris,

    I was wondering if you could give a quick run through (or example) of how the set point local mono works - (i, j, k)? Tis confusing to me. I would like for the user to deform the mesh at runtime with the mouse, or stepping thru selections?
    Amazing work on the water, BTW.
     
  28. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    You can always have a look in the MegaFFDEditor.cs file to see how the moving is done, but below is a simple method you can add to the MegaFFD class. The values x, y, and z is the FFD lattice point you wish to move, and the Vector3 localmove is the amount you want to move it by in the local space of the object. The function then gets the current position of the lattice point, adds on the amount to move and sets it back again. Hope that helps.

     
  29. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    Had a quick play with getting rigid bodies to float in the water.
     
    Last edited: Mar 1, 2013
  30. Toad

    Toad

    Joined:
    Aug 14, 2010
    Posts:
    298
    That looks chuffing amazing!
     
  31. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    940
    Really amazing!

    Do you think that you will share this cool demo with your customers? :)

    Kenshin
     
  32. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    Fantastic !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    6R
     
  33. Mikie

    Mikie

    Joined:
    Dec 27, 2011
    Posts:
    367
    Looks like a great program. $100 and I would buy today.
     
  34. tr1stan

    tr1stan

    Joined:
    Jan 23, 2009
    Posts:
    150
    HI Chris, I just get some trouble with point cache animation.

    What I did:
    1. Add a fbx object with mesh filter and mesh renderer to the hierarchy
    2. Add Mega Modify Object and Mega Point Cache script to that object
    3. import the .pc2 file

    Then unity popup a "Mapping Failed" error. What could possibly be wrong?

    And when I add the modify object script to the mesh there's some error message in console
    Code (csharp):
    1. Instantiating mesh due to calling MeshFilter.mesh during edit mode. This will leak meshes. Please use MeshFilter.sharedMesh instead.
    2. UnityEngine.MeshFilter:get_mesh()
    3. MegaModifyObject:FindMesh1(GameObject, GameObject) (at Assets/Mega-Fiers/Scripts/MegaFiers/Modifiers/MegaModifyObject.cs:199)
    4. MegaModifyObject:ReStart1(Boolean) (at Assets/Mega-Fiers/Scripts/MegaFiers/Modifiers/MegaModifyObject.cs:83)
    5. MegaModifyObject:Reset() (at Assets/Mega-Fiers/Scripts/MegaFiers/Modifiers/MegaModifyObject.cs:59)
     
  35. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    FOOOOOOOK OMFG! Now that's impressive :eek: :eek: :eek:

    Uh the shock smile is in the advanced editor but it's not translated correctly in the posts?
     
  36. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    @tr1stan Firstly you can ignore the shared mesh error message, it is something that happens for any system that alters meshes in edit mode, it can be ignored as it means nothing in edit mode and doesn't happen in run mode.

    As for the point cache, first make sure you whatever is making the pc2 file is making local space data not world space, ie if its from Max make sure you use the Object space point cache modifier and not the world space version. Second if you have messed about with the pivot at all try resetting it all, ie reset xform. Still havnt quite figured out what the fbx exporter or Unity importer does to the local transform that Iam not, but if you alter pivots it will change the vertices positions and a match wont be found. Thirdly make sure that the first frame of the point cache matches the fbx exported, ie the first frame cant be deformed in anyway from the orginal base mesh. I will sometime add a load mapping system like the morph so first frames wont have to match.

    If none of those get you any closer then you can email me at chris@west-racing.com and I can look at the files to see what is going on, but in every case of a mapping failure so far reported to me it has been one of those above that was the problem.
    Chris
     
  37. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,293
    now i want an ios shader that can handle this in the new ipad.
    Will this work on ios?
     
  38. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
  39. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    @M_Stolley - The modifier will work fine on IOS.

    @elbows - Well done doing that, I was reading that thread the other day and wondering if morphs can be made to work, would make for nice facial anims on mobile devices (no bone limits). Actually what you are doing, ie linking bone rotation to morph channel changes is on my todo list, its a system Max has to drive things like muscle bulges for arm bends, you beat me to it :)

    Would be great to see Speecher working with MegaFiers, there are two other speech systems that are supposed to be using MegaFiers to drive the animation but they both seem to be busy on other things. And off course you could always use Di-O-Matics speech system to build morph animations in Max and then export them.
     
  40. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Cool. I've owned Speecher for less than a day and can't really say quite how good it is yet, not till I get one of my models working properly with it. I was hoping to do a 'cleaner' integration with MegaFiers but the way Speecher appears to work makes this too big a challenge for me. So I was quite pleased with myself when I came up with the bone angle way of bridging the systems.

    Anyway since I have the luxury of being able to use bones that aren't also driving a skinned mesh, I think my system will be a lot simpler/cruder than what you'll need to do with replicate that interesting Max muscle stuff, so I don't really consider myself to have beaten you to it ;) By this I mean that as my bones aren't driving a mesh, I can setup the animation of the bones in a way that makes it trivial to drive morph percentages. e.g. I can just create a single bone for each facial pose that Speecher is looking for, and of each frame of the animation I just set one bone to have an x angle of 100. Then I feed that to the relevant percentage value in the morph animator. Thats the theory anyway, it was pretty late at night when I got a glimpse of my initial test seeming to work so maybe there is some factor I haven't thought of yet.

    This sort of thing makes me quite sad that Evolver website for free rigged models went away due to Autodesk acquisition. I got a lot of models from there with morph facial animations for my own use, but it would be more fun to talk about these systems if we could still point people in that direction for lots of compatible models.

    One of these days I might even get round to creating something nice with MegaFiers instead of getting distracted by all the possibilities and hacking stuff together! I sure hope that day comes since your product is still one of my most treasured asset store purchases, I just wish I too had a brother that could take care of the art assets - can you add that to the next version? :D
     
  41. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    +1 on the brother...now finish the damn shape-dealio...enough splashing around stuff;)
     
  42. lastprogrammer

    lastprogrammer

    Joined:
    Apr 30, 2011
    Posts:
    166
    So I am working with Megafiers but I cam across a problem. I have a catapult that I am bending with the 'MegaBend' modifier, and it works just fine. But then I am trying to place a ball inside the catapult's scoop part so that catapult would appear to be holding a ball to launch it. But I can't seem to find a way to know where to place the ball.

    I have tried creating an empty object and attach it to the Catapult object so that the empty object would bend with the Catapult but it wouldn't work. Then I tried to access the vertices of the Catapult object so that I can position my ball to the same position of a vertex but whenever I access the vertices with unity, MegaBend stops working.

    Can you help me?
     
    Last edited: Apr 6, 2012
  43. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,056
    Yeah that would be useful to know how to do.
     
  44. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    Yeah that is something that will be properly in the next update. You can do it now in a couple of ways, first you were almost there using a vertex position but getting them from the mesh as you found out for some reason stops the mesh being updated by the system, I think Unity caches calls todo with the mesh so something there is confusing either Unity or MegaFiers. You can still do it by looking at the 'sverts' array in the Mega Modify Object, that holds the deformed state of the mesh so if you know the vertex index just grab the position from that array.

    The other way is to run through through the stack of modifiers passing in the start position to the first and then passing the result to any other modifiers on the stack, I will en devour to do an example script for this tomorrow. But until then you can use the first method to locate an object, so one way would be to find the nearest three vertices say to the location of the object to want to stick to the deforming object and then compute the barycentric coord for that and then you can use that with the modified positions to compute the location of the object. Hope that helps.
     
  45. lastprogrammer

    lastprogrammer

    Joined:
    Apr 30, 2011
    Posts:
    166
    Yes that works! The first solution that is. But the coordinates of the vertex is wrong since I have scaled the object up 8 times it's originally imported size. Is there a simple modifier that I can just scale my object up to size? I see the free form modifier but that isn't working so well.

    No matter. I'll just re-export from max.

    Thanks for the help.
     
  46. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    You could just change the fbx import scale setting for the object and reimport. But yeah the vertices are in local space so if you have a scaling applied in the transform then you will need to take that into account. Just transforming the svert by the transform matrix will give you the world space position.
     
  47. ChuckT

    ChuckT

    Joined:
    Aug 18, 2008
    Posts:
    94
    any word on pushing the new update to the store? I'd love to use the cache animator play on load stuff.
     
  48. lastprogrammer

    lastprogrammer

    Joined:
    Apr 30, 2011
    Posts:
    166
    Alright, So I have been able to successfully position my object on the catapult's arm, but I need to rotate it properly now, and I can't seem to figure it out.

    Now, I can get three vertices but do you know how to get a world rotation quaternion (or vector3) out of them? I've tried looking up math on the web but I can't find any specific solution.

    Thanks.

    [Edit:]

    Ok, it looks like someone answered this question for me in my other thread. Thanks anyhow!
     
    Last edited: Apr 7, 2012
  49. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    I do hope to get the update submitted in the next day or two.

    I am at the moment working on a system to allow objects to be attached to a deforming mesh and it will do the rotation as well.
     
  50. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Happy to report that my Speecher integration went well, pretty much a complete success. Had some issues with Speecher in built apps, so spent a little time modifying the Physics to Animation tool so that it records the morph anim percent settings to an animation clip. Now I only have to use Speecher in the editor, the final app uses standard Unity animation stuff Megafiers only.

    I expect this is something of a niche at the moment and providing assets that are built upon/bridge between other asset store products is probably not so easy, so if anybody requires this stuff please PM me. My assistance worn be free Im afraid, since I presently have no income.

    By the way when I was doing this I think I noticed a little problem with the MegaMorphAnim script, its referring to channel 9 twice in various places, and not referring to channel 8 at all. Only takes seconds to fix.