Directions of the different Vector3 axes

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
abego
Posts: 7
Joined: Fri May 31, 2019 7:57 pm

Directions of the different Vector3 axes

Post by abego » Fri May 31, 2019 10:18 pm

Hi there!

I have just started using BEPUphysics v2 on a server for a game. The server runs on .NET Core 2.0 as a console application, and the game-client is made with Unity. During testing and exploring the demos, I have gotten very confused about which axes of positions in the engine corresponds to which direction (right, upwards and forwards). I think I have found that the X-axis of positions in the engine are in the Right direction, the Y-Axis is the forward direction and the Z-axis is the upwards direction. In the CharacterController Demo, the characters forward direction is stored in the Y-Axis. But I have also found some situations where it seems as if this is not true, such as in the RagdollDemo where the Y-Axis of the "gravity" parameter in DemoPoseIntegratorCallbacks is set to 10, which should mean that gravity pulls forwards (which it does not appear to do in the demo).

Code: Select all

Simulation = Simulation.Create(BufferPool, new SubgroupFilteredCallbacks { CollisionFilters = collisionFilters }, new DemoPoseIntegratorCallbacks(new Vector3(0, -10, 0)));
It also seems as if the AddRagdoll Method's "position" parameter uses the Y-axis as the upwards axis (taken from the Initialize Method):

Code: Select all

	    int ragdollIndex = 0;
            var spacing = new Vector3(2f, 3, 1);
            int width = 8;
            int height = 8;
            int length = 8;
            var origin = -0.5f * spacing * new Vector3(width, 0, length) + new Vector3(0, 0.2f, 0);
            for (int i = 0; i < width; ++i)
            {
                for (int j = 0; j < height; ++j) <--- the 'j' variable runs along the height
                {
                    for (int k = 0; k < length; ++k)                'j' is passed as the y parameter                 
                    {                                                \/
                        AddRagdoll(origin + spacing * new Vector3(i, j, k), Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), MathHelper.Pi * 0.05f), ragdollIndex++, collisionFilters, Simulation);
                    }
                }
            }
            
The reason I am concerned about this is that Unity uses a left-handed coordinate system where X is the right-axis, Y is the upwards-axis and Z is the forward-axis, and I would like to synchronize positions between the server and the player.

Norbo
Site Admin
Posts: 4708
Joined: Tue Jul 04, 2006 4:45 am

Re: Directions of the different Vector3 axes

Post by Norbo » Fri May 31, 2019 11:43 pm

For 3D, the demos use a convention of:
right: +X
up: +Y
forward: -Z

The character's 2D horizontal motion basis has no component named 'Z' since it's just 2D. That's why Y is on the horizontal plane there.

The physics engine itself, however, is indifferent. It has no concept of 'right' or left', or 'up' and 'down'. Those interpretations are left to the application.

The closest the engine comes to defining a convention is in some collision shapes. Boxes have a width, height, and length, corresponding to extents on the local X, Y, and Z axes respectively. Of course, you can use whatever names for whatever axes; the math doesn't change.

abego
Posts: 7
Joined: Fri May 31, 2019 7:57 pm

Re: Directions of the different Vector3 axes

Post by abego » Sat Jun 01, 2019 1:19 pm

Thank you, that makes sense. I think I just confused myself down the line.

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests