Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transform matrix not changing for TranslateZ #398

Closed
YTN0 opened this issue Dec 22, 2022 · 8 comments
Closed

Transform matrix not changing for TranslateZ #398

YTN0 opened this issue Dec 22, 2022 · 8 comments
Labels
support Usage questions

Comments

@YTN0
Copy link

YTN0 commented Dec 22, 2022

I am trying to add support for transforms, and during testing it doesn't look like the transform matrix is changing then I use the "transform: translateZ(dp);" property.

I have the perspective setup on the parent element, and am trying to set the translateZ to different values, however the resulting transform matrix is always the same. Here are 4 results from setting translateZ to 0dp, 50dp, 100dp and 150dp (with perspective set to 500dp).

{{ {M11:1 M12:0 M13:0 M14:0} {M21:0 M22:1 M23:0 M24:0} {M31:-1.6 M32:-0.9 M33:1 M34:-0.002} {M41:0 M42:0 M43:0 M44:1} }}

{{ {M11:1 M12:0 M13:0 M14:0} {M21:0 M22:1 M23:0 M24:0} {M31:-1.6 M32:-0.9 M33:1 M34:-0.002} {M41:0 M42:0 M43:0 M44:1} }}

{{ {M11:1 M12:0 M13:0 M14:0} {M21:0 M22:1 M23:0 M24:0} {M31:-1.6 M32:-0.9 M33:1 M34:-0.002} {M41:0 M42:0 M43:0 M44:1} }}

{{ {M11:1 M12:0 M13:0 M14:0} {M21:0 M22:1 M23:0 M24:0} {M31:-1.6 M32:-0.9 M33:1 M34:-0.002} {M41:0 M42:0 M43:0 M44:1} }}

Any ideas as to why it's not changing? I don't see any Rml errors being generated.

@mikke89
Copy link
Owner

mikke89 commented Dec 24, 2022

Do you have some code to replicate this?

@YTN0
Copy link
Author

YTN0 commented Dec 24, 2022

@mikke89 I assume you mean Rml code. I have attached that. The only other thing I do is attach a breakpoint to the incoming SetTransform(const Rml::Matrix4f* transform) and view / print the results.

MenuScreen.zip

@mikke89
Copy link
Owner

mikke89 commented Dec 24, 2022

Everything seems to be working fine here. The second submitted transform clearly has the z-translation, corresponding to the value set in the RML:

[0]	1.00000000	const float
[1]	0.00000000	const float
[2]	0.00000000	const float
[3]	0.00000000	const float
[4]	0.00000000	const float
[5]	1.00000000	const float
[6]	0.00000000	const float
[7]	0.00000000	const float
[8]	-2.02399993	const float
[9]	-1.76800001	const float
[10]	1.00000000	const float
[11]	-0.00200000009	const float
[12]	-303.599976	const float
[13]	-265.200012	const float
[14]	150.000000	const float
[15]	0.699999988	const float

Did you check all the submitted transforms during a render frame?

@YTN0
Copy link
Author

YTN0 commented Dec 24, 2022

Did you try changing the translateZ value in the rml and seeing if the matrix value changed?

I'll check my code again... But I wasn't getting that coming through.

Is this what you're seeing in the SetTransform() . method ?

@mikke89
Copy link
Owner

mikke89 commented Dec 24, 2022

Yes, and yes :)

@YTN0
Copy link
Author

YTN0 commented Dec 24, 2022

Thanks... Guess I'll have to deep dive into why I am getting different results. It could be something related to the C++ to C# bridging.

@YTN0
Copy link
Author

YTN0 commented Dec 27, 2022

@mikke89 So I figured out the transform issue. It was related to how I was reading it.

However, in order to get this working correctly, I had to enable depth testing and depth writing, but when I do that, the z-index stuff seems to get messed up i.e. The buttons on the window are no longer displayed, since I suspect they are now behind the window.

I tried adjusting the z-index, but that didn't make any difference. I think part of the problem is that the vertices don't have an z component set on them (only x and y).

I am assuming the geometry is sorted by z-index, correct? And does the transform apply to any children i.e. if the transform is set on a window, that is also applicable to any children of that window?

@mikke89
Copy link
Owner

mikke89 commented Dec 27, 2022

Draw calls are submitted in the order they should be rendered in. Depth testing and writing should not be necessary. The only exception would be if you need to support arbitrary overlapping transformations at the same z-index (we don't really care about this situation in the included backends), and then you would not be able to use transparency for this geometry.

Yes, transforms apply to the element's children as well, any further transforms on the children are chained.

@mikke89 mikke89 added the support Usage questions label Dec 27, 2022
@mikke89 mikke89 closed this as completed Jan 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Usage questions
Projects
None yet
Development

No branches or pull requests

2 participants