CodePlexProject Hosting for Open Source Software

It is possible to use custom view transformations other than the built-in ones. To do this you have to override the necessary transform functions. The

sheetengine.transforms.transformPoint = func1;where func1 is a function that receives a point in world coordinates (JSON with x,y,z keys) and returns a point in camera coordinates (JSON with u,v keys). The

sheetengine.transforms.transformPointz = func2;where func2 is a function that receives a point in world coordinates (JSON with x,y,z keys) and returns a point in camera coordinates including depth value (JSON with u,v,z keys). The

sheetengine.transforms.inverseTransformPoint = func3;where func3 is a function that receives a point in camera coordinates (JSON with u,v keys) and returns a point in world coordinates (JSON with x,y,z keys, z can be null). Also, the view direction of the camera should be specified with

sheetengine.viewSource = vs;where vs is a JSON with keys x,y,z.

Example:

sheetengine.transforms.transformPoint = function(p) { var u = p.x; var v = p.y; return { u: u, v: v }; }; sheetengine.transforms.transformPointz = function(p) { var u = p.x; var v = p.y; var z = -p.z; return { u: u, v: v, z: z }; }; sheetengine.transforms.inverseTransformPoint = function(p) { var x = (p.u - sheetengine.canvasCenter.u); var y = (p.v - sheetengine.canvasCenter.v); return { x:Math.floor(x), y:Math.floor(y), z:null }; }; sheetengine.viewSource = { x: 0, y: 0, z: -1};

Last edited Dec 11, 2012 at 9:38 PM by dobsonl, version 2