Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Need to loop through 15,000 meshes, possible?

Discussion in 'Animation' started by mr_pablo, Nov 27, 2014.

  1. mr_pablo

    mr_pablo

    Joined:
    Jun 26, 2014
    Posts:
    12
    I have 15,000 OBJ meshes (created via Brekel Pro PointCloud v2) that I need to load as a single animation.

    I did some initial tests with 1,500 meshes, using a script to load the mesh objects into an IList and simply swap the GameObjects mesh on Update. It worked well and didn't take too long to load after hitting play.

    But it did use up about 6.5GB of RAM.

    Now, I need to get this to work with 15,000 meshes!

    Without throwing a ton of RAM at it, is there any better way to do this?

    My script is attached (not written by me originally, but edited to use an IList rather then an array). As you can see, it has to Instantiate the asset in order to add the mesh. Is there a better, more RAM efficient way to achieve this?

    Alternatively, has anyone ever found a way to convert OBJ sequences into a single mesh? I tried exporting the sequence from Studio Max, but as the OBJ Sequence Importer for 3DSM creates a "fake" animation, when exported to FBX, there is no animation present in Unity.
     

    Attached Files:

  2. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,046
    Do you have an example max file to test with?
     
  3. mr_pablo

    mr_pablo

    Joined:
    Jun 26, 2014
    Posts:
    12
  4. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,046
    No luck, max file is only 250k big, when loaded just an empty scene with a camera and an ObjLoader ojbect which is a stand in object.
     
  5. mr_pablo

    mr_pablo

    Joined:
    Jun 26, 2014
    Posts:
    12
  6. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,046
    I had a chat with the author of MegaFiers to see if it is something he can do, he said he did have a system he was working on a while back for playing back mesh caches, said he would see about finishing it off and says it has an option to either play back from an array of meshes like your system or he has an option to save out an optimized cache file which can then be read from at runtime for no memory overhead.
     
  7. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,518
    Finished of the Object Cache system using your example objects, quick calculation shows the cache file would be about 1GB for 15000 frames of data, video below showing the system working with your example data.
     
  8. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,518
    Did some more work on the system, optimized the cache file to reduce it by half as well.
     
  9. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    mr_pablo I commented on your previous post.
    SpookyCat has the best solution for the task at hand, but here are a couple alternate options which, though aren't as good or as easy as Mega-fiers system, they can accomplish the issue you have without the large file foot print.

    Do you really NEED all the 15,000 iterative mesh objects in your Unity scene or are you just trying overcome the problem of having each animation frame represented as a separate mesh object?

    Please not these alternative options will take time to implement but would result in a small file size.

    1. In Max - hide/unhide at the object visibility level on every frame. (15,000).
    I worked up the first 60 frames to give you an example.
    https://www.dropbox.com/s/1xavioulgszotd7/objectvis_invis.mov?dl=0
    And if you don't need the actual mesh in the scene, you could render this out and project it on a cylindrical object with alpha masking and normal info to put the animation into your scene. Animate the cylindrical object in Unity to mimic the movement of the 15,000 obj meshes to match the movement. This may have a type of animated holographic look to it.

    2. Rig and skin one of the "neutral-ist" poses of the 15,000 meshes to a standard rig. Animate the standard rig doing the same actions as the obj files are doing. Apply an animated noise modifier to the mesh and export the rig and mesh as a animated .fbx file with baked animation.
    Here's a rough example in Max of one of the meshes skin weighted to biped with 8 basic default footsteps applied to the biped. The skin is being displaced by an animated noise modifier.
    https://www.dropbox.com/s/rckxq4laqm3l3lf/onemesh_junkfootsteps.mov?dl=0


    Like I said SpookyCat has the best solution but I thought I'd give a couple alternate solutions that are possible.
     
  10. mr_pablo

    mr_pablo

    Joined:
    Jun 26, 2014
    Posts:
    12
    Simply, wow!

    Is this version available for purchase?

    Just curious, if I purchase your plugin, and it somehow is not able to handle the shear number of meshes I need to throw at it, is there a refund available?
     
  11. mr_pablo

    mr_pablo

    Joined:
    Jun 26, 2014
    Posts:
    12
    Thank you for the ideas!

    However, with idea 1, animating the visibility simply doesn't work for me when exporting to an FBX, as it's not a proper mesh animation. Where you able to get that method to work in Unity?

    And idea 2 sounds cool, but it would mean hand animating each frame no?

    EDIT - and yea, the 15K meshes are a must, as it makes up the entire animated sequence :)
     
  12. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,518
    MegaCache has been submitted to the AssetStore so hopefully will be approved this week otherwise it is available now on our website www.megafiers.com

     
  13. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Hey mr_pablo just wanted to fill in the blanks I believe you missed from the examples I showed.

    Idea 1 works but does not result in a .fbx export as I mentioned in the original post. I gave a simple example of how this could be used if you don't need to have the mesh be interactive within the scene.

    Idea 2 is pretty simple, but requires a little ability to animate a simple bipedal rig, through the 15,000 frames. Not a daunting task if your looking to have the mesh in the scene and have control over the animation, without the headache of messing with the 15,000 separate mesh objects. And this process gives the added bonus to add to or take away animation segments as you see fit.

    The 15k meshes are only a must if the above two processes aren't considered as alternative solutions.

    But like I said Spooky Cat has the best/easiest solution with MegaCache.

    Please share the results of the solution you end up using. Interested in seeing the outcome.
     
  14. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,518

    Attached Files:

    Last edited: Dec 23, 2014