2022-11-06 20:49:04 -03:00
|
|
|
#ifndef Z64LIGHT_H
|
|
|
|
|
#define Z64LIGHT_H
|
2020-08-31 18:02:37 -05:00
|
|
|
|
2021-08-04 04:21:31 +01:00
|
|
|
#include "ultra64.h"
|
|
|
|
|
#include "PR/gbi.h"
|
|
|
|
|
#include "color.h"
|
2023-03-30 13:17:55 -03:00
|
|
|
#include "z64math.h"
|
2021-03-27 14:29:30 -05:00
|
|
|
|
2023-03-04 15:53:10 -03:00
|
|
|
struct PlayState;
|
|
|
|
|
|
|
|
|
|
|
2021-07-05 18:14:27 -07:00
|
|
|
typedef struct {
|
|
|
|
|
/* 0x00 */ u8 ambientColor[3];
|
|
|
|
|
/* 0x03 */ s8 diffuseDir1[3];
|
|
|
|
|
/* 0x06 */ u8 diffuseColor1[3];
|
|
|
|
|
/* 0x09 */ s8 diffusePos2[3];
|
|
|
|
|
/* 0x0C */ u8 diffuseColor[3];
|
|
|
|
|
/* 0x0F */ u8 fogColor[3];
|
2022-11-06 20:49:04 -03:00
|
|
|
/* 0x12 */ s16 fogNear;
|
2023-01-14 07:18:13 -08:00
|
|
|
/* 0x14 */ s16 zFar;
|
2021-07-05 18:14:27 -07:00
|
|
|
} LightSettings; // size = 0x16
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
/* 0x00 */ s16 ambientColor[3];
|
|
|
|
|
/* 0x06 */ s16 diffuseColor1[3];
|
|
|
|
|
/* 0x0C */ s16 diffuseColor2[3];
|
|
|
|
|
/* 0x12 */ s16 fogColor[3];
|
|
|
|
|
/* 0x18 */ s16 fogNear;
|
2023-01-14 07:18:13 -08:00
|
|
|
/* 0x1A */ s16 zFar;
|
2022-03-04 21:14:52 -03:00
|
|
|
} EnvLightSettings; // size = 0x1C
|
2021-07-05 18:14:27 -07:00
|
|
|
|
2021-03-27 14:29:30 -05:00
|
|
|
typedef struct {
|
|
|
|
|
/* 0x0 */ s16 x;
|
|
|
|
|
/* 0x2 */ s16 y;
|
|
|
|
|
/* 0x4 */ s16 z;
|
|
|
|
|
/* 0x6 */ u8 color[3];
|
|
|
|
|
/* 0x9 */ u8 drawGlow;
|
|
|
|
|
/* 0xA */ s16 radius;
|
|
|
|
|
} LightPoint; // size = 0xC
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
/* 0x0 */ s8 x;
|
|
|
|
|
/* 0x1 */ s8 y;
|
|
|
|
|
/* 0x2 */ s8 z;
|
|
|
|
|
/* 0x3 */ u8 color[3];
|
|
|
|
|
} LightDirectional; // size = 0x6
|
|
|
|
|
|
2021-05-18 22:28:04 -04:00
|
|
|
typedef union LightParams {
|
2021-03-27 14:29:30 -05:00
|
|
|
LightPoint point;
|
|
|
|
|
LightDirectional dir;
|
|
|
|
|
} LightParams; // size = 0xC
|
2020-08-31 18:02:37 -05:00
|
|
|
|
2021-05-18 22:28:04 -04:00
|
|
|
typedef struct LightInfo {
|
2020-08-31 18:02:37 -05:00
|
|
|
/* 0x0 */ u8 type;
|
2021-03-27 14:29:30 -05:00
|
|
|
/* 0x2 */ LightParams params;
|
2020-08-31 18:02:37 -05:00
|
|
|
} LightInfo; // size = 0xE
|
|
|
|
|
|
2021-05-18 22:28:04 -04:00
|
|
|
typedef struct Lights {
|
2021-03-27 14:29:30 -05:00
|
|
|
/* 0x00 */ u8 enablePosLights;
|
|
|
|
|
/* 0x01 */ u8 numLights;
|
|
|
|
|
/* 0x08 */ Lightsn l;
|
|
|
|
|
} Lights; // size = 0x80
|
2020-08-31 18:02:37 -05:00
|
|
|
|
2021-03-27 14:29:30 -05:00
|
|
|
typedef struct LightNode {
|
|
|
|
|
/* 0x0 */ LightInfo* info;
|
|
|
|
|
/* 0x4 */ struct LightNode* prev;
|
|
|
|
|
/* 0x8 */ struct LightNode* next;
|
|
|
|
|
} LightNode; // size = 0xC
|
|
|
|
|
|
|
|
|
|
#define LIGHTS_BUFFER_SIZE 32
|
|
|
|
|
|
2021-05-18 22:28:04 -04:00
|
|
|
typedef struct LightsBuffer {
|
2021-03-27 14:29:30 -05:00
|
|
|
/* 0x000 */ s32 numOccupied;
|
|
|
|
|
/* 0x004 */ s32 searchIndex;
|
|
|
|
|
/* 0x008 */ LightNode lights[LIGHTS_BUFFER_SIZE];
|
|
|
|
|
} LightsBuffer; // size = 0x188
|
|
|
|
|
|
2021-05-18 22:28:04 -04:00
|
|
|
typedef struct LightContext {
|
2021-03-27 14:29:30 -05:00
|
|
|
/* 0x0 */ LightNode* listHead;
|
|
|
|
|
/* 0x4 */ Color_RGB8 ambient;
|
2023-01-14 07:18:13 -08:00
|
|
|
/* 0x7 */ Color_RGB8 fogColor;
|
|
|
|
|
/* 0xA */ s16 fogNear; // how close until fog starts taking effect. range 0 - 996
|
|
|
|
|
/* 0xC */ s16 zFar; // draw distance. range 0 - 12800
|
2021-03-27 14:29:30 -05:00
|
|
|
} LightContext; // size = 0x10
|
2020-08-31 18:02:37 -05:00
|
|
|
|
2021-05-18 22:28:04 -04:00
|
|
|
typedef enum LightType {
|
2022-08-07 16:43:58 -07:00
|
|
|
/* 0 */ LIGHT_POINT_NOGLOW,
|
|
|
|
|
/* 1 */ LIGHT_DIRECTIONAL,
|
|
|
|
|
/* 2 */ LIGHT_POINT_GLOW
|
2021-03-27 14:29:30 -05:00
|
|
|
} LightType;
|
2020-08-31 18:02:37 -05:00
|
|
|
|
2021-03-27 14:29:30 -05:00
|
|
|
typedef void (*LightsBindFunc)(Lights* lights, LightParams* params, Vec3f* vec);
|
2022-06-26 08:57:37 -07:00
|
|
|
typedef void (*LightsPosBindFunc)(Lights* lights, LightParams* params, struct PlayState* play);
|
2020-08-31 18:02:37 -05:00
|
|
|
|
|
|
|
|
#endif
|