Exemplo n.º 1
0
        void DrawTrailGizmos()
        {
            Gizmos.matrix = transform.localToWorldMatrix;

            var trails = new GPUTrail[trailBuffer.count];

            trailBuffer.GetData(trails);

            const float size   = 0.05f;
            const float length = 0.1f;

            for (int y = 0; y < instancesCount; y++)
            {
                var offset = y * boneCount;
                for (int x = 0; x < boneCount - 1; x++)
                {
                    int index = x + offset;
                    var cur   = trails[index];
                    Gizmos.color = Color.white;

                    // var next = trails[index + 1];
                    // Gizmos.DrawLine(cur.position, next.position);
                    Gizmos.DrawWireSphere(cur.position, size);

                    Vector3 t = cur.tangent, n = cur.normal, b = cur.binormal;
                    Gizmos.color = Color.green;
                    Gizmos.DrawLine(cur.position, cur.position + t * length);
                    Gizmos.color = Color.red;
                    Gizmos.DrawLine(cur.position, cur.position + n * length);
                    Gizmos.color = Color.blue;
                    Gizmos.DrawLine(cur.position, cur.position + b * length);
                }
            }
        }
        void DebugTrail(GPUTrail tr)
        {
            Vector3 t = tr.tangent, n = tr.normal, b = tr.binormal;

            if (float.IsNaN(t.x) || float.IsNaN(t.y) || float.IsNaN(t.z) || t.sqrMagnitude <= float.Epsilon)
            {
                Debug.Log(t);
            }
            if (float.IsNaN(n.x) || float.IsNaN(n.y) || float.IsNaN(n.z) || n.sqrMagnitude <= float.Epsilon)
            {
                Debug.Log(n);
            }
            if (float.IsNaN(b.x) || float.IsNaN(b.y) || float.IsNaN(b.z) || b.sqrMagnitude <= float.Epsilon)
            {
                Debug.Log(b);
            }
        }