Incorrect localToContent() screen coordinates with Quad Distortion on snapshot group

I have created a newSnapshot with an image object added to the group.  The localToContent code correctly displays the X,Y of the SmallCircle in relation to the screen:

local screenWidth  = display.actualContentWidth  local screenHeight = display.actualContentHeight local backgroundGraphic = display.newImageRect( "backgroundGraphic",360,2378)  snapshot = display.newSnapshot( screenWidth \* 2 , screenHeight \* 2 ) snapshotGroup = snapshot.group snapshotGroup:insert( backgroundGraphic ) --add SmallCircle to snapshop group SmallCircle= display.newImage( "SmallCircle.png") snapshotGroup:insert( SmallCircle ) --Determine Screen Coordinates of SmallCircle (Returns correct screen coordinates) local sqCenterX1, sqCenterY1 = SmallCircle:localToContent( 0, 0 )

If I apply Quadrilateral Distortion on the snapshot, the localToContent code does not display the correct X,Y coordinates of the Small Circle.

--Quadrilateral Distortion w = screenWidth  \* .45 h = screenHeight \* .45 snapshot.path.x1 = w snapshot.path.y1 = h snapshot.path.x2 = -w snapshot.path.y2 = -h snapshot.path.x3 = w snapshot.path.y3 = -h snapshot.path.x4 = -w snapshot.path.y4 = h snapshot:invalidate() --Determine Screen Coordinates of SmallCircle (Incorrect coordinates returned) local sqCenterX1, sqCenterY1 = SmallCircle:localToContent( 0, 0 ) --Incorrectly returns the same x,y screen coordinates of the smallcircle without quad distortion. The distortion should change the coordinates as the small circle graphic in relation to the screen.

Can anyone help me figure out how to fix this issue?

Thanks in advance.

Here is a cleaner version of the code:

local snapshot = display.newSnapshot( 640, 960 ) snapshot.x    = display.contentCenterX snapshot.y    = display.contentCenterY local snapshotGroup = snapshot.group local myImage = display.newImage( "grid.jpg" ) snapshotGroup:insert( myImage ) local screenWidth  = display.actualContentWidth  local screenHeight = display.actualContentHeight CameraAngle = .2 w = screenWidth  \* CameraAngle h = screenHeight \* CameraAngle snapshot.path.x1 = w snapshot.path.y1 = h snapshot.path.x2 = -w snapshot.path.y2 = -h snapshot.path.x3 = w snapshot.path.y3 = -h snapshot.path.x4 = -w snapshot.path.y4 = h snapshot:invalidate() redsquare= display.newImage( "redsquare.jpg") redsquare.x = 0 redsquare.y = 440 redsquare:toFront() snapshotGroup:insert( redsquare ) snapshot:invalidate() local sqCenterX1, sqCenterY1 = redsquare:localToContent( 0, 0 ) print(sqCenterX1..":"..sqCenterY1) 

When I distort the snapshot the redsquare should have new x,y screen coordinates when using localToContent().

Basically the localToContent() does not use the distortion value and bases the x,y coordinates on the flat (2D) angle.

Thanks again.

Here is an image:

https://www.dropbox.com/s/7ieymfbdqg5xo23/screen.jpg?dl=0

You said in the PM that you filed a bug report.  What is the Case ID for it?  It would have come to you in email after you filed it.  This is the first I’ve heard of this.  I don’t know that this is a bug because you probably need to draw things pre-deform.

Rob

Thanks Rob…Here is the case number: 40102

My understanding is that localToContent() will display the x,y coordinates of an object on the screen.  When the object is distorted in a snapshot it does not work as expected.  I’m not sure if that is a bug or designed that way.

Basically what I am trying to do is place an object on the distorted plane (For example a tree) that moves with the snapshot.  If I can figure out where the distorted object is in relation to the screen I can simply place the new object in that spot.  if localToContent() gave me the correct x,y position then I have a solution.

Thanks for your help.

(Note: I submitted code with the bug request that will better explain the issue)

Its waiting to be verified and assigned to an engineer.

Rob

Thank you.  If it’s not a bug I’ll submit a feature request.

I found something that might assist in solving my issue… just trying to reverse engineer it.

http://ryoushin.com/cmerighi/en-US/2006-09-30_21/Quadrilateral_Distortion_Algorithm

Here is a cleaner version of the code:

local snapshot = display.newSnapshot( 640, 960 ) snapshot.x    = display.contentCenterX snapshot.y    = display.contentCenterY local snapshotGroup = snapshot.group local myImage = display.newImage( "grid.jpg" ) snapshotGroup:insert( myImage ) local screenWidth  = display.actualContentWidth  local screenHeight = display.actualContentHeight CameraAngle = .2 w = screenWidth  \* CameraAngle h = screenHeight \* CameraAngle snapshot.path.x1 = w snapshot.path.y1 = h snapshot.path.x2 = -w snapshot.path.y2 = -h snapshot.path.x3 = w snapshot.path.y3 = -h snapshot.path.x4 = -w snapshot.path.y4 = h snapshot:invalidate() redsquare= display.newImage( "redsquare.jpg") redsquare.x = 0 redsquare.y = 440 redsquare:toFront() snapshotGroup:insert( redsquare ) snapshot:invalidate() local sqCenterX1, sqCenterY1 = redsquare:localToContent( 0, 0 ) print(sqCenterX1..":"..sqCenterY1) 

When I distort the snapshot the redsquare should have new x,y screen coordinates when using localToContent().

Basically the localToContent() does not use the distortion value and bases the x,y coordinates on the flat (2D) angle.

Thanks again.

Here is an image:

https://www.dropbox.com/s/7ieymfbdqg5xo23/screen.jpg?dl=0

You said in the PM that you filed a bug report.  What is the Case ID for it?  It would have come to you in email after you filed it.  This is the first I’ve heard of this.  I don’t know that this is a bug because you probably need to draw things pre-deform.

Rob

Thanks Rob…Here is the case number: 40102

My understanding is that localToContent() will display the x,y coordinates of an object on the screen.  When the object is distorted in a snapshot it does not work as expected.  I’m not sure if that is a bug or designed that way.

Basically what I am trying to do is place an object on the distorted plane (For example a tree) that moves with the snapshot.  If I can figure out where the distorted object is in relation to the screen I can simply place the new object in that spot.  if localToContent() gave me the correct x,y position then I have a solution.

Thanks for your help.

(Note: I submitted code with the bug request that will better explain the issue)

Its waiting to be verified and assigned to an engineer.

Rob

Thank you.  If it’s not a bug I’ll submit a feature request.

I found something that might assist in solving my issue… just trying to reverse engineer it.

http://ryoushin.com/cmerighi/en-US/2006-09-30_21/Quadrilateral_Distortion_Algorithm