Esempio n. 1
0
        public unsafe DisplacementMesh Clone()
        {
            DisplacementMesh ret = new DisplacementMesh(width, height);

            ret.Copy(this, Point.Empty, this.Bounds);
            return(ret);
        }
Esempio n. 2
0
 public ConfigToken(ConfigToken toCopy)
 {
     this.mesh   = toCopy.mesh;
     this.grid   = toCopy.grid;
     this.width  = toCopy.width;
     this.height = toCopy.height;
 }
Esempio n. 3
0
        private void ConfigDialog_Load(object sender, EventArgs e)
        {
            this.BackColor       = SystemColors.Control;
            this.Text            = GridWarp.StaticDialogName;
            this.DesktopLocation = Owner.PointToScreen(new Point(0, 30));
            this.Size            = new Size(Owner.ClientSize.Width, Owner.ClientSize.Height - 30);
            this.WindowState     = Owner.WindowState;

            surface          = new Surface(EnvironmentParameters.SourceSurface.Size);
            mesh             = new DisplacementMesh(surface.Size);
            canvas.Surface   = surface;
            canvas.Selection = EnvironmentParameters.GetSelectionAsPdnRegion();
            mesh.Render(surface, EnvironmentParameters.SourceSurface, EnvironmentParameters.SourceSurface.Bounds);
        }
Esempio n. 4
0
        protected override void OnSetRenderInfo(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs)
        {
            base.OnSetRenderInfo(parameters, dstArgs, srcArgs);

            ConfigToken token = parameters as ConfigToken;

            if (token != null && token.mesh != null)
            {
                mesh = token.mesh;
                if (mesh.Size != dstArgs.Surface.Size)
                {
                    mesh = mesh.Resize(dstArgs.Size);
                }
            }
        }
Esempio n. 5
0
 public unsafe void Copy(DisplacementMesh srcMesh, Point dstOffset, Rectangle srcRect)
 {
     for (int y = 0; y < srcRect.Height; ++y)
     {
         DisplacementVector *
             src = srcMesh.GetPointAddressUnchecked(srcRect.X, y + srcRect.Y),
             dst = this.GetPointAddressUnchecked(dstOffset.X, y + dstOffset.Y);
         for (int x = 0; x < srcRect.Width; ++x)
         {
             *dst = *src;
             ++src;
             ++dst;
         }
     }
 }
Esempio n. 6
0
        public DisplacementGrid(Stream s, DisplacementMesh mesh)
        {
            using (BinaryReader br = new BinaryReader(s))
            {
                handlesx  = br.ReadInt32();
                handlesy  = br.ReadInt32();
                this.mesh = mesh;
                SetSize(handlesx - 1, handlesy - 1);

                for (int j = 0; j < handlesy; ++j)
                {
                    for (int i = 0; i < handlesx; ++i)
                    {
                        points[i, j].X = br.ReadSingle();
                        points[i, j].Y = br.ReadSingle();
                    }
                }
            }
        }
Esempio n. 7
0
        public unsafe DisplacementMesh Resize(Size size)
        {
            DisplacementMesh ret = new DisplacementMesh(size);

            float xfactor = (float)width / size.Width;
            float yfactor = (float)height / size.Height;

            for (int y = 0; y < size.Height; ++y)
            {
                DisplacementVector *ptr = ret.GetPointAddressUnchecked(0, y);
                float srcy = y * yfactor;;
                for (int x = 0; x < size.Width; ++x)
                {
                    float srcx           = x * xfactor;
                    DisplacementVector v = GetBilinearSample(srcx, srcy);
                    ptr->X = v.X / xfactor;
                    ptr->Y = v.Y / yfactor;
                    ++ptr;
                }
            }
            return(ret);
        }
Esempio n. 8
0
        public void Load(Stream s)
        {
            using (BinaryReader br = new BinaryReader(s))
            {
                Size size = ReadHeader(br);

                if (size.Width == width && size.Height == height)
                {
                    LoadData(br);
                }
                else
                {
                    DisplacementMesh loaded = new DisplacementMesh(size);
                    loaded.LoadData(br);

                    this.Dispose(true); // safe to toss our own data at this point

                    DisplacementMesh resized = loaded.Resize(this.Size);
                    loaded.Dispose();

                    this.scan0 = resized.scan0;
                }
            }
        }
Esempio n. 9
0
 public DisplacementGrid(int width, int height, DisplacementMesh mesh)
 {
     this.mesh = mesh;
     SetSize(width, height);
 }
Esempio n. 10
0
 public DisplacementGrid(Size size, DisplacementMesh mesh)
     : this(size.Width, size.Height, mesh)
 {
 }
Esempio n. 11
0
 public DisplacementGrid(int width, int height, DisplacementMesh mesh, bool useLinearInterpolation = false)
 {
     this.mesh = mesh;
     this.useLinearInterpolation = useLinearInterpolation;
     SetSize(width, height);
 }
Esempio n. 12
0
 public DisplacementGrid(Size size, DisplacementMesh mesh, bool useLinearInterpolation = false)
     : this(size.Width, size.Height, mesh, useLinearInterpolation)
 {
 }