WorldBuilding/MissionEditor/Adding Precipitation

From TDN

This page is a Work In Progress.


Contents

Introduction

Environment effects are really useful for doing Rain, Snow, and just about anything else that can fall from the sky in large amounts.

PrecipitationData

In order for precipitation to work in the engine, you need to add a PrecipitationData datablock somewhere in script. Some versions of Torque have environment.cs already, which is where I suggest you put it. If you don't, then you can create a new one by going to "./[Mod]/Server/Scripts" and adding it there. Don't forget to exec the script in Game.cs!

An example of a PrecipitationData datablock:

datablock PrecipitationData(myRain)
{
   dropTexture = "~/data/enviroment/myRainDrop";
   splashTexture = "~/data/enviroment/myRainSplash";
   dropSize = 10;
   splashSize = 0.1;
   useTrueBillboards = false;
   splashMS = 250;
};


The example above creates myRain, assigns the drop and splash textures, and the sizes for both. You can edit useTrueBillboards and splashMS, but it isn't really needed.


Adding it to your Mission

We now need to specify in your mission file the precipitation that is being used. An example:

   new Precipitation(rain) {
      position = "0 0 0"; //Doesn't matter where it goes
      rotation = "1 0 0 0"; //Doesn't matter either
      scale = "1 1 1"; 
      nameTag = "Rain"; //Give it a name
      dataBlock = "myRain"; //Use the datablock that we created earlier
      minSpeed = "12"; //How Slow?
      maxSpeed = "19"; // How fast?
      minMass = "0.05"; //How small?
      maxMass = "5"; //How Big?
      maxTurbulence = "0.1"; //How turbulent?
      turbulenceSpeed = "0.2";
      rotateWithCamVel = "1"; // Do you want the precipitation to always face the camera?
      useTurbulence = "1";
      numDrops = "2000"; // How many drops should be seen at once? Be careful with this one!
      boxWidth = "30";
      boxHeight = "50";
      doCollision = "1"; //Want the precipitation to go through interiors?
   };


Look at the comments, and determine what your settings should be.


Multiple Precipitation Effects

Adding multiple precipitation effects will give the effect a much more distinct look, but might drop the FPS quite a bit.


External Links

Tim Aste's Content Pack (Includes many precipitation effects)
Follow this tutorial for more information until this article is further complete - Precipitations Tutorial