Game Development Community

dev|Pro Game Development Curriculum

Computational Fluid Dynamics: MetaBlobs

by Jack Stone · 12/20/2013 (3:02 pm) · 15 comments

This resource adds support for "metablobs" to T3D. This can allow for very realistic fluid simulations, much more so than can be achieved with particle effects.

Included are a realistic Water material, a Lava Material, A Tar material, and a Mud material. I have also included a ported version of the renderMonkey glitter shader.


Tutorial:

First, download the resource from here: (4.2MB's, .RAR archive)
http://www.phoenixgamedevelopment.com/downloads/FluidDynamics.rar

Copy the "Fluid Dynamics" folder to:
"game/art/shapes/FluidDynamics"

Inside the archive is a folder called "SHADERS". All files in this folder should be copied to:
game/shaders/common/
Drop the files directly in that folder, do not include the "SHADERS" directory itself.

There should also be a folder called "CODE". All files in this directory should be added to:
"engine/source/T3D/examples/metaBlobs"
In your compiler, you will then need to add these files to the build.

In order to add MetaBlob based objects to the world using the editor, add the following line to:
"game/tools/worldeditor/scripts/editors/creator.ed.cs

Around line 100, under:
%this.registerMissionObject( "RenderShapeExample" );
add:
%this.registerMissionObject( "metaBlobExample" );

The resource folder also contains a sample mission file showing how to create a metablob object from code.

Finally, execute the file "fluiddynamics.cs" by adding the line:
exec("art/shapes/FluidDynamics/fluiddynamics.cs");
to:
"game/scripts/server/scriptExec.cs"

Any questions, comments, etc, can be directed to:
jackstone@phoenixgamedevelopment.com


#1
12/20/2013 (3:26 pm)
Was waiting for this, great work @Jack Stone
Regarding the copyright notices, from what ic is that you used
BSD licensed stuff - this is compatible with MIT, just to make this clear for others who wish to integrate it in their engines.
#2
12/20/2013 (3:31 pm)
Great resource...
Jolinar disregard my last email ;)
#3
12/21/2013 (1:21 am)
Vids or it didn't happen!
#4
12/21/2013 (2:55 am)
Lukas - check out his blog. There have been plenty of vids along the way :).

Jack - awesome, great to see you finally release this! Trying to think of devious ways to use this...
#5
12/21/2013 (4:56 am)
Would you happen to know if this would work with torque 3D 1.2?
Yes, it builds and I was able to add a metaBlog in the mission editor. I didn't see a default mission file in the download.
There is a problem seeing the blob, I had to tweak the settings to make it visible and even then it would disappear when viewed from certain angles. It might be the graphics card I'm testing with, it's kinda old. I can try on a new machine later.
#6
12/21/2013 (5:17 am)
Jack,
Hey was wondering if there is a way to modify the code so the metablobs could be used as a ai class?
#7
12/21/2013 (7:41 pm)

Hello everyone, thanks for all the replies! I wasn't expecting this kind of attention so quickly!

@J0linar: I'm not sure what you mean by "ic", but regarding licensing, the BSD licence is free for commercial and non-commerical use, and of course T3D is now under the MIT license, so there should be no issues there either. Having said that of course, I'm not a lawyer, so I'm basing this only on my own research.

@Lukas, yes, I should have linked my blog to this, there have been quite a few videos! Following this link:
http://phoenixgamedevelopment.com/blogs/index.php?s=project+130
Should bring up all of the posts related to this.

Thanks a lot for the plug by the way @Daniel!!!

@kcpdad: I can't see any reason why this wouldn't work with T3D 1.2. I actually developed it with an older build of T3D, and only copied the files to the latest version before I uploaded it.
I did have an issue during the development where the blog would disappear at certain angles, but I thought I solved that. Can you post a picture or video of what you're seeing?

@Kory, what do you mean exactly? You want the metablobs to have functions such as setmovedestination, etc, so that you can control them like an ai entity?
If I was doing that, I would think the easiest way would in fact be to code your own ai functions into the existing class, rather than trying to integrate it. There is some code in the download called "LavaLamp" which is a very simple example of how to move metablobs with a random direction and position, you could fairly easily modify that to do what you want?
#8
12/25/2013 (8:13 am)
Quote:The resource folder also contains a sample mission file showing how to create a metablob object from code.

hmmm couldn't find the mission in the .rar file...

havta say, great xmas present btw... looks awesome...
#9
12/27/2013 (1:29 pm)
Gibby (and kcpdad), sorry, you're right, I forgot to add the mission file to the .rar. I have added it and reuploaded the .rar, it should be there now.

For anyone with the old .rar (without the example file), creating a metablob from script is done like so:

new metaBlobExample() {
      Material = "FDWaterMat";
      mGridSize = "30";
      numMetaballs = "25";
      minExtent = "40";
      maxExtent = "80";
      maxtickcount = "40";
      GravAccel = "0.005";
      timescale = "0.01";
      force = "50";
      ElevationAngle = "25";
      position = "3.66346 -3.72079 243.4";
      rotation = "1 0 0 0";
      scale = "1 1 1";
      canSave = "1";
      canSaveDynamicFields = "1";
   };
   new metaBlobExample() {
      Material = "FDLavaMat";
      mGridSize = "20";
      numMetaballs = "15";
      minExtent = "40";
      maxExtent = "80";
      maxtickcount = "40";
      GravAccel = "0";
      timescale = "0.01";
      force = "30";
      ElevationAngle = "0";
      position = "5.24897 -21.2752 251.996";
      rotation = "1 0 0 0";
      scale = "1 1 1";
      canSave = "1";
      canSaveDynamicFields = "1";
   };
   new metaBlobExample() {
      Material = "FDTarMat";
      mGridSize = "10";
      numMetaballs = "10";
      minExtent = "40";
      maxExtent = "80";
      maxtickcount = "40";
      GravAccel = "0.005";
      timescale = "0.01";
      force = "0";
      ElevationAngle = "0";
      position = "11.4052 -35.9157 264.142";
      rotation = "1 0 0 0";
      scale = "1 1 1";
      canSave = "1";
      canSaveDynamicFields = "1";
   };
   new metaBlobExample() {
      Material = "FDMudMat";
      mGridSize = "20";
      numMetaballs = "10";
      minExtent = "40";
      maxExtent = "80";
      maxtickcount = "40";
      GravAccel = "0.005";
      timescale = "0.01";
      force = "15";
      ElevationAngle = "25";
      position = "23.8393 10.8419 260.147";
      rotation = "0 0 1 197.052";
      scale = "1 1 1";
      canSave = "1";
      canSaveDynamicFields = "1";
   };
#10
12/27/2013 (3:22 pm)
@Jack: Thanks for the mission file! Looks amazing!!!
#11
12/27/2013 (8:04 pm)
You're welcome, thanks very much!
#12
01/13/2014 (2:07 pm)
I see this is parented to sceneObject - can the metaBlobs be made collidable? I wanna cause damage when I collide with lava...
#13
01/23/2014 (12:42 pm)
Maybe re-parent to GameBase to make it collidable? But you would have to have collision geometry. Might be a lot easier to have the lava flowing on the ground or pouring from a cliff and use a trigger to cause the damage....
#14
10/31/2014 (1:59 pm)
Is anyone out there using this? I have it working, but the blobs disappear when the camera faces them at a perpendicular angle...
#15
11/01/2014 (9:04 am)
Here's a vid to demonstrate - when the player's head [camera] turns, the blobs aren't rendered: