Пример #1
0
        private static void Cone3DRandom(
            Transform source, List <Transform> results, int count, float spreadH, float spreadV)
        {
            if (!PrepareTransformList(source, results, count))
            {
                return;
            }

            Vector3 origin  = source.origin;
            Vector3 forward = -source.basis.z;
            Vector3 up      = source.basis.y;
            Vector3 right   = source.basis.x;

            // always shoot one dead centre.
            results[0] = source;
            for (int i = 1; i < count; ++i)
            {
                float   rSpreadH = ZqfGodotUtils.RandomRange(-spreadH, spreadH);
                float   rSpreadV = ZqfGodotUtils.RandomRange(-spreadV, spreadV);
                Vector3 end      = ZqfGodotUtils.VectorMA(origin, 8192, forward);
                end        = ZqfGodotUtils.VectorMA(end, rSpreadH, right);
                end        = ZqfGodotUtils.VectorMA(end, rSpreadV, up);
                results[i] = source.LookingAt(end, Vector3.Up);
                //results[i].SetLookAt(source.origin, end, Vector3.Up);
            }
        }
Пример #2
0
        private static void Cone3D(
            Transform source, List <Transform> results, int count, float spreadH, float spreadV)
        {
            if (!PrepareTransformList(source, results, count))
            {
                return;
            }

            Vector3 origin  = source.origin;
            Vector3 forward = -source.basis.z;
            Vector3 up      = source.basis.y;
            Vector3 right   = source.basis.x;

            float radians     = 0;
            float radiansStep = ZqfGodotUtils.TAU / (count - 1);

            for (int i = 0; i < count; ++i)
            {
                float   rSpreadH = Mathf.Cos(radians) * spreadH;
                float   rSpreadV = Mathf.Sin(radians) * spreadV;
                Vector3 end      = ZqfGodotUtils.VectorMA(origin, 8192, forward);
                end        = ZqfGodotUtils.VectorMA(end, rSpreadH, right);
                end        = ZqfGodotUtils.VectorMA(end, rSpreadV, up);
                results[i] = source.LookingAt(end, Vector3.Up);
                //results[i].SetLookAt(source.origin, end, source.basis.y);
                radians += radiansStep;
            }
        }