예제 #1
0
 public void DehighlightForIcon()
 {
     if (this.current != null)
     {
         for (int i = 0; i < this.current.zones.Count; i++)
         {
             List <int> indexes = this.current.zones[i];
             if (!this.IsPainted(this.current.zones[i][0], this.current.color))
             {
                 FloodAlgorithm.FillIndexes(indexes, this.highlightEngine, this.startColor);
             }
             this.drawText.LoadRawTextureData(this.highlightEngine.pixels);
         }
     }
 }
예제 #2
0
    public void FillOnCopy(Point pColor, Color32 color, byte[] pixels)
    {
        int  num = this.colorSourceText.width * pColor.i + pColor.j;
        byte b   = this.paintEngine.source[num];

        if (b < 253)
        {
            b += 1;
        }
        else
        {
            b = 1;
        }
        this.paintEngine.paintColor = color;
        FloodAlgorithm.FloodFillCopy(pColor.j, pColor.i, this.paintEngine, pixels, b);
    }
예제 #3
0
    private IEnumerator HighlightCoroutine(float animDuration)
    {
        yield return(0);

        float i           = 0f;
        float currentTime = 0f;

        while (i <= 1f)
        {
            currentTime += Time.deltaTime;
            i            = currentTime / animDuration;
            Color32 colorUp   = Color32.Lerp(this.startColor, this.highlightColor, i);
            Color32 colorDown = Color32.Lerp(this.highlightColor, this.startColor, i);
            for (int j = 0; j < this.current.zones.Count; j++)
            {
                List <int> indexes = this.current.zones[j];
                FloodAlgorithm.FillIndexes(indexes, this.highlightEngine, colorUp);
            }
            if (this.prev != null)
            {
                for (int k = 0; k < this.prev.zones.Count; k++)
                {
                    List <int> indexes2 = this.prev.zones[k];
                    FloodAlgorithm.FillIndexes(indexes2, this.highlightEngine, colorDown);
                }
            }
            this.drawText.LoadRawTextureData(this.highlightEngine.pixels);
            this.drawText.Apply();
            yield return(0);
        }
        yield return(0);

        if (this.prev != null)
        {
            this.prev.zones.Clear();
            this.prev = null;
        }
        yield return(0);

        this.highlightCoroutine = null;
        yield break;
    }
예제 #4
0
    public void FillPoint(Point pColor, Color32 color, bool writeData = true)
    {
        int  num = this.colorSourceText.width * pColor.i + pColor.j;
        byte b   = this.paintEngine.source[num];

        if (b < 253)
        {
            b += 1;
        }
        else
        {
            b = 1;
        }
        this.paintEngine.paintColor = color;
        FloodAlgorithm.FloodFill(pColor.j, pColor.i, this.paintEngine, b);
        if (writeData)
        {
            UnityEngine.Debug.Log("save fill");
            this.drawText.LoadRawTextureData(this.paintEngine.pixels);
            this.drawText.Apply(false);
        }
    }
예제 #5
0
    public void startBreaking()
    {
        float energy = energySlider.value;

        Destroy(canvas);

        var mesh3d     = new VolumeticMesh3D();
        var tetra      = GameObject.Find("Tetra");
        var shaderBase = tetra.GetComponent <ShaderBase>();

        var tetrahedra = shaderBase.tetraPart.tetrahedra;

        for (int i = 0; i < tetrahedra.Count; i++)
        {
            var vertices = tetrahedra[i].tetra;
            mesh3d.addTetrahedron(vertices[0], vertices[1], vertices[2], vertices[3]);
        }

        for (int i = 0; i < 1; i++)
        {
            float x = Random.Range(0, 1);
            float y = Random.Range(0, 1);
            mesh3d.propagatingCracks(new Vector3(1F, 1F, 0), new Vector3(x, y, 1), 0.5F, 0.9F, 0.9F);
        }

        List <List <int> > fragments = new List <List <int> >();

        fragments = FloodAlgorithm.floodSplit3D(ref mesh3d);

        List <Tetrahedron> fracTetras;
        List <Plane>       fracPlanes;
        List <TetraPart>   tetraParts = mesh3d.getTetraParts(fragments, out fracTetras, out fracPlanes);

        int frag;

        if (tetraParts[0].tetrahedra.Count == 0)
        {
            frag = 1;
        }
        else
        {
            frag = 0;
        }

        Vector3 node = tetraParts[frag].tetrahedra[0].tetra[0];

        for (int i = 0; i < fracTetras.Count; i++)
        {
            TetraPart part1, part2;
            fracTetras[i].Split(fracPlanes[i], out part1, out part2);
            if (Vector3.Dot((node - fracPlanes[i].point), fracPlanes[i].normal) > 0)
            {
                tetraParts[frag].Append(part1);
                tetraParts[1 - frag].Append(part2);
            }
            else
            {
                tetraParts[frag].Append(part2);
                tetraParts[1 - frag].Append(part1);
            }
        }
        var sb = GameObject.Find("Tetra").GetComponent <ShaderBase>();

        sb.tetraPart = tetraParts[0];
        sb.FlushTetraPart();
        var sb2 = new GameObject().AddComponent <ShaderBase>();

        sb2.material  = sb.material;
        sb2.tetraPart = tetraParts[1];
        sb2.FlushTetraPart();
    }
예제 #6
0
    public void HighlightColor(int colorId)
    {
        if (this.currentColorId == colorId)
        {
            UnityEngine.Debug.Log("Rehighlight. Skip");
            return;
        }
        if (this.highlightCoroutine != null)
        {
            if (this.prev != null)
            {
                for (int i = 0; i < this.prev.zones.Count; i++)
                {
                    List <int> indexes = this.prev.zones[i];
                    FloodAlgorithm.FillIndexes(indexes, this.highlightEngine, this.startColor);
                }
            }
            base.StopCoroutine(this.highlightCoroutine);
        }
        this.currentColorId = colorId;
        PaletteEntity paletteEntity = this.pd.entities[colorId];
        Color32       newColor      = this.startColor;

        if (this.current != null)
        {
            this.prev = this.current;
        }
        this.current         = new FloodHighlightController.HState();
        this.current.colorId = colorId;
        this.current.color   = paletteEntity.color;
        this.current.zones   = new List <List <int> >();
        for (int j = 0; j < paletteEntity.indexes.Length; j++)
        {
            int num = paletteEntity.indexes[j];
            if (!this.IsPainted(num, paletteEntity.color))
            {
                Point point = default(Point);
                point.i = Mathf.FloorToInt((float)num / (float)this.paintEngine.texWidth);
                point.j = num - point.i * this.paintEngine.texWidth;
                byte b = this.paintEngine.source[num];
                if (b < 253)
                {
                    b += 1;
                }
                else
                {
                    b = 1;
                }
                List <int> item = FloodAlgorithm.FloodFillExtended(point.j, point.i, this.highlightEngine, newColor, b);
                this.current.zones.Add(item);
            }
        }
        if (this.prev != null)
        {
            for (int k = this.prev.zones.Count - 1; k >= 0; k--)
            {
                if (this.IsPainted(this.prev.zones[k][0], this.prev.color))
                {
                    this.prev.zones.RemoveAt(k);
                }
            }
        }
        this.highlightCoroutine = base.StartCoroutine(this.HighlightCoroutine(this.duration));
    }