![]() |
Super Mario 64 Source
A Super Mario 64 decompilation, brought to you by a bunch of clever folks.
|
#include <ultra64.h>
#include "sm64.h"
#include "game/level_update.h"
#include "math_util.h"
#include "game/memory.h"
#include "graph_node.h"
#include "game/rendering_graph_node.h"
#include "game/area.h"
#include "geo_layout.h"
Functions | |
void | init_scene_graph_node_links (struct GraphNode *graphNode, s32 type) |
Initialize a geo node with a given type. More... | |
struct GraphNodeRoot * | init_graph_node_root (struct AllocOnlyPool *pool, struct GraphNodeRoot *graphNode, s16 areaIndex, s16 x, s16 y, s16 width, s16 height) |
Allocated and returns a newly created root node. More... | |
struct GraphNodeOrthoProjection * | init_graph_node_ortho_projection (struct AllocOnlyPool *pool, struct GraphNodeOrthoProjection *graphNode, f32 scale) |
Allocates and returns a newly created otrhographic projection node. More... | |
struct GraphNodePerspective * | init_graph_node_perspective (struct AllocOnlyPool *pool, struct GraphNodePerspective *graphNode, f32 fov, s16 near, s16 far, GraphNodeFunc nodeFunc, s32 unused) |
Allocates and returns a newly created perspective node. More... | |
struct GraphNodeStart * | init_graph_node_start (struct AllocOnlyPool *pool, struct GraphNodeStart *graphNode) |
Allocates and returns a newly created start node. More... | |
struct GraphNodeMasterList * | init_graph_node_master_list (struct AllocOnlyPool *pool, struct GraphNodeMasterList *graphNode, s16 on) |
Allocates and returns a newly created master list node. More... | |
struct GraphNodeLevelOfDetail * | init_graph_node_render_range (struct AllocOnlyPool *pool, struct GraphNodeLevelOfDetail *graphNode, s16 minDistance, s16 maxDistance) |
Allocates and returns a newly created render range node. More... | |
struct GraphNodeSwitchCase * | init_graph_node_switch_case (struct AllocOnlyPool *pool, struct GraphNodeSwitchCase *graphNode, s16 numCases, s16 selectedCase, GraphNodeFunc nodeFunc, s32 unused) |
Allocates and returns a newly created switch case node. More... | |
struct GraphNodeCamera * | init_graph_node_camera (struct AllocOnlyPool *pool, struct GraphNodeCamera *graphNode, f32 *fromPos, f32 *toPos, GraphNodeFunc func, s32 preset) |
Allocates and returns a newly created camera node. More... | |
struct GraphNodeTranslationRotation * | init_graph_node_translation_rotation (struct AllocOnlyPool *pool, struct GraphNodeTranslationRotation *graphNode, s32 drawingLayer, void *displayList, Vec3s translation, Vec3s rotation) |
Allocates and returns a newly created translation rotation node. More... | |
struct GraphNodeTranslation * | init_graph_node_translation (struct AllocOnlyPool *pool, struct GraphNodeTranslation *graphNode, s32 drawingLayer, void *displayList, Vec3s translation) |
Allocates and returns a newly created translation node. More... | |
struct GraphNodeRotation * | init_graph_node_rotation (struct AllocOnlyPool *pool, struct GraphNodeRotation *graphNode, s32 drawingLayer, void *displayList, Vec3s rotation) |
Allocates and returns a newly created rotation node. More... | |
struct GraphNodeScale * | init_graph_node_scale (struct AllocOnlyPool *pool, struct GraphNodeScale *graphNode, s32 drawingLayer, void *displayList, f32 scale) |
Allocates and returns a newly created scaling node. More... | |
struct GraphNodeObject * | init_graph_node_object (struct AllocOnlyPool *pool, struct GraphNodeObject *graphNode, struct GraphNode *sharedChild, Vec3f pos, Vec3s angle, Vec3f scale) |
Allocates and returns a newly created object node. More... | |
struct GraphNodeCullingRadius * | init_graph_node_culling_radius (struct AllocOnlyPool *pool, struct GraphNodeCullingRadius *graphNode, s16 radius) |
Allocates and returns a newly created frustum culling radius node. More... | |
struct GraphNodeAnimatedPart * | init_graph_node_animated_part (struct AllocOnlyPool *pool, struct GraphNodeAnimatedPart *graphNode, s32 drawingLayer, void *displayList, Vec3s translation) |
Allocates and returns a newly created animated part node. More... | |
struct GraphNodeBillboard * | init_graph_node_billboard (struct AllocOnlyPool *pool, struct GraphNodeBillboard *graphNode, s32 drawingLayer, void *displayList, Vec3s translation) |
Allocates and returns a newly created billboard node. More... | |
struct GraphNodeDisplayList * | init_graph_node_display_list (struct AllocOnlyPool *pool, struct GraphNodeDisplayList *graphNode, s32 drawingLayer, void *displayList) |
Allocates and returns a newly created displaylist node. More... | |
struct GraphNodeShadow * | init_graph_node_shadow (struct AllocOnlyPool *pool, struct GraphNodeShadow *graphNode, s16 shadowScale, u8 shadowSolidity, u8 shadowType) |
Allocates and returns a newly created shadow node. More... | |
struct GraphNodeObjectParent * | init_graph_node_object_parent (struct AllocOnlyPool *pool, struct GraphNodeObjectParent *graphNode, struct GraphNode *sharedChild) |
Allocates and returns a newly created object parent node. More... | |
struct GraphNodeGenerated * | init_graph_node_generated (struct AllocOnlyPool *pool, struct GraphNodeGenerated *graphNode, GraphNodeFunc gfxFunc, s32 parameter) |
Allocates and returns a newly created generated node. More... | |
struct GraphNodeBackground * | init_graph_node_background (struct AllocOnlyPool *pool, struct GraphNodeBackground *graphNode, u16 background, GraphNodeFunc backgroundFunc, s32 zero) |
Allocates and returns a newly created background node. More... | |
struct GraphNodeHeldObject * | init_graph_node_held_object (struct AllocOnlyPool *pool, struct GraphNodeHeldObject *graphNode, s32 objNode, Vec3s translation, GraphNodeFunc nodeFunc, s32 unused) |
Allocates and returns a newly created held object node. More... | |
struct GraphNode * | geo_add_child (struct GraphNode *parent, struct GraphNode *childNode) |
Adds 'childNode' to the end of the list children from 'parent'. More... | |
struct GraphNode * | geo_remove_child (struct GraphNode *graphNode) |
Remove a node from the scene graph. More... | |
struct GraphNode * | geo_make_first_child (struct GraphNode *newFirstChild) |
Reorders the given node so it's the first child of its parent. More... | |
void | geo_call_global_function_nodes_helper (struct GraphNode *graphNode, s32 callContext) |
Helper function for geo_call_global_function_nodes that recursively traverses the scene graph and calls the functions of global nodes. More... | |
void | geo_call_global_function_nodes (struct GraphNode *graphNode, s32 callContext) |
Call the update functions of geo nodes that are stored in global variables. More... | |
void | geo_reset_object_node (struct GraphNodeObject *graphNode) |
When objects are cleared, this is called on all object nodes (loaded or unloaded). More... | |
void | geo_obj_init (struct GraphNodeObject *graphNode, void *sharedChild, Vec3f pos, Vec3s angle) |
Initialize an object node using the given parameters. More... | |
void | geo_obj_init_spawninfo (struct GraphNodeObject *graphNode, struct SpawnInfo *spawn) |
Initialize and object node using the given SpawnInfo struct. More... | |
void | geo_obj_init_animation (struct GraphNodeObject *graphNode, void *sp34) |
Initialize the animation of an object node. More... | |
void | geo_obj_init_animation_accel (struct GraphNodeObject *graphNode, void *sp34, u32 animAccel) |
Initialize the animation of an object node. More... | |
s32 | retrieve_animation_index (s32 frame, u16 **attributes) |
Retrieves an index into animation data based on the attribute pointer An attribute is an x-, y- or z-component of the translation / rotation for a part Each attribute is a pair of s16's, where the first s16 represents the maximum frame and the second s16 the actual index. More... | |
s16 | geo_update_animation_frame (struct GraphNodeObject_sub *obj, s32 *accelAssist) |
Update the animation frame of an object. More... | |
void | geo_retreive_animation_translation (struct GraphNodeObject *obj, Vec3f position) |
Unused function to retrieve an object's current animation translation Assumes that it has x, y and z data in animations, which isn't always the case since some animation types only have vertical or lateral translation. More... | |
struct GraphNodeRoot * | geo_find_root (struct GraphNode *graphNode) |
Unused function to find the root of the geo node tree, which should be a GraphNodeRoot. More... | |
Variables | |
s16 | identityMtx [4][4] = { { 1, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 } } |
s16 | zeroMtx [4][4] = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } } |
Vec3f | gVec3fZero = { 0.0f, 0.0f, 0.0f } |
Vec3s | gVec3sZero = { 0, 0, 0 } |
Vec3f | gVec3fOne = { 1.0f, 1.0f, 1.0f } |
UNUSED Vec3s | gVec3sOne = { 1, 1, 1 } |
Adds 'childNode' to the end of the list children from 'parent'.
Call the update functions of geo nodes that are stored in global variables.
These variables include gCurGraphNodeMasterList, gCurGraphNodeCamFrustum, gCurGraphNodeCamera and gCurGraphNodeObject. callContext is one of the GEO_CONTEXT_ defines. The graphNode argument should be of type GraphNodeRoot.
Helper function for geo_call_global_function_nodes that recursively traverses the scene graph and calls the functions of global nodes.
struct GraphNodeRoot* geo_find_root | ( | struct GraphNode * | graphNode | ) |
Unused function to find the root of the geo node tree, which should be a GraphNodeRoot.
If it is not for some reason, null is returned.
Reorders the given node so it's the first child of its parent.
This is called on the Mario object when he is spawned. That's why Mario's object is always drawn before any other objects. (Note that the geo order is independent from processing group order, where Mario is not first.)
void geo_obj_init | ( | struct GraphNodeObject * | graphNode, |
void * | sharedChild, | ||
Vec3f | pos, | ||
Vec3s | angle | ||
) |
Initialize an object node using the given parameters.
void geo_obj_init_animation | ( | struct GraphNodeObject * | graphNode, |
void * | sp34 | ||
) |
Initialize the animation of an object node.
void geo_obj_init_animation_accel | ( | struct GraphNodeObject * | graphNode, |
void * | sp34, | ||
u32 | animAccel | ||
) |
Initialize the animation of an object node.
void geo_obj_init_spawninfo | ( | struct GraphNodeObject * | graphNode, |
struct SpawnInfo * | spawn | ||
) |
Initialize and object node using the given SpawnInfo struct.
Remove a node from the scene graph.
It changes the links with its siblings and with its parent, it doesn't deallocate the memory since geo nodes are allocated in a pointer-bumping pool that gets thrown out when changing areas.
void geo_reset_object_node | ( | struct GraphNodeObject * | graphNode | ) |
When objects are cleared, this is called on all object nodes (loaded or unloaded).
void geo_retreive_animation_translation | ( | struct GraphNodeObject * | obj, |
Vec3f | position | ||
) |
Unused function to retrieve an object's current animation translation Assumes that it has x, y and z data in animations, which isn't always the case since some animation types only have vertical or lateral translation.
This might have been used for positioning the shadow under an object, which currently happens in-line in geo_process_shadow where it also accounts for animations without lateral translation.
s16 geo_update_animation_frame | ( | struct GraphNodeObject_sub * | obj, |
s32 * | accelAssist | ||
) |
Update the animation frame of an object.
The animation flags determine whether it plays forwards or backwards, and whether it stops or loops at the end etc.
struct GraphNodeAnimatedPart* init_graph_node_animated_part | ( | struct AllocOnlyPool * | pool, |
struct GraphNodeAnimatedPart * | graphNode, | ||
s32 | drawingLayer, | ||
void * | displayList, | ||
Vec3s | translation | ||
) |
Allocates and returns a newly created animated part node.
struct GraphNodeBackground* init_graph_node_background | ( | struct AllocOnlyPool * | pool, |
struct GraphNodeBackground * | graphNode, | ||
u16 | background, | ||
GraphNodeFunc | backgroundFunc, | ||
s32 | zero | ||
) |
Allocates and returns a newly created background node.
struct GraphNodeBillboard* init_graph_node_billboard | ( | struct AllocOnlyPool * | pool, |
struct GraphNodeBillboard * | graphNode, | ||
s32 | drawingLayer, | ||
void * | displayList, | ||
Vec3s | translation | ||
) |
Allocates and returns a newly created billboard node.
struct GraphNodeCamera* init_graph_node_camera | ( | struct AllocOnlyPool * | pool, |
struct GraphNodeCamera * | graphNode, | ||
f32 * | fromPos, | ||
f32 * | toPos, | ||
GraphNodeFunc | func, | ||
s32 | preset | ||
) |
Allocates and returns a newly created camera node.
struct GraphNodeCullingRadius* init_graph_node_culling_radius | ( | struct AllocOnlyPool * | pool, |
struct GraphNodeCullingRadius * | graphNode, | ||
s16 | radius | ||
) |
Allocates and returns a newly created frustum culling radius node.
struct GraphNodeDisplayList* init_graph_node_display_list | ( | struct AllocOnlyPool * | pool, |
struct GraphNodeDisplayList * | graphNode, | ||
s32 | drawingLayer, | ||
void * | displayList | ||
) |
Allocates and returns a newly created displaylist node.
struct GraphNodeGenerated* init_graph_node_generated | ( | struct AllocOnlyPool * | pool, |
struct GraphNodeGenerated * | graphNode, | ||
GraphNodeFunc | gfxFunc, | ||
s32 | parameter | ||
) |
Allocates and returns a newly created generated node.
struct GraphNodeHeldObject* init_graph_node_held_object | ( | struct AllocOnlyPool * | pool, |
struct GraphNodeHeldObject * | graphNode, | ||
s32 | objNode, | ||
Vec3s | translation, | ||
GraphNodeFunc | nodeFunc, | ||
s32 | unused | ||
) |
Allocates and returns a newly created held object node.
struct GraphNodeMasterList* init_graph_node_master_list | ( | struct AllocOnlyPool * | pool, |
struct GraphNodeMasterList * | graphNode, | ||
s16 | on | ||
) |
Allocates and returns a newly created master list node.
struct GraphNodeObject* init_graph_node_object | ( | struct AllocOnlyPool * | pool, |
struct GraphNodeObject * | graphNode, | ||
struct GraphNode * | sharedChild, | ||
Vec3f | pos, | ||
Vec3s | angle, | ||
Vec3f | scale | ||
) |
Allocates and returns a newly created object node.
struct GraphNodeObjectParent* init_graph_node_object_parent | ( | struct AllocOnlyPool * | pool, |
struct GraphNodeObjectParent * | graphNode, | ||
struct GraphNode * | sharedChild | ||
) |
Allocates and returns a newly created object parent node.
struct GraphNodeOrthoProjection* init_graph_node_ortho_projection | ( | struct AllocOnlyPool * | pool, |
struct GraphNodeOrthoProjection * | graphNode, | ||
f32 | scale | ||
) |
Allocates and returns a newly created otrhographic projection node.
struct GraphNodePerspective* init_graph_node_perspective | ( | struct AllocOnlyPool * | pool, |
struct GraphNodePerspective * | graphNode, | ||
f32 | fov, | ||
s16 | near, | ||
s16 | far, | ||
GraphNodeFunc | nodeFunc, | ||
s32 | unused | ||
) |
Allocates and returns a newly created perspective node.
struct GraphNodeLevelOfDetail* init_graph_node_render_range | ( | struct AllocOnlyPool * | pool, |
struct GraphNodeLevelOfDetail * | graphNode, | ||
s16 | minDistance, | ||
s16 | maxDistance | ||
) |
Allocates and returns a newly created render range node.
struct GraphNodeRoot* init_graph_node_root | ( | struct AllocOnlyPool * | pool, |
struct GraphNodeRoot * | graphNode, | ||
s16 | areaIndex, | ||
s16 | x, | ||
s16 | y, | ||
s16 | width, | ||
s16 | height | ||
) |
Allocated and returns a newly created root node.
struct GraphNodeRotation* init_graph_node_rotation | ( | struct AllocOnlyPool * | pool, |
struct GraphNodeRotation * | graphNode, | ||
s32 | drawingLayer, | ||
void * | displayList, | ||
Vec3s | rotation | ||
) |
Allocates and returns a newly created rotation node.
struct GraphNodeScale* init_graph_node_scale | ( | struct AllocOnlyPool * | pool, |
struct GraphNodeScale * | graphNode, | ||
s32 | drawingLayer, | ||
void * | displayList, | ||
f32 | scale | ||
) |
Allocates and returns a newly created scaling node.
struct GraphNodeShadow* init_graph_node_shadow | ( | struct AllocOnlyPool * | pool, |
struct GraphNodeShadow * | graphNode, | ||
s16 | shadowScale, | ||
u8 | shadowSolidity, | ||
u8 | shadowType | ||
) |
Allocates and returns a newly created shadow node.
struct GraphNodeStart* init_graph_node_start | ( | struct AllocOnlyPool * | pool, |
struct GraphNodeStart * | graphNode | ||
) |
Allocates and returns a newly created start node.
struct GraphNodeSwitchCase* init_graph_node_switch_case | ( | struct AllocOnlyPool * | pool, |
struct GraphNodeSwitchCase * | graphNode, | ||
s16 | numCases, | ||
s16 | selectedCase, | ||
GraphNodeFunc | nodeFunc, | ||
s32 | unused | ||
) |
Allocates and returns a newly created switch case node.
struct GraphNodeTranslation* init_graph_node_translation | ( | struct AllocOnlyPool * | pool, |
struct GraphNodeTranslation * | graphNode, | ||
s32 | drawingLayer, | ||
void * | displayList, | ||
Vec3s | translation | ||
) |
Allocates and returns a newly created translation node.
struct GraphNodeTranslationRotation* init_graph_node_translation_rotation | ( | struct AllocOnlyPool * | pool, |
struct GraphNodeTranslationRotation * | graphNode, | ||
s32 | drawingLayer, | ||
void * | displayList, | ||
Vec3s | translation, | ||
Vec3s | rotation | ||
) |
Allocates and returns a newly created translation rotation node.
Initialize a geo node with a given type.
Sets all links such that there are no siblings, parent or children for this node.
Retrieves an index into animation data based on the attribute pointer An attribute is an x-, y- or z-component of the translation / rotation for a part Each attribute is a pair of s16's, where the first s16 represents the maximum frame and the second s16 the actual index.
This index can be used to index in the array with actual animation values.
Vec3f gVec3fOne = { 1.0f, 1.0f, 1.0f } |
Vec3f gVec3fZero = { 0.0f, 0.0f, 0.0f } |
Vec3s gVec3sZero = { 0, 0, 0 } |
s16 identityMtx[4][4] = { { 1, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 } } |
s16 zeroMtx[4][4] = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } } |