示例#1
0
        void PaintEarth(Vector3 cursorLocation)
        {
            if (enableRotation)
            {
                return;
            }

            // Convert cursor location to texture coordinates
            Vector2 uv = Conversion.GetUVFromSpherePoint(cursorLocation);

            // Paints thick pixel on texture position
            int x = (int)(uv.x * earthTex.width);
            int y = (int)(uv.y * earthTex.height);

            for (int j = -penWidth; j < penWidth; j++)
            {
                int jj = (y + j) * earthTex.width;
                for (int k = -penWidth; k < penWidth; k++)
                {
                    int colorIndex = jj + x + k;
                    if (colorIndex < 0 || colorIndex >= colors.Length)
                    {
                        continue;
                    }
                    Color32 currentColor = colors[colorIndex];

                    float t = 1.0f - Mathf.Clamp01((float)(j * j + k * k) / (penWidth * penWidth));             // for smooth drawing
                    colors[colorIndex] = Color32.Lerp(currentColor, penColor, t);
                }
            }
            needTextureUpdate = true;
        }
        float ComputeCenteredHorizontalOffset()
        {
            Vector3 centerLocation = map.GetCurrentMapLocation();
            Vector2 uv             = Conversion.GetUVFromSpherePoint(centerLocation);

            return(uv.x);
        }