Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using Assets.Plugins.SVLTools.Extensions;
- using Assets.Plugins.SVLTools.Init;
- using Assets.Scripts.CoordinateSystems;
- using UnityEngine;
- namespace Assets.Scripts.SpaceObjects.Components.Infographic.Trajectory
- {
- public class TrajectoryGlLinesRenderer : InitableCacheBehaviour,
- ITrajectoryRenderer
- {
- #region Private
- private readonly List<Vector3> _points = new List<Vector3>();
- private CoordinateSystem _coordinateSystem;
- #endregion
- #region Public
- public Material LinesMaterial;
- #endregion
- #region Interface
- public override void Init()
- {
- base.Init();
- _coordinateSystem = gameObject.GetComponentInParent<CoordinateSystem>();
- }
- public float Width { get; set; }
- public void AddFirst(Vector3d point)
- {
- _points.Add(CoordinateToUnit(point));
- }
- public void RemoveFirst()
- {
- _points.RemoveAt(0);
- }
- public void RemoveLast()
- {
- _points.RemoveAt(_points.Count - 1);
- }
- public void Set(Vector3d point, int index)
- {
- _points[index] = CoordinateToUnit(point);
- }
- public void Clear()
- {
- _points.Clear();
- }
- public void CloseCurve(bool value)
- {
- }
- public void SetTrajectoryVisibleLength(float length)
- {
- }
- public void SetTailOpacity(float tailOpacity)
- {
- }
- #endregion
- #region Logic
- private Vector3 CoordinateToUnit(Vector3d coordinate)
- {
- return (coordinate * _coordinateSystem.BaseCoordinateToUnitK).ToVector3();
- }
- private void OnRenderObject()
- {
- //if (Camera.current.cullingMask != (Camera.current.cullingMask | 1 << gameObject.layer))
- // return;
- //LinesMaterial.SetPass(0);
- //GL.PushMatrix();
- //GL.MultMatrix(transform.localToWorldMatrix);
- //GL.Begin(GL.LINES);
- //GL.Color(new Color(1, 1, 1, 1F));
- //var last = _points[0];
- //for (int i = 1; i < _points.Count - 1; ++i)
- //{
- // var first = _points[i];
- // GL.Vertex3(last.x, last.y, last.z);
- // GL.Vertex3(first.x, first.y, first.z);
- // last = first;
- //}
- //GL.End();
- //GL.PopMatrix();
- }
- void OnDrawGizmos()
- {
- for (int i = 0; i < _points.Count - 2; ++i)
- Debug.DrawLine(_points[i], _points[i+1], Color.green);
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement