Пример #1
0
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService edSvc =
                (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (edSvc == null)
            {
                return(value);
            }
            pd        = context.PropertyDescriptor;
            component = context.Instance;

            if (pd == null)
            {
                return(value);
            }

            Vector3 v = (Vector3)value;

            using (EulerEditor ctrol = new EulerEditor(Euler.FromDirection(v)))
            {
                ctrol.EulerChanged += ctrol_EulerChanged;
                edSvc.DropDownControl(ctrol);
                return(ctrol.Orientation.ToDirection());
            }
        }
Пример #2
0
        private Matrix ComputeLocalTransform(Vector3 offset)
        {
            var dir = Vector3.Normalize(Vector3.TransformCoordinates(offset, Matrix.RotationY(-Numerics.PIover2)));
            //(0,0,1) -> euler(0,0,0)
            var euler          = Euler.FromDirection(dir);
            var rotationMatrix = euler.ToMatrix() * Matrix.RotationY(Numerics.PIover2);

            localTransform             = rotationMatrix;
            localTransform.Translation = Offset;

            //update the childrens local Transforms
            var invRotation = Matrix.Invert(rotationMatrix);

            return(invRotation);
        }
Пример #3
0
        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;
            }
        }
Пример #4
0
 private void btPick_Click(object sender, EventArgs e)
 {
     using (AttitudePickerForm form = new AttitudePickerForm(Euler.FromDirection(direction)))
     {
         Vector3 oldDir = direction;
         form.OrientationChanged += new EventHandler(form_OrientationChanged);
         if (form.ShowDialog() == DialogResult.OK)
         {
             Vector3 dir = form.Orientation.ToDirection();
             direction = oldDir;
             if (direction != dir)
             {
                 direction       = dir;
                 tbAttitude.Text = StringConverter.GetString(direction);
                 OnDirectionChanged();
             }
         }
     }
 }
Пример #5
0
 public static Frame CreateNode(Light light, Vector3 position, Vector3 direction)
 {
     return(CreateNode(light, position, Euler.FromDirection(direction)));
 }