Ejemplo n.º 1
0
 private static void RenderCollisionBounds(ParticleSystem system, GizmoType gizmoType)
 {
     if (system.trigger.enabled)
     {
         if (TriggerModuleUI.s_VisualizeBounds)
         {
             ParticleSystem.Particle[] array = new ParticleSystem.Particle[system.particleCount];
             int   particles = system.GetParticles(array);
             Color color     = Gizmos.color;
             Gizmos.color = Color.green;
             Matrix4x4 matrix = Matrix4x4.identity;
             if (system.main.simulationSpace == ParticleSystemSimulationSpace.Local)
             {
                 matrix = system.GetLocalToWorldMatrix();
             }
             Matrix4x4 matrix2 = Gizmos.matrix;
             Gizmos.matrix = matrix;
             for (int i = 0; i < particles; i++)
             {
                 ParticleSystem.Particle particle = array[i];
                 Vector3 currentSize3D            = particle.GetCurrentSize3D(system);
                 Gizmos.DrawWireSphere(particle.position, Math.Max(currentSize3D.x, Math.Max(currentSize3D.y, currentSize3D.z)) * 0.5f * system.trigger.radiusScale);
             }
             Gizmos.color  = color;
             Gizmos.matrix = matrix2;
         }
     }
 }
Ejemplo n.º 2
0
 private static void RenderCollisionBounds(ParticleSystem system, GizmoType gizmoType)
 {
     if (system.trigger.enabled && s_VisualizeBounds)
     {
         ParticleSystem.Particle[] particles = new ParticleSystem.Particle[system.particleCount];
         int   num   = system.GetParticles(particles);
         Color color = Gizmos.color;
         Gizmos.color = Color.green;
         Matrix4x4 identity = Matrix4x4.identity;
         if (system.main.simulationSpace == ParticleSystemSimulationSpace.Local)
         {
             identity = system.GetLocalToWorldMatrix();
         }
         Matrix4x4 matrix = Gizmos.matrix;
         Gizmos.matrix = identity;
         for (int i = 0; i < num; i++)
         {
             ParticleSystem.Particle particle = particles[i];
             Vector3 vector = particle.GetCurrentSize3D(system);
             Gizmos.DrawWireSphere(particle.position, (Math.Max(vector.x, Math.Max(vector.y, vector.z)) * 0.5f) * system.trigger.radiusScale);
         }
         Gizmos.color  = color;
         Gizmos.matrix = matrix;
     }
 }
Ejemplo n.º 3
0
        private static void RenderPivots(ParticleSystem system, GizmoType gizmoType)
        {
            ParticleSystemRenderer component = system.GetComponent <ParticleSystemRenderer>();

            if (!(component == null))
            {
                if (component.enabled)
                {
                    if (RendererModuleUI.s_VisualizePivot)
                    {
                        ParticleSystem.Particle[] array = new ParticleSystem.Particle[system.particleCount];
                        int   particles = system.GetParticles(array);
                        Color color     = Gizmos.color;
                        Gizmos.color = Color.green;
                        Matrix4x4 matrix = Matrix4x4.identity;
                        if (system.main.simulationSpace == ParticleSystemSimulationSpace.Local)
                        {
                            matrix = system.GetLocalToWorldMatrix();
                        }
                        Matrix4x4 matrix2 = Gizmos.matrix;
                        Gizmos.matrix = matrix;
                        for (int i = 0; i < particles; i++)
                        {
                            ParticleSystem.Particle particle = array[i];
                            Vector3 currentSize3D            = particle.GetCurrentSize3D(system);
                            Gizmos.DrawWireSphere(particle.position, Math.Max(currentSize3D.x, Math.Max(currentSize3D.y, currentSize3D.z)) * 0.05f);
                        }
                        Gizmos.color  = color;
                        Gizmos.matrix = matrix2;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 绘制粒子公告板
        /// </summary>
        /// <param name="particle">要绘制的粒子</param>
        /// <param name="vh">顶点辅助器</param>
        private void DrawParticleBillboard(ParticleSystem.Particle particle, VertexHelper vh)
        {
            Vector3    center   = particle.position;
            Quaternion rotation = Quaternion.Euler(particle.rotation3D);

            if (ParticleSystem.main.simulationSpace == ParticleSystemSimulationSpace.World)
            {
                center = rectTransform.InverseTransformPoint(center);
            }

            float timeAlive       = particle.startLifetime - particle.remainingLifetime;
            float globalTimeAlive = timeAlive / particle.startLifetime;

            Vector3 size3D = particle.GetCurrentSize3D(ParticleSystem);

            Vector3 leftTop = Vector3.zero, rightTop = Vector3.zero, rightBottom = Vector3.zero, leftBottom = Vector3.zero;

            if (m_RenderMode == UiParticleRenderMode.StreachedBillboard)
            {
                GetStrechedBillboardsSizeAndRotation(particle, globalTimeAlive, ref size3D, out rotation);
                leftTop     = new Vector3(-size3D.x * 0.5f, 0);
                rightTop    = new Vector3(-size3D.x * 0.5f, size3D.y);
                rightBottom = new Vector3(size3D.x * 0.5f, size3D.y);
                leftBottom  = new Vector3(size3D.x * 0.5f, 0);
            }
            else
            {
                leftTop     = new Vector3(-size3D.x * 0.5f, size3D.y * 0.5f);
                rightTop    = new Vector3(size3D.x * 0.5f, size3D.y * 0.5f);
                rightBottom = new Vector3(size3D.x * 0.5f, -size3D.y * 0.5f);
                leftBottom  = new Vector3(-size3D.x * 0.5f, -size3D.y * 0.5f);
            }

            leftTop     = rotation * leftTop + center;
            rightTop    = rotation * rightTop + center;
            rightBottom = rotation * rightBottom + center;
            leftBottom  = rotation * leftBottom + center;

            Color32 color32 = particle.GetCurrentColor(ParticleSystem);
            int     i       = vh.currentVertCount;

            Vector2[] uvs = new Vector2[4];

            if (!ParticleSystem.textureSheetAnimation.enabled)
            {
                EvaluateQuadUVs(uvs);
            }
            else
            {
                EvaluateTexturesheetUVs(particle, timeAlive, uvs);
            }

            vh.AddVert(leftBottom, color32, uvs[0]);
            vh.AddVert(leftTop, color32, uvs[1]);
            vh.AddVert(rightTop, color32, uvs[2]);
            vh.AddVert(rightBottom, color32, uvs[3]);

            vh.AddTriangle(i, i + 1, i + 2);
            vh.AddTriangle(i + 2, i + 3, i);
        }
Ejemplo n.º 5
0
        private void DrawParticleBillboard(
            ParticleSystem.Particle particle,
            VertexHelper vh,
            ParticleSystem.MinMaxCurve frameOverTime,
            ParticleSystem.MinMaxCurve velocityOverTimeX,
            ParticleSystem.MinMaxCurve velocityOverTimeY,
            ParticleSystem.MinMaxCurve velocityOverTimeZ,
            bool isWorldSimulationSpace,
            ParticleSystem.TextureSheetAnimationModule textureSheetAnimationModule)
        {
            var center   = particle.position;
            var rotation = Quaternion.Euler(particle.rotation3D);

            if (isWorldSimulationSpace)
            {
                center = rectTransform.InverseTransformPoint(center);
            }

            float timeAlive       = particle.startLifetime - particle.remainingLifetime;
            float globalTimeAlive = timeAlive / particle.startLifetime;

            Vector3 size3D = particle.GetCurrentSize3D(ParticleSystem);

            if (m_RenderMode == UiParticleRenderMode.StreachedBillboard)
            {
                GetStrechedBillboardsSizeAndRotation(particle, globalTimeAlive, ref size3D, out rotation,
                                                     velocityOverTimeX, velocityOverTimeY, velocityOverTimeZ);
            }

            var leftTop     = new Vector3(-size3D.x * 0.5f, size3D.y * 0.5f);
            var rightTop    = new Vector3(size3D.x * 0.5f, size3D.y * 0.5f);
            var rightBottom = new Vector3(size3D.x * 0.5f, -size3D.y * 0.5f);
            var leftBottom  = new Vector3(-size3D.x * 0.5f, -size3D.y * 0.5f);


            leftTop     = rotation * leftTop + center;
            rightTop    = rotation * rightTop + center;
            rightBottom = rotation * rightBottom + center;
            leftBottom  = rotation * leftBottom + center;

            Color32 color32 = particle.GetCurrentColor(ParticleSystem);
            var     i       = vh.currentVertCount;

            Vector2 uv0;
            Vector2 uv1;
            Vector2 uv2;
            Vector2 uv3;

            CalculateUvs(particle, frameOverTime, textureSheetAnimationModule, timeAlive, out uv0, out uv1, out uv2,
                         out uv3);

            vh.AddVert(leftBottom, color32, uv0);
            vh.AddVert(leftTop, color32, uv1);
            vh.AddVert(rightTop, color32, uv2);
            vh.AddVert(rightBottom, color32, uv3);

            vh.AddTriangle(i, i + 1, i + 2);
            vh.AddTriangle(i + 2, i + 3, i);
        }
Ejemplo n.º 6
0
        private void DrawParticleMesh(
            ParticleSystem.Particle particle,
            VertexHelper vh,
            ParticleSystem.MinMaxCurve frameOverTime,
            bool isWorldSimulationSpace,
            ParticleSystem.TextureSheetAnimationModule textureSheetAnimationModule, Vector3[] verts, int[] triangles,
            Vector2[] uvs)
        {
            var center   = particle.position;
            var rotation = Quaternion.Euler(particle.rotation3D);

            if (isWorldSimulationSpace)
            {
                center = rectTransform.InverseTransformPoint(center);
            }

            float timeAlive       = particle.startLifetime - particle.remainingLifetime;
            float globalTimeAlive = timeAlive / particle.startLifetime;

            Vector3 size3D  = particle.GetCurrentSize3D(ParticleSystem);
            Color32 color32 = particle.GetCurrentColor(ParticleSystem);

            Vector2 uv0;
            Vector2 uv1;
            Vector2 uv2;
            Vector2 uv3;

            CalculateUvs(particle, frameOverTime, textureSheetAnimationModule, timeAlive, out uv0, out uv1, out uv2,
                         out uv3);

            var currentVertCount = vh.currentVertCount;

            for (int j = 0; j < verts.Length; j++)
            {
                Vector3 pos = verts[j];
                pos.x *= size3D.x;
                pos.y *= size3D.y;
                pos.z *= size3D.z;
                pos    = rotation * pos + center;

                var uvXpercent = uvs[j].x;
                var uvYpercent = uvs[j].y;

                var newUvx = Mathf.Lerp(uv0.x, uv2.x, uvXpercent);
                var newUvy = Mathf.Lerp(uv0.y, uv2.y, uvYpercent);

                vh.AddVert(pos, color32, new Vector2(newUvx, newUvy));
            }

            for (int i = 0; i < triangles.Length; i += 3)
            {
                vh.AddTriangle(currentVertCount + triangles[i],
                               currentVertCount + triangles[i + 1],
                               currentVertCount + triangles[i + 2]);
            }
        }
Ejemplo n.º 7
0
        void RenderCollisionBounds()
        {
            if (s_VisualizeBounds == false)
            {
                return;
            }

            Color oldColor = Handles.color;

            Handles.color = s_CollisionBoundsColor;
            Matrix4x4 oldMatrix = Handles.matrix;

            Vector3[] points0 = new Vector3[20];
            Vector3[] points1 = new Vector3[20];
            Vector3[] points2 = new Vector3[20];

            Handles.SetDiscSectionPoints(points0, Vector3.zero, Vector3.forward, Vector3.right, 360, 1.0f);
            Handles.SetDiscSectionPoints(points1, Vector3.zero, Vector3.up, -Vector3.right, 360, 1.0f);
            Handles.SetDiscSectionPoints(points2, Vector3.zero, Vector3.right, Vector3.up, 360, 1.0f);

            Vector3[] points = new Vector3[points0.Length + points1.Length + points2.Length];
            points0.CopyTo(points, 0);
            points1.CopyTo(points, 20);
            points2.CopyTo(points, 40);

            foreach (ParticleSystem ps in m_ParticleSystemUI.m_ParticleSystems)
            {
                if (!ps.collision.enabled)
                {
                    continue;
                }

                ParticleSystem.Particle[] particles = new ParticleSystem.Particle[ps.particleCount];
                int count = ps.GetParticles(particles);

                Matrix4x4 transform = Matrix4x4.identity;
                if (ps.main.simulationSpace == ParticleSystemSimulationSpace.Local)
                {
                    transform = ps.localToWorldMatrix;
                }

                for (int i = 0; i < count; i++)
                {
                    ParticleSystem.Particle particle = particles[i];
                    Vector3 size = particle.GetCurrentSize3D(ps);

                    float radius = System.Math.Max(size.x, System.Math.Max(size.y, size.z)) * 0.5f * ps.collision.radiusScale;
                    Handles.matrix = transform * Matrix4x4.TRS(particle.position, Quaternion.identity, new Vector3(radius, radius, radius));
                    Handles.DrawPolyLine(points);
                }
            }

            Handles.color  = oldColor;
            Handles.matrix = oldMatrix;
        }
        // render pivots
        override public void OnSceneViewGUI()
        {
            if (s_VisualizePivot == false)
            {
                return;
            }

            Color oldColor = Handles.color;

            Handles.color = Color.green;
            Matrix4x4 oldMatrix = Handles.matrix;

            Vector3[] lineSegments = new Vector3[6];

            foreach (ParticleSystem ps in m_ParticleSystemUI.m_ParticleSystems)
            {
                ParticleSystem.Particle[] particles = new ParticleSystem.Particle[ps.particleCount];
                int count = ps.GetParticles(particles);

                Matrix4x4 transform = Matrix4x4.identity;
                if (ps.main.simulationSpace == ParticleSystemSimulationSpace.Local)
                {
                    transform = ps.GetLocalToWorldMatrix();
                }
                Handles.matrix = transform;

                for (int i = 0; i < count; i++)
                {
                    ParticleSystem.Particle particle = particles[i];
                    Vector3 size = particle.GetCurrentSize3D(ps) * 0.05f;

                    lineSegments[0] = particle.position - (Vector3.right * size.x);
                    lineSegments[1] = particle.position + (Vector3.right * size.x);

                    lineSegments[2] = particle.position - (Vector3.up * size.y);
                    lineSegments[3] = particle.position + (Vector3.up * size.y);

                    lineSegments[4] = particle.position - (Vector3.forward * size.z);
                    lineSegments[5] = particle.position + (Vector3.forward * size.z);

                    Handles.DrawLines(lineSegments);
                }
            }

            Handles.color  = oldColor;
            Handles.matrix = oldMatrix;
        }
Ejemplo n.º 9
0
        private void DrawParticleMesh(ParticleSystem.Particle particle, VertexHelper vh,
                                      ParticleSystem.MinMaxCurve frameOverTime, bool isWorldSimulationSpace,
                                      ParticleSystem.TextureSheetAnimationModule textureSheetAnimationModule,
                                      Vector3[] verts, int[] triangles, Vector2[] uvs)
        {
            var center   = particle.position;
            var rotation = Quaternion.Euler(particle.rotation3D);

            if (isWorldSimulationSpace)
            {
                center = rectTransform.InverseTransformPoint(center);
            }

            float timeAlive = particle.startLifetime - particle.remainingLifetime;

            Vector3 size3D = particle.GetCurrentSize3D(Particle);

            Color32 color32 = particle.GetCurrentColor(Particle);

            CalculateUvs(particle, frameOverTime, textureSheetAnimationModule, timeAlive, out uv4[0], out uv4[1], out uv4[2], out uv4[3]);

            int count = vh.currentVertCount;

            Vector3 position;

            Vector2 point = new Vector2();

            for (int j = 0; j < verts.Length; j++)
            {
                position    = verts[j];
                position.x *= size3D.x;
                position.y *= size3D.y;
                position.z *= size3D.z;
                position    = rotation * position + center;

                point.x = Mathf.Lerp(uv4[0].x, uv4[2].x, uvs[j].x);
                point.y = Mathf.Lerp(uv4[0].y, uv4[2].y, uvs[j].y);

                vh.AddVert(position, color32, point);
            }

            for (int i = 0; i < triangles.Length; i += 3)
            {
                vh.AddTriangle(count + triangles[i], count + triangles[i + 1], count + triangles[i + 2]);
            }
        }
Ejemplo n.º 10
0
 private void RenderCollisionBounds()
 {
     if (CollisionModuleUI.s_VisualizeBounds)
     {
         Color color = Handles.color;
         Handles.color = Color.green;
         Matrix4x4 matrix = Handles.matrix;
         Vector3[] array  = new Vector3[20];
         Vector3[] array2 = new Vector3[20];
         Vector3[] array3 = new Vector3[20];
         Handles.SetDiscSectionPoints(array, Vector3.zero, Vector3.forward, Vector3.right, 360f, 1f);
         Handles.SetDiscSectionPoints(array2, Vector3.zero, Vector3.up, -Vector3.right, 360f, 1f);
         Handles.SetDiscSectionPoints(array3, Vector3.zero, Vector3.right, Vector3.up, 360f, 1f);
         Vector3[] array4 = new Vector3[array.Length + array2.Length + array3.Length];
         array.CopyTo(array4, 0);
         array2.CopyTo(array4, 20);
         array3.CopyTo(array4, 40);
         ParticleSystem[] particleSystems = this.m_ParticleSystemUI.m_ParticleSystems;
         for (int i = 0; i < particleSystems.Length; i++)
         {
             ParticleSystem particleSystem = particleSystems[i];
             if (particleSystem.collision.enabled)
             {
                 ParticleSystem.Particle[] array5 = new ParticleSystem.Particle[particleSystem.particleCount];
                 int       particles = particleSystem.GetParticles(array5);
                 Matrix4x4 lhs       = Matrix4x4.identity;
                 if (particleSystem.main.simulationSpace == ParticleSystemSimulationSpace.Local)
                 {
                     lhs = particleSystem.GetLocalToWorldMatrix();
                 }
                 for (int j = 0; j < particles; j++)
                 {
                     ParticleSystem.Particle particle = array5[j];
                     Vector3 currentSize3D            = particle.GetCurrentSize3D(particleSystem);
                     float   num = Math.Max(currentSize3D.x, Math.Max(currentSize3D.y, currentSize3D.z)) * 0.5f * particleSystem.collision.radiusScale;
                     Handles.matrix = lhs * Matrix4x4.TRS(particle.position, Quaternion.identity, new Vector3(num, num, num));
                     Handles.DrawPolyLine(array4);
                 }
             }
         }
         Handles.color  = color;
         Handles.matrix = matrix;
     }
 }
Ejemplo n.º 11
0
        private static void RenderCollisionBounds(ParticleSystem system, GizmoType gizmoType)
        {
            if (CollisionModuleUI.s_LastInteractedEditor == null)
            {
                return;
            }
            if (!CollisionModuleUI.s_LastInteractedEditor.enabled)
            {
                return;
            }
            if (!CollisionModuleUI.s_LastInteractedEditor.m_VisualizeBounds)
            {
                return;
            }
            if (CollisionModuleUI.s_LastInteractedEditor.m_ParticleSystemUI.m_ParticleSystem != system)
            {
                return;
            }
            ParticleSystem.Particle[] array = new ParticleSystem.Particle[system.particleCount];
            int   particles = system.GetParticles(array);
            Color color     = Gizmos.color;

            Gizmos.color = Color.green;
            Matrix4x4 matrix = Matrix4x4.identity;

            if (system.simulationSpace == ParticleSystemSimulationSpace.Local)
            {
                matrix = system.GetLocalToWorldMatrix();
            }
            Matrix4x4 matrix2 = Gizmos.matrix;

            Gizmos.matrix = matrix;
            for (int i = 0; i < particles; i++)
            {
                ParticleSystem.Particle particle = array[i];
                Vector3 currentSize3D            = particle.GetCurrentSize3D(system);
                Gizmos.DrawWireSphere(particle.position, Math.Max(currentSize3D.x, Math.Max(currentSize3D.y, currentSize3D.z)) * 0.5f * CollisionModuleUI.s_LastInteractedEditor.m_RadiusScale.floatValue);
            }
            Gizmos.color  = color;
            Gizmos.matrix = matrix2;
        }
Ejemplo n.º 12
0
 public override void OnSceneViewGUI()
 {
     if (RendererModuleUI.s_VisualizePivot)
     {
         Color color = Handles.color;
         Handles.color = Color.green;
         Matrix4x4        matrix          = Handles.matrix;
         Vector3[]        array           = new Vector3[6];
         ParticleSystem[] particleSystems = this.m_ParticleSystemUI.m_ParticleSystems;
         for (int i = 0; i < particleSystems.Length; i++)
         {
             ParticleSystem            particleSystem = particleSystems[i];
             ParticleSystem.Particle[] array2         = new ParticleSystem.Particle[particleSystem.particleCount];
             int       particles = particleSystem.GetParticles(array2);
             Matrix4x4 matrix2   = Matrix4x4.identity;
             if (particleSystem.main.simulationSpace == ParticleSystemSimulationSpace.Local)
             {
                 matrix2 = particleSystem.GetLocalToWorldMatrix();
             }
             Handles.matrix = matrix2;
             for (int j = 0; j < particles; j++)
             {
                 ParticleSystem.Particle particle = array2[j];
                 Vector3 vector = particle.GetCurrentSize3D(particleSystem) * 0.05f;
                 array[0] = particle.position - Vector3.right * vector.x;
                 array[1] = particle.position + Vector3.right * vector.x;
                 array[2] = particle.position - Vector3.up * vector.y;
                 array[3] = particle.position + Vector3.up * vector.y;
                 array[4] = particle.position - Vector3.forward * vector.z;
                 array[5] = particle.position + Vector3.forward * vector.z;
                 Handles.DrawLines(array);
             }
         }
         Handles.color  = color;
         Handles.matrix = matrix;
     }
 }
Ejemplo n.º 13
0
        protected override void OnPopulateMesh(VertexHelper vh)
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                if (!Initialize())
                {
                    return;
                }
            }
#endif

            // prepare vertices
            vh.Clear();

            if (!gameObject.activeInHierarchy)
            {
                return;
            }

            // iterate through current particles
            int count = _particleSystem.GetParticles(_particles);

            for (int i = 0; i < count; ++i)
            {
                ParticleSystem.Particle particle = _particles[i];

                // get particle properties
                Vector2 position   = (_particleSystem.simulationSpace == ParticleSystemSimulationSpace.Local ? particle.position : _transform.InverseTransformPoint(particle.position));
                float   rotation   = -particle.rotation * Mathf.Deg2Rad;
                float   rotation90 = rotation + Mathf.PI / 2;
                Color32 color      = particle.GetCurrentColor(_particleSystem);
                Vector3 size       = particle.GetCurrentSize3D(_particleSystem) * 0.5f;

                // apply scale
                if (_particleSystem.scalingMode == ParticleSystemScalingMode.Shape)
                {
                    position /= canvas.scaleFactor;
                }

                // apply texture sheet animation
                Vector4 particleUV = _uv;
                if (_textureSheetAnimation.enabled)
                {
                    float frameProgress = 1 - (particle.remainingLifetime / particle.startLifetime);
                    //                float frameProgress = textureSheetAnimation.frameOverTime.curveMin.Evaluate(1 - (particle.lifetime / particle.startLifetime)); // TODO - once Unity allows MinMaxCurve reading
                    frameProgress = Mathf.Repeat(frameProgress * _textureSheetAnimation.cycleCount, 1);
                    int frame = 0;

                    switch (_textureSheetAnimation.animation)
                    {
                    case ParticleSystemAnimationType.WholeSheet:
                        frame = Mathf.FloorToInt(frameProgress * _textureSheetAnimationFrames);
                        break;

                    case ParticleSystemAnimationType.SingleRow:
                        frame = Mathf.FloorToInt(frameProgress * _textureSheetAnimation.numTilesX);

                        int row = _textureSheetAnimation.rowIndex;
                        //                    if (textureSheetAnimation.useRandomRow) { // FIXME - is this handled internally by rowIndex?
                        //                        row = Random.Range(0, textureSheetAnimation.numTilesY, using: particle.randomSeed);
                        //                    }
                        frame += row * _textureSheetAnimation.numTilesX;
                        break;
                    }

                    frame %= _textureSheetAnimationFrames;

                    particleUV.x = (frame % _textureSheetAnimation.numTilesX) * _textureSheedAnimationFrameSize.x;
                    particleUV.y = Mathf.FloorToInt(frame / _textureSheetAnimation.numTilesX) * _textureSheedAnimationFrameSize.y;
                    particleUV.z = particleUV.x + _textureSheedAnimationFrameSize.x;
                    particleUV.w = particleUV.y + _textureSheedAnimationFrameSize.y;
                }

                _quad[0]       = UIVertex.simpleVert;
                _quad[0].color = color;
                _quad[0].uv0   = new Vector2(particleUV.x, particleUV.y);

                _quad[1]       = UIVertex.simpleVert;
                _quad[1].color = color;
                _quad[1].uv0   = new Vector2(particleUV.x, particleUV.w);

                _quad[2]       = UIVertex.simpleVert;
                _quad[2].color = color;
                _quad[2].uv0   = new Vector2(particleUV.z, particleUV.w);

                _quad[3]       = UIVertex.simpleVert;
                _quad[3].color = color;
                _quad[3].uv0   = new Vector2(particleUV.z, particleUV.y);

                if (rotation == 0)
                {
                    // no rotation
                    Vector2 corner1 = new Vector2(position.x - size.x, position.y - size.y);
                    Vector2 corner2 = new Vector2(position.x + size.x, position.y + size.y);

                    _quad[0].position = new Vector2(corner1.x, corner1.y);
                    _quad[1].position = new Vector2(corner1.x, corner2.y);
                    _quad[2].position = new Vector2(corner2.x, corner2.y);
                    _quad[3].position = new Vector2(corner2.x, corner1.y);
                }
                else
                {
                    // apply rotation
                    Vector2 right = new Vector2(Mathf.Cos(rotation), Mathf.Sin(rotation)) * size.x;
                    Vector2 up    = new Vector2(Mathf.Cos(rotation90), Mathf.Sin(rotation90)) * size.y;

                    _quad[0].position = position - right - up;
                    _quad[1].position = position - right + up;
                    _quad[2].position = position + right + up;
                    _quad[3].position = position + right - up;
                }

                vh.AddUIVertexQuad(_quad);
            }
        }
Ejemplo n.º 14
0
    private void AddParticleBillboard(int particleIndex, bool isWorldSimulationSpace)
    {
        ParticleSystem.Particle particle = particles[particleIndex];

        Color32 color32 = particle.GetCurrentColor(pfx);

        // compute texture coordinates

        Profiler.BeginSample("compute texture coordinates");

        Vector2 coord0, coord1, coord2, coord3;

        if (textureSheetAnimation.enabled)
        {
            CalculateAnimatedUvs(particle, textureSheetAnimation, out coord0, out coord1, out coord2, out coord3);
        }
        else
        {
            CalculateUvs(out coord0, out coord1, out coord2, out coord3);
        }


        Profiler.EndSample();

        // compute vertex positions

        Profiler.BeginSample("compute vertex positions");

        Vector3   size3D        = particle.GetCurrentSize3D(pfx);
        Matrix4x4 toLocalMatrix = rectTransform.worldToLocalMatrix;

        GetPositions(particle, isWorldSimulationSpace, size3D, toLocalMatrix,
                     out Vector3 leftBottom, out Vector3 leftTop, out Vector3 rightTop, out Vector3 rightBottom);

        Profiler.EndSample();

        Profiler.BeginSample("set mesh data");

        // set vertices

        void AddVertex(int index, Vector3 position, Color32 color, Vector2 uv0)
        {
            vertices[index] = position;
            colors[index]   = color;
            coords[index]   = uv0;
        }

        int vertexIndex = particleIndex * 4;
        int v0          = vertexIndex;
        int v1          = vertexIndex + 1;
        int v2          = vertexIndex + 2;
        int v3          = vertexIndex + 3;

        AddVertex(v0, leftBottom, color32, coord0);
        AddVertex(v1, leftTop, color32, coord1);
        AddVertex(v2, rightTop, color32, coord2);
        AddVertex(v3, rightBottom, color32, coord3);

        // set triangles indices

        int triangleIndex = particleIndex * 6;

        triangles[triangleIndex]     = v0;
        triangles[triangleIndex + 1] = v1;
        triangles[triangleIndex + 2] = v2;

        triangles[triangleIndex + 3] = v2;
        triangles[triangleIndex + 4] = v3;
        triangles[triangleIndex + 5] = v0;

        Profiler.EndSample();
    }
Ejemplo n.º 15
0
        private void DrawParticleBillboard(ParticleSystem.Particle particle, VertexHelper vh)
        {
            var center = particle.position;

            var rotation = Quaternion.Euler(particle.rotation3D);

            if (ParticleSystem.main.simulationSpace == ParticleSystemSimulationSpace.World)
            {
                center = rectTransform.InverseTransformPoint(center);
            }

            float timeAlive       = particle.startLifetime - particle.remainingLifetime;
            float globalTimeAlive = timeAlive / particle.startLifetime;

            Vector3 size3D = Vector3.zero;

                    #if UNITY_5_4_OR_NEWER
            size3D = particle.GetCurrentSize3D(ParticleSystem);
            #else
            var size = particle.GetCurrentSize(ParticleSystem);
            size3D = new Vector3(size, size, size);
            #endif

            if (m_RenderMode == UiParticleRenderMode.StreachedBillboard)
            {
                GetStrechedBillboardsSizeAndRotation(particle, globalTimeAlive, ref size3D, ref rotation);
            }


            var leftTop     = new Vector3(-size3D.x * 0.5f, size3D.y * 0.5f);
            var rightTop    = new Vector3(size3D.x * 0.5f, size3D.y * 0.5f);
            var rightBottom = new Vector3(size3D.x * 0.5f, -size3D.y * 0.5f);
            var leftBottom  = new Vector3(-size3D.x * 0.5f, -size3D.y * 0.5f);


            leftTop     = rotation * leftTop + center;
            rightTop    = rotation * rightTop + center;
            rightBottom = rotation * rightBottom + center;
            leftBottom  = rotation * leftBottom + center;

            Color32 color32 = particle.GetCurrentColor(ParticleSystem);
            var     i       = vh.currentVertCount;

            Vector2[] uvs = new Vector2[4];

            if (!ParticleSystem.textureSheetAnimation.enabled)
            {
                uvs [0] = new Vector2(0f, 0f);
                uvs [1] = new Vector2(0f, 1f);
                uvs [2] = new Vector2(1f, 1f);
                uvs [3] = new Vector2(1f, 0f);
            }
            else
            {
                var textureAnimator = ParticleSystem.textureSheetAnimation;

                float lifeTimePerCycle = particle.startLifetime / textureAnimator.cycleCount;
                float timePerCycle     = timeAlive % lifeTimePerCycle;

                float timeAliveAnim01 = timePerCycle / lifeTimePerCycle;;                 // in percents


                float frame01;
                var   totalFramesCount = textureAnimator.numTilesY * textureAnimator.numTilesX;
                #if UNITY_5_4_OR_NEWER
                frame01 = textureAnimator.frameOverTime.Evaluate(timeAliveAnim01);
                #else
                frame01 = m_FrameOverLifetime.Evaluate(timeAliveAnim01, (int)particle.randomSeed, 0, totalFramesCount - 1);
                #endif



                var frame = 0f;
                switch (textureAnimator.animation)
                {
                case ParticleSystemAnimationType.WholeSheet:
                {
                    frame = Mathf.Clamp(Mathf.Floor(frame01 * totalFramesCount), 0, totalFramesCount - 1);
                    break;
                }

                case ParticleSystemAnimationType.SingleRow:
                {
                    frame = Mathf.Clamp(Mathf.Floor(frame01 * textureAnimator.numTilesX), 0, textureAnimator.numTilesX - 1);
                    int row = textureAnimator.rowIndex;
                    if (textureAnimator.useRandomRow)
                    {
                        Random.InitState((int)particle.randomSeed);
                        row = Random.Range(0, textureAnimator.numTilesY);
                    }
                    frame += row * textureAnimator.numTilesX;
                    break;
                }
                }


                int x = (int)frame % textureAnimator.numTilesX;
                int y = (int)frame / textureAnimator.numTilesY;


                var xDelta = 1f / textureAnimator.numTilesX;
                var yDelta = 1f / textureAnimator.numTilesY;
                y = textureAnimator.numTilesY - 1 - y;
                var sX = x * xDelta;
                var sY = y * yDelta;
                var eX = sX + xDelta;
                var eY = sY + yDelta;

                uvs [0] = new Vector2(sX, sY);
                uvs [1] = new Vector2(sX, eY);
                uvs [2] = new Vector2(eX, eY);
                uvs [3] = new Vector2(eX, sY);
            }

            vh.AddVert(leftBottom, color32, uvs [0]);
            vh.AddVert(leftTop, color32, uvs [1]);
            vh.AddVert(rightTop, color32, uvs [2]);
            vh.AddVert(rightBottom, color32, uvs [3]);

            vh.AddTriangle(i, i + 1, i + 2);
            vh.AddTriangle(i + 2, i + 3, i);
        }
Ejemplo n.º 16
0
    protected override void OnPopulateMesh(VertexHelper vh)
    {
        if (ps.textureSheetAnimation.enabled)
        {
        }

        Matrix4x4 matrix = Matrix4x4.TRS(Vector3.zero, transform.rotation, Vector3.one);

        vh.Clear();

        int num = ps.GetParticles(p);

        for (int i = 0; i < num; i++)
        {
            ParticleSystem.Particle pp = p[i];

            Vector3 size = pp.GetCurrentSize3D(ps);

            if (psr.renderMode == ParticleSystemRenderMode.Billboard)
            {
                size = new Vector3(Mathf.Clamp(size.x, minSize, maxSize), Mathf.Clamp(size.y, minSize, maxSize), Mathf.Clamp(size.z, minSize, maxSize));
            }

            Color color = pp.GetCurrentColor(ps);

            Vector3 pos;

            if (ps.main.simulationSpace == ParticleSystemSimulationSpace.World)
            {
                Vector3 tp = pp.position - transform.position;

                if (ps.main.scalingMode == ParticleSystemScalingMode.Hierarchy)
                {
                    pos = new Vector3(tp.x / transform.lossyScale.x, tp.y / transform.lossyScale.y, tp.z / transform.lossyScale.z);
                }
                else
                {
                    size = size * fix;

                    size = new Vector3(size.x * canvas.rootCanvas.transform.localScale.x / transform.lossyScale.x * transform.localScale.x, size.y * canvas.rootCanvas.transform.localScale.y / transform.lossyScale.y * transform.localScale.y, size.z * canvas.transform.localScale.z / transform.lossyScale.z * transform.localScale.z);

                    pos = PublicTools.WorldPositionToCanvasPosition(m_camera, canvasRectSizeDelta, tp);

                    pos = new Vector3(pos.x * canvas.rootCanvas.transform.localScale.x / transform.lossyScale.x, pos.y * canvas.rootCanvas.transform.localScale.y / transform.lossyScale.y);
                }
            }
            else
            {
                if (ps.main.scalingMode == ParticleSystemScalingMode.Hierarchy)
                {
                    pos = pp.position;

                    pos = matrix.MultiplyPoint3x4(pos);
                }
                else
                {
                    size = size * fix;

                    size = new Vector3(size.x * canvas.rootCanvas.transform.localScale.x / transform.lossyScale.x * transform.localScale.x, size.y * canvas.rootCanvas.transform.localScale.y / transform.lossyScale.y * transform.localScale.y, size.z * canvas.transform.localScale.z / transform.lossyScale.z * transform.localScale.z);

                    pos = matrix.MultiplyPoint3x4(pp.position);

                    pos = PublicTools.WorldPositionToCanvasPosition(m_camera, canvasRectSizeDelta, pos);

                    pos = new Vector3(pos.x * canvas.rootCanvas.transform.localScale.x / transform.lossyScale.x * transform.localScale.x, pos.y * canvas.rootCanvas.transform.localScale.y / transform.lossyScale.y * transform.localScale.y);
                }
            }

            float uFix;
            float vFix;
            float uFixPlus;
            float vFixPlus;

            if (ps.textureSheetAnimation.enabled)
            {
                uFix = 1f / ps.textureSheetAnimation.numTilesX;
                vFix = 1f / ps.textureSheetAnimation.numTilesY;

                int frameNum;

                if (ps.textureSheetAnimation.animation == ParticleSystemAnimationType.WholeSheet)
                {
                    frameNum = ps.textureSheetAnimation.numTilesX * ps.textureSheetAnimation.numTilesY;
                }
                else
                {
                    frameNum = ps.textureSheetAnimation.numTilesX;
                }

                int frame;

                if (frameOverTime.mode == ParticleSystemCurveMode.Curve)
                {
                    float t = (pp.startLifetime - pp.remainingLifetime) / pp.startLifetime;

                    frame = (int)(frameOverTime.curve.Evaluate(t) * frameNum);
                }
                else if (frameOverTime.mode == ParticleSystemCurveMode.TwoConstants)
                {
                    Random.InitState((int)pp.randomSeed);

                    frame = (int)(Random.Range(frameOverTime.constantMin, frameOverTime.constantMax) * frameNum);

                    //frame = (int)(Mathf.Clamp(Random.value, frameOverTime.constantMin, frameOverTime.constantMax) * frameNum);
                }
                else if (frameOverTime.mode == ParticleSystemCurveMode.Constant)
                {
                    frame = (int)(frameOverTime.constant * frameNum);
                }
                else
                {
                    throw new System.Exception("unknown frameOverTime.mode");
                }

                if (ps.textureSheetAnimation.animation == ParticleSystemAnimationType.WholeSheet)
                {
                    uFixPlus = uFix * (frame % ps.textureSheetAnimation.numTilesX);
                    vFixPlus = vFix * (ps.textureSheetAnimation.numTilesY - 1 - frame / ps.textureSheetAnimation.numTilesX);
                }
                else
                {
                    uFixPlus = uFix * frame;
                    vFixPlus = vFix * (ps.textureSheetAnimation.numTilesY - 1 - ps.textureSheetAnimation.rowIndex);
                }
            }
            else
            {
                uFix     = 1;
                vFix     = 1;
                uFixPlus = 0;
                vFixPlus = 0;
            }

            Vector3 scale = Vector3.one;

            Quaternion qq;

            if (psr.renderMode == ParticleSystemRenderMode.Billboard)
            {
                qq = Quaternion.AngleAxis(pp.rotation, Vector3.back);
            }
            else if (psr.renderMode == ParticleSystemRenderMode.Mesh)
            {
                qq = Quaternion.AngleAxis(pp.rotation, pp.axisOfRotation);
            }
            else if (psr.renderMode == ParticleSystemRenderMode.Stretch)
            {
                Vector3 vv = matrix.inverse.MultiplyPoint3x4(pos);

                tmpTrans.localPosition = vv;

                float lengthScale = transform.lossyScale.x / transform.lossyScale.z * psr.lengthScale;

                if (ps.main.simulationSpace == ParticleSystemSimulationSpace.Local)
                {
                    tmpTrans.LookAt(transform.TransformPoint(vv + pp.velocity), Vector3.back);

                    tmpTrans.localPosition = tmpTrans.localPosition - transform.InverseTransformDirection(tmpTrans.forward) * lengthScale * 0.5f;

                    tmpTrans.Rotate(Vector3.up, 90f);

                    tmpTrans.Rotate(Vector3.left, -90f);

                    qq = tmpTrans.localRotation;
                }
                else
                {
                    tmpTrans.LookAt(transform.TransformPoint(vv) + pp.velocity, Vector3.back);

                    tmpTrans.localPosition = tmpTrans.localPosition - transform.InverseTransformDirection(tmpTrans.forward) * lengthScale * 0.5f;

                    tmpTrans.Rotate(Vector3.up, 90f);

                    tmpTrans.Rotate(Vector3.left, -90f);

                    qq = tmpTrans.rotation;
                }

                pos = matrix.MultiplyPoint3x4(tmpTrans.localPosition);

                scale.x = lengthScale;
            }
            else
            {
                throw new System.Exception("error!");
            }

            Matrix4x4 mm = Matrix4x4.TRS(Vector3.zero, qq, scale);

            if (ps.main.simulationSpace == ParticleSystemSimulationSpace.Local && psr.renderMode != ParticleSystemRenderMode.Billboard)
            {
                mm = matrix * mm;
            }

            for (int m = 0; m < vertexCount; m++)
            {
                Color nowColor = color;

                //Color nowColor = Color.clear;

                Vector3 vv = mm.MultiplyPoint3x4(vertices[m]);

                //vv = new Vector3(pos.x + vv.x * size.x, pos.y + vv.y * size.y, pos.z + vv.z * size.z);

                vv = new Vector3(pos.x + vv.x * size.x, pos.y + vv.y * size.y, 0);

                Vector3 nowPos = matrix.inverse.MultiplyPoint3x4(vv);

                Vector2 tmpUv = uv[m];

                Vector2 nowUv = new Vector2(tmpUv.x * uFix + uFixPlus, tmpUv.y * vFix + vFixPlus);

                vh.AddVert(nowPos, nowColor, nowUv);
            }

            for (int m = 0; m < triangles.Length / 3; m++)
            {
                vh.AddTriangle(i * vertexCount + triangles[m * 3], i * vertexCount + triangles[m * 3 + 1], i * vertexCount + triangles[m * 3 + 2]);
            }
        }
    }
        public void ReconstructParticleSystem()
        {
            foreach (ParticleCollider curParticleCollider in particleColliders)
            {
                GameObject curGO = curParticleCollider.gameObject;
                ParticleSystem.Particle curParticle = curParticleCollider.Particle;

                float   rotationCorrection = 1f;
                Vector3 pivot = particleSystemRenderer.pivot;
                Vector3 size  = curParticle.GetCurrentSize3D(particleSys);

                // Get hierarchy scale
                Vector3 transformScale = particleSys.transform.localScale;

                // Apply position
                switch (particleSys.main.simulationSpace)
                {
                case ParticleSystemSimulationSpace.Local:
                    curGO.transform.SetParent(particleSys.gameObject.transform);
                    curGO.transform.localPosition = curParticle.position;

                    pivot = Vector3.Scale(pivot, transformScale);
                    break;

                case ParticleSystemSimulationSpace.World:
                    curGO.transform.SetParent(null);
                    curGO.transform.position = curParticle.position;

                    size = Vector3.Scale(size, transformScale);
                    break;
                }

                switch (particleSystemRenderer.renderMode)
                {
                case ParticleSystemRenderMode.Billboard:
                    // Billboard to camera
                    curGO.transform.LookAt(curGO.transform.position + cam.transform.rotation * Vector3.forward, cam.transform.rotation * Vector3.up);

                    rotationCorrection = -1f;
                    break;

                case ParticleSystemRenderMode.Mesh:
                    curGO.transform.rotation = Quaternion.identity;

                    // For mesh pivots, Z is Y and Y is Z
                    pivot.z = particleSystemRenderer.pivot.y * -1f;
                    pivot.y = particleSystemRenderer.pivot.z * -1f;

                    pivot *= curParticle.GetCurrentSize(particleSys);
                    break;

                default:
                    Debug.LogError("Unsupported render mode " + particleSystemRenderer.renderMode);
                    break;
                }

                // Apply rotation
                curGO.transform.Rotate(new Vector3(curParticle.rotation3D.x, curParticle.rotation3D.y, curParticle.rotation3D.z * rotationCorrection));

                // Apply scale
                curGO.transform.localScale = size;

                // Apply pivot
                pivot = Vector3.Scale(pivot, size);
                curGO.transform.position += (curGO.transform.right * pivot.x);
                curGO.transform.position += (curGO.transform.up * pivot.y);
                curGO.transform.position += (curGO.transform.forward * pivot.z * -1f);

                // Apply texture sheet animation
                ParticleSystem.TextureSheetAnimationModule texModule = particleSys.textureSheetAnimation;
                if (texModule.enabled)
                {
                    SubUVTextureInfo subUV = new SubUVTextureInfo(texModule, curParticle);

                    switch (texModule.animation)
                    {
                    case ParticleSystemAnimationType.WholeSheet:
                        curParticleCollider.gameObject.GetComponent <MeshRenderer>().material.mainTextureScale  = new Vector2(1 / subUV.columns, 1 / subUV.rows);
                        curParticleCollider.gameObject.GetComponent <MeshRenderer>().material.mainTextureOffset = new Vector2(subUV.currentColumn / subUV.columns, (subUV.rows - subUV.currentRow - 1) / subUV.rows);

                        break;

                    case ParticleSystemAnimationType.SingleRow:
                        Debug.Log("Single Row texture sheet animations currently not supported.");

                        break;

                    default:
                        Debug.Log("Unsupported texture sheet animation animation type.");

                        break;
                    }
                }

                // Apply color
                Color    particleColor = curParticle.GetCurrentColor(particleSys);
                Material mat           = curGO.GetComponent <MeshRenderer>().material;
                Color    matColor      = particleSystemRenderer.material.GetColor(TINT_COLOR);
                curGO.GetComponent <MeshRenderer>().material.SetColor(TINT_COLOR, particleColor * matColor);
            }
        }
Ejemplo n.º 18
0
        private void DrawParticleBillboard(ParticleSystem.Particle particle, VertexHelper vh)
        {
            /*Vector3 vector = particle.get_position();
             *          Quaternion quaternion = Quaternion.Euler(particle.get_rotation3D());
             *          if (this.ParticleSystem.get_main().get_simulationSpace() == 1)
             *          {
             *                  vector = base.get_rectTransform().InverseTransformPoint(vector);
             *          }
             *          float num = particle.get_startLifetime() - particle.get_remainingLifetime();
             *          float timeAlive = num / particle.get_startLifetime();
             *          Vector3 currentSize3D = particle.GetCurrentSize3D(this.ParticleSystem);
             *          if (this.m_RenderMode == UiParticleRenderMode.StreachedBillboard)
             *          {
             *                  this.GetStrechedBillboardsSizeAndRotation(particle, timeAlive, ref currentSize3D, out quaternion);
             *          }
             *          Vector3 vector2 = new Vector3(-currentSize3D.x * 0.5f, currentSize3D.y * 0.5f);
             *          Vector3 vector3 = new Vector3(currentSize3D.x * 0.5f, currentSize3D.y * 0.5f);
             *          Vector3 vector4 = new Vector3(currentSize3D.x * 0.5f, -currentSize3D.y * 0.5f);
             *          Vector3 vector5 = new Vector3(-currentSize3D.x * 0.5f, -currentSize3D.y * 0.5f);
             *          vector2 = quaternion * vector2 + vector;
             *          vector3 = quaternion * vector3 + vector;
             *          vector4 = quaternion * vector4 + vector;
             *          vector5 = quaternion * vector5 + vector;
             *          Color32 currentColor = particle.GetCurrentColor(this.ParticleSystem);
             *          int currentVertCount = vh.get_currentVertCount();
             *          Vector2[] array = new Vector2[4];
             *          if (!this.ParticleSystem.get_textureSheetAnimation().get_enabled())
             *          {
             *                  this.EvaluateQuadUVs(array);
             *          }
             *          else
             *          {
             *                  this.EvaluateTexturesheetUVs(particle, num, array);
             *          }
             *          vh.AddVert(vector5, currentColor, array[0]);
             *          vh.AddVert(vector2, currentColor, array[1]);
             *          vh.AddVert(vector3, currentColor, array[2]);
             *          vh.AddVert(vector4, currentColor, array[3]);
             *          vh.AddTriangle(currentVertCount, currentVertCount + 1, currentVertCount + 2);
             *          vh.AddTriangle(currentVertCount + 2, currentVertCount + 3, currentVertCount);*/

            Vector3    vector     = particle.position;
            Quaternion quaternion = Quaternion.Euler(particle.rotation3D);

            if (this.ParticleSystem.main.simulationSpace == ParticleSystemSimulationSpace.World)
            {
                vector = base.rectTransform.InverseTransformPoint(vector);
            }
            float   num           = particle.startLifetime - particle.remainingLifetime;
            float   timeAlive     = num / particle.startLifetime;
            Vector3 currentSize3D = particle.GetCurrentSize3D(this.ParticleSystem);

            if (this.m_RenderMode == UiParticleRenderMode.StreachedBillboard)
            {
                this.GetStrechedBillboardsSizeAndRotation(particle, timeAlive, ref currentSize3D, out quaternion);
            }
            Vector3 vector2 = new Vector3(-currentSize3D.x * 0.5f, currentSize3D.y * 0.5f);
            Vector3 vector3 = new Vector3(currentSize3D.x * 0.5f, currentSize3D.y * 0.5f);
            Vector3 vector4 = new Vector3(currentSize3D.x * 0.5f, -currentSize3D.y * 0.5f);
            Vector3 vector5 = new Vector3(-currentSize3D.x * 0.5f, -currentSize3D.y * 0.5f);

            vector2 = quaternion * vector2 + vector;
            vector3 = quaternion * vector3 + vector;
            vector4 = quaternion * vector4 + vector;
            vector5 = quaternion * vector5 + vector;
            Color32 currentColor     = particle.GetCurrentColor(this.ParticleSystem);
            int     currentVertCount = vh.currentVertCount;

            Vector2[] array = new Vector2[4];
            if (!this.ParticleSystem.textureSheetAnimation.enabled)
            {
                this.EvaluateQuadUVs(array);
            }
            else
            {
                this.EvaluateTexturesheetUVs(particle, num, array);
            }
            vh.AddVert(vector5, currentColor, array[0]);
            vh.AddVert(vector2, currentColor, array[1]);
            vh.AddVert(vector3, currentColor, array[2]);
            vh.AddVert(vector4, currentColor, array[3]);
            vh.AddTriangle(currentVertCount, currentVertCount + 1, currentVertCount + 2);
            vh.AddTriangle(currentVertCount + 2, currentVertCount + 3, currentVertCount);
        }