Example #1
0
    void Awake()
    {
        if (_statistics == null)
        {
            _statistics = gameObject.GetComponent <FlightStatistics>();
        }

        _collisionIndicatorRenderer = _collisionIndicator.GetComponent <Renderer>();
        _collisionIndicatorLight    = _collisionIndicator.GetComponent <Light>();

        _collisionIndicatorRenderer.gameObject.SetActive(false);

        InitializeLine();

        Transform lineParent = AerodynamicsVisualizationManager.GetOrCreateLineParent();

        // _line.rectTransform.SetParent(lineParent);

        _isVisualizationActive = true;
    }
    void Awake()
    {
        if (_segments.Length < 3)
        {
            Debug.LogError("At least three segment profiles need to be defined!");
        }

        _trailObject = new GameObject(gameObject.name + "_TrailMesh");

        Transform lineParent = AerodynamicsVisualizationManager.GetOrCreateLineParent();

        _trailObject.transform.parent = lineParent;

        MeshFilter meshFilter = _trailObject.AddComponent <MeshFilter>();

        _mesh = meshFilter.mesh;
        _mesh.MarkDynamic();

        _meshRenderer                      = _trailObject.AddComponent <MeshRenderer>();
        _instanceMaterial                  = new Material(_material);
        _meshRenderer.material             = _instanceMaterial;
        _meshRenderer.shadowCastingMode    = ShadowCastingMode.Off;
        _meshRenderer.reflectionProbeUsage = ReflectionProbeUsage.Off;
        _meshRenderer.receiveShadows       = false;
        _meshRenderer.enabled              = false;

        _vertices   = new Vector3[(_maxPoints + 1) * 2];
        _uvs        = new Vector2[(_maxPoints + 1) * 2];
        _triangles  = new int[_maxPoints * 6];
        _meshColors = new Color[(_maxPoints + 1) * 2];

        _points              = new CircularBuffer <Point>(_maxPoints);
        _pointPositions      = new CircularBuffer <Vector3>(_maxPoints);
        _pointWindVelocities = new CircularBuffer <Vector3>(_maxPoints);

        _isInitialized = true;

        Reset();
        Emit();
    }