Пример #1
0
        //                        FUNCTIONS
        ///////////////////////////////////////////////////////////////////////////

        public DrawInfo(FogMap map, FogShape shape, float xradius, float yradius)
        {
            // convert size to fog space
            fogForward   = shape.Forward;
            forwardAngle = FogTools.ClockwiseAngle(Vector2.up, fogForward) * Mathf.Deg2Rad;
            float   sin            = Mathf.Sin(-forwardAngle);
            float   cos            = Mathf.Cos(-forwardAngle);
            Vector2 relativeoffset = new Vector2(shape.Offset.x * cos - shape.Offset.y * sin, shape.Offset.x * sin + shape.Offset.y * cos);

            fogCenterPos = FogConversion.WorldToFog(FogConversion.WorldToFogPlane(shape.EyePosition, map.Plane) + relativeoffset, map.Offset, map.Resolution, map.Size);
            fogEyePos    = new Vector2_1(FogConversion.WorldToFog(shape.EyePosition, map.Plane, map.Offset, map.Resolution, map.Size));

            // find ranges
            if (shape.VisibleCells == null)
            {
                xMin = Mathf.Max(0, Mathf.RoundToInt(fogCenterPos.x - xradius));
                xMax = Mathf.Min(map.Resolution.x - 1, Mathf.RoundToInt(fogCenterPos.x + xradius));
                yMin = Mathf.Max(0, Mathf.RoundToInt(fogCenterPos.y - yradius));
                yMax = Mathf.Min(map.Resolution.y - 1, Mathf.RoundToInt(fogCenterPos.y + yradius));
            }
            else
            {
                fogCenterPos = FogConversion.SnapToNearestFogPixel(fogCenterPos);
                fogEyePos    = new Vector2_1(FogConversion.SnapToNearestFogPixel(FogConversion.WorldToFog(shape.EyePosition, map.Offset, map.Resolution, map.Size)));

                Vector2_1 pos = new Vector2_1(Mathf.RoundToInt(fogCenterPos.x), Mathf.RoundToInt(fogCenterPos.y));
                Vector2_1 rad = new Vector2_1(Mathf.RoundToInt(xradius), Mathf.RoundToInt(yradius));
                xMin = Mathf.Max(0, Mathf.RoundToInt(pos.x - rad.x));
                xMax = Mathf.Min(map.Resolution.x - 1, Mathf.RoundToInt(pos.x + rad.x));
                yMin = Mathf.Max(0, Mathf.RoundToInt(pos.y - rad.y));
                yMax = Mathf.Min(map.Resolution.y - 1, Mathf.RoundToInt(pos.y + rad.y));
            }
        }
Пример #2
0
    ////////////////////////////////////////////////////////////////////////////////

    public Vector2_1 WorldPositionToFogPosition(Vector3 position)
    {
        Vector2 mappos = FogConversion.WorldToFogPlane(position, Plane) - MapOffset;

        mappos.Scale(MapResolution.vector2 / MapSize);

        Vector2_1 mapposi = new Vector2_1(mappos);

        mapposi += new Vector2_1(MapResolution.x >> 1, MapResolution.y >> 1);
        return(mapposi);
    }
Пример #3
0
    ///////////////////////////////////////////////////////////////////////////

    void FillShape(FogManager fow, FogShape shape)
    {
        if (AntiFlicker)
        {
            // snap to nearest fog pixel
            shape.EyePosition = FogConversion.SnapWorldPositionToNearestFogPixel(fow, FogConversion.WorldToFogPlane(_Transform.position, fow.Plane), fow.MapOffset, fow.MapResolution, fow.MapSize);
            shape.EyePosition = FogConversion.FogPlaneToWorld(shape.EyePosition.x, shape.EyePosition.y, _Transform.position.y, fow.Plane);
        }
        else
        {
            shape.EyePosition = _Transform.position;
        }
        shape.Forward = FogConversion.TransformFogPlaneForward(_Transform, fow.Plane);
        shape.Offset  = Offset;
        shape.Radius  = Radius;
    }