Ejemplo n.º 1
0
		public void InitLight(LightStyle lightStyle)
		{
			this.lightStyle = lightStyle;
			this.lightVectors[0] = new Point3D(0f, 0f, 0f);
			this.lightVectors[1] = new Point3D(0f, 0f, 1f);
			this.lightVectors[2] = new Point3D(0f, 0f, -1f);
			this.lightVectors[3] = new Point3D(-1f, 0f, 0f);
			this.lightVectors[4] = new Point3D(1f, 0f, 0f);
			this.lightVectors[5] = new Point3D(0f, -1f, 0f);
			this.lightVectors[6] = new Point3D(0f, 1f, 0f);
			this.TransformPoints(this.lightVectors, false);
			this.lightVectors[1].X -= this.lightVectors[0].X;
			this.lightVectors[1].Y -= this.lightVectors[0].Y;
			this.lightVectors[1].Z -= this.lightVectors[0].Z;
			this.lightVectors[2].X -= this.lightVectors[0].X;
			this.lightVectors[2].Y -= this.lightVectors[0].Y;
			this.lightVectors[2].Z -= this.lightVectors[0].Z;
			this.lightVectors[3].X -= this.lightVectors[0].X;
			this.lightVectors[3].Y -= this.lightVectors[0].Y;
			this.lightVectors[3].Z -= this.lightVectors[0].Z;
			this.lightVectors[4].X -= this.lightVectors[0].X;
			this.lightVectors[4].Y -= this.lightVectors[0].Y;
			this.lightVectors[4].Z -= this.lightVectors[0].Z;
			this.lightVectors[5].X -= this.lightVectors[0].X;
			this.lightVectors[5].Y -= this.lightVectors[0].Y;
			this.lightVectors[5].Z -= this.lightVectors[0].Z;
			this.lightVectors[6].X -= this.lightVectors[0].X;
			this.lightVectors[6].Y -= this.lightVectors[0].Y;
			this.lightVectors[6].Z -= this.lightVectors[0].Z;
		}
Ejemplo n.º 2
0
 internal void InitLight(LightStyle lightStyle)
 {
     this.lightStyle = lightStyle;
     lightVectors[0] = new Point3D(0f, 0f, 0f);
     lightVectors[1] = new Point3D(0f, 0f, 1f);
     lightVectors[2] = new Point3D(0f, 0f, -1f);
     lightVectors[3] = new Point3D(-1f, 0f, 0f);
     lightVectors[4] = new Point3D(1f, 0f, 0f);
     lightVectors[5] = new Point3D(0f, -1f, 0f);
     lightVectors[6] = new Point3D(0f, 1f, 0f);
     TransformPoints(lightVectors, withPerspective: false);
     lightVectors[1].X -= lightVectors[0].X;
     lightVectors[1].Y -= lightVectors[0].Y;
     lightVectors[1].Z -= lightVectors[0].Z;
     lightVectors[2].X -= lightVectors[0].X;
     lightVectors[2].Y -= lightVectors[0].Y;
     lightVectors[2].Z -= lightVectors[0].Z;
     lightVectors[3].X -= lightVectors[0].X;
     lightVectors[3].Y -= lightVectors[0].Y;
     lightVectors[3].Z -= lightVectors[0].Z;
     lightVectors[4].X -= lightVectors[0].X;
     lightVectors[4].Y -= lightVectors[0].Y;
     lightVectors[4].Z -= lightVectors[0].Z;
     lightVectors[5].X -= lightVectors[0].X;
     lightVectors[5].Y -= lightVectors[0].Y;
     lightVectors[5].Z -= lightVectors[0].Z;
     lightVectors[6].X -= lightVectors[0].X;
     lightVectors[6].Y -= lightVectors[0].Y;
     lightVectors[6].Z -= lightVectors[0].Z;
 }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (Area.Checked)
            {
                // Set chart type to Area
                Chart1.Series["Series1"].ChartType = SeriesChartType.Area;
                Chart1.Series["Series2"].ChartType = SeriesChartType.Area;
                LineTensionList.Enabled            = false;
            }
            else if (SplineArea.Checked)
            {
                // Set chart type to SplineArea and set line tension
                LineTensionList.Enabled                 = true;
                Chart1.Series["Series1"].ChartType      = SeriesChartType.SplineArea;
                Chart1.Series["Series1"]["LineTension"] = LineTensionList.SelectedItem.Text;
                Chart1.Series["Series2"].ChartType      = SeriesChartType.SplineArea;
                Chart1.Series["Series2"]["LineTension"] = LineTensionList.SelectedItem.Text;
            }

            // Set Show of marker Lines
            Chart1.Series["Series1"]["ShowMarkerLines"] = ShowMarkers.Checked.ToString();
            Chart1.Series["Series2"]["ShowMarkerLines"] = ShowMarkers.Checked.ToString();


            // Disable/enable X axis margin
            Chart1.ChartAreas["ChartArea1"].AxisX.IsMarginVisible = ShowMargins.Checked;

            // set the lighting choice
            if (LightingType.SelectedItem.Text != "")
            {
                Chart1.ChartAreas["ChartArea1"].Area3DStyle.LightStyle = (LightStyle)LightStyle.Parse(typeof(LightStyle), LightingType.SelectedItem.Text);
            }
        }
Ejemplo n.º 4
0
 private static void DefaultArray(string test, ref LightStyle[] array)
 {
     if (array == null)
     {
         LightStyle style = test;
         if (style != null)
         {
             LightStyle[] styleArray1 = new LightStyle[] { style };
             array = styleArray1;
         }
         else
         {
             array = new LightStyle[0];
         }
     }
     else if (array.Length == 0)
     {
         LightStyle style2 = test;
         if (style2 != null)
         {
             LightStyle[] styleArray2 = new LightStyle[] { style2 };
             array = styleArray2;
         }
     }
 }
Ejemplo n.º 5
0
        private void UpdateChartSettings()
        {
            if (radioButtonArea.Checked)
            {
                // Set chart type to Area
                chart1.Series["Series1"].ChartType = SeriesChartType.Area;
                chart1.Series["Series2"].ChartType = SeriesChartType.Area;
                chart1.Series["Series1"].DeleteCustomProperty("LineTension");
                chart1.Series["Series2"].DeleteCustomProperty("LineTension");
                comboBoxTension.Enabled = false;
            }
            else
            {
                // Set chart type to SplineArea and set line tension
                comboBoxTension.Enabled                 = true;
                chart1.Series["Series1"].ChartType      = SeriesChartType.SplineArea;
                chart1.Series["Series1"]["LineTension"] = comboBoxTension.Text;
                chart1.Series["Series2"].ChartType      = SeriesChartType.SplineArea;
                chart1.Series["Series2"]["LineTension"] = comboBoxTension.Text;
            }

            // Disable/enable X axis margin
            chart1.ChartAreas["Default"].AxisX.IsMarginVisible = checkBoxShowMargin.Checked;
            chart1.Series["Series1"]["ShowMarkerLines"]        = ShowMarkerLines.Checked.ToString();
            chart1.Series["Series2"]["ShowMarkerLines"]        = ShowMarkerLines.Checked.ToString();

            // Set area lighting
            if (LightingType.Text != "")
            {
                chart1.ChartAreas["Default"].Area3DStyle.LightStyle = (LightStyle)LightStyle.Parse(typeof(LightStyle), LightingType.Text);
            }
        }
Ejemplo n.º 6
0
 private void Start()
 {
     if (this._lightStyle == null)
     {
         this._lightStyle = LightStyleDefault.Singleton;
     }
     this.simulationIdle = this._lightStyle.CreateSimulation(LightStyle.time, this);
 }
Ejemplo n.º 7
0
 public bool Blend(LightStyle style, float targetWeight, float fadeLength)
 {
     if (fadeLength <= 0f)
     {
         this.Play(style);
         return(true);
     }
     targetWeight = Mathf.Clamp01(targetWeight);
     if (style == this._lightStyle)
     {
         float num;
         float current = this.CalculateSumWeight(true, out num);
         if (Mathf.Approximately(1f - current, targetWeight))
         {
             return(true);
         }
         float num3 = Mathf.MoveTowards(current, 1f - targetWeight, Time.deltaTime / fadeLength);
         if (num3 <= 0f)
         {
             foreach (Clip clip in this.clips.Values)
             {
                 clip.weight = 0f;
             }
         }
         else
         {
             float num4 = num3 / current;
             foreach (Clip clip2 in this.clips.Values)
             {
                 clip2.weight *= num4;
             }
         }
     }
     else
     {
         float num5;
         Clip  orMakeClip = this.GetOrMakeClip(style);
         if (Mathf.Approximately(orMakeClip.weight, targetWeight))
         {
             return(true);
         }
         orMakeClip.weight = Mathf.MoveTowards(orMakeClip.weight, targetWeight, Time.deltaTime / fadeLength);
         float num6 = this.CalculateSumWeight(false, out num5);
         if ((num6 != orMakeClip.weight) && (num6 > 1f))
         {
             float num7 = num6 - orMakeClip.weight;
             foreach (Clip clip4 in this.clips.Values)
             {
                 if (clip4 != orMakeClip)
                 {
                     clip4.weight /= num7;
                     clip4.weight *= 1f - orMakeClip.weight;
                 }
             }
         }
     }
     return(false);
 }
 public void Copy(GLight other)
 {
     this.m_position    = other.m_position;
     this.m_orientation = other.m_orientation;
     this.m_style       = other.m_style;
     this.m_flare       = other.m_flare;
     this.m_color_index = other.m_color_index;
     this.m_intensity   = other.m_intensity;
     this.m_range       = other.m_range;
     this.m_spot_angle  = other.m_spot_angle;
 }
Ejemplo n.º 9
0
    private Clip GetOrMakeClip(LightStyle style)
    {
        Clip clip;

        if (!this.clips.TryGetValue(style, out clip))
        {
            clip = new Clip {
                simulation = style.CreateSimulation(LightStyle.time, this)
            };
            this.clips[style] = clip;
        }
        return(clip);
    }
Ejemplo n.º 10
0
 private void CrossFadeDone()
 {
     LightStylist.Clip clip;
     if (this.clips.TryGetValue(this.crossfadeThisFrame, out clip))
     {
         this.clips.Remove(this.style);
         this.GetOrMakeClip(this._lightStyle).weight = 0f;
         this._lightStyle    = this.style;
         this.simulationIdle = clip.simulation;
     }
     this.crossfadeThisFrame = null;
     this.crossfadeNextFrame = null;
 }
Ejemplo n.º 11
0
 private LightStylist.Clip GetOrMakeClip(LightStyle style)
 {
     LightStylist.Clip clip;
     if (this.clips.TryGetValue(style, out clip))
     {
         return(clip);
     }
     clip = new LightStylist.Clip()
     {
         simulation = style.CreateSimulation(LightStyle.time, this)
     };
     this.clips[style] = clip;
     return(clip);
 }
Ejemplo n.º 12
0
 public DLight(Vector3 pos)
 {
     enabled     = false;
     position    = Vector3.Zero;
     style       = LightStyle.POINT;
     flare       = LightFlare.NONE;
     _rot_yaw    = 0f;
     _rot_pitch  = 0f;
     color_index = 0;
     intensity   = 1f;
     range       = 10f;
     angle       = 45f;
     _rotation   = CalculateRotationMatrix(this);
 }
Ejemplo n.º 13
0
 public void Copy(DLight src)
 {
     enabled     = src.enabled;
     position    = src.position;
     style       = src.style;
     flare       = src.flare;
     _rot_yaw    = src._rot_yaw;
     _rot_pitch  = src._rot_pitch;
     color_index = src.color_index;
     intensity   = src.intensity;
     range       = src.range;
     angle       = src.angle;
     _rotation   = src._rotation;
 }
Ejemplo n.º 14
0
 public bool CrossFade(LightStyle style, float fadeLength)
 {
     if (this.crossfadeThisFrame != style)
     {
         this.crossfadeThisFrame = style;
         this.crossfadeNextFrame = null;
         this.crossfadeLength    = fadeLength;
         if (this.Blend(style, 1f, fadeLength))
         {
             this.CrossFadeDone();
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 15
0
 public void Play(LightStyle style, double time)
 {
     if (style == this._lightStyle)
     {
         this.clips.Clear();
     }
     else
     {
         Clip orMakeClip = this.GetOrMakeClip(style);
         this.clips.Clear();
         this.clips[style] = orMakeClip;
         orMakeClip.weight = 1f;
         orMakeClip.simulation.ResetTime(time);
     }
 }
Ejemplo n.º 16
0
        private void UpdateChartSettings()
        {
            if (comboBoxChartType.Text == "")
            {
                return;
            }

            // Loop through all series
            foreach (Series series in chart1.Series)
            {
                // Set marker lines
                series["ShowMarkerLines"] = ShowMarkerLines.Checked.ToString();

                // Set chart type and line tension
                if (comboBoxChartType.Text == "Spline Range")
                {
                    series.ChartType            = SeriesChartType.SplineRange;
                    comboBoxLineTension.Enabled = true;
                    series["LineTension"]       = comboBoxLineTension.Text;
                }
                else
                {
                    series.ChartType            = SeriesChartType.Range;
                    comboBoxLineTension.Enabled = false;
                    series.DeleteCustomProperty("LineTension");
                }
            }

            // Disable/enable X axis margin
            chart1.ChartAreas["Default"].AxisX.IsMarginVisible = checkBoxShowMargin.Checked;

            // Set area lighting
            if (LightingType.Text != "")
            {
                chart1.ChartAreas["Default"].Area3DStyle.LightStyle = (LightStyle)LightStyle.Parse(typeof(LightStyle), LightingType.Text);
            }

            if (UsePerspective.Checked)
            {
                chart1.ChartAreas["Default"].Area3DStyle.Perspective = 10;
                chart1.ChartAreas["Default"].Area3DStyle.PointDepth  = 200;
            }
            else
            {
                chart1.ChartAreas["Default"].Area3DStyle.Perspective = 0;
                chart1.ChartAreas["Default"].Area3DStyle.PointDepth  = 100;
            }
        }
Ejemplo n.º 17
0
    void Start()
    {
        try
        {
            renderDistanceSlider.value = PlayerPrefs.GetInt("ViewDistance");

            if (PlayerPrefs.GetInt("Clouds") == 0)
            {
                enableClouds.isOn = false;
            }
            if (PlayerPrefs.GetInt("Clouds") == 1)
            {
                enableClouds.isOn = true;
            }

            if (PlayerPrefs.GetInt("CloudStyle") == 1)
            {
                style = CloudStyle.Fast;
                cloudStyleDropdown.value = 1;
            }
            if (PlayerPrefs.GetInt("CloudStyle") == 2)
            {
                style = CloudStyle.Fancy;
                cloudStyleDropdown.value = 2;
            }

            if (PlayerPrefs.GetInt("LightStyle") == 1)
            {
                lightStyle = LightStyle.Fast;
                lightStyleDropdown.value = 1;
            }
            if (PlayerPrefs.GetInt("LightStyle") == 2)
            {
                lightStyle = LightStyle.Fancy;
                lightStyleDropdown.value = 2;
            }
        }
        catch
        {
            renderDistanceSlider.value = VoxelData.ViewDistanceInChunks;
        }

        if (Application.platform == RuntimePlatform.WebGLPlayer)
        {
            enableThreading.isOn = false;
        }
    }
Ejemplo n.º 18
0
    public void ChangeLightStyle()
    {
        if (lightStyleDropdown.value == 1)
        {
            block.shader            = blockShader;
            transparentBlock.shader = transparentBlockShader;
            lightStyle = LightStyle.Fast;
        }
        if (lightStyleDropdown.value == 2)
        {
            block.shader            = standard;
            transparentBlock.shader = standard;
            lightStyle = LightStyle.Fancy;
        }

        PlayerPrefs.SetInt("LightStyle", lightStyleDropdown.value);
    }
Ejemplo n.º 19
0
    private void Start()
    {
        lightIntensity      = lightMinIntensity;
        lightTransitionTime = float.Parse("0.0" + (dayLength / 2).ToString());

        if (!mainMenu.newWorld)
        {
            worldData = SaveSystem.LoadWorld(worldData.worldName);
        }
        else
        {
            worldData = SaveSystem.LoadWorld(mainMenu.worldNameInput.text, mainMenu.seed);
        }

        Random.InitState(seed);

        Shader.SetGlobalFloat("minGlobalLightLevel", VoxelData.minLightLevel);
        Shader.SetGlobalFloat("maxGlobalLightLevel", VoxelData.maxLightLevel);

        if (enableThreading)
        {
            ChunkUpdateThread = new Thread(new ThreadStart(ThreadedUpdate));
            ChunkUpdateThread.Start();
        }

        try
        {
            float[] light = SaveSystem.LoadDayData(worldData.worldName);
            time           = light[0];
            lightIntensity = light[1];
        }
        catch
        {
            time           = 0;
            lightIntensity = lightMinIntensity;
        }

        mainMenu.generatingWait.SetActive(true);
        lightStyle             = Instance.mainMenu.settingsMenu.GetComponent <Settings>().lightStyle;
        spawnPosition          = new Vector3((VoxelData.WorldSizeInChunks * VoxelData.ChunkWidth) / 2f, VoxelData.ChunkHeight - 50f, (VoxelData.WorldSizeInChunks * VoxelData.ChunkWidth) / 2f);
        sun.transform.position = new Vector3(((VoxelData.WorldSizeInChunks * VoxelData.ChunkWidth) / 2f), 150, ((VoxelData.WorldSizeInChunks * VoxelData.ChunkWidth) / 2f));
        GenerateWorld();
        playerLastChunkCoord = GetChunkCoordFromVector3(player.position);
    }
Ejemplo n.º 20
0
        public DLight(JObject root)
        {
            enabled = root["enabled"].GetBool(false);
            style   = root["style"].GetEnum <LightStyle>(LightStyle.SPOT);
            flare   = root["flare"].GetEnum <LightFlare>(LightFlare.NONE);

            position   = root["position"].GetVector3(Vector3.Zero);
            _rot_yaw   = root["rot_yaw"].GetFloat(0f);
            _rot_pitch = root["rot_pitch"].GetFloat(0f);

            color_index = root["color_index"].GetInt(0);

            intensity = root["intensity"].GetFloat(1f);
            range     = root["range"].GetFloat(1f);
            angle     = root["angle"].GetFloat(45f);

            // Note: The above wrote directly to the backing values (_rot_yaw, _rot_pitch and _angle), so
            // we are responsible for updating the backing for _rotation. This was done so we didn't recalculate
            // rotation for each of those properties
            _rotation = CalculateRotationMatrix(this);
        }
Ejemplo n.º 21
0
 private static void DefaultArray(string test, ref LightStyle[] array)
 {
     if (array == null)
     {
         LightStyle lightStyle = test;
         if (!lightStyle)
         {
             array = new LightStyle[0];
         }
         else
         {
             array = new LightStyle[] { lightStyle };
         }
     }
     else if ((int)array.Length == 0)
     {
         LightStyle lightStyle1 = test;
         if (lightStyle1)
         {
             array = new LightStyle[] { lightStyle1 };
         }
     }
 }
Ejemplo n.º 22
0
 public static LightStyle.Mod Lerp(LightStyle.Mod a, LightStyle.Mod b, float t, LightStyle.Mod.Mask mask)
 {
     b.mask = b.mask & mask;
     if ((int)b.mask == 0)
     {
         return a;
     }
     a.mask = a.mask & mask;
     if ((int)a.mask == 0)
     {
         return b;
     }
     LightStyle.Mod.Mask mask1 = a.mask & b.mask;
     if ((int)mask1 != 0)
     {
         float single = 1f - t;
         if ((int)mask != 0)
         {
             for (LightStyle.Mod.Element i = LightStyle.Mod.Element.Red; i < (LightStyle.Mod.Element.Green | LightStyle.Mod.Element.Blue | LightStyle.Mod.Element.Alpha | LightStyle.Mod.Element.Intensity | LightStyle.Mod.Element.Range | LightStyle.Mod.Element.SpotAngle); i = (LightStyle.Mod.Element)((int)i + (int)LightStyle.Mod.Element.Green))
             {
                 if ((mask1 & LightStyle.Mod.ElementToMask(i)) == LightStyle.Mod.ElementToMask(i))
                 {
                     float faceValue = a.GetFaceValue(i);
                     float faceValue1 = b.GetFaceValue(i);
                     float single1 = faceValue * single + faceValue1 * t;
                     a.SetFaceValue(i, single1);
                 }
             }
         }
     }
     if (mask1 != a.mask)
     {
         a = a | b;
     }
     return a;
 }
Ejemplo n.º 23
0
 public bool AllOf(LightStyle.Mod.Mask mask)
 {
     return (this.mask & mask) == mask;
 }
Ejemplo n.º 24
0
 protected Simulation(LightStyle creator)
 {
     this.creator = creator;
 }
Ejemplo n.º 25
0
 public void SetModify(LightStyle.Mod.Element element)
 {
     LightStyle.Mod mask = this;
     mask.mask = mask.mask | LightStyle.Mod.ElementToMask(element);
 }
Ejemplo n.º 26
0
        protected override GraphicsPath Draw3DSurface(ChartArea area, ChartGraphics graph, Matrix3D matrix, LightStyle lightStyle, DataPoint3D prevDataPointEx, float positionZ, float depth, ArrayList points, int pointIndex, int pointLoopIndex, float tension, DrawingOperationTypes operationType, float topDarkening, float bottomDarkening, PointF thirdPointPosition, PointF fourthPointPosition, bool clippedSegment)
        {
            if (pointLoopIndex != 2)
            {
                return(base.Draw3DSurface(area, graph, matrix, lightStyle, prevDataPointEx, positionZ, depth, points, pointIndex, pointLoopIndex, tension, operationType, topDarkening, bottomDarkening, thirdPointPosition, fourthPointPosition, clippedSegment));
            }
            DataPoint3D dataPoint3D = (DataPoint3D)points[pointIndex];

            if (dataPoint3D.index == 2)
            {
                int         num     = 0;
                DataPoint3D pointEx = ChartGraphics3D.FindPointByIndex(points, dataPoint3D.index - 1, dataPoint3D, ref num);
                this.DrawLabels3D(area, graph, area.Common, pointEx, positionZ, depth);
            }
            this.DrawLabels3D(area, graph, area.Common, dataPoint3D, positionZ, depth);
            return(new GraphicsPath());
        }
Ejemplo n.º 27
0
 public bool Blend(LightStyle style, float targetWeight)
 {
     return(this.Blend(style, targetWeight, 0.3f));
 }
Ejemplo n.º 28
0
 public float? this[LightStyle.Mod.Element element]
 {
     get
     {
         if (!this.Contains(element))
         {
             return null;
         }
         return new float?(this.GetFaceValue(element));
     }
     set
     {
         if (!value.HasValue)
         {
             this.ClearModify(element);
         }
         else
         {
             this.SetFaceValue(element, value.Value);
             this.SetModify(element);
         }
     }
 }
Ejemplo n.º 29
0
 public bool Contains(LightStyle.Mod.Element element)
 {
     return this.AllOf(LightStyle.Mod.ElementToMask(element));
 }
Ejemplo n.º 30
0
 public float GetFaceValue(LightStyle.Mod.Element element)
 {
     switch (element)
     {
         case LightStyle.Mod.Element.Red:
         {
             return this.r;
         }
         case LightStyle.Mod.Element.Green:
         {
             return this.g;
         }
         case LightStyle.Mod.Element.Blue:
         {
             return this.b;
         }
         case LightStyle.Mod.Element.Alpha:
         {
             return this.a;
         }
         case LightStyle.Mod.Element.Intensity:
         {
             return this.intensity;
         }
         case LightStyle.Mod.Element.Range:
         {
             return this.range;
         }
         case LightStyle.Mod.Element.SpotAngle:
         {
             return this.spotAngle;
         }
     }
     throw new ArgumentOutOfRangeException("element");
 }
Ejemplo n.º 31
0
 public void SetFaceValue(LightStyle.Mod.Element element, float value)
 {
     switch (element)
     {
         case LightStyle.Mod.Element.Red:
         {
             this.r = value;
             break;
         }
         case LightStyle.Mod.Element.Green:
         {
             this.g = value;
             break;
         }
         case LightStyle.Mod.Element.Blue:
         {
             this.b = value;
             break;
         }
         case LightStyle.Mod.Element.Alpha:
         {
             this.a = value;
             break;
         }
         case LightStyle.Mod.Element.Intensity:
         {
             this.intensity = value;
             break;
         }
         case LightStyle.Mod.Element.Range:
         {
             this.range = value;
             break;
         }
         case LightStyle.Mod.Element.SpotAngle:
         {
             this.spotAngle = value;
             break;
         }
         default:
         {
             throw new ArgumentOutOfRangeException("element");
         }
     }
 }
Ejemplo n.º 32
0
 public LightStyle.Mod BindMod(LightStyle.Mod.Mask mask)
 {
     if (!this.destroyed)
     {
         this.UpdateBinding();
     }
     LightStyle.Mod mod = this.mod;
     mod.mask = mod.mask & mask;
     return mod;
 }
Ejemplo n.º 33
0
 public void BindToLight(Light light, LightStyle.Mod.Mask mask)
 {
     if (mask != (LightStyle.Mod.Mask.Red | LightStyle.Mod.Mask.Green | LightStyle.Mod.Mask.Blue | LightStyle.Mod.Mask.Alpha | LightStyle.Mod.Mask.Intensity | LightStyle.Mod.Mask.Range | LightStyle.Mod.Mask.SpotAngle))
     {
         if (this.destroyed)
         {
             return;
         }
         this.UpdateBinding();
         if ((this.mod.mask & mask) == this.mod.mask)
         {
             this.mod.ApplyTo(light);
         }
         else
         {
             LightStyle.Mod mod = this.mod;
             mod.mask = mod.mask & mask;
             mod.ApplyTo(light);
         }
     }
     else
     {
         this.BindToLight(light);
     }
 }
Ejemplo n.º 34
0
    protected void LateUpdate()
    {
        float num;

        LightStyle.Mod mod;
        if (this.crossfadeThisFrame != null)
        {
            this.crossfadeNextFrame = this.crossfadeThisFrame;
            this.crossfadeThisFrame = null;
        }
        else if ((this.crossfadeNextFrame != null) && !this.CrossFade(this.crossfadeNextFrame, this.crossfadeLength))
        {
            this.crossfadeNextFrame = this.crossfadeThisFrame;
            this.crossfadeThisFrame = null;
        }
        float num2 = this.CalculateSumWeight(true, out num);

        if (num2 == 0f)
        {
            while (this.clipsInSortingArray > 0)
            {
                this.sortingArray[--this.clipsInSortingArray] = null;
            }
            if (this._lightStyle == null)
            {
                return;
            }
            mod = this.simulationIdle.BindMod(this._mask);
        }
        else
        {
            int count = this.clips.Count;
            if (this.clipsInSortingArray != count)
            {
                if (this.clipsInSortingArray > count)
                {
                    while (this.clipsInSortingArray > count)
                    {
                        this.sortingArray[--this.clipsInSortingArray] = null;
                    }
                }
                else if ((this.sortingArray == null) || (this.sortingArray.Length < count))
                {
                    Array.Resize <Clip>(ref this.sortingArray, ((count / 4) + (((count % 4) != 0) ? 1 : 2)) * 4);
                }
            }
            int num4 = 0;
            foreach (Clip clip in this.clips.Values)
            {
                if (clip.weight > 0f)
                {
                    this.sortingArray[num4++] = clip;
                }
            }
            if (this.clipsInSortingArray < num4)
            {
                this.clipsInSortingArray = num4;
            }
            else
            {
                while (this.clipsInSortingArray > num4)
                {
                    this.sortingArray[--this.clipsInSortingArray] = null;
                }
            }
            Array.Sort <Clip>(this.sortingArray, 0, this.clipsInSortingArray);
            float weight = this.sortingArray[0].weight;
            mod = this.sortingArray[0].simulation.BindMod(this._mask);
            for (int i = 1; i < this.clipsInSortingArray; i++)
            {
                Clip clip2 = this.sortingArray[i];
                weight += clip2.weight;
                mod     = LightStyle.Mod.Lerp(mod, clip2.simulation.BindMod(this._mask), clip2.weight / weight, this._mask);
            }
            if (this._lightStyle != null)
            {
                LightStyle.Mod b = this.simulationIdle.BindMod(this._mask);
                if (num2 < 1f)
                {
                    mod = LightStyle.Mod.Lerp(mod, b, 1f - num2, this._mask);
                }
                else
                {
                    mod |= b;
                }
            }
        }
        foreach (Light light in this.lights)
        {
            if (light != null)
            {
                mod.ApplyTo(light, this._mask);
            }
        }
    }
Ejemplo n.º 35
0
 public void ClearModify(LightStyle.Mod.Element element)
 {
     LightStyle.Mod maskNot = this;
     maskNot.mask = maskNot.mask & LightStyle.Mod.ElementToMaskNot(element);
 }
Ejemplo n.º 36
0
 public static LightStyle.Mod.Mask ElementToMaskNot(LightStyle.Mod.Element element)
 {
     return (LightStyle.Mod.Mask)(~((int)LightStyle.Mod.Element.Green << (int)(element & (LightStyle.Mod.Element.Green | LightStyle.Mod.Element.Blue | LightStyle.Mod.Element.Alpha | LightStyle.Mod.Element.Intensity | LightStyle.Mod.Element.Range | LightStyle.Mod.Element.SpotAngle))) & (LightStyle.Mod.Element.Green | LightStyle.Mod.Element.Blue | LightStyle.Mod.Element.Alpha | LightStyle.Mod.Element.Intensity | LightStyle.Mod.Element.Range | LightStyle.Mod.Element.SpotAngle));
 }
Ejemplo n.º 37
0
 protected override bool DeconstructSimulation(LightStyle.Simulation simulation)
 {
     return false;
 }
Ejemplo n.º 38
0
 public bool Blend(LightStyle style)
 {
     return(this.Blend(style, 1f, 0.3f));
 }
Ejemplo n.º 39
0
        /// <summary>
        /// Draws a 3D surface connecting the two specified points in 2D space.
        /// Used to draw Line based charts.
        /// </summary>
        /// <param name="area">Chart area reference.</param>
        /// <param name="graph">Chart graphics.</param>
        /// <param name="matrix">Coordinates transformation matrix.</param>
        /// <param name="lightStyle">LightStyle style (None, Simplistic, Realistic).</param>
        /// <param name="prevDataPointEx">Previous data point object.</param>
        /// <param name="positionZ">Z position of the back side of the 3D surface.</param>
        /// <param name="depth">Depth of the 3D surface.</param>
        /// <param name="points">Array of points.</param>
        /// <param name="pointIndex">Index of point to draw.</param>
        /// <param name="pointLoopIndex">Index of points loop.</param>
        /// <param name="tension">Line tension.</param>
        /// <param name="operationType">AxisName of operation Drawing, Calculating Path or Both</param>
        /// <param name="topDarkening">Darkenning scale for top surface. 0 - None.</param>
        /// <param name="bottomDarkening">Darkenning scale for bottom surface. 0 - None.</param>
        /// <param name="thirdPointPosition">Position where the third point is actually located or float.NaN if same as in "firstPoint".</param>
        /// <param name="fourthPointPosition">Position where the fourth point is actually located or float.NaN if same as in "secondPoint".</param>
        /// <param name="clippedSegment">Indicates that drawn segment is 3D clipped. Only top/bottom should be drawn.</param>
        /// <returns>Returns elemnt shape path if operationType parameter is set to CalcElementPath, otherwise Null.</returns>
        protected override GraphicsPath Draw3DSurface(
            ChartArea area,
            ChartGraphics graph,
            Matrix3D matrix,
            LightStyle lightStyle,
            DataPoint3D prevDataPointEx,
            float positionZ,
            float depth,
            ArrayList points,
            int pointIndex,
            int pointLoopIndex,
            float tension,
            DrawingOperationTypes operationType,
            float topDarkening,
            float bottomDarkening,
            PointF thirdPointPosition,
            PointF fourthPointPosition,
            bool clippedSegment)
        {
            // Create graphics path for selection
            GraphicsPath resultPath = ((operationType & DrawingOperationTypes.CalcElementPath) == DrawingOperationTypes.CalcElementPath)
                                ? new GraphicsPath() : null;

            // Check if points are drawn from sides to center (do only once)
            if (centerPointIndex == int.MaxValue)
            {
                centerPointIndex = GetCenterPointIndex(points);
            }

            //************************************************************
            //** Find line first & second points
            //************************************************************
            DataPoint3D secondPoint     = (DataPoint3D)points[pointIndex];
            int         pointArrayIndex = pointIndex;
            DataPoint3D firstPoint      = ChartGraphics.FindPointByIndex(
                points,
                secondPoint.index - 1,
                (this.multiSeries) ? secondPoint : null,
                ref pointArrayIndex);

            // Fint point with line properties
            DataPoint3D pointAttr = secondPoint;

            if (prevDataPointEx.dataPoint.IsEmpty)
            {
                pointAttr = prevDataPointEx;
            }
            else if (firstPoint.index > secondPoint.index)
            {
                pointAttr = firstPoint;
            }

            // Adjust point visual properties
            Color          color     = (useBorderColor) ? pointAttr.dataPoint.BorderColor : pointAttr.dataPoint.Color;
            ChartDashStyle dashStyle = pointAttr.dataPoint.BorderDashStyle;

            if (pointAttr.dataPoint.IsEmpty && pointAttr.dataPoint.Color == Color.Empty)
            {
                color = Color.Gray;
            }
            if (pointAttr.dataPoint.IsEmpty && pointAttr.dataPoint.BorderDashStyle == ChartDashStyle.NotSet)
            {
                dashStyle = ChartDashStyle.Solid;
            }

            //************************************************************
            //** Create "middle" point
            //************************************************************
            DataPoint3D middlePoint = new DataPoint3D();

            middlePoint.xPosition = secondPoint.xPosition;
            middlePoint.yPosition = firstPoint.yPosition;

            // Check if reversed drawing order required
            bool originalDrawOrder = true;

            if ((pointIndex + 1) < points.Count)
            {
                DataPoint3D p = (DataPoint3D)points[pointIndex + 1];
                if (p.index == firstPoint.index)
                {
                    originalDrawOrder = false;
                }
            }

            // Check in which order vertical & horizontal lines segments should be drawn
            if (centerPointIndex != int.MaxValue)
            {
                if (pointIndex >= centerPointIndex)
                {
                    originalDrawOrder = false;
                }
            }

            // Draw two segments of the step line
            GraphicsPath resultPathLine1, resultPathLine2;

            if (originalDrawOrder)
            {
                // Draw first line
                middlePoint.dataPoint = secondPoint.dataPoint;
                resultPathLine1       = graph.Draw3DSurface(
                    area, matrix, lightStyle, SurfaceNames.Top, positionZ, depth, color,
                    pointAttr.dataPoint.BorderColor, pointAttr.dataPoint.BorderWidth, dashStyle,
                    firstPoint, middlePoint,
                    points, pointIndex, 0f, operationType, LineSegmentType.First,
                    (this.showPointLines) ? true : false, false,
                    area.ReverseSeriesOrder,
                    this.multiSeries, 0, true);

                // No second draw of the prev. front line required
                graph.frontLinePen = null;

                // Draw second line
                middlePoint.dataPoint = firstPoint.dataPoint;
                resultPathLine2       = graph.Draw3DSurface(
                    area, matrix, lightStyle, SurfaceNames.Top, positionZ, depth, color,
                    pointAttr.dataPoint.BorderColor, pointAttr.dataPoint.BorderWidth, dashStyle,
                    middlePoint, secondPoint,
                    points, pointIndex, 0f, operationType, LineSegmentType.Last,
                    (this.showPointLines) ? true : false, false,
                    area.ReverseSeriesOrder,
                    this.multiSeries, 0, true);

                // No second draw of the prev. front line required
                graph.frontLinePen = null;
            }
            else
            {
                // Draw second line
                middlePoint.dataPoint = firstPoint.dataPoint;
                resultPathLine2       = graph.Draw3DSurface(
                    area, matrix, lightStyle, SurfaceNames.Top, positionZ, depth, color,
                    pointAttr.dataPoint.BorderColor, pointAttr.dataPoint.BorderWidth, dashStyle,
                    middlePoint, secondPoint,
                    points, pointIndex, 0f, operationType, LineSegmentType.Last,
                    (this.showPointLines) ? true : false, false,
                    area.ReverseSeriesOrder,
                    this.multiSeries, 0, true);

                // No second draw of the prev. front line required
                graph.frontLinePen = null;

                // Draw first line
                middlePoint.dataPoint = secondPoint.dataPoint;
                resultPathLine1       = graph.Draw3DSurface(
                    area, matrix, lightStyle, SurfaceNames.Top, positionZ, depth, color,
                    pointAttr.dataPoint.BorderColor, pointAttr.dataPoint.BorderWidth, dashStyle,
                    firstPoint, middlePoint,
                    points, pointIndex, 0f, operationType, LineSegmentType.First,
                    (this.showPointLines) ? true : false, false,
                    area.ReverseSeriesOrder,
                    this.multiSeries, 0, true);

                // No second draw of the prev. front line required
                graph.frontLinePen = null;
            }

            if (resultPath != null)
            {
                if (area.Common.ProcessModeRegions)
                {
                    if (resultPathLine1 != null && resultPathLine1.PointCount > 0)
                    {
                        area.Common.HotRegionsList.AddHotRegion(
                            resultPathLine1,
                            false,
                            graph,
                            prevDataPointEx.dataPoint,
                            prevDataPointEx.dataPoint.series.Name,
                            prevDataPointEx.index - 1);
                    }
                }

                if (resultPathLine2 != null && resultPathLine2.PointCount > 0)
                {
                    resultPath.AddPath(resultPathLine2, true);
                }
            }
            return(resultPath);
        }
Ejemplo n.º 40
0
 protected abstract bool DeconstructSimulation(LightStyle.Simulation simulation);
Ejemplo n.º 41
0
        protected override GraphicsPath Draw3DSurface(ChartArea area, ChartGraphics graph, Matrix3D matrix, LightStyle lightStyle, DataPoint3D prevDataPointEx, float positionZ, float depth, ArrayList points, int pointIndex, int pointLoopIndex, float tension, DrawingOperationTypes operationType, float topDarkening, float bottomDarkening, PointF thirdPointPosition, PointF fourthPointPosition, bool clippedSegment)
        {
            GraphicsPath graphicsPath = ((operationType & DrawingOperationTypes.CalcElementPath) == DrawingOperationTypes.CalcElementPath) ? new GraphicsPath() : null;

            if (base.centerPointIndex == 2147483647)
            {
                base.centerPointIndex = base.GetCenterPointIndex(points);
            }
            DataPoint3D dataPoint3D  = (DataPoint3D)points[pointIndex];
            int         num          = pointIndex;
            DataPoint3D dataPoint3D2 = ChartGraphics3D.FindPointByIndex(points, dataPoint3D.index - 1, base.multiSeries ? dataPoint3D : null, ref num);
            DataPoint3D dataPoint3D3 = dataPoint3D;

            if (prevDataPointEx.dataPoint.Empty)
            {
                dataPoint3D3 = prevDataPointEx;
            }
            else if (dataPoint3D2.index > dataPoint3D.index)
            {
                dataPoint3D3 = dataPoint3D2;
            }
            Color          color       = base.useBorderColor ? dataPoint3D3.dataPoint.BorderColor : dataPoint3D3.dataPoint.Color;
            ChartDashStyle borderStyle = dataPoint3D3.dataPoint.BorderStyle;

            if (dataPoint3D3.dataPoint.Empty && dataPoint3D3.dataPoint.Color == Color.Empty)
            {
                color = Color.Gray;
            }
            if (dataPoint3D3.dataPoint.Empty && dataPoint3D3.dataPoint.BorderStyle == ChartDashStyle.NotSet)
            {
                borderStyle = ChartDashStyle.Solid;
            }
            if (this.currentKagiDirection == 0)
            {
                this.kagiUpColor = dataPoint3D.dataPoint.series.Color;
                string         text           = ((DataPointAttributes)dataPoint3D.dataPoint.series)["PriceUpColor"];
                ColorConverter colorConverter = new ColorConverter();
                if (text != null)
                {
                    try
                    {
                        this.kagiUpColor = (Color)colorConverter.ConvertFromString(null, CultureInfo.InvariantCulture, text);
                    }
                    catch
                    {
                        throw new InvalidOperationException(SR.ExceptionKagiAttributeFormatInvalid("Up Brick color"));
                    }
                }
                this.currentKagiDirection = ((dataPoint3D2.yPosition > dataPoint3D.yPosition) ? 1 : (-1));
            }
            Color       backColor    = (this.currentKagiDirection == 1) ? this.kagiUpColor : color;
            DataPoint3D dataPoint3D4 = new DataPoint3D();

            dataPoint3D4.xPosition = dataPoint3D.xPosition;
            dataPoint3D4.yPosition = dataPoint3D2.yPosition;
            bool flag = true;

            if (pointIndex + 1 < points.Count)
            {
                DataPoint3D dataPoint3D5 = (DataPoint3D)points[pointIndex + 1];
                if (dataPoint3D5.index == dataPoint3D2.index)
                {
                    flag = false;
                }
            }
            if (base.centerPointIndex != 2147483647 && pointIndex >= base.centerPointIndex)
            {
                flag = false;
            }
            DataPoint3D dataPoint3D6 = null;

            if (dataPoint3D.index >= 2)
            {
                int num2 = (dataPoint3D2.yPosition > dataPoint3D.yPosition) ? 1 : (-1);
                if (num2 != this.currentKagiDirection)
                {
                    DataPoint3D dataPoint3D7 = ChartGraphics3D.FindPointByIndex(points, dataPoint3D.index - 2, base.multiSeries ? dataPoint3D : null, ref num);
                    bool        flag2        = false;
                    if (dataPoint3D2.yPosition > dataPoint3D7.yPosition && dataPoint3D2.yPosition > dataPoint3D.yPosition && dataPoint3D7.yPosition > dataPoint3D.yPosition)
                    {
                        flag2 = true;
                    }
                    else if (dataPoint3D2.yPosition < dataPoint3D7.yPosition && dataPoint3D2.yPosition < dataPoint3D.yPosition && dataPoint3D7.yPosition < dataPoint3D.yPosition)
                    {
                        flag2 = true;
                    }
                    if (flag2)
                    {
                        dataPoint3D6           = new DataPoint3D();
                        dataPoint3D6.xPosition = dataPoint3D.xPosition;
                        dataPoint3D6.yPosition = dataPoint3D7.yPosition;
                        dataPoint3D6.dataPoint = dataPoint3D.dataPoint;
                    }
                }
            }
            GraphicsPath[] array = new GraphicsPath[3];
            for (int i = 0; i < 2; i++)
            {
                DataPoint3D     firstPoint      = dataPoint3D2;
                DataPoint3D     secondPoint     = dataPoint3D;
                LineSegmentType lineSegmentType = LineSegmentType.First;
                switch (i)
                {
                case 0:
                    lineSegmentType        = (LineSegmentType)(flag ? 1 : 3);
                    dataPoint3D4.dataPoint = (flag ? dataPoint3D.dataPoint : dataPoint3D2.dataPoint);
                    firstPoint             = (flag ? dataPoint3D2 : dataPoint3D4);
                    secondPoint            = (flag ? dataPoint3D4 : dataPoint3D);
                    break;

                case 1:
                    lineSegmentType        = (LineSegmentType)((!flag) ? 1 : 3);
                    dataPoint3D4.dataPoint = ((!flag) ? dataPoint3D.dataPoint : dataPoint3D.dataPoint);
                    firstPoint             = ((!flag) ? dataPoint3D2 : dataPoint3D4);
                    secondPoint            = ((!flag) ? dataPoint3D4 : dataPoint3D);
                    break;
                }
                if (lineSegmentType == LineSegmentType.First || dataPoint3D6 == null)
                {
                    array[i] = new GraphicsPath();
                    array[i] = graph.Draw3DSurface(area, matrix, lightStyle, SurfaceNames.Top, positionZ, depth, backColor, dataPoint3D3.dataPoint.BorderColor, dataPoint3D3.dataPoint.BorderWidth, borderStyle, firstPoint, secondPoint, points, pointIndex, 0f, operationType, lineSegmentType, (byte)(base.showPointLines ? 1 : 0) != 0, false, area.reverseSeriesOrder, base.multiSeries, 0, true);
                }
                else
                {
                    if (!flag)
                    {
                        backColor = ((this.currentKagiDirection == -1) ? this.kagiUpColor : color);
                    }
                    array[i]                  = new GraphicsPath();
                    array[i]                  = graph.Draw3DSurface(area, matrix, lightStyle, SurfaceNames.Top, positionZ, depth, backColor, dataPoint3D3.dataPoint.BorderColor, dataPoint3D3.dataPoint.BorderWidth, borderStyle, firstPoint, dataPoint3D6, points, pointIndex, 0f, operationType, LineSegmentType.Middle, (byte)(base.showPointLines ? 1 : 0) != 0, false, area.reverseSeriesOrder, base.multiSeries, 0, true);
                    graph.frontLinePen        = null;
                    this.currentKagiDirection = ((this.currentKagiDirection != 1) ? 1 : (-1));
                    backColor                 = ((!flag) ? ((this.currentKagiDirection == -1) ? this.kagiUpColor : color) : ((this.currentKagiDirection == 1) ? this.kagiUpColor : color));
                    array[2]                  = new GraphicsPath();
                    array[2]                  = graph.Draw3DSurface(area, matrix, lightStyle, SurfaceNames.Top, positionZ, depth, backColor, dataPoint3D3.dataPoint.BorderColor, dataPoint3D3.dataPoint.BorderWidth, borderStyle, dataPoint3D6, secondPoint, points, pointIndex, 0f, operationType, lineSegmentType, (byte)(base.showPointLines ? 1 : 0) != 0, false, area.reverseSeriesOrder, base.multiSeries, 0, true);
                    if (!flag)
                    {
                        backColor = ((this.currentKagiDirection == 1) ? this.kagiUpColor : color);
                    }
                }
                graph.frontLinePen = null;
            }
            if (graphicsPath != null)
            {
                if (array[0] != null)
                {
                    graphicsPath.AddPath(array[0], true);
                }
                if (array[1] != null)
                {
                    graphicsPath.AddPath(array[1], true);
                }
                if (array[2] != null)
                {
                    graphicsPath.AddPath(array[2], true);
                }
            }
            return(graphicsPath);
        }
Ejemplo n.º 42
0
        protected override GraphicsPath Draw3DSurface(ChartArea area, ChartGraphics graph, Matrix3D matrix, LightStyle lightStyle, DataPoint3D prevDataPointEx, float positionZ, float depth, ArrayList points, int pointIndex, int pointLoopIndex, float tension, DrawingOperationTypes operationType, float topDarkening, float bottomDarkening, PointF thirdPointPosition, PointF fourthPointPosition, bool clippedSegment)
        {
            GraphicsPath graphicsPath = ((operationType & DrawingOperationTypes.CalcElementPath) == DrawingOperationTypes.CalcElementPath) ? new GraphicsPath() : null;

            if (base.centerPointIndex == 2147483647)
            {
                base.centerPointIndex = base.GetCenterPointIndex(points);
            }
            DataPoint3D dataPoint3D  = (DataPoint3D)points[pointIndex];
            int         num          = pointIndex;
            DataPoint3D dataPoint3D2 = ChartGraphics3D.FindPointByIndex(points, dataPoint3D.index - 1, base.multiSeries ? dataPoint3D : null, ref num);
            DataPoint3D dataPoint3D3 = dataPoint3D;

            if (prevDataPointEx.dataPoint.Empty)
            {
                dataPoint3D3 = prevDataPointEx;
            }
            else if (dataPoint3D2.index > dataPoint3D.index)
            {
                dataPoint3D3 = dataPoint3D2;
            }
            Color          backColor   = base.useBorderColor ? dataPoint3D3.dataPoint.BorderColor : dataPoint3D3.dataPoint.Color;
            ChartDashStyle borderStyle = dataPoint3D3.dataPoint.BorderStyle;

            if (dataPoint3D3.dataPoint.Empty && dataPoint3D3.dataPoint.Color == Color.Empty)
            {
                backColor = Color.Gray;
            }
            if (dataPoint3D3.dataPoint.Empty && dataPoint3D3.dataPoint.BorderStyle == ChartDashStyle.NotSet)
            {
                borderStyle = ChartDashStyle.Solid;
            }
            DataPoint3D dataPoint3D4 = new DataPoint3D();

            dataPoint3D4.xPosition = dataPoint3D.xPosition;
            dataPoint3D4.yPosition = dataPoint3D2.yPosition;
            bool flag = true;

            if (pointIndex + 1 < points.Count)
            {
                DataPoint3D dataPoint3D5 = (DataPoint3D)points[pointIndex + 1];
                if (dataPoint3D5.index == dataPoint3D2.index)
                {
                    flag = false;
                }
            }
            if (base.centerPointIndex != 2147483647 && pointIndex >= base.centerPointIndex)
            {
                flag = false;
            }
            GraphicsPath graphicsPath2;
            GraphicsPath graphicsPath3;

            if (flag)
            {
                dataPoint3D4.dataPoint = dataPoint3D.dataPoint;
                graphicsPath2          = graph.Draw3DSurface(area, matrix, lightStyle, SurfaceNames.Top, positionZ, depth, backColor, dataPoint3D3.dataPoint.BorderColor, dataPoint3D3.dataPoint.BorderWidth, borderStyle, dataPoint3D2, dataPoint3D4, points, pointIndex, 0f, operationType, LineSegmentType.First, (byte)(base.showPointLines ? 1 : 0) != 0, false, area.reverseSeriesOrder, base.multiSeries, 0, true);
                graph.frontLinePen     = null;
                dataPoint3D4.dataPoint = dataPoint3D2.dataPoint;
                graphicsPath3          = graph.Draw3DSurface(area, matrix, lightStyle, SurfaceNames.Top, positionZ, depth, backColor, dataPoint3D3.dataPoint.BorderColor, dataPoint3D3.dataPoint.BorderWidth, borderStyle, dataPoint3D4, dataPoint3D, points, pointIndex, 0f, operationType, LineSegmentType.Last, (byte)(base.showPointLines ? 1 : 0) != 0, false, area.reverseSeriesOrder, base.multiSeries, 0, true);
                graph.frontLinePen     = null;
            }
            else
            {
                dataPoint3D4.dataPoint = dataPoint3D2.dataPoint;
                graphicsPath3          = graph.Draw3DSurface(area, matrix, lightStyle, SurfaceNames.Top, positionZ, depth, backColor, dataPoint3D3.dataPoint.BorderColor, dataPoint3D3.dataPoint.BorderWidth, borderStyle, dataPoint3D4, dataPoint3D, points, pointIndex, 0f, operationType, LineSegmentType.Last, (byte)(base.showPointLines ? 1 : 0) != 0, false, area.reverseSeriesOrder, base.multiSeries, 0, true);
                graph.frontLinePen     = null;
                dataPoint3D4.dataPoint = dataPoint3D.dataPoint;
                graphicsPath2          = graph.Draw3DSurface(area, matrix, lightStyle, SurfaceNames.Top, positionZ, depth, backColor, dataPoint3D3.dataPoint.BorderColor, dataPoint3D3.dataPoint.BorderWidth, borderStyle, dataPoint3D2, dataPoint3D4, points, pointIndex, 0f, operationType, LineSegmentType.First, (byte)(base.showPointLines ? 1 : 0) != 0, false, area.reverseSeriesOrder, base.multiSeries, 0, true);
                graph.frontLinePen     = null;
            }
            if (graphicsPath != null)
            {
                if (area.Common.ProcessModeRegions && graphicsPath2 != null && graphicsPath2.PointCount > 0)
                {
                    area.Common.HotRegionsList.AddHotRegion(graphicsPath2, false, graph, prevDataPointEx.dataPoint, prevDataPointEx.dataPoint.series.Name, prevDataPointEx.index - 1);
                }
                if (graphicsPath3 != null && graphicsPath3.PointCount > 0)
                {
                    graphicsPath.AddPath(graphicsPath3, true);
                }
            }
            return(graphicsPath);
        }
Ejemplo n.º 43
0
 public void SetModify(LightStyle.Mod.Element element, float assignValue)
 {
     this.SetFaceValue(element, assignValue);
     LightStyle.Mod mask = this;
     mask.mask = mask.mask | LightStyle.Mod.ElementToMask(element);
 }
Ejemplo n.º 44
0
 /// <summary>
 /// Sets the user-defined <see cref="LightStyle"/> setting for the given index. 
 /// </summary>
 /// <param name="style">Style to set</param>
 /// <param name="charts">Reference to an array of <see cref="Chart"/> object.</param>
 public static void SetChartLighting(LightStyle style, ref Chart[] charts)
 {
     if (charts == null) return;
     foreach (Chart chart in charts)
         chart.ChartAreas[0].Area3DStyle.LightStyle = style;
 }
Ejemplo n.º 45
0
 public void ApplyTo(Light light, LightStyle.Mod.Mask applyMask)
 {
     LightStyle.Mod.Mask mask = this.mask & applyMask;
     if ((int)(mask & (LightStyle.Mod.Mask.Red | LightStyle.Mod.Mask.Green | LightStyle.Mod.Mask.Blue | LightStyle.Mod.Mask.Alpha)) != 0)
     {
         if ((mask & (LightStyle.Mod.Mask.Red | LightStyle.Mod.Mask.Green | LightStyle.Mod.Mask.Blue | LightStyle.Mod.Mask.Alpha)) != (LightStyle.Mod.Mask.Red | LightStyle.Mod.Mask.Green | LightStyle.Mod.Mask.Blue | LightStyle.Mod.Mask.Alpha))
         {
             Color color = light.color;
             if ((mask & LightStyle.Mod.Mask.Red) == LightStyle.Mod.Mask.Red)
             {
                 color.r = this.r;
             }
             if ((mask & LightStyle.Mod.Mask.Green) == LightStyle.Mod.Mask.Green)
             {
                 color.g = this.g;
             }
             if ((mask & LightStyle.Mod.Mask.Blue) == LightStyle.Mod.Mask.Blue)
             {
                 color.b = this.b;
             }
             if ((mask & LightStyle.Mod.Mask.Alpha) == LightStyle.Mod.Mask.Alpha)
             {
                 color.a = this.a;
             }
             light.color = color;
         }
         else
         {
             light.color = this.color;
         }
     }
     if ((mask & LightStyle.Mod.Mask.Intensity) == LightStyle.Mod.Mask.Intensity)
     {
         light.intensity = this.intensity;
     }
     if ((mask & LightStyle.Mod.Mask.Range) == LightStyle.Mod.Mask.Range)
     {
         light.range = this.range;
     }
     if ((mask & LightStyle.Mod.Mask.SpotAngle) == LightStyle.Mod.Mask.SpotAngle)
     {
         light.spotAngle = this.spotAngle;
     }
 }
        /// <summary>
        /// Draws a 3D surface connecting the two specified points in 2D space.
        /// Used to draw Line based charts.
        /// </summary>
        /// <param name="area">Chart area reference.</param>
        /// <param name="graph">Chart graphics.</param>
        /// <param name="matrix">Coordinates transformation matrix.</param>
        /// <param name="lightStyle">LightStyle style (None, Simplistic, Realistic).</param>
        /// <param name="prevDataPointEx">Previous data point object.</param>
        /// <param name="positionZ">Z position of the back side of the 3D surface.</param>
        /// <param name="depth">Depth of the 3D surface.</param>
        /// <param name="points">Array of points.</param>
        /// <param name="pointIndex">Index of point to draw.</param>
        /// <param name="pointLoopIndex">Index of points loop.</param>
        /// <param name="tension">Line tension.</param>
        /// <param name="operationType">AxisName of operation Drawing, Calculating Path or Both</param>
        /// <param name="topDarkening">Darkenning scale for top surface. 0 - None.</param>
        /// <param name="bottomDarkening">Darkenning scale for bottom surface. 0 - None.</param>
        /// <param name="thirdPointPosition">Position where the third point is actually located or float.NaN if same as in "firstPoint".</param>
        /// <param name="fourthPointPosition">Position where the fourth point is actually located or float.NaN if same as in "secondPoint".</param>
        /// <param name="clippedSegment">Indicates that drawn segment is 3D clipped. Only top/bottom should be drawn.</param>
        /// <returns>Returns elemnt shape path if operationType parameter is set to CalcElementPath, otherwise Null.</returns>
        protected override GraphicsPath Draw3DSurface(
            ChartArea area,
            ChartGraphics graph,
            Matrix3D matrix,
            LightStyle lightStyle,
            DataPoint3D prevDataPointEx,
            float positionZ,
            float depth,
            ArrayList points,
            int pointIndex,
            int pointLoopIndex,
            float tension,
            DrawingOperationTypes operationType,
            float topDarkening,
            float bottomDarkening,
            PointF thirdPointPosition,
            PointF fourthPointPosition,
            bool clippedSegment)
        {
            // Create graphics path for selection
            GraphicsPath resultPath = ((operationType & DrawingOperationTypes.CalcElementPath) == DrawingOperationTypes.CalcElementPath)
                                ? new GraphicsPath() : null;

            // Check if points are drawn from sides to center (do only once)
            if (centerPointIndex == int.MaxValue)
            {
                centerPointIndex = GetCenterPointIndex(points);
            }

            //************************************************************
            //** Find line first & second points
            //************************************************************
            DataPoint3D secondPoint     = (DataPoint3D)points[pointIndex];
            int         pointArrayIndex = pointIndex;
            DataPoint3D firstPoint      = ChartGraphics.FindPointByIndex(
                points,
                secondPoint.index - 1,
                (this.multiSeries) ? secondPoint : null,
                ref pointArrayIndex);

            // Fint point with line properties
            DataPoint3D pointAttr = secondPoint;

            if (prevDataPointEx.dataPoint.IsEmpty)
            {
                pointAttr = prevDataPointEx;
            }
            else if (firstPoint.index > secondPoint.index)
            {
                pointAttr = firstPoint;
            }

            // Adjust point visual properties
            Color          color     = (useBorderColor) ? pointAttr.dataPoint.BorderColor : pointAttr.dataPoint.Color;
            ChartDashStyle dashStyle = pointAttr.dataPoint.BorderDashStyle;

            if (pointAttr.dataPoint.IsEmpty && pointAttr.dataPoint.Color == Color.Empty)
            {
                color = Color.Gray;
            }
            if (pointAttr.dataPoint.IsEmpty && pointAttr.dataPoint.BorderDashStyle == ChartDashStyle.NotSet)
            {
                dashStyle = ChartDashStyle.Solid;
            }

            // Set up kagi chart
            if (currentKagiDirection == 0)
            {
                // Get up price color
                this.kagiUpColor = secondPoint.dataPoint.series.Color;
                string         priceUpColorString = secondPoint.dataPoint.series[CustomPropertyName.PriceUpColor];
                ColorConverter colorConverter     = new ColorConverter();
                if (priceUpColorString != null)
                {
                    try
                    {
                        this.kagiUpColor = (Color)colorConverter.ConvertFromString(null, CultureInfo.InvariantCulture, priceUpColorString);
                    }
                    catch
                    {
                        throw(new InvalidOperationException(SR.ExceptionKagiAttributeFormatInvalid("Up Brick color")));
                    }
                }

                // Check direction of first line (up or down)
                currentKagiDirection = (firstPoint.yPosition > secondPoint.yPosition) ?
                                       1 : -1;
            }

            // Set up movement colors and width
            Color lineColor = (currentKagiDirection == 1) ? this.kagiUpColor : color;

            //************************************************************
            //** Create "middle" point
            //************************************************************
            DataPoint3D middlePoint = new DataPoint3D();

            middlePoint.xPosition = secondPoint.xPosition;
            middlePoint.yPosition = firstPoint.yPosition;

            // Check if reversed drawing order required
            bool originalDrawOrder = true;

            if ((pointIndex + 1) < points.Count)
            {
                DataPoint3D p = (DataPoint3D)points[pointIndex + 1];
                if (p.index == firstPoint.index)
                {
                    originalDrawOrder = false;
                }
            }

            // Check in which order vertical & horizontal lines segments should be drawn
            if (centerPointIndex != int.MaxValue)
            {
                if (pointIndex >= centerPointIndex)
                {
                    originalDrawOrder = false;
                }
            }


            // Check if vertical line should be draw as to segments of different color
            DataPoint3D vertSplitPoint = null;

            if (secondPoint.index >= 3)            //Point3D.index is 1 based
            {
                // Check current direction
                int direction = (firstPoint.yPosition > secondPoint.yPosition) ?
                                1 : -1;

                // Proceed only when direction is changed
                if (direction != currentKagiDirection)
                {
                    // Find prev line low & high
                    DataPoint3D prevPoint = ChartGraphics.FindPointByIndex(
                        points,
                        secondPoint.index - 2,
                        (this.multiSeries) ? secondPoint : null,
                        ref pointArrayIndex);

                    bool twoVertSegments = false;
                    if (firstPoint.yPosition > prevPoint.yPosition &&
                        firstPoint.yPosition > secondPoint.yPosition &&
                        prevPoint.yPosition > secondPoint.yPosition)
                    {
                        twoVertSegments = true;
                    }
                    else if (firstPoint.yPosition < prevPoint.yPosition &&
                             firstPoint.yPosition < secondPoint.yPosition &&
                             prevPoint.yPosition < secondPoint.yPosition)
                    {
                        twoVertSegments = true;
                    }

                    if (twoVertSegments)
                    {
                        vertSplitPoint           = new DataPoint3D();
                        vertSplitPoint.xPosition = secondPoint.xPosition;
                        vertSplitPoint.yPosition = prevPoint.yPosition;
                        vertSplitPoint.dataPoint = secondPoint.dataPoint;
                    }
                }
            }

            // Draw two or three segments of the step line
            GraphicsPath[] resultPathLine = new GraphicsPath[3];
            for (int segmentIndex = 0; segmentIndex < 2; segmentIndex++)
            {
                DataPoint3D     point1 = firstPoint, point2 = secondPoint;
                LineSegmentType lineSegmentType = LineSegmentType.First;

                if (segmentIndex == 0)
                {
                    lineSegmentType       = (originalDrawOrder) ? LineSegmentType.First : LineSegmentType.Last;
                    middlePoint.dataPoint = (originalDrawOrder) ? secondPoint.dataPoint : firstPoint.dataPoint;
                    point1 = (originalDrawOrder) ? firstPoint : middlePoint;
                    point2 = (originalDrawOrder) ? middlePoint : secondPoint;
                }
                else if (segmentIndex == 1)
                {
                    lineSegmentType       = (!originalDrawOrder) ? LineSegmentType.First : LineSegmentType.Last;
                    middlePoint.dataPoint = (!originalDrawOrder) ? secondPoint.dataPoint : secondPoint.dataPoint;
                    point1 = (!originalDrawOrder) ? firstPoint : middlePoint;
                    point2 = (!originalDrawOrder) ? middlePoint : secondPoint;
                }

                // Draw horizontal surface
                if (lineSegmentType == LineSegmentType.First ||
                    vertSplitPoint == null)
                {
                    resultPathLine[segmentIndex] = new GraphicsPath();
                    resultPathLine[segmentIndex] = graph.Draw3DSurface(
                        area, matrix, lightStyle, SurfaceNames.Top, positionZ, depth, lineColor,
                        pointAttr.dataPoint.BorderColor, pointAttr.dataPoint.BorderWidth, dashStyle,
                        point1, point2,
                        points, pointIndex, 0f, operationType, lineSegmentType,
                        (this.showPointLines) ? true : false, false,
                        area.ReverseSeriesOrder,
                        this.multiSeries, 0, true);
                }
                else
                {
                    if (!originalDrawOrder)
                    {
                        lineColor = (currentKagiDirection == -1) ? this.kagiUpColor : color;
                    }

                    // Draw verticla line as two segments
                    resultPathLine[segmentIndex] = new GraphicsPath();
                    resultPathLine[segmentIndex] = graph.Draw3DSurface(
                        area, matrix, lightStyle, SurfaceNames.Top, positionZ, depth, lineColor,
                        pointAttr.dataPoint.BorderColor, pointAttr.dataPoint.BorderWidth, dashStyle,
                        point1, vertSplitPoint,
                        points, pointIndex, 0f, operationType, LineSegmentType.Middle,
                        (this.showPointLines) ? true : false, false,
                        area.ReverseSeriesOrder,
                        this.multiSeries, 0, true);

                    // No second draw of the prev. front line required
                    graph.frontLinePen = null;

                    // Change direction
                    currentKagiDirection = (currentKagiDirection == 1) ? -1 : 1;

                    // Set color
                    if (originalDrawOrder)
                    {
                        lineColor = (currentKagiDirection == 1) ? this.kagiUpColor : color;
                    }
                    else
                    {
                        lineColor = (currentKagiDirection == -1) ? this.kagiUpColor : color;
                    }

                    resultPathLine[2] = new GraphicsPath();
                    resultPathLine[2] = graph.Draw3DSurface(
                        area, matrix, lightStyle, SurfaceNames.Top, positionZ, depth, lineColor,
                        pointAttr.dataPoint.BorderColor, pointAttr.dataPoint.BorderWidth, dashStyle,
                        vertSplitPoint, point2,
                        points, pointIndex, 0f, operationType, lineSegmentType,
                        (this.showPointLines) ? true : false, false,
                        area.ReverseSeriesOrder,
                        this.multiSeries, 0, true);

                    if (!originalDrawOrder)
                    {
                        lineColor = (currentKagiDirection == 1) ? this.kagiUpColor : color;
                    }
                }

                // No second draw of the prev. front line required
                graph.frontLinePen = null;
            }

            if (resultPath != null)
            {
                if (resultPathLine[0] != null)
                {
                    resultPath.AddPath(resultPathLine[0], true);
                }
                if (resultPathLine[1] != null)
                {
                    resultPath.AddPath(resultPathLine[1], true);
                }
                if (resultPathLine[2] != null)
                {
                    resultPath.AddPath(resultPathLine[2], true);
                }
            }
            return(resultPath);
        }
Ejemplo n.º 47
0
 public bool AnyOf(LightStyle.Mod.Mask mask)
 {
     return (int)(this.mask & mask) != 0;
 }
Ejemplo n.º 48
0
 public bool CrossFade(LightStyle style)
 {
     return(this.CrossFade(style, 0.3f));
 }
Ejemplo n.º 49
0
 public void ToggleModify(LightStyle.Mod.Element element)
 {
     LightStyle.Mod mask = this;
     mask.mask = mask.mask ^ LightStyle.Mod.ElementToMask(element);
 }