Esempio n. 1
0
        private void btnAddLight_Click(object sender, RoutedEventArgs e)
        {
            UnitLight light = new UnitLight();

            light.LightDebugName = new String8Property()
            {
                Value = "New"
            };
            light.LightColor = new ColorRGBProperty()
            {
                Color = Colors.White
            };
            light.LightType = new KeyProperty()
            {
                InstanceId = LightTypes.First(l => l.Value == "Point").Key
            };
            light.LightCullDistance = new KeyProperty()
            {
                InstanceId = LightCullDistances.First(l => l.Value == "Max").Key
            };

            light.LightTransform = new TransformProperty();
            light.LightTransform.SetMatrix(new TranslateTransform3D(0, 0, 10).Value);
            //light.LightTransform.SetMatrix(new TranslateTransform3D(0, 0, meshMain.Bounds.SizeZ + 10).Value);

            UnitFileEntry.UnitLights.Add(light);

            light.CreateGeometry();

            viewPort.Children.Add(light.ModelRepresentation);
            UnitFileEntry.UnitLights.Changed();
        }
Esempio n. 2
0
        void newLight_LightTypeChanged(object sender, EventArgs e)
        {
            UnitLight light = sender as UnitLight;

            light.UpdateTransform();
            viewPort.Children.Remove(light.ModelRepresentation);
            light.ModelRepresentation = light.CreateGeometry();
            viewPort.Children.Add(light.ModelRepresentation);

            lbLights.SelectedItem = light;
        }
Esempio n. 3
0
        private void cbLightType_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            UnitLight light = ((FrameworkElement)((sender as ComboBox).Parent)).DataContext as UnitLight;

            if (light != null)
            {
                light.UpdateTransform();

                if (light.ModelRepresentation != null)
                {
                    viewPort.Children.Remove(light.ModelRepresentation);
                }
                light.CreateGeometry();
                viewPort.Children.Add(light.ModelRepresentation);
                // manipulator.Bind(light.ModelRepresentation);
            }
        }
Esempio n. 4
0
        private void btnCloneLight_Click(object sender, RoutedEventArgs e)
        {
            if (lbLights.SelectedItem is UnitLight)
            {
                UnitLight selLight = (UnitLight)lbLights.SelectedItem;
                selLight.UpdateTransform();

                UnitLight light = new UnitLight();
                light.LightDebugName = new String8Property()
                {
                    Value = "New"
                };
                light.LightColor        = selLight.LightColor;
                light.LightType         = selLight.LightType;
                light.LightCullDistance = selLight.LightCullDistance;
                light.LightId           = selLight.LightId;

                light.LightInnerRadius  = selLight.LightInnerRadius;
                light.LightOuterRadius  = selLight.LightOuterRadius;
                light.LightSpecLevels   = selLight.LightSpecLevels;
                light.LightLength       = selLight.LightLength;
                light.IsVolumetric      = selLight.IsVolumetric;
                light.LightDiffuseLevel = selLight.LightDiffuseLevel;
                light.LightVolStrength  = selLight.LightVolStrength;
                light.LightFalloffStart = selLight.LightFalloffStart;

                light.LightTransform = new TransformProperty();
                light.LightTransform.SetMatrix(selLight.LightTransform.GetAsMatrix3D());
                light.LightTransform.Unknown = selLight.LightTransform.Unknown;
                light.LightTransform.Flags   = selLight.LightTransform.Flags;

                light.CreateGeometry();

                UnitFileEntry.UnitLights.Add(light);
                UnitFileEntry.UnitLights.Changed();

                if (chkLights.IsChecked.GetValueOrDefault(false))
                {
                    viewPort.Children.Add(light.ModelRepresentation);
                }
            }
        }