Tilted Inverted Pyramid Platform: Difference between revisions

Jump to navigation Jump to search
→‎References: Maybe you'll revert this change cuz you don't need this, but I do. Especially idk where the tilt inaccuracy bug occurs
((joke))
(→‎References: Maybe you'll revert this change cuz you don't need this, but I do. Especially idk where the tilt inaccuracy bug occurs)
Line 23: Line 23:
The Tilting Inverted Pyramid creates a transformation matrix using its x,y,z coordinates and its x,y,z normal. The pyramid is initialized with x and z-normals of 0, and a y-normal of 1, so that the pyramid will always spawn in with its flat portion facing directly upwards. Once the pyramid is initialized, it behaves by calculating new normals when Mario is standing on it and then tilts and moves Mario with it. When Mario is on the platform, a matrix is formed from the difference between Mario’s x,y,z coordinates and the platforms x,y,z coordinates. This matrix is then multiplied by the transformation matrix to give a new matrix encoding Mario’s position before the platform rotates. The game calculates an approximate distance between Mario’s position and the platform’s position by the usual distance formula √(dx^2+dy^2+dz^2 ), where dx,dz represent the difference between Mario and the platform’s x and z coordinates, and dy is always assumed to be 500. The game then calculates new normal for the pyramid by scaling each factor dx,dy,dz by the approximate distance. Once the new target normals are calculated, the pyramid approaches these values by incrementing the current normal by .01 until they reach a final target normal. Every time the pyramids normals are updated, the platform’s orientation is updated to match. Finally, if Mario is on the pyramid, the game creates a new matrix encoding Mario’s expected new position on the platform and uses the difference between it and the previous position matrix to update Mario’s position.
The Tilting Inverted Pyramid creates a transformation matrix using its x,y,z coordinates and its x,y,z normal. The pyramid is initialized with x and z-normals of 0, and a y-normal of 1, so that the pyramid will always spawn in with its flat portion facing directly upwards. Once the pyramid is initialized, it behaves by calculating new normals when Mario is standing on it and then tilts and moves Mario with it. When Mario is on the platform, a matrix is formed from the difference between Mario’s x,y,z coordinates and the platforms x,y,z coordinates. This matrix is then multiplied by the transformation matrix to give a new matrix encoding Mario’s position before the platform rotates. The game calculates an approximate distance between Mario’s position and the platform’s position by the usual distance formula √(dx^2+dy^2+dz^2 ), where dx,dz represent the difference between Mario and the platform’s x and z coordinates, and dy is always assumed to be 500. The game then calculates new normal for the pyramid by scaling each factor dx,dy,dz by the approximate distance. Once the new target normals are calculated, the pyramid approaches these values by incrementing the current normal by .01 until they reach a final target normal. Every time the pyramids normals are updated, the platform’s orientation is updated to match. Finally, if Mario is on the pyramid, the game creates a new matrix encoding Mario’s expected new position on the platform and uses the difference between it and the previous position matrix to update Mario’s position.
==References==
==References==
https://github.com/n64decomp/sm64/blob/1372ae1bb7cbedc03df366393188f4f05dcfc422/src/game/behaviors/tilting_inverted_pyramid.inc.c
[https://github.com/n64decomp/sm64/blob/f9982e0ef5891d2b3e4381c305c80f7d86166e85/src/engine/math_util.c#L374 mtxf_align_terrain_normal(transform, normal, pos, 0);]
[https://github.com/n64decomp/sm64/blob/1372ae1bb7cbedc03df366393188f4f05dcfc422/src/game/object_helpers.c#L652 linear_mtxf_mul_vec3f(*transform, posAfterRotation, dist);]
[[Category:Objects]]
[[Category:Objects]]
{{objects}}
{{objects}}
134

edits

Navigation menu