can the perspective be adjusted?

Jan 30, 2013 at 12:52 PM

could the perspective be adjusted to an angle like this? http://i.imgur.com/T6dUa.png

Coordinator
Jan 30, 2013 at 1:56 PM

Yes. See the custom view transformations example, or read here: http://sheetengine.codeplex.com/wikipage?title=Custom%20view%20transformations&referringTitle=Documentation

You need something very close to the built-in functions, but different ratios. So check out how

sheetengine.transforms.transformPoint, sheetengine.transforms.transformPointz and sheetengine.transforms.inverseTransformPoint

work and you can figure it out.

Jan 31, 2013 at 7:26 PM
Thanks for the reply! Any idea how I can figure out what the math for my transformation would be?
Coordinator
Jan 31, 2013 at 10:11 PM
This is something I've come up with:
  var su = Math.SQRT1_2;
  var sv = Math.SQRT1_2 / 2 * 1.2;
  var angle = Math.PI/12;
  
  function transformPoint(p) {
    var u = (p.x - p.y);
    var v = (p.x + p.y);
    var r = sheetengine.geometry.rotateAroundAxis({x:u,y:v,z:0}, {x:0,y:0,z:1}, angle);
    return { u: r.x*su, v: r.y*sv - p.z };
  };
  function transformPointz(p) {
    var u = (p.x - p.y);
    var v = (p.x + p.y);
    var z = -(p.x + p.y);
    var r = sheetengine.geometry.rotateAroundAxis({x:u,y:v,z:0}, {x:0,y:0,z:1}, angle);
    return { u: r.x*su, v: r.y*sv - p.z, z: z };
  };
Image
I basically rotated the points in the original equation with an angle, and used a slightly bigger scale level on the v-axis. You also have to define the inversetransform function which is basically the inverse of what we did in the above functions.. so above input is x,y,z, output is u,v, whereas in the inverse function the input is u,v, and output is x,y,z. Don't forget to define this, otherwise some z-ordering calculations could be wrong.
Feb 1, 2013 at 4:28 PM
That isn't pixel perfect but it is damn close! do you know how I could calculate the exact rotation and angle needed for it to be pixel perfect? Is that even possible? the isometric view seemed to be pixel perfect.
Coordinator
Feb 1, 2013 at 10:06 PM
No, sorry, I'm not that genius of math and transformations :) I would just play with su, sv and angle parameters up to the point when it looks good to me. It's a bit more artistic approach than pixel-perfect geometry, but eventually it all comes down to a sort of "artwork" and what looks good to the human eye and what doesn't. One suitable method though could be to keep the angle fixed, rotate a sheet (with equal sides) in a direction so that it faces exactly the camera (rotating around z-axis is all we need here to get the sides of the sheets move to be perpendicular as displayed), and then set the su/sv parameters so that the width/height ratio of the sheet as visible is exactly 1. It might be the solution you are looking for.