MegaFlow

MegaFlow

Overview of MegaFlow

Have you ever wanted to simulate a wind tunnel in your game, or have leaves of snow blow through your village flowing naturally around buildings, speeding up down alley ways or settling slowly in the lee of an obstacle, Lava flowing down a volcano side or Waterfalls cascading over rocks, Or a car stirring up leaves as it drives along a road in Autumn, vortices for your plane wings, perhaps an object floating along fast moving water, tornadoes, or even simulate gravity around objects in space, if so then MegaFlow can help.

MegaFlow is a set of systems that allow you to use Vector Fields to control the movement of objects or particle systems in Unity. Vector fields are a 2D or 3D grids of values that describe the direction and magnitude of velocities for that point in space. The Vector Field can be generated by systems such as Maya Fluids, FumeFX, Krakatoa, etc. MegaFlow can import the files generated by those systems in the form of .FXD or .FXA files, it also has an exporter for Maya that will export any Maya fluid simulation to the MegaFlow .FLW format. You can then import a single frame or multiple frames into the MegaFlow system in Unity and then use that to control the movement of particles from either the Shuriken or Legacy particle system, or control movement of Rigid Bodies or just general objects. Don’t worry though if you don’t have access to any Fluid Simulation software as MegaFlow also comes with a system that allows you to author your own Vector Fields inside Unity using multiple splines to define flow directions and forces.

Leaves & Smoke
Also included in MegaFlow is a system that allows you to have moving sources so you can easily have objects interact with a flow field, for example you could have a flow field that represents the airflow over a car at speed, then using the moving source system you can attach that flow to a moving car so as it drives through particle leaves or smoke particle systems the smoke and leaves will interact with the turbulent airflow around the car. See below for an example video.

MegaFlow Around MegaFlier
The movement of objects interacting with the Vector Fields is via a simple physics simulation which has parameters that allow you to control the overall force the field applies and the mass of the objects that are interacting with it, this means you can adjust the look and feel of the flow from either a very tight following of the flow to a subtle influencing only of objects that move through the field. You can change the force the field exerts or reverse the flow direction. All the values can be adjusted at runtime via script of the Unity animation system if required.The physics code used is optimized for performance and makes use of multi threading on any system that has multiple cores for super fast performance even with 10’s of thousands of particles being moved.

MegaFlow Particles

If a system such as FumeFX or Maya fluids has been used to create the Vector Fields then that would allow you to place obstacles into the flow, if the flow is then used to control a Particle system you can get even more performance back by disabling the collision system in the Particle system, since the Vector Field will now handle moving the particles around objects in the way, this can get you quite a saving in CPU time in complex scenes. You can off course still use the collision system of the particles or rigid bodies alongside the flow system if you wish.

The Vector Field source can have any number of Vector Fields loaded so you can do animation of flows if required, or just easily swap the flow field being used to change the look and flow of your scene. You can ask the system to show you the flow through the system of objects via the visualization options, or display the flow as either vector lines or colored cells.

megaflow3

megaflow4

megaflow5
Included in MegaFlow are various components to help you use the Vector Fields in your projects. There are components to control the Unity particle systems as well as a component you can attach to any rigid body object that will then allow that object to be influenced by the Vector Field. There is also an example Smoke Gun script that will inject large numbers of objects into a scene so you can see how they flow.

Features

  • Support for FumeFX FXD file import
  • Support for FGA file import
  • Custom Maya Fluids Exporter
  • Create Vector Fields in Unity
  • Multi-Threaded physics
  • Highly optimized physics code
  • C# Source Code Included
  • Multiple frames of flow data per source
  • Control Legacy or Shuriken particles
  • Moving Source
  • Object interaction with flow
  • Control Rigid Bodies
  • Control Normal Objects
  • Works in Unity Free
  • Works on Mobile devices
  • Flow visualization
  • Create a 3d Texture from the flow
  • MegaShapes Lite included

Exporters

As well as the custom exporter for Maya which you can get by sending an email to us with your invoice number and we will get that sent off to you there are also other free to use exporters for the FGA format out there. Don’t forget though that MegaFlow supports FXD files as well and most Fluid Dynamics software should be able to export to that.

MegaFlow API

Below are some methods you can call from your own scripts to access the flow data directly. We will be adding more methods as they are requested or needed by users of the system.

public void SetMatrix()

This prepares the internal matrices used by MegaFlow so you can call the GetGridVelWorld methods below with world positions and have world space velocity values returned. You must call this once before calling GetGridVelWorld, and call it again if the Flow object moves or its frame is changed. If the flow source does not change then you call this just the once.

public Vector3 GetGridVelWorld(Vector3 pos, ref bool inbounds)
pos – World space position to sample
inbounds – ref to bool value which on return will contain false if the sample point is outside the field

This will calculate the velocity at the point defined in world space, the value returned will be the velocity value also in world space. If the sample point is outside the bounds of the field then the inbounds boll will be set to false.

public Color GetCol(float vel)
vel – The velocity to get the color for

Returns the color for the velocity passed in using the defined Gradient for the flow.

public void SetFrame(int f)
f – The frame number to change to

You can change the frame of flow data to use if you have more than one frame created. If you change the frame be sure to call SetMatrix again.

Video Examples

Below are some videos showing the MegaFlow system being used in a couple of scenarios, the first uses a Maya Fluid simulation to simulate the airflow around objects in a scene, the second shows the in Unity creation of Vector Fields from splines and that then being used to control a particle system. The third shows a Vector Field being created inside Unity using splines to define flows.

mfthumb1s

MegaFlow Create

Moving Sources

MegaFlow allows for sources to move so objects can interact with the flow fields, as in the example below which shows a car driving through smoke and leaves.
Click to Play