nokola
Topic Author
Posts: 117
Joined: 10 Mar 2015, 05:29

How to use TransformToVisual with PlaneProjection present?

14 Nov 2017, 16:27

I have a child inside a scrollviewer that is offset from it about (10,80) pixels. The code below works OK as long as the firstChild control has no PlaneProjection attached.
// get coordinates of a specific point relative to parent
Point pointToTransform = new Point(10, 20);
Matrix4 matrix = container.TransformToVisual(firstChild)
Vector4 resultVector = (new Vector4(pointToTransform.X, pointToTransform.Y, 0, 1) * transformMatrix);
Point result = resultVector.XY;
Without PlaneProjection, I get resultVector == -16,-79.21875,0,1
With PlaneProjection on firstChild, I get resultVector == -268.247,488.8769,-2322.5,0.9999921

This is not a blocker, since I can compute the offsets before applying any transforms (in which case I can just use matrix[3].XY since there's only translation), however curious to know.
 
User avatar
sfernandez
Site Admin
Posts: 1166
Joined: 22 Dec 2011, 19:20

Re: How to use TransformToVisual with PlaneProjection present?

17 Nov 2017, 09:34

Hi,

Could you please create a ticket in our bugtracker and attach the xaml+cs so we can debug and investigate this issue?

Thanks.
 
nokola
Topic Author
Posts: 117
Joined: 10 Mar 2015, 05:29

Re: How to use TransformToVisual with PlaneProjection present?

17 Nov 2017, 17:53

Opened http://www.noesisengine.com/bugs/view.php?id=1194
I'm not sure if it's a bug or just me not understanding something matrix-related properly.
Copy-pasting the short summary of the bug here in case it could benefit someone from the forum:
0001194: How to use TransformToVisual with PlaneProjection present?
Description Note: this may not be a bug, but me misunderstanding something.
I have a child inside a container that is offset by some margin (say 93x541 pixels.) The child is being animated. Trying to find that offset using TransformToVisual.
All is Ok until I add a PlaneProjection to the child control, then my computation results are *way* off.
Steps To Reproduce 1. Use default Noesis buttons samples and get the LayoutRoot and StartButton in code
2. Run this code on Start button click:
_startButton.Projection = new PlaneProjection
{
RotationX = 10
};

Matrix4 transformMatrix = _rootGrid.TransformToVisual(_startButton);
Vector4 resultOffset = Vector4.WAxis * transformMatrix;

Actual:
resultOffset == {353.7869,-278.3919,-1860.621,1.000067}

Expected:
resultOffset is something like: {-93.94475,-541.2817,0,1}. This is the result without PlaneProjection.
Then resultOffset.XY is the offset.

What am I missing? Maybe a call to "normalize" the matrix?

Who is online

Users browsing this forum: No registered users and 4 guests