Пример #1
0
        // This is called to update UV dragging
        protected virtual void UpdateDragUV()
        {
            float u_ray;

            // Calculate intersection position
            Line2D ray = new Line2D(General.Map.VisualCamera.Position, General.Map.VisualCamera.Target);

            Sidedef.Line.Line.GetIntersection(ray, out u_ray);
            Vector3D intersect = General.Map.VisualCamera.Position + (General.Map.VisualCamera.Target - General.Map.VisualCamera.Position) * u_ray;

            // Calculate offsets
            Vector3D dragdelta   = intersect - dragorigin;
            Vector3D dragdeltaxy = dragdelta * deltaxy;
            Vector3D dragdeltaz  = dragdelta * deltaz;
            float    offsetx     = dragdeltaxy.GetLength();
            float    offsety     = dragdeltaz.GetLength();

            if ((Math.Sign(dragdeltaxy.x) < 0) || (Math.Sign(dragdeltaxy.y) < 0) || (Math.Sign(dragdeltaxy.z) < 0))
            {
                offsetx = -offsetx;
            }
            if ((Math.Sign(dragdeltaz.x) < 0) || (Math.Sign(dragdeltaz.y) < 0) || (Math.Sign(dragdeltaz.z) < 0))
            {
                offsety = -offsety;
            }

            // Apply offsets
            int newoffsetx = startoffsetx - (int)Math.Round(offsetx);
            int newoffsety = startoffsety + (int)Math.Round(offsety);

            mode.ApplyTextureOffsetChange(prevoffsetx - newoffsetx, prevoffsety - newoffsety);
            prevoffsetx = newoffsetx;
            prevoffsety = newoffsety;

            mode.ShowTargetInfo();
        }