- Home /
Change Global cartesian system vectors
Hello everyone,
I'm working on a visualization tool in which I use Unity to show some result from an external physics engine. The problem is that this physics engine is not using the same cartesian system as Unity, meaning that I have to convert every data incoming from the external physics engine. I would like to know if instead of convert all incoming data, I could change the Global cartesian system directly in the setting of Unity, for exemple if I could change the direction of "x" vector so that the frame respect the right-hand rule ?
Answer by Bunny83 · Oct 17, 2017 at 03:45 PM
No. The whole Unity engine is based on a left handed system. So manually changing for example the camera matrix which is responsible for the world to camera space conversion it would mess up things like frustum culling.
The easiest solution is to setup a transformation matrix which does the desired conversion. So just multiply your incoming data with that matrix to get the proper coordinates in Unity.
Note that a left to right hand or right to left hand conversion does not only need a position conversion but if meshes are involved you also need to reverse the winding order of each triangle.
Normally if you just want to switch between left and right hand system you would just multiply the z value by "-1" as in almost all systems x and y are the same but z is different. The "normal" matematical system uses the same x and y as Unity but has a z that is pointing towards the camera, not away from it.
What kind of "data" do you talk about?
you also need to reverse the winding order of each triangle
in some situations you can also skip reversing the winding and ins$$anonymous$$d reverse the culling mode from cull-back-facing to cull-front-facing. i'm not actually sure if that's an option w/ unity cameras tho.
Well, Unity doesn't have a global setting to define what's a front and what's a back face and which one gets culled. So as far as i know in Unity CW (clockwise) triangles are generally considered "front faces" and CCW (counter clockwise) triangles are backfaces.
The actual culling mode depends on the used shader. So if you use just a few shaders where you have the source available you can simply swap the culling mode. $$anonymous$$ost shaders cull backfaces by default. A few don't cull at all. If you set the cullingmode to "front", only backfaces would be rendered.
$$anonymous$$ostly position, speed and acceleration vectors, so I guess i'll have to convert everything. Thanks for the advice on transformation matrix. Anyway I think I'll do the conversion before sending them to Unity.What kind of "data" do you talk about?
Your answer
Follow this Question
Related Questions
How to avoid changing transform.parent? 2 Answers
Why Matrix4x4.MultiplyPoint does row-major access while Matrix4x4 is column-major? 1 Answer
How is a gameobject rotated when you set it's forward? 0 Answers
How to find perpendicular line in 2D? 3 Answers
Is there such a thing as Unity Algebra? 0 Answers