コード例 #1
0
        void CreateLineVertices()
        {
            if (vertices == null)
            {
                vertices = new List <Vector3>(numPoints + 1);
            }
            else
            {
                vertices.Clear();
            }

            float elevationStart = 0, elevationEnd = 0;

            if (usesViewport)
            {
                lineWidth     *= 6.0f;
                elevationStart = map.ComputeEarthHeight(path[0], false);
                elevationEnd   = map.ComputeEarthHeight(path[path.Length - 1], false);
            }

            Vector3 mapPos;

            for (int s = 0; s <= numPoints; s++)
            {
                float t      = (float)s / numPoints;
                int   index  = (int)((path.Length - 1) * t);
                int   findex = Mathf.Min(index + 1, path.Length - 1);
                float t0     = t * (path.Length - 1);
                t0    -= index;
                mapPos = Vector2.Lerp(path[index], path[findex], t0);
                if (usesViewport)
                {
                    if (map.renderViewportRect.Contains(map.Map2DToRenderViewport(mapPos)))
                    {
                        float elevation = Mathf.Lerp(elevationStart, elevationEnd, t);
                        elevation += arcElevation > 0 ? Mathf.Sin(t * Mathf.PI) * arcElevation : 0;
                        mapPos     = map.Map2DToWorldPosition(mapPos, elevation, HEIGHT_OFFSET_MODE.ABSOLUTE_CLAMPED, false);
                        vertices.Add(mapPos);
                    }
                }
                else
                {
                    if (arcElevation > 0)
                    {
                        mapPos.z = -Mathf.Sin(t0 * Mathf.PI) * arcElevation;
                    }
                    vertices.Add(mapPos);
                }
            }
        }