コード例 #1
0
 private Vector2[,] Sample(Texture texture, int width, int height, int step = 4)
 {
     Vector2[,] array = new Vector2[width, height];
     Color[] pixels = this.WindowFriction.GetPixels();
     for (int i = 0; i < height; i++)
     {
         for (int j = 0; j < width; j++)
         {
             float num  = (float)j / (float)width;
             float num2 = (float)i / (float)height;
             int   num3 = (int)(num * (float)texture.width);
             int   num4 = (int)(num2 * (float)texture.height);
             int   num5 = num4 * width + num3 - step;
             int   num6 = num4 * width + num3 + step;
             int   num7 = (num4 + step) * width + num3;
             int   num8 = (num4 - step) * width + num3;
             float x    = 0f;
             float y    = 0f;
             if (WaterRaindropsIME.IsValidTextureIndex(num5, width, height) && WaterRaindropsIME.IsValidTextureIndex(num6, width, height))
             {
                 x = pixels[num6].r - pixels[num5].r;
             }
             if (WaterRaindropsIME.IsValidTextureIndex(num7, width, height) && WaterRaindropsIME.IsValidTextureIndex(num8, width, height))
             {
                 y = pixels[num7].r - pixels[num8].r;
             }
             array[j, i] = new Vector2(x, y);
         }
     }
     return(array);
 }
コード例 #2
0
 private void CreateSimulation()
 {
     this._Initialized = true;
     this.CreateRenderTexture();
     this._Matrices = new Matrix4x4[4096];
     this._Buffer   = new CommandBuffer();
     this._Mesh     = WaterRaindropsIME.BuildQuad(1f, 1f);
     this.CreateFrictionMap();
 }
コード例 #3
0
 private void Advance()
 {
     this._Droplets.RemoveAll((WaterRaindropsIME.Droplet x) => !WaterRaindropsIME.IsVisible(x) || x.Life <= 0f || x.Volume <= 0f);
     for (int i = 0; i < this._Droplets.Count; i++)
     {
         WaterRaindropsIME.Droplet droplet = this._Droplets[i];
         this.OnDropletUpdate(ref droplet);
         if (!WaterRaindropsIME.IsVisible(droplet))
         {
             this._Droplets[i] = droplet;
         }
         else
         {
             this.Draw(i, droplet.Position, droplet.Volume, droplet.Velocity);
             this._Droplets[i] = droplet;
         }
     }
 }
コード例 #4
0
 internal void Initialize(WaterRaindropsIME reference)
 {
     this._Reference        = reference;
     this._PreviousPosition = this._Reference.transform.forward * this._Rotation + this._Reference.transform.position * this._Translation;
 }