This project is read-only.

Simple Rotation and Perspective - I'm stumped

Mar 21, 2011 at 7:31 PM

Maybe this is because I really don't understand what I'm doing, but I'm looking to take a given image (let's call it "img") (which is a jpg 173 w / 136 h ) on a Canvas called "MyViewPort" (which is 640 w / 480 h) and Rotate both the X and Z by 30 degrees and have a 45 degree field of view. Then I'm looking to do the same thing, but zoom in by 200%. In both cases, the image doesn't translate at all, it stays exactly where it is.

I've looked through the samples and toyed around with this quite a bit, but can't really get anything working. Most of the time my click event on the image that is supposed to rotate it and apply perspective just makes the img disappear entirely or almost just off the page.

Not sure what I'm doing wrong here.

        Dim rotateX = Matrix3DFactory.CreateRotationX(MathHelper.ToRadians(30))
        Dim rotateZ = Matrix3DFactory.CreateRotationZ(MathHelper.ToRadians(30))
        Dim centerAtOrigin = Matrix3DFactory.CreateTranslation(-img.ActualWidth * 0.5, -img.ActualHeight * 0.5, 0)
        Dim world = centerAtOrigin * rotateX * rotateZ
        Dim aspectRatio = MyViewPort.Width / MyViewPort.Height
        Dim projection = Matrix3DFactory.CreatePerspectiveFieldOfViewLH(MathHelper.ToRadians(45), aspectRatio, 1, 4000)
        Dim viewport = Matrix3DFactory.CreateViewportTransformation(MyViewPort.Width, MyViewPort.Height)
        Dim viewProjection = Matrix3DFactory.CreateViewportProjection(world, Matrix3D.Identity, projection, viewport)
        img.Projection = New Matrix3DProjection() With {.ProjectionMatrix = viewProjection}

Any ideas?

Mar 29, 2011 at 5:20 PM

Wow, I guess this project really is dead.

May 16, 2011 at 11:23 PM
Edited May 16, 2011 at 11:24 PM

You're not alone, I know a bit about what I'm doing, and it hasn't been as easy as it should be to make this work.

BTW, I don't think the project is dead, but the author is busy doing things for paying customers.