public Vector3 GetRandDirection(Spherical directionPivot, Spherical extends)
        {
            float   jitHeading = -extends.Phi + (float)_rand.NextDouble() * (2 * extends.Phi);
            float   jitPith    = -extends.Theta + (float)_rand.NextDouble() * (2 * extends.Theta);
            Vector3 direction  = Spherical.ToCartesian(directionPivot.Theta + jitPith, directionPivot.Phi + jitHeading);

            return(direction);
        }
        public Vector3 GetRandDirection()
        {
            float jitPith    = (float)_rand.NextDouble() * Numerics.PI;
            float jitHeading = (float)_rand.NextDouble() * Numerics.TwoPI;

            Vector3 direction = Spherical.ToCartesian(jitPith, jitHeading);

            return(direction);
        }
        private void CreateLights()
        {
            _lights = new Frame[6];
            Random ran = new Random();

            Color3[] colors = new Color3[8]
            {
                new Color3(Color.Yellow.ToArgb()), new Color3(Color.Red.ToArgb()), new Color3(Color.Green.ToArgb()), new Color3(Color.LightCoral.ToArgb()),
                new Color3(Color.DarkBlue.ToArgb()), new Color3(Color.Gray.ToArgb()), new Color3(Color.IndianRed.ToArgb()), new Color3(Color.LightSalmon.ToArgb())
            };

            float     step      = Numerics.TwoPI / _lights.Length;
            Spherical spherical = new Spherical(Numerics.PIover2, 0);

            for (int i = 0; i < _lights.Length; i++)
            {
                var light = new Light()
                {
                    Diffuse = colors[i % 8],
                    //Diffuse = new Vector3((float)ran.NextDouble(),(float)ran.NextDouble(),(float)ran.NextDouble()),
                    Specular = new Vector3(0.2f, 0.2f, 0.2f),
                    Type     = LightType.Point,
                    Enable   = true
                };
                spherical.Phi = step * i;
                var pos = spherical.ToCartesian() * 300;
                pos.Y = 50;

                var instance = new FrameLight(light);
                var node     = SceneManager.Scene.Create("light" + i, instance,
                                                         localPosition: pos,
                                                         localRotationEuler: Euler.FromDirection(new Vector3(0, -1, 0)),
                                                         localScale: new Vector3(1, 1, 1));
                SceneManager.Scene.Dynamics.Add(new Dynamic(x =>
                {
                    Frame n         = node;
                    n.LocalPosition = Vector3.TransformCoordinates(n.LocalPosition,
                                                                   Matrix.RotationY(Numerics.ToRadians(1)));
                    n.ComputeLocalPose();
                    n.CommitChanges();
                }));
                _lights[i] = node;
            }
        }
Beispiel #4
0
 void Update()
 {
     sphericalPosition += speed * Time.deltaTime;
     transform.position = sphericalPosition.ToCartesian();
 }