Skip to content

Commit

Permalink
Wind Waker: housi
Browse files Browse the repository at this point in the history
  • Loading branch information
magcius committed Oct 8, 2023
1 parent 3217988 commit f4e7726
Show file tree
Hide file tree
Showing 5 changed files with 238 additions and 42 deletions.
18 changes: 9 additions & 9 deletions src/TwilightPrincess/d_kankyo_wether.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function dKyw_wether_move_draw(globals: dGlobals, deltaTimeInFrames: numb
}

export function dKyw_wether_init2(globals: dGlobals): void {

}

export function dKyw_wether_delete2(globals: dGlobals): void {
Expand Down Expand Up @@ -954,7 +954,7 @@ export class dKankyo_housi_Packet {
const mb = new GXMaterialBuilder();
// noclip modification: Use VTX instead of separate draw calls for the color.
//mb.setChanCtrl(GX.ColorChannelID.COLOR0A0, false, GX.ColorSrc.REG, GX.ColorSrc.VTX, 0, GX.DiffuseFunction.NONE, GX.AttenuationFunction.NONE);

mb.setTexCoordGen(GX.TexCoordID.TEXCOORD0, GX.TexGenType.MTX2x4, GX.TexGenSrc.TEX0, GX.TexGenMatrix.IDENTITY);
mb.setTevOrder(0, GX.TexCoordID.TEXCOORD0, GX.TexMapID.TEXMAP0, GX.RasColorChannelID.COLOR0A0);
mb.setTevColorIn(0, GX.CC.C1, GX.CC.RASC, GX.CC.TEXC, GX.CC.ZERO);
Expand Down Expand Up @@ -1025,7 +1025,7 @@ export class dKankyo_housi_Packet {

if (envLight.housiCount === 0)
return;

this.ddraw.beginDraw(globals.modelCache.cache);
this.drawHousi(globals, renderInstManager, viewerInput);
this.ddraw.endDraw(renderInstManager);
Expand Down Expand Up @@ -1177,7 +1177,7 @@ export class dKankyo_rain_Packet {
const sibukiCount = envLight.rainCount >>> 1;
if (sibukiCount < 1)
return;

const alphaTarget = this.sibukiHidden ? 0.0 : 200/255;
this.sibukiAlpha = cLib_addCalc(this.sibukiAlpha, alphaTarget, 0.2, 3.0, 0.001);

Expand Down Expand Up @@ -1781,7 +1781,7 @@ function wether_move_star(globals: dGlobals, deltaTimeInFrames: number): void {
let starAmount = 1.0;

const curTime = envLight.curTime;

if (curTime >= 330.0 && curTime < 45.0)
starAmount = 1.0;
else if (curTime >= 75.0 && curTime < 285.0)
Expand Down Expand Up @@ -1877,7 +1877,7 @@ function vrkumo_move(globals: dGlobals, deltaTimeInFrames: number): void {

let skyboxOffsY: number;
skyboxOffsY = 1000.0 + pkt.strength * -500.0;


{
const fili = globals.roomStatus[globals.mStayNo].fili;
Expand All @@ -1904,7 +1904,7 @@ function vrkumo_move(globals: dGlobals, deltaTimeInFrames: number): void {
if (rnd_1 > 15000.0) {
rnd_1 = cM_rndF(1000.0) + 14000;
}

let x = Math.sin(rnd_0);
if (Math.abs(rnd_1 * x) != 0.0) {
if (x <= 0.0) {
Expand All @@ -1925,7 +1925,7 @@ function vrkumo_move(globals: dGlobals, deltaTimeInFrames: number): void {

kumo.position[0] = x;
kumo.position[1] = 0;
kumo.position[2] = z;
kumo.position[2] = z;

distFromCenterXZ = Math.hypot(kumo.position[0], kumo.position[2]);
}
Expand Down Expand Up @@ -1953,7 +1953,7 @@ function vrkumo_move(globals: dGlobals, deltaTimeInFrames: number): void {

let alphaTarget: number;
let alphaMaxVel = 1.0;

if (i < pkt.count) {
alphaMaxVel = 0.1;
if (kumo.distFalloff >= 0.05 && kumo.distFalloff < 0.2)
Expand Down
18 changes: 11 additions & 7 deletions src/WindWaker/d_a.ts
Original file line number Diff line number Diff line change
Expand Up @@ -895,17 +895,19 @@ class d_a_kytag00 extends fopAc_ac_c {

if (this.effectMode === Kytag00EffectMode.Rain) {
this.raincnt_set(globals, target);
} else if (this.effectMode === Kytag00EffectMode.Housi) {
envLight.housiCount = target * 300.0;
} else if (this.effectMode === Kytag00EffectMode.Thunder) {
if (envLight.thunderMode === ThunderMode.Off)
envLight.thunderMode = 2;
envLight.thunderMode = ThunderMode.TagActivated;
} else if (this.effectMode === Kytag00EffectMode.ThunderAndRain) {
if (envLight.thunderMode === ThunderMode.Off)
envLight.thunderMode = 2;
envLight.thunderMode = ThunderMode.TagActivated;
this.raincnt_set(globals, target);
} else if (this.effectMode === Kytag00EffectMode.Moya9) {
// TODO(jstpierre): moya
if (envLight.thunderMode === ThunderMode.Off)
envLight.thunderMode = 2;
envLight.thunderMode = ThunderMode.TagActivated;
this.raincnt_set(globals, target);
} else {
// TODO(jstpierre): The rest of the modes.
Expand All @@ -924,16 +926,18 @@ class d_a_kytag00 extends fopAc_ac_c {

if (this.effectMode === Kytag00EffectMode.Rain) {
this.raincnt_cut(globals);
} else if (this.effectMode === Kytag00EffectMode.Housi) {
envLight.housiCount = 0;
} else if (this.effectMode === Kytag00EffectMode.Thunder) {
if (envLight.thunderMode === 2)
if (envLight.thunderMode === ThunderMode.TagActivated)
envLight.thunderMode = ThunderMode.Off;
} else if (this.effectMode === Kytag00EffectMode.ThunderAndRain) {
if (envLight.thunderMode === 2)
if (envLight.thunderMode === ThunderMode.TagActivated)
envLight.thunderMode = ThunderMode.Off;
this.raincnt_cut(globals);
} else if (this.effectMode === Kytag00EffectMode.Moya9) {
// TODO(jstpierre): moya
if (envLight.thunderMode === 2)
if (envLight.thunderMode === ThunderMode.TagActivated)
envLight.thunderMode = ThunderMode.Off;
this.raincnt_cut(globals);
}
Expand Down Expand Up @@ -4643,7 +4647,7 @@ export class d_a_ff extends fopAc_ac_c {
mDoMtx_YrotS(calc_mtx, this.rot[1]);
mDoMtx_XrotM(calc_mtx, this.rot[0]);
MtxPosition(this.speed, scratchVec3a);
vec3.add(this.pos, this.pos, this.speed);
vec3.scaleAndAdd(this.pos, this.pos, this.speed, deltaTimeInFrames);
}

if (this.pos[1] >= this.groundY + 12.5) {
Expand Down
26 changes: 14 additions & 12 deletions src/WindWaker/d_kankyo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ColorKind, MaterialParams } from "../gx/gx_render.js";
import { arrayRemove, assert, assertExists, nArray } from "../util.js";
import { ViewerRenderInput } from "../viewer.js";
import { cLib_addCalc, cLib_addCalc2, cM_rndF } from "./SComponent.js";
import { ThunderMode, ThunderState, dKankyo__CommonTextures, dKankyo__Windline, dKankyo_rain_Packet, dKankyo_star_Packet, dKankyo_sun_Packet, dKankyo_vrkumo_Packet, dKankyo_wave_Packet, dKy_wave_chan_init, dKyr__sun_arrival_check, dKyw_rain_set, dKyw_wether_draw, dKyw_wether_draw2, dKyw_wether_move, dKyw_wether_move_draw, dKyw_wether_move_draw2, dKyw_wind_set } from "./d_kankyo_wether.js";
import { ThunderMode, ThunderState, dKankyo__CommonTextures, dKankyo__Windline, dKankyo_housi_Packet, dKankyo_rain_Packet, dKankyo_star_Packet, dKankyo_sun_Packet, dKankyo_vrkumo_Packet, dKankyo_wave_Packet, dKy_wave_chan_init, dKyr__sun_arrival_check, dKyw_rain_set, dKyw_wether_draw, dKyw_wether_draw2, dKyw_wether_move, dKyw_wether_move_draw, dKyw_wether_move_draw2, dKyw_wind_set } from "./d_kankyo_wether.js";
import { stage_envr_info_class, stage_palet_info_class, stage_palet_info_class__DifAmb, stage_pselect_info_class, stage_vrbox_info_class } from "./d_stage.js";
import { cPhs__Status, fGlobals, fopKyM_Create, fpcPf__Register, fpc__ProcessName, fpc_bs__Constructor, kankyo_class } from "./framework.js";
import { dGlobals } from "./zww_scenes.js";
Expand Down Expand Up @@ -107,17 +107,6 @@ export class dScnKy_env_light_c {

// Weather.
public colpatWeather = 0;

// Wind
public windTactAngleX: number = 0;
public windTactAngleY: number = 0;
public windVec = vec3.fromValues(0.0, 0.0, 0.0);
public windPower = 0.0;
public customWindPower = 0.0;

// TODO(jstpierre): Move these weather states to their own structs?

// Dice weather system
public diceWeatherStop: boolean = false;
public diceWeatherMode: DiceWeatherMode = DiceWeatherMode.Sunny;
public diceWeatherChangeTime: number;
Expand All @@ -126,6 +115,13 @@ export class dScnKy_env_light_c {
public diceWeatherCounter: number = 0;
public diceWeatherTime: number = 0.0;

// Wind
public windTactAngleX: number = 0;
public windTactAngleY: number = 0;
public windVec = vec3.fromValues(0.0, 0.0, 0.0);
public windPower = 0.0;
public customWindPower = 0.0;

// Rain.
public rainCount: number = 0;
public rainCountOrig: number = 0;
Expand Down Expand Up @@ -153,6 +149,9 @@ export class dScnKy_env_light_c {
public waveScaleBottom = 0.0;
public waveReset = false;

// Housi.
public housiCount = 0;

// Wether packets
public wetherCommonTextures: dKankyo__CommonTextures;
public sunPacket: dKankyo_sun_Packet | null = null;
Expand All @@ -161,6 +160,7 @@ export class dScnKy_env_light_c {
public windline: dKankyo__Windline | null = null;
public wavePacket: dKankyo_wave_Packet | null = null;
public starPacket: dKankyo_star_Packet | null = null;
public housiPacket: dKankyo_housi_Packet | null = null;

public eventNightStop: boolean = false;
public forceTimePass: boolean = false;
Expand Down Expand Up @@ -1384,6 +1384,8 @@ class d_kyeff extends kankyo_class {
envLight.wavePacket.destroy(device);
if (envLight.starPacket !== null)
envLight.starPacket.destroy(device);
if (envLight.housiPacket !== null)
envLight.housiPacket.destroy(device);
}
}

Expand Down
Loading

0 comments on commit f4e7726

Please sign in to comment.