# Mirror matrix around plane

## Recommended Posts

Hi,

I want to mirror a Mat4 around Y-axis (XZ plane).

```1  0 0 0
0 -1 0 0
0  0 1 0
0  0 0 1```

Multiplying with the above matrix doesn't work. How can I do it?

Thanks.

tolga

Is there any specific task that you are trying to solve? Could you please give us more details about it.

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

14 minutes ago, silent said:

tolga

Is there any specific task that you are trying to solve? Could you please give us more details about it.

Thanks!

Hi, thanks for the reply. I'm working on HairWorks and final output looks like it's mirrored around forward axis of the mesh. Maybe, I'm converting matrices wrong, but it looks like the hair is in the correct place, just mirrored around forward axis. That's why I'm trying to mirror the skinning matrices around Y-axis. Thanks.

Is it possible to see a bit more of code? Maybe the issue is there, not in the matrix mirroring.

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Hi,

I've attached a video where you can clearly see that the hair is inverted around Y-axis (forward). The hair should be at the back, in my case it's in front of the guy.

In UNIGINE, the matrices are stored as columns, where in NV Hair they are stored as rows, so I have a small conversion function like this:

```	static inline gfsdk_float4x4 toNvHairMat4x4(const mat4& matrix)
{
gfsdk_float4x4 result;
memset(&result, 0, sizeof(gfsdk_float4x4));

result._11 = matrix.m00;
result._12 = matrix.m10;
result._13 = matrix.m20;
result._14 = matrix.m30;

result._21 = matrix.m01;
result._22 = matrix.m11;
result._23 = matrix.m21;
result._24 = matrix.m31;

result._31 = matrix.m02;
result._32 = matrix.m12;
result._33 = matrix.m22;
result._34 = matrix.m32;

result._41 = matrix.m03;
result._42 = matrix.m13;
result._43 = matrix.m23;
result._44 = matrix.m33;

return result;
}```

Also, while setting up I set the handedness hint to RIGHT handed, which should be the case in UNIGINE?

Thanks!

tolga

As Denis already mentioned, please check If your model imported correctly (right-handed Cartesian, Y+ is  forward, Z+ is Up) and adjust matrices conversion logic f needed.

If you will not find a proper solution to this, could you please send us a minimal test scene with original model and code?

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Hi Silent,

How can I send you a sample?

Thanks.

You can zip data and source dirs and upload them to any filehosting (or the FTP server that I have in my signature). After that just give me a link via PM.

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Please try to replace conversionSettings.m_targetHandednessHint = NvHair::HandednessHint::RIGHT to NvHair::HandednessHint::LEFT.

It's hard to understand why is that so, maybe the FBX axes are not correct.

Don't forget to check the modified sources in attachment:fix.zip

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Hi silent, I tried that but doesn't change much. I found out that the fbx scale is in cm, but the Unigine world is in meters. getIBoneBindTransform returns in cm. I will try to scale the fbx to cm now.

Did you have a chance to apply all the changes from the attached archive?

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Hi silent,

Thank you very much for the effort. I have to deal with some other urgent stuff. I will return to this later. I'll keep you updated on this one.

Thanks.