The 3D transform, its stack, the look-at matrix and the projection. More...
Go to the source code of this file.
Macros | |
| #define | TRANSFORM_DMA (DMA_COPY_WORDS(12)) |
| one matrix | |
Typedefs | |
| typedef s32(*) | Dot3Fn(s32 ax, s32 bx, s32 ay, s32 by, s32 az, s32 bz) |
Functions | |
| void | Render_ResetTransformState (void) |
| Allocates the one-level save area (heap slot HEAP_SLOT_TRANSFORM_STACK), clears gTransformStackDepth and resets gTransform to identity. | |
| void | Transform_Push (void) |
| Saves gTransform into the save area (one level deep; a second save is ignored). | |
| void | Transform_Store (void *dst) |
| Copies gTransform to dst. Called by BattleFx_RunAtalanta. | |
| void | Transform_Load (const void *src) |
| Copies the matrix at src into gTransform. Called by BattleFx_RunAtalanta. | |
| void | Transform_Pop (void) |
| Restores gTransform from the save area, if Transform_Push saved it. | |
| void | SceneTransform_ResetMatrix (void) |
| Resets gTransform to identity. Reached through the far-call table. | |
| void | SceneTransform_ApplyRotation (s32 *angles) |
| Rotates gTransform by angles[0], angles[1] and angles[2] about the X, Y and Z axes, in that order, with one combined matrix. | |
| void | SceneTransform_ApplyPitch (s32 angle) |
| Rotates gTransform about the X axis by angle. | |
| void | SceneTransform_ApplyYaw (s32 angle) |
| Rotates gTransform about the Y axis by angle. | |
| void | SceneTransform_ApplyRoll (s32 angle) |
| Rotates gTransform about the Z axis by angle. | |
| void | SceneTransform_ApplyPosition (const s32 *position) |
| Translates gTransform by position (x, y, z in 16.16). | |
| void | SceneTransform_ApplyScale (const s32 *scale) |
| Scales gTransform by scale (x, y, z factors in 16.16). | |
| void | SceneTransform_ApplyRotationTranslation (s32 *angles, s32 *position) |
| Rotates gTransform by angles and translates it by position in one matrix. | |
| void | SceneTransform_ApplyScaledRotation (s32 *angles, s32 *position, s32 *scale) |
| Rotates by angles, scales each rotation row by scale and translates by position, in one matrix. | |
| void | Transform_BuildLookAt (s32 *eye, s32 *target, s32 *out) |
| Builds in out the camera matrix of an eye at eye looking at target. | |
| void | Transform_SetLookAt (s32 *eye, s32 *target) |
| Makes the camera at eye looking at target the whole of gTransform. | |
| void | Transform_ApplyLookAt (s32 *eye, s32 *target) |
| Multiplies the camera at eye looking at target into gTransform. | |
| void | Projection_SetFieldOfView (u32 fieldOfView, s32 nearDepth, s32 farDepth) |
| Sets gProjection from a vertical field of view: the focal length is 80 (half the screen height) over the tangent of half the angle. | |
| void | Projection_Set (u32 focal, u32 nearDepth, u32 farDepth) |
| Sets gProjection's focal length and depth range directly. | |
| s32 | Render_ProjectPoint (const void *point, s32 *screen) |
| Reads three word-aligned coordinates from point, transforms them by gTransform and projects them to the screen: screen[0] and screen[1] are its pixel position and screen[2] its whole-unit depth. | |
The 3D transform, its stack, the look-at matrix and the projection.
Part of runtime.c, the runtime object, compiled only through it.
Definition in file transform.c.
| #define TRANSFORM_DMA (DMA_COPY_WORDS(12)) |
one matrix
Definition at line 11 of file transform.c.
Referenced by Transform_Load(), Transform_Pop(), Transform_Push(), and Transform_Store().
Definition at line 13 of file transform.c.
| void Render_ResetTransformState | ( | void | ) |
Allocates the one-level save area (heap slot HEAP_SLOT_TRANSFORM_STACK), clears gTransformStackDepth and resets gTransform to identity.
Called by the battle scene setup and the field camera before a scene's first transform.
Definition at line 19 of file transform.c.
Referenced by Battle_RunEncounter(), BattleFx_DrawStreaks(), BattleFx_RunAtalanta(), BattleFx_RunBind(), BattleFx_RunBoreas(), BattleFx_RunCastingImpact(), BattleFx_RunFrost(), BattleFx_RunJudgment(), BattleFx_RunParticleStreams(), BattleFx_RunProcne(), BattleFx_RunRingAndSparkScene(), BattleFx_RunThor(), BattleFx_RunTriangleStrike(), BattlePres_SetupTransitionScene(), BattlePres_SetupTransitionSceneAtDepth(), BattlePresentation_DispatchAction(), BattlePresentation_UpdateCamera(), Camera_ApplyTransformByFlag(), Camera_ConfigureScene(), Camera_InitDefaultTransform(), Camera_ResetSceneDefaults(), LuckyDice_Run(), Map_InitializePerspectiveScene(), memcpy(), ObjectSystem_UpdateCameraFixed(), Render_ResetTransformState(), and WorldMap_UpdateView().
| void Transform_Push | ( | void | ) |
Saves gTransform into the save area (one level deep; a second save is ignored).
Called by the battle effects that draw a part with its own transform, with Transform_Pop after.
Definition at line 30 of file transform.c.
Referenced by BattleFx_RunAstralBlast(), BattleFx_RunDjinnHeal(), BattleFx_RunDjinniEntrance(), BattleFx_RunSwirlingStars(), memcpy(), and Transform_Push().
| void Transform_Store | ( | void * | dst | ) |
Copies gTransform to dst. Called by BattleFx_RunAtalanta.
Definition at line 39 of file transform.c.
Referenced by BattleFx_RunAtalanta(), memcpy(), and Transform_Store().
| void Transform_Load | ( | const void * | src | ) |
Copies the matrix at src into gTransform. Called by BattleFx_RunAtalanta.
Definition at line 44 of file transform.c.
Referenced by BattleFx_RunAtalanta(), memcpy(), and Transform_Load().
| void Transform_Pop | ( | void | ) |
Restores gTransform from the save area, if Transform_Push saved it.
Definition at line 49 of file transform.c.
Referenced by BattleFx_RunAstralBlast(), BattleFx_RunDjinnHeal(), BattleFx_RunDjinniEntrance(), BattleFx_RunSwirlingStars(), memcpy(), and Transform_Pop().
| void SceneTransform_ResetMatrix | ( | void | ) |
Resets gTransform to identity. Reached through the far-call table.
Definition at line 58 of file transform.c.
Referenced by memcpy(), and SceneTransform_ResetMatrix().
| void SceneTransform_ApplyRotation | ( | s32 * | angles | ) |
Rotates gTransform by angles[0], angles[1] and angles[2] about the X, Y and Z axes, in that order, with one combined matrix.
Reached through the far-call table.
Definition at line 66 of file transform.c.
Referenced by memcpy(), and SceneTransform_ApplyRotation().
| void SceneTransform_ApplyPitch | ( | s32 | angle | ) |
Rotates gTransform about the X axis by angle.
Called by the battle and field cameras.
Definition at line 97 of file transform.c.
Referenced by BattleFx_DrawStreaks(), BattleFx_RunAtalanta(), BattleFx_RunCastingImpact(), BattleFx_RunDjinnHeal(), BattleFx_RunDjinniEntrance(), BattleFx_RunHaunt(), BattleFx_RunHealingMotes(), BattleFx_RunJudgment(), BattleFx_RunRingAndSparkScene(), BattleFx_RunStatBoost(), BattleFx_RunSwirlingStars(), BattleFx_RunTargetMotes(), BattleFx_RunThor(), BattlePres_SetupTransitionScene(), BattlePres_SetupTransitionSceneAtDepth(), BattlePresentation_UpdateCamera(), Camera_ConfigureScene(), Camera_InitDefaultTransform(), Camera_ResetSceneDefaults(), Map_InitializePerspectiveScene(), memcpy(), SceneTransform_ApplyPitch(), and WorldMap_UpdateView().
| void SceneTransform_ApplyYaw | ( | s32 | angle | ) |
Rotates gTransform about the Y axis by angle.
Called by the battle and field cameras.
Definition at line 113 of file transform.c.
Referenced by BattleFx_DrawStreaks(), BattleFx_RunAstralBlast(), BattleFx_RunAtalanta(), BattleFx_RunBind(), BattleFx_RunCastingImpact(), BattleFx_RunDjinnHeal(), BattleFx_RunDjinniEntrance(), BattleFx_RunHealingMotes(), BattleFx_RunJudgment(), BattleFx_RunParticleStreams(), BattleFx_RunProcne(), BattleFx_RunRingAndSparkScene(), BattleFx_RunStatBoost(), BattleFx_RunSwirlingStars(), BattleFx_RunTargetMotes(), BattleFx_RunThor(), BattleFx_RunTriangleStrike(), BattlePres_SetupTransitionScene(), BattlePres_SetupTransitionSceneAtDepth(), BattlePresentation_UpdateCamera(), Camera_ConfigureScene(), Camera_InitDefaultTransform(), Camera_ResetSceneDefaults(), Map_InitializePerspectiveScene(), memcpy(), SceneTransform_ApplyYaw(), and WorldMap_UpdateView().
| void SceneTransform_ApplyRoll | ( | s32 | angle | ) |
Rotates gTransform about the Z axis by angle.
Called by battle effects that spin their picture.
Definition at line 129 of file transform.c.
Referenced by BattleFx_DrawStreaks(), BattleFx_RunAstralBlast(), BattleFx_RunAtalanta(), BattleFx_RunBind(), BattleFx_RunCastingImpact(), BattleFx_RunDjinnHeal(), BattleFx_RunDjinniEntrance(), BattleFx_RunHealingMotes(), BattleFx_RunJudgment(), BattleFx_RunParticleStreams(), BattleFx_RunProcne(), BattleFx_RunRingAndSparkScene(), BattleFx_RunStatBoost(), BattleFx_RunSwirlingStars(), BattleFx_RunThor(), BattleFx_RunTriangleStrike(), memcpy(), and SceneTransform_ApplyRoll().
| void SceneTransform_ApplyPosition | ( | const s32 * | position | ) |
Translates gTransform by position (x, y, z in 16.16).
Called by the battle and field cameras and effects.
Definition at line 145 of file transform.c.
Referenced by BattleFx_RunAstralBlast(), BattleFx_RunDjinnBeams(), BattleFx_RunDjinnHeal(), BattleFx_RunDjinniEntrance(), BattleFx_RunFrost(), BattleFx_RunHaunt(), BattleFx_RunHealingMotes(), BattleFx_RunParticleStreams(), BattleFx_RunProcne(), BattleFx_RunSleep(), BattleFx_RunStatBoost(), BattleFx_RunStatReduction(), BattleFx_RunSwirlingStars(), BattleFx_RunTargetBursts(), BattleFx_RunTargetMotes(), BattleFx_RunThor(), BattlePres_SetupTransitionScene(), BattlePres_SetupTransitionSceneAtDepth(), BattlePresentation_UpdateCamera(), Camera_ConfigureScene(), Camera_InitDefaultTransform(), Camera_ResetSceneDefaults(), Map_InitializePerspectiveScene(), memcpy(), SceneTransform_ApplyPosition(), and WorldMap_UpdateView().
| void SceneTransform_ApplyScale | ( | const s32 * | scale | ) |
Scales gTransform by scale (x, y, z factors in 16.16).
Called by a few battle effects (Bind, Astral Blast, Thor).
Definition at line 158 of file transform.c.
Referenced by BattleFx_RunAstralBlast(), BattleFx_RunBind(), BattleFx_RunThor(), BattleFx_RunTriangleStrike(), memcpy(), and SceneTransform_ApplyScale().
Rotates gTransform by angles and translates it by position in one matrix.
Reached through the far-call table.
Definition at line 171 of file transform.c.
Referenced by memcpy(), and SceneTransform_ApplyRotationTranslation().
Rotates by angles, scales each rotation row by scale and translates by position, in one matrix.
Definition at line 202 of file transform.c.
Referenced by memcpy(), and SceneTransform_ApplyScaledRotation().
Builds in out the camera matrix of an eye at eye looking at target.
The camera's sideways axis is kept level (no Y component). Called by Transform_SetLookAt and Transform_ApplyLookAt.
Definition at line 243 of file transform.c.
Referenced by memcpy(), Transform_ApplyLookAt(), Transform_BuildLookAt(), and Transform_SetLookAt().
Makes the camera at eye looking at target the whole of gTransform.
Called by the battle cameras.
Definition at line 318 of file transform.c.
Referenced by BattlePres_SetupTransitionScene(), BattlePres_SetupTransitionSceneAtDepth(), BattlePresentation_DispatchAction(), Camera_ApplyTransformByFlag(), LuckyDice_Run(), Map_InitializePerspectiveScene(), memcpy(), ObjectSystem_UpdateCameraFixed(), Transform_SetLookAt(), and WorldMap_UpdateView().
Multiplies the camera at eye looking at target into gTransform.
Called by the battle and field object cameras.
Definition at line 324 of file transform.c.
Referenced by Camera_ApplyTransformByFlag(), memcpy(), ObjectSystem_UpdateCameraFixed(), and Transform_ApplyLookAt().
Sets gProjection from a vertical field of view: the focal length is 80 (half the screen height) over the tangent of half the angle.
Points nearer than nearDepth or farther than farDepth are not drawn. Reached through the far-call table.
Definition at line 335 of file transform.c.
Referenced by memcpy(), and Projection_SetFieldOfView().
Sets gProjection's focal length and depth range directly.
Called by the battle cameras and effects.
Definition at line 350 of file transform.c.
Referenced by BattleFx_RunThor(), BattlePres_SetupTransitionScene(), BattlePres_SetupTransitionSceneAtDepth(), BattlePresentation_DispatchAction(), Camera_ConfigureScene(), Camera_ResetSceneDefaults(), Map_InitializePerspectiveScene(), memcpy(), Projection_Set(), and WorldMap_UpdateView().
Reads three word-aligned coordinates from point, transforms them by gTransform and projects them to the screen: screen[0] and screen[1] are its pixel position and screen[2] its whole-unit depth.
Returns the projection scale (16.16), or 0 when the point is outside the depth range, when only the transformed point is written. Called by the battle and field code that places sprites in 3D.
Definition at line 364 of file transform.c.
Referenced by BattleFx_RunBeamSequence(), BattleMotion_ProjectConditionalPosition(), BattleMotion_ProjectPosition(), BattleMotion_ProjectScaledPosition(), BattlePres_SetupTransitionScene(), BattlePres_SetupTransitionSceneAtDepth(), BattleUnit_ProjectToScreen(), Camera_WorldToScreen(), EffectPosition_ProjectPoint(), Event_ShowSpeakerMessage(), LuckyDice_Run(), memcpy(), Render_PlaceProjectedSprite(), Render_ProjectPoint(), and UiText_OpenMessageAtObject().