Exemple #1
0
    public void retrieveMeshInfo()
    {
        if (!meshTarget)
        {
            Debug.LogWarning("No mesh target assigned!");
            return;
        }

        List <float> TriLength = new List <float>();

        Debug.Log("Vertices: " + meshTarget.GetComponent <MeshFilter>().sharedMesh.vertices.Length);
        Debug.Log("Triangles: " + meshTarget.GetComponent <MeshFilter>().sharedMesh.triangles.Length);

        Vector3[] vertices = meshTarget.GetComponent <MeshFilter>().sharedMesh.vertices;
        int[]     tris     = meshTarget.GetComponent <MeshFilter>().sharedMesh.triangles;

        for (int i = 0; i < tris.Length; i += 3)
        {
            float l = HayateHelper.SignedVolumeOfTriangle(vertices[tris[i]], vertices[tris[i + 1]], vertices[tris[i + 2]]);

            if (l != 0)
            {
                TriLength.Add(l);
            }
        }
        TriLength.Sort();

        Debug.Log("Smallest trangle: " + TriLength[1] + " Largest triangle: " + TriLength[TriLength.Count - 1]);
        Debug.Log("Mesh target ready to work with " + vertices.Length + " particles.");
    }
Exemple #2
0
    public void CreateParticles(Vector3 _Position, float _Width, float _Height, float _Depth, float TargetParticleSize, float _UiScale, HayateEnums.BuildOrder _buildOrder)
    {
        particleSystem.Stop();
        ParticleSystem.Particle[] p = new ParticleSystem.Particle[maxParticles];

        p = HayateHelper.CreateParticlesDynamically(this, _Position, _Width, _Height, _Depth, TargetParticleSize, _UiScale, _buildOrder);
        particleSystem.SetParticles(p, maxParticles);
        particleSystem.Play();
    }
Exemple #3
0
    public void UpdateMeshCoordinates()
    {
        if (!meshTarget)
        {
            Debug.LogWarning("No mesh target assigned!");
            return;
        }

        resetMesh = meshTarget.GetComponent <MeshFilter>().sharedMesh;

        meshTarget.GetComponent <MeshFilter>().mesh = HayateHelper.SubDivide(meshTarget, divisionType, smallestTriangle);
    }
Exemple #4
0
    public int maxParticles = 1000;     // In Unity 3.5, Shuriken does not support particleSystem.maxParticles

    void Start()
    {
        if (isAlwaysOnTop)
        {
#if UNITY_4_5 || UNITY_4_6 || UNITY_5_0
            particleSystem.renderer.sortingLayerName = "Foreground";
            particleSystem.renderer.sortingOrder     = 2;
#endif
        }

        if (detachTransformParticleAfterParticleDeath && !Application.isPlaying)
        {
            Debug.Log("Detaching transform particles only work when playing the scene.");
        }

        if (UseCalculationMethodX == HayateEnums.CalculationMethod.precalculatedTexture ||
            UseCalculationMethodY == HayateEnums.CalculationMethod.precalculatedTexture ||
            UseCalculationMethodZ == HayateEnums.CalculationMethod.precalculatedTexture
            )
        {
            UpdateTexture();
        }

        if (UseCalculationMethodX == HayateEnums.CalculationMethod.Audio || UseCalculationMethodY == HayateEnums.CalculationMethod.Audio || UseCalculationMethodZ == HayateEnums.CalculationMethod.Audio)
        {
            HayateHelper.CalculateAudioTurbulence(this);
        }

        if (randomizeOffsetAtStart)
        {
            Offset = new Vector3(UnityEngine.Random.Range(randomOffsetRange.x, randomOffsetRange.y), UnityEngine.Random.Range(randomOffsetRange.x, randomOffsetRange.y), UnityEngine.Random.Range(randomOffsetRange.x, randomOffsetRange.y));
        }

        if (CreateOnStart && useSfx)
        {
            CreateParticles(transform.InverseTransformPoint(transform.position), Width, Height, Depth, TargetParticleSize, UiScale, buildOrder);
            particleSystem.Play();
        }

        previousUpdate = Time.realtimeSinceStartup;
    }