![]() |
Super Mario 64 Source
A Super Mario 64 decompilation, brought to you by a bunch of clever folks.
|
This file contains the functions and helpers for rendering the various GdObj primitives to the screen. More...
#include <ultra64.h>
#include <macros.h>
#include <config.h>
#include "gd_types.h"
#include "gd_macros.h"
#include "gd_main.h"
#include "objects.h"
#include "dynlist_proc.h"
#include "old_menu.h"
#include "debug_utils.h"
#include "gd_math.h"
#include "shape_helper.h"
#include "renderer.h"
#include "prevent_bss_reordering.h"
#include "draw_objects.h"
Data Structures | |
struct | BetaVtx |
A possible remnant of an early ObjVertex structure that contained texture S,T coordinates. More... | |
Enumerations | |
enum | SceneType { RENDER_SCENE = 26, FIND_PICKS = 27 } |
Modes for drawscene() More... | |
Functions | |
void | func_80179B64 (struct ObjGroup *group) |
Forms uncalled recursive loop with Unknown80179ACC() More... | |
void | update_shaders (struct ObjShape *, struct GdVec3f *) |
void | draw_shape_faces (struct ObjShape *shape) |
Render the faceGroup of an ObjShape . More... | |
void | register_light (struct ObjLight *light) |
Count input ObjLight as an active light, if it wasn't already counted. More... | |
void | setup_lights (void) |
Set the ambient light color and turn on G_CULL_BACK. More... | |
void | Unknown801781DC (struct ObjZone *zone) |
void | draw_shape (struct ObjShape *shape, s32 flag, f32 c, f32 d, f32 e, f32 f, f32 g, f32 h, f32 i, f32 j, f32 k, f32 l, f32 m, f32 n, s32 colorIdx, Mat4f *rotMtx) |
void | draw_shape_2d (struct ObjShape *shape, s32 flag, UNUSED f32 c, UNUSED f32 d, UNUSED f32 e, f32 f, f32 g, f32 h, UNUSED f32 i, UNUSED f32 j, UNUSED f32 k, UNUSED f32 l, UNUSED f32 m, UNUSED f32 n, UNUSED s32 color, UNUSED s32 p) |
void | draw_light (struct ObjLight *light) |
void | draw_material (struct ObjMaterial *mtl) |
void | create_mtl_gddl_if_empty (struct ObjMaterial *mtl) |
Create a GdDisplayList and store its number in the input ObjMaterial if this material doesn't have one. More... | |
void | check_face_bad_vtx (struct ObjFace *face) |
A function for checking if an ObjFace has bad vertices. More... | |
struct GdColour * | gd_get_colour (s32 idx) |
Convert a numeric index into pointer to a struct GdColour. More... | |
void | Unknown80178ECC (f32 v0X, f32 v0Y, f32 v0Z, f32 v1X, f32 v1Y, f32 v1Z) |
Uncalled function that would render a triangle. More... | |
void | draw_face (struct ObjFace *face) |
Rendering function for ObjFace structures. More... | |
void | draw_rect_fill (s32 color, f32 ulx, f32 uly, f32 lrx, f32 lry) |
Render a filled rectangle from (ulx , uly ) to (lrx , lry ). More... | |
void | draw_rect_stroke (s32 color, f32 ulx, f32 uly, f32 lrx, f32 lry) |
Render a stroked rectangle (aka border box) from (ulx , uly ) to (lrx , lry ). More... | |
void | Unknown801792F0 (struct GdObj *obj) |
Uncalled function that calls other orphan stub functions. More... | |
void | draw_label (struct ObjLabel *label) |
void | draw_net (struct ObjNet *self) |
void | draw_gadget (struct ObjGadget *gdgt) |
void | draw_camera (struct ObjCamera *cam) |
void | Unknown80179ACC (struct GdObj *obj) |
Forms uncalled recursive loop with func_80179B64(). More... | |
void | func_80179B9C (struct GdVec3f *pos, struct ObjCamera *cam, struct ObjView *view) |
void | check_grabable_click (struct GdObj *input) |
Check if the current cursor position is near enough to input to grab that GdObj . More... | |
void | drawscene (enum SceneType process, struct ObjGroup *interactables, struct ObjGroup *lightgrp) |
The main function for rendering the components of an ObjView . More... | |
void | nop_obj_draw (UNUSED struct GdObj *nop) |
A drawing function that does nothing. More... | |
void | draw_particle (struct GdObj *obj) |
Rendering function for ObjParticle . More... | |
void | draw_bone (struct GdObj *obj) |
Rendering fucntion for ObjBone . More... | |
void | draw_joint (struct GdObj *obj) |
Rendering function for ObjJoint . More... | |
void | draw_group (struct ObjGroup *grp) |
Call apply_obj_draw_fn() to all GdObj in input ObjGroup More... | |
void | draw_plane (struct GdObj *obj) |
Rendering function for ObjPlane . More... | |
void | apply_obj_draw_fn (struct GdObj *obj) |
Apply GdObj.objDrawFn to the input GdObj if that object is draw-able. More... | |
void | Proc8017A980 (struct ObjLight *light) |
void | create_shape_mtl_gddls (struct ObjShape *shape) |
Create GdDisplayList s for any ObjMaterial s in shape that don't already have a GdDL. More... | |
void | unref_8017AEDC (struct ObjGroup *grp) |
Uncalled function that calls a stubbed function (func_8017BED0() ) for all GdObj s in grp . More... | |
s32 | create_shape_gddl (struct ObjShape *s) |
Start a new GdDisplayList struct and store its reference index in the input ObjShape . More... | |
void | create_gddl_for_shapes (struct ObjGroup *grp) |
Create GdDisplayList structs for all ObjShapes in grp by calling create_shape_gddl() . More... | |
void | map_face_materials (struct ObjGroup *faces, struct ObjGroup *mtls) |
Map material id's to ObjMaterial pointers for an ObjGroup of ObjFace structs. More... | |
void | calc_vtx_normal (struct ObjVertex *vtx, struct ObjGroup *facegrp) |
Calculate the normal for vtx based on ObjFaces in facegrp . More... | |
void | find_thisface_verts (struct ObjFace *face, struct ObjGroup *verts) |
Convert vertex indices in an ObjFace into pointers. More... | |
void | map_vertices (struct ObjGroup *facegrp, struct ObjGroup *vtxgrp) |
Convert vertex ID numbers for an ObjGroup of ObjFace s into pointers to ObjVertex structures. More... | |
void | unpick_obj (struct GdObj *obj) |
Unselect a grabbable objects. More... | |
void | find_closest_pickable_obj (struct GdObj *input) |
Find the closest object to the cursor on an A-button press. More... | |
void | set_view_update_camera (struct ObjCamera *cam) |
Set the global view camera if not already set. More... | |
void | update_view (struct ObjView *view) |
The main per-frame function for handling a view. More... | |
void | unref_8017BC94 (void) |
Stub function. More... | |
This file contains the functions and helpers for rendering the various GdObj primitives to the screen.
enum SceneType |
Modes for drawscene()
Enumerator | |
---|---|
RENDER_SCENE | render the primitives to screen |
FIND_PICKS | only check position of primitives relative to cursor click |
Apply GdObj.objDrawFn
to the input GdObj
if that object is draw-able.
obj | GdObj to draw |
Check if the current cursor position is near enough to input
to grab that GdObj
.
The range is +/- 20 units for being close to a grab point.
If the object can be grabbed, its information is stored in a buffer by store_in_pickbuf()
.
input | GdObj to check position of |
Create GdDisplayList
structs for all ObjShapes
in grp
by calling create_shape_gddl()
.
printf
call void create_mtl_gddl_if_empty | ( | struct ObjMaterial * | mtl | ) |
Create a GdDisplayList
and store its number in the input ObjMaterial
if this material doesn't have one.
Start a new GdDisplayList
struct and store its reference index in the input ObjShape
.
s | ObjShape to create GdDL for |
-1
if the DL couldn't be created, or the created DL's reference index printf
call Create GdDisplayList
s for any ObjMaterial
s in shape
that don't already have a GdDL.
Doesn't do anything if shape
's mtlGroup
is NULL
shape | Input ObjShape to create material GdDLs for |
Rendering fucntion for ObjBone
.
Call apply_obj_draw_fn()
to all GdObj
in input ObjGroup
grp | ObjGroup of objects to draw |
void draw_material | ( | struct ObjMaterial * | mtl | ) |
Rendering function for ObjParticle
.
Render a filled rectangle from (ulx
, uly
) to (lrx
, lry
).
color | GdColour index |
ulx,uly | upper left point |
lrx,lry | lower right point |
Render a stroked rectangle (aka border box) from (ulx
, uly
) to (lrx
, lry
).
color | GdColour index |
ulx,uly | upper left point |
lrx,lry | lower right point |
void draw_shape | ( | struct ObjShape * | shape, |
s32 | flag, | ||
f32 | c, | ||
f32 | d, | ||
f32 | e, | ||
f32 | f, | ||
f32 | g, | ||
f32 | h, | ||
f32 | i, | ||
f32 | j, | ||
f32 | k, | ||
f32 | l, | ||
f32 | m, | ||
f32 | n, | ||
s32 | colorIdx, | ||
Mat4f * | rotMtx | ||
) |
void draw_shape_2d | ( | struct ObjShape * | shape, |
s32 | flag, | ||
UNUSED f32 | c, | ||
UNUSED f32 | d, | ||
UNUSED f32 | e, | ||
f32 | f, | ||
f32 | g, | ||
f32 | h, | ||
UNUSED f32 | i, | ||
UNUSED f32 | j, | ||
UNUSED f32 | k, | ||
UNUSED f32 | l, | ||
UNUSED f32 | m, | ||
UNUSED f32 | n, | ||
UNUSED s32 | color, | ||
UNUSED s32 | p | ||
) |
Render the faceGroup
of an ObjShape
.
This is called from draw_shape() and draw_shape_2d(), or when creating the shape GdDisplayList
when calling create_shape_gddl()
void drawscene | ( | enum SceneType | process, |
struct ObjGroup * | interactables, | ||
struct ObjGroup * | lightgrp | ||
) |
The main function for rendering the components of an ObjView
.
It called both for drawing the various GdObj
primatives as well as when checking the location of a cursor click.
process | determines if this is rendering the scene or just checking click location |
interactables | components of ObjView |
lightgrp | lights of `ObjView |
Find the closest object to the cursor on an A-button press.
This function is applied to all objects in an ObjView.components
group to find the object closest to the cursor when there's an A press
input | GdObj to check |
Convert vertex indices in an ObjFace
into pointers.
Using the group of ObjVertex
or ObjParticle
structures in verts
, convert indices in face
into pointers. The indices are offests into the list contained in verts
group
face | ObjFace to find vertices for |
verts | ObjGroup to index in for ObjVertex or ObjPaticle structures |
Forms uncalled recursive loop with Unknown80179ACC()
Convert a numeric index into pointer to a struct GdColour.
A simple switch case to convert from index idx
to a pointer to the three f32 GdColour structure. Goddard stored the index in a structure, and uses this function to get the colour RGB values if needed. -1 uses the environment colour. A possible enhancement for this is to ennumerate all colours, and then use those enumerations and/or enum type where ever a colour is requested
idx | Index of colour |
Map material id's to ObjMaterial
pointers for an ObjGroup
of ObjFace
structs.
This is the final function used in dynlist processing (see chk_shapegen()
)
[in,out] | faces | ObjGroup of ObjFace structs to map over |
[in] | mtls | ObjGroup of ObjMaterial structs to map ids to pointers |
Convert vertex ID numbers for an ObjGroup
of ObjFace
s into pointers to ObjVertex
structures.
This function takes an ObjGroup
of ObjFace
structures whose vertices
field has indices and not pointers. These indices are transformed into pointers of ObjVertex
or ObjParticle
structures from the vtxgrp
ObjGroup
.
facegrp | ObjGroup of ObjFaces to map vertex indices to pointers |
vtxgrp | ObjGroup of ObjVertices /ObjParticles to be mapped against |
chk_shapegen()
, which performs a very similar task... A drawing function that does nothing.
This function is used for GdObj
s that don't need to be rendered
Count input ObjLight
as an active light, if it wasn't already counted.
Set the global view camera if not already set.
This function is used to find the first ObjCamera
when running update_view()
.
cam | ObjCamera to set to the update camera, if possible |
Uncalled function that would render a triangle.
Uncalled function that calls other orphan stub functions.
Forms uncalled recursive loop with func_80179B64().
This function seems to turn off the otherwise unused OBJ_DRAW_UNK01
flag for the GdObj.drawFlags
Uncalled function that calls a stubbed function (func_8017BED0()
) for all GdObj
s in grp
.
grp | Unknown group of objects |
The main per-frame function for handling a view.
This function handles updating and rendering a given ObjView
structure. It also handles the A button input for grabbing an area of an ObjShape
that is contained in the ObjView.components
group
view | The ObjView to update |
u8 gUnref_801B9B30[0x88] |
s32 mtlDlNum |
u32 pad00 |
s32 shapesDrawn |
|
static |
|
static |
|
static |
buffer of objects near click
|
static |
now, only data is the object number of a selected joint
|
static |
distance between object position and cursor click location
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
struct { ... } sUpdateViewState |
Various counters and pointers set in update_view() and used in various draw_XXX
functions.
|
static |
s32 unreadCounter |
s32 unused18 |