예제 #1
0
파일: Markers.cs 프로젝트: RealGrep/NavHud
 public void SetValues(Values values)
 {
     // The colors of the Particles/Additive shader turn out to be twice as bright.. somehow..?
     // So I'll multiply by scaleColor to compensate.
     Color scaleColor = new Color(0.5f, 0.5f, 0.5f, 0.5f);
     _r = values.Distance;
     _objects[Prograde   ].GetComponent<Renderer>().material.SetColor("_TintColor", values.ProgradeColor * scaleColor);
     _objects[Retrograde ].GetComponent<Renderer>().material.SetColor("_TintColor", values.ProgradeColor * scaleColor);
     _objects[Normal     ].GetComponent<Renderer>().material.SetColor("_TintColor", values.NormalColor * scaleColor);
     _objects[Antinormal ].GetComponent<Renderer>().material.SetColor("_TintColor", values.NormalColor * scaleColor);
     _objects[Radial     ].GetComponent<Renderer>().material.SetColor("_TintColor", values.RadialColor * scaleColor);
     _objects[Antiradial ].GetComponent<Renderer>().material.SetColor("_TintColor", values.RadialColor * scaleColor);
     _objects[Target     ].GetComponent<Renderer>().material.SetColor("_TintColor", values.TargetColor * scaleColor);
     _objects[Antitarget ].GetComponent<Renderer>().material.SetColor("_TintColor", values.TargetColor * scaleColor);
     _objects[Maneuver   ].GetComponent<Renderer>().material.SetColor("_TintColor", values.ManeuverColor * scaleColor);
     for (int i = 0; i < 9; i++)
     {
         _objects[i].transform.localScale = values.VectorSize * Vector3.one;
     }
 }
예제 #2
0
 public void SetValues(Values values)
 {
     _r = values.Distance;
     _object.transform.localScale = values.VectorSize * Vector3.one;
 }
예제 #3
0
        public void SetValues(Values values)
        {
            _lineWidth = values.LineWidth;
            _r = values.Distance;

            for (int i = 0; i < _lines.Length; i++)
            {
                _lines[i].SetWidth(_lineWidth, _lineWidth);
                _lines[i].SetColors(values.AlignmentColor, values.AlignmentColor);
            }
        }
예제 #4
0
        public void SetValues(Values values)
        {
            _length = values.NumberAzimuthLinesQuarter * 4;

            double r = values.Distance;
            int oldLength = _lines.Length;
            if (oldLength < _length)
            {
                Array.Resize(ref _lines, _length);
                Array.Resize(ref _objects, _length);

                for (int i = oldLength; i < _lines.Length; i++)
                {
                    _objects[i] = new GameObject();
                    // layers 0,1,15,19 <32
                    _objects[i].layer = 7;

                    // Add line
                    _lines[i] = _objects[i].AddComponent< LineRenderer >() as LineRenderer;
                    _lines[i].GetComponent<Renderer>().material = new Material(Shader.Find("Particles/Additive"));
                }
            }

            float t;
            float p;

            for (int i = 0; i < _lines.Length; i++)
            {
                _lines[i].SetWidth(values.LineWidth, values.LineWidth);
                _lines[i].SetVertexCount(values.NumberAzimuthVerts);

                p = 2 * i * Mathf.PI / _length;
                for (int j = 0; j < values.NumberAzimuthVerts; j++)
                {
                    t = Mathf.PI * ((float)j / (values.NumberAzimuthVerts - 1) - 0.5f);
                    _lines[i].SetPosition(j, r * new Vector3d(Mathf.Cos(p) * Mathf.Cos(t), Mathf.Sin(p) * Mathf.Cos(t), Mathf.Sin(t)));
                }
                _objects[i].SetActive(_active);
            }

            for (int i = _length; i < _objects.Length; i++)
            {
                _objects[i].SetActive(false);
            }

            for (int i = 0; i < _length; i++)
            {
                if (i % values.NumberAzimuthLinesQuarter != 0)
                {
                    _lines[i].SetColors(values.AzimuthColor, values.AzimuthColor);
                }
            }
            _lines[0].SetColors(values.NorthColor, values.NorthColor);
            _lines[values.NumberAzimuthLinesQuarter].SetColors(values.EastColor, values.EastColor);
            _lines[2 * values.NumberAzimuthLinesQuarter].SetColors(values.SouthColor, values.SouthColor);
            _lines[3 * values.NumberAzimuthLinesQuarter].SetColors(values.WestColor, values.WestColor);

            if (_hasParent)
            {
                SetParent(_parent);
            }
        }
예제 #5
0
파일: NavHud.cs 프로젝트: plague006/NavHud
        private void OnMainWindow(int windowID)
        {
            GUILayout.BeginHorizontal(GUILayout.Width(450f));
            GUILayout.BeginVertical(GUILayout.Width(200f));

            GUILayout.BeginHorizontal();
            Enabled = GUILayout.Toggle(Enabled, "Show HUD", GUILayout.ExpandWidth(true));
            _settingKeyBinding ^= GUILayout.Button("[" + (_settingKeyBinding ? "???" : _toggleKey.ToString()) + "]", GUILayout.Width(40f));
            GUILayout.EndHorizontal();
            MarkersEnabled = GUILayout.Toggle(MarkersEnabled, "Show markers");
            LinesEnabled = GUILayout.Toggle(LinesEnabled, "Show lines");
            WaypointEnabled = GUILayout.Toggle(WaypointEnabled, "Show waypoint");
            EnableMap = GUILayout.Toggle(EnableMap, "Show in map");
            EnableText = GUILayout.Toggle(EnableText, "Show HUD text");
            HideWithUI = GUILayout.Toggle(HideWithUI, "Hide with UI");
            LockText = GUILayout.Toggle(LockText, "Lock HUD text");

            if (GUILayout.Button("Reset"))
            {
                _values = new Values();
                _behaviour.Values = _values;
            }

            GUILayout.EndVertical();
            GUILayout.BeginVertical(GUILayout.Width(250f));

            _sizeScrollPos = GUILayout.BeginScrollView(_sizeScrollPos, false, false, GUILayout.Height(220f));

            GUIStyle labelStyle = new GUIStyle(HighLogic.Skin.label);
            labelStyle.alignment = TextAnchor.MiddleCenter;

            GUILayout.Label("Vector size", labelStyle);
            _values.VectorSize = GUILayout.HorizontalSlider(_values.VectorSize, 0.001f, 0.1f);
            GUILayout.Label("Line width", labelStyle);
            _values.LineWidth = GUILayout.HorizontalSlider(_values.LineWidth, 0.0001f, 0.01f);

            GUILayout.Label("# of Altitude lines", labelStyle);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("-", GUILayout.Width(40f)) & _values.NumberZenithLinesHalf > 0)
            {
                _values.NumberZenithLinesHalf--;
            }
            _values.NumberZenithLinesHalf = (int.Parse(GUILayout.TextField((_values.NumberZenithLinesHalf * 2 + 1).ToString())) - 1) / 2;
            if (GUILayout.Button("+", GUILayout.Width(40f)))
            {
                _values.NumberZenithLinesHalf++;
            }
            GUILayout.EndHorizontal();

            GUILayout.Label("# of Azimuth lines", labelStyle);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("-", GUILayout.Width(40f)) & _values.NumberAzimuthLinesQuarter > 1)
            {
                _values.NumberAzimuthLinesQuarter--;
            }
            _values.NumberAzimuthLinesQuarter = int.Parse(GUILayout.TextField((_values.NumberAzimuthLinesQuarter * 4).ToString())) / 4;
            if (GUILayout.Button("+", GUILayout.Width(40f)))
            {
                _values.NumberAzimuthLinesQuarter++;
            }
            GUILayout.EndHorizontal();

            GUILayout.EndScrollView();

            /*
            if(GUILayout.Button("Cameras?")){
                for(int i=0; i<Camera.allCameras.Length; i++){
                    Debug.Log(i+": "+Camera.allCameras[i].ToString()+"  "+Camera.allCameras[i].depth+"  "+Camera.allCameras[i].cullingMask);
                }
            }
            */

            GUILayout.Label("Colors", labelStyle, GUILayout.ExpandWidth(true));
            _colorScrollPos = GUILayout.BeginScrollView(_colorScrollPos, false, false, GUILayout.Height(250f));
            if (ColorButton(_values.HudTextColor, "HUD Text Color")) OnColorWindow = OnColorWindowHudText;
            GUILayout.Label("Markers", labelStyle, GUILayout.ExpandWidth(true));
            if (ColorButton(_values.HeadingColor, "Heading")) OnColorWindow = OnColorWindowHeading;
            if (ColorButton(_values.ProgradeColor, "Velocity")) OnColorWindow = OnColorWindowPrograde;
            if (ColorButton(_values.NormalColor, "Normal")) OnColorWindow = OnColorWindowNormal;
            if (ColorButton(_values.RadialColor, "Radial")) OnColorWindow = OnColorWindowRadial;
            if (ColorButton(_values.TargetColor, "Target")) OnColorWindow = OnColorWindowTarget;
            if (ColorButton(_values.AlignmentColor, "Alignment")) OnColorWindow = OnColorWindowAlignment;
            if (ColorButton(_values.ManeuverColor, "Maneuver")) OnColorWindow = OnColorWindowManeuver;
            GUILayout.Label("Lines", labelStyle, GUILayout.ExpandWidth(true));
            if (ColorButton(_values.HorizonColor, "Horizon")) OnColorWindow = OnColorWindowHorizon;
            if (ColorButton(_values.NorthColor, "North")) OnColorWindow = OnColorWindowNorth;
            if (ColorButton(_values.EastColor, "East")) OnColorWindow = OnColorWindowEast;
            if (ColorButton(_values.SouthColor, "South")) OnColorWindow = OnColorWindowSouth;
            if (ColorButton(_values.WestColor, "West")) OnColorWindow = OnColorWindowWest;
            if (ColorButton(_values.UpperHalfColor, "Upper half")) OnColorWindow = OnColorWindowUpperHalf;
            if (ColorButton(_values.LowerHalfColor, "Lower half")) OnColorWindow = OnColorWindowLowerHalf;
            if (ColorButton(_values.AzimuthColor, "Vertical")) OnColorWindow = OnColorWindowAzimuth;
            GUILayout.EndScrollView();

            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            if (_values.IChanged)
            {
                _behaviour.Values = _values;
                Debug.Log("NavHUD settings changed.");
            }
            GUI.DragWindow();
        }
예제 #6
0
        public void SetValues(Values values)
        {
            _r = values.Distance;
            _size = values.VectorSize;

            _lines[0].SetWidth(values.LineWidth, values.LineWidth);
            _lines[1].SetWidth(1f * _size, 0.0f);
            _lines[2].SetWidth(values.LineWidth, values.LineWidth);
            _lines[3].SetWidth(1f * _size, 0.0f);

            for (int i = 0; i < _lines.Length; i++)
            {
                _lines[i].SetColors(values.HeadingColor, values.HeadingColor);
            }
        }
예제 #7
0
 /*
 private void SetActive()
 {
     _zenithLines.SetActive(_active && _linesEnabled);
     _azimuthLines.SetActive(_active && _linesEnabled);
     _markers.SetDirectionsActive(_active && _markersEnabled);
     _targetAlignmentMarker.SetActive(_active && _markersEnabled && _alignActive);
     _markers.SetManeuverActive(_active && _markersEnabled && _maneuverActive);
     _markers.SetTargetActive(_active && _markersEnabled && _targetActive);
     _edgeMarkers.SetDirectionsActive(_active && _markersEnabled && _edgeMarkersEnabled);
     _edgeMarkers.SetAlignmentActive(_active && _markersEnabled && _edgeMarkersEnabled && _alignActive);
     _edgeMarkers.SetManeuverActive(_active && _markersEnabled && _edgeMarkersEnabled && _maneuverActive);
     _edgeMarkers.SetTargetActive(_active && _markersEnabled && _edgeMarkersEnabled && _targetActive);
 }*/
 private void SetValues(Values values)
 {
     _headingMarker.SetValues(values);
     _zenithLines.SetValues(values);
     _azimuthLines.SetValues(values);
     _targetAlignmentMarker.SetValues(values);
     _markers.SetValues(values);
     _waypointMarker.SetValues(values);
     _edgeMarkers.SetValues(values);
 }
예제 #8
0
 public void SetValues(Values values)
 {
     _r = (float)values.Distance;
     _lines[Prograde     ].SetColors(values.ProgradeColor, values.ProgradeColor);
     _lines[Retrograde   ].SetColors(values.ProgradeColor, values.ProgradeColor);
     _lines[Normal       ].SetColors(values.NormalColor, values.NormalColor);
     _lines[Antinormal   ].SetColors(values.NormalColor, values.NormalColor);
     _lines[Radial       ].SetColors(values.RadialColor, values.RadialColor);
     _lines[Antiradial   ].SetColors(values.RadialColor, values.RadialColor);
     _lines[Target       ].SetColors(values.TargetColor, values.TargetColor);
     _lines[Antitarget   ].SetColors(values.TargetColor, values.TargetColor);
     _lines[Maneuver     ].SetColors(values.ManeuverColor, values.ManeuverColor);
     _lines[Heading      ].SetColors(values.HeadingColor, values.HeadingColor);
     _lines[Antiheading  ].SetColors(values.HeadingColor, values.HeadingColor);
     _lines[Alignment    ].SetColors(values.AlignmentColor, values.AlignmentColor);
     _lines[Antialignment].SetColors(values.AlignmentColor, values.AlignmentColor);
     for (int i = 0; i < _lines.Length; i++)
     {
         _lines[i].SetWidth(0f, 0.01f*_r);
     }
 }
예제 #9
0
        public void SetValues(Values values)
        {
            _length = values.NumberZenithLinesHalf * 2 + 1;

            double r = values.Distance;
            int oldLength = _lines.Length;
            if (oldLength < _length)
            {
                Array.Resize(ref _lines, _length);
                Array.Resize(ref _objects, _length);

                for (int i = oldLength; i < _lines.Length; i++)
                {
                    _objects[i] = new GameObject();
                    // layers 0,1,15,19 <32
                    _objects[i].layer = 7;

                    // Add line
                    _lines[i] = _objects[i].AddComponent< LineRenderer >() as LineRenderer;
                    _lines[i].GetComponent<Renderer>().material = new Material(Shader.Find("Particles/Additive"));
                }
            }

            float t;
            float p;

            for (int i = 0; i < _length; i++)
            {
                _lines[i].SetWidth(values.LineWidth, values.LineWidth);
                _lines[i].SetVertexCount(values.NumberZenithVerts);

                p = Mathf.PI * ((float)(i + 1) / (_length + 1) - 0.5f);
                for (int j = 0; j < values.NumberZenithVerts; j++)
                {
                    t = 2 * j * Mathf.PI / (values.NumberZenithVerts - 1);
                    _lines[i].SetPosition(j, r * new Vector3d(-Mathf.Sin(t) * Mathf.Cos(p), Mathf.Cos(t) * Mathf.Cos(p), Mathf.Sin(p)));
                }
                _objects[i].SetActive(_active);
            }

            for (int i = _length; i < _objects.Length; i++)
            {
                _objects[i].SetActive(false);
            }

            for (int i = 0; i < values.NumberZenithLinesHalf; i++)
            {
                _lines[i].SetColors(values.LowerHalfColor, values.LowerHalfColor);
            }
            for (int i = values.NumberZenithLinesHalf + 1; i < _length; i++)
            {
                _lines[i].SetColors(values.UpperHalfColor, values.UpperHalfColor);
            }
            _lines[values.NumberZenithLinesHalf].SetColors(values.HorizonColor, values.HorizonColor);

            if (_hasParent)
            {
                SetParent(_parent);
            }
        }
예제 #10
0
 public void SetValues(Values values)
 {
     _r = values.Distance;
     _object.transform.localScale = values.VectorSize * Vector3.one;
 }