Advertisement
Guest User

Untitled

a guest
May 27th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.26 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using Assets.Plugins.SVLTools.Extensions;
  3. using Assets.Plugins.SVLTools.Init;
  4. using Assets.Scripts.CoordinateSystems;
  5. using UnityEngine;
  6.  
  7. namespace Assets.Scripts.SpaceObjects.Components.Infographic.Trajectory
  8. {
  9.     public class TrajectoryGlLinesRenderer : InitableCacheBehaviour,
  10.         ITrajectoryRenderer
  11.     {
  12.         #region Private
  13.  
  14.         private readonly List<Vector3> _points = new List<Vector3>();
  15.  
  16.         private CoordinateSystem _coordinateSystem;
  17.  
  18.         #endregion
  19.  
  20.         #region Public
  21.  
  22.         public Material LinesMaterial;
  23.  
  24.         #endregion
  25.        
  26.         #region Interface
  27.  
  28.         public override void Init()
  29.         {
  30.             base.Init();
  31.  
  32.             _coordinateSystem = gameObject.GetComponentInParent<CoordinateSystem>();
  33.         }
  34.  
  35.         public float Width { get; set; }
  36.  
  37.         public void AddFirst(Vector3d point)
  38.         {
  39.             _points.Add(CoordinateToUnit(point));
  40.         }
  41.  
  42.         public void RemoveFirst()
  43.         {
  44.             _points.RemoveAt(0);
  45.         }
  46.  
  47.         public void RemoveLast()
  48.         {
  49.             _points.RemoveAt(_points.Count - 1);
  50.         }
  51.  
  52.         public void Set(Vector3d point, int index)
  53.         {
  54.             _points[index] = CoordinateToUnit(point);
  55.         }
  56.  
  57.         public void Clear()
  58.         {
  59.             _points.Clear();
  60.         }
  61.  
  62.         public void CloseCurve(bool value)
  63.         {
  64.         }
  65.  
  66.         public void SetTrajectoryVisibleLength(float length)
  67.         {
  68.         }
  69.  
  70.         public void SetTailOpacity(float tailOpacity)
  71.         {
  72.         }
  73.  
  74.         #endregion
  75.  
  76.         #region Logic
  77.  
  78.         private Vector3 CoordinateToUnit(Vector3d coordinate)
  79.         {
  80.             return (coordinate * _coordinateSystem.BaseCoordinateToUnitK).ToVector3();
  81.         }
  82.  
  83.         private void OnRenderObject()
  84.         {
  85.             //if (Camera.current.cullingMask != (Camera.current.cullingMask | 1 << gameObject.layer))
  86.             //  return;
  87.  
  88.             //LinesMaterial.SetPass(0);
  89.  
  90.             //GL.PushMatrix();
  91.  
  92.             //GL.MultMatrix(transform.localToWorldMatrix);
  93.  
  94.             //GL.Begin(GL.LINES);
  95.  
  96.             //GL.Color(new Color(1, 1, 1, 1F));
  97.  
  98.             //var last = _points[0];
  99.             //for (int i = 1; i < _points.Count - 1; ++i)
  100.             //{
  101.             //  var first = _points[i];
  102.             //  GL.Vertex3(last.x, last.y, last.z);
  103.             //  GL.Vertex3(first.x, first.y, first.z);
  104.             //  last = first;
  105.             //}
  106.  
  107.             //GL.End();
  108.  
  109.             //GL.PopMatrix();
  110.         }
  111.  
  112.         void OnDrawGizmos()
  113.         {
  114.             for (int i = 0; i < _points.Count - 2; ++i)
  115.                 Debug.DrawLine(_points[i], _points[i+1], Color.green);
  116.         }
  117.  
  118.         #endregion
  119.     }
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement