Finish CSamusHud and subsystems

This commit is contained in:
Jack Andersen 2017-04-13 09:28:31 -10:00
parent 84578e9909
commit 0fe125d913
42 changed files with 1094 additions and 316 deletions

View File

@ -35,6 +35,10 @@ struct ITweakGui : ITweak
virtual float GetEnergyBarShadowSpeed() const=0;
virtual float GetEnergyBarDrainDelay() const=0;
virtual bool GetEnergyBarAlwaysResetDelay() const=0;
virtual float GetHudDamagePracticalsGainConstant() const=0;
virtual float GetHudDamagePracticalsGainLinear() const=0;
virtual float GetHudDamagePracticalsInitConstant() const=0;
virtual float GetHudDamagePracticalsInitLinear() const=0;
virtual float GetHudDamageLightSpotAngle() const=0;
virtual float GetDamageLightAngleC() const=0;
virtual float GetDamageLightAngleL() const=0;
@ -43,6 +47,15 @@ struct ITweakGui : ITweak
virtual atVec3f GetDamageLightCenterTranslate() const=0;
virtual float GetDamageLightXfXAngle() const=0;
virtual float GetDamageLightXfZAngle() const=0;
virtual float GetHudDecoShakeTranslateVelConstant() const=0;
virtual float GetHudDecoShakeTranslateVelLinear() const=0;
virtual float GetMaxDecoDamageShakeTranslate() const=0;
virtual float GetDecoDamageShakeDeceleration() const=0;
virtual float GetDecoShakeGainConstant() const=0;
virtual float GetDecoShakeGainLinear() const=0;
virtual float GetDecoShakeInitConstant() const=0;
virtual float GetDecoShakeInitLinear() const=0;
virtual float GetMaxDecoDamageShakeRotate() const=0;
virtual atUint32 GetHudCamFovTweak() const=0;
virtual atUint32 GetHudCamYTweak() const=0;
virtual atUint32 GetHudCamZTweak() const=0;
@ -65,7 +78,20 @@ struct ITweakGui : ITweak
virtual float GetFreeLookFadeTime() const=0;
virtual float GetFreeLookSfxPitchScale() const=0;
virtual bool GetNoAbsoluteFreeLookSfxPitch() const=0;
virtual float GetFaceReflectionDistance() const=0;
virtual float GetFaceReflectionHeight() const=0;
virtual float GetMissileWarningPulseTime() const=0;
virtual float GetExplosionLightFalloffMultConstant() const=0;
virtual float GetExplosionLightFalloffMultLinear() const=0;
virtual float GetExplosionLightFalloffMultQuadratic() const=0;
virtual float GetHudDamagePeakFactor() const=0;
virtual float GetHudDamageFilterGainConstant() const=0;
virtual float GetHudDamageFilterGainLinear() const=0;
virtual float GetHudDamageFilterInitConstant() const=0;
virtual float GetHudDamageFilterInitLinear() const=0;
virtual float GetHudDamagePulseDuration() const=0;
virtual float GetHudDamageColorGain() const=0;
virtual float GetHudDecoShakeTranslateGain() const=0;
virtual float GetHudLagOffsetScale() const=0;
virtual float GetScanAppearanceOffset() const=0;
virtual float GetBallViewportYReduction() const=0;
@ -86,6 +112,15 @@ struct ITweakGui : ITweak
virtual const zeus::CColor& GetXRayFogColor() const=0;
virtual float GetThermalVisorLevel() const=0;
virtual const zeus::CColor& GetThermalVisorColor() const=0;
virtual const zeus::CColor& GetVisorHudLightAdd(int v) const=0;
virtual const zeus::CColor& GetVisorHudLightMultiply(int v) const=0;
virtual const zeus::CColor& GetHudReflectivityLightColor() const=0;
virtual float GetHudLightAttMulConstant() const=0;
virtual float GetHudLightAttMulLinear() const=0;
virtual float GetHudLightAttMulQuadratic() const=0;
static float FaceReflectionDistanceDebugValueToActualValue(float v) { return 0.015f * v + 0.2f; }
static float FaceReflectionHeightDebugValueToActualValue(float v) { return 0.005f * v - 0.05f; }
};
}

View File

@ -9,79 +9,83 @@ struct ITweakGuiColors : BigYAML
{
struct VisorEnergyInitColors
{
zeus::CColor tankFilled;
zeus::CColor tankEmpty;
zeus::CColor digitsFont;
zeus::CColor digitsOutline;
const zeus::CColor& tankFilled;
const zeus::CColor& tankEmpty;
const zeus::CColor& digitsFont;
const zeus::CColor& digitsOutline;
};
struct VisorEnergyBarColors
{
zeus::CColor filled;
zeus::CColor empty;
zeus::CColor shadow;
const zeus::CColor& filled;
const zeus::CColor& empty;
const zeus::CColor& shadow;
};
virtual zeus::CColor GetRadarStuffColor() const=0;
virtual zeus::CColor GetRadarPlayerPaintColor() const=0;
virtual zeus::CColor GetRadarEnemyPaintColor() const=0;
virtual zeus::CColor GetHudMessageFill() const=0;
virtual zeus::CColor GetHudMessageOutline() const=0;
virtual zeus::CColor GetHudFrameColor() const=0;
virtual zeus::CColor GetMissileIconColorActive() const=0;
virtual zeus::CColor GetVisorBeamMenuItemActive() const=0;
virtual zeus::CColor GetVisorBeamMenuItemInactive() const=0;
virtual zeus::CColor GetEnergyBarFilledLowEnergy() const=0;
virtual zeus::CColor GetEnergyBarShadowLowEnergy() const=0;
virtual zeus::CColor GetEnergyBarEmptyLowEnergy() const=0;
virtual zeus::CColor GetHudDamageLightColor() const=0;
virtual zeus::CColor GetVisorMenuTextFont() const=0;
virtual zeus::CColor GetVisorMenuTextOutline() const=0;
virtual zeus::CColor GetBeamMenuTextFont() const=0;
virtual zeus::CColor GetBeamMenuTextOutline() const=0;
virtual zeus::CColor GetEnergyWarningFont() const=0;
virtual zeus::CColor GetThreatWarningFont() const=0;
virtual zeus::CColor GetMissileWarningFont() const=0;
virtual zeus::CColor GetThreatBarFilled() const=0;
virtual zeus::CColor GetThreatBarShadow() const=0;
virtual zeus::CColor GetThreatBarEmpty() const=0;
virtual zeus::CColor GetMissileBarFilled() const=0;
virtual zeus::CColor GetMissileBarShadow() const=0;
virtual zeus::CColor GetMissileBarEmpty() const=0;
virtual zeus::CColor GetThreatIconColor() const=0;
virtual zeus::CColor GetTickDecoColor() const=0;
virtual zeus::CColor GetHelmetLightColor() const=0;
virtual zeus::CColor GetThreatIconSafeColor() const=0;
virtual zeus::CColor GetMissileIconColorInactive() const=0;
virtual zeus::CColor GetMissileIconColorChargedCanAlt() const=0;
virtual zeus::CColor GetMissileIconColorChargedNoAlt() const=0;
virtual zeus::CColor GetMissileIconColorDepleteAlt() const=0;
virtual zeus::CColor GetVisorBeamMenuLozColor() const=0;
virtual zeus::CColor GetEnergyWarningOutline() const=0;
virtual zeus::CColor GetThreatWarningOutline() const=0;
virtual zeus::CColor GetMissileWarningOutline() const=0;
virtual zeus::CColor GetEnergyBarFlashColor() const=0;
virtual zeus::CColor GetXRayEnergyDecoColor() const=0;
virtual zeus::CColor GetPowerBombDigitAvailableFont() const=0;
virtual zeus::CColor GetPowerBombDigitAvailableOutline() const=0;
virtual zeus::CColor GetBallBombFilledColor() const=0;
virtual zeus::CColor GetBallBombEmptyColor() const=0;
virtual zeus::CColor GetPowerBombIconAvailableColor() const=0;
virtual zeus::CColor GetBallBombEnergyColor() const=0;
virtual zeus::CColor GetBallBombDecoColor() const=0;
virtual zeus::CColor GetPowerBombDigitDelpetedFont() const=0;
virtual zeus::CColor GetPowerBombDigitDelpetedOutline() const=0;
virtual zeus::CColor GetPowerBombIconDepletedColor() const=0;
virtual zeus::CColor GetThreatIconWarningColor() const=0;
virtual zeus::CColor GetHudCounterFill() const=0;
virtual zeus::CColor GetHudCounterOutline() const=0;
virtual zeus::CColor GetThreatDigitsFont() const=0;
virtual zeus::CColor GetThreatDigitsOutline() const=0;
virtual zeus::CColor GetMissileDigitsFont() const=0;
virtual zeus::CColor GetMissileDigitsOutline() const=0;
virtual zeus::CColor GetThermalDecoColor() const=0;
virtual zeus::CColor GetThermalOutlinesColor() const=0;
virtual zeus::CColor GetThermalLockColor() const=0;
virtual const zeus::CColor& GetRadarStuffColor() const=0;
virtual const zeus::CColor& GetRadarPlayerPaintColor() const=0;
virtual const zeus::CColor& GetRadarEnemyPaintColor() const=0;
virtual const zeus::CColor& GetHudMessageFill() const=0;
virtual const zeus::CColor& GetHudMessageOutline() const=0;
virtual const zeus::CColor& GetHudFrameColor() const=0;
virtual const zeus::CColor& GetMissileIconColorActive() const=0;
virtual const zeus::CColor& GetVisorBeamMenuItemActive() const=0;
virtual const zeus::CColor& GetVisorBeamMenuItemInactive() const=0;
virtual const zeus::CColor& GetEnergyBarFilledLowEnergy() const=0;
virtual const zeus::CColor& GetEnergyBarShadowLowEnergy() const=0;
virtual const zeus::CColor& GetEnergyBarEmptyLowEnergy() const=0;
virtual const zeus::CColor& GetHudDamageLightColor() const=0;
virtual const zeus::CColor& GetVisorMenuTextFont() const=0;
virtual const zeus::CColor& GetVisorMenuTextOutline() const=0;
virtual const zeus::CColor& GetBeamMenuTextFont() const=0;
virtual const zeus::CColor& GetBeamMenuTextOutline() const=0;
virtual const zeus::CColor& GetEnergyWarningFont() const=0;
virtual const zeus::CColor& GetThreatWarningFont() const=0;
virtual const zeus::CColor& GetMissileWarningFont() const=0;
virtual const zeus::CColor& GetThreatBarFilled() const=0;
virtual const zeus::CColor& GetThreatBarShadow() const=0;
virtual const zeus::CColor& GetThreatBarEmpty() const=0;
virtual const zeus::CColor& GetMissileBarFilled() const=0;
virtual const zeus::CColor& GetMissileBarShadow() const=0;
virtual const zeus::CColor& GetMissileBarEmpty() const=0;
virtual const zeus::CColor& GetThreatIconColor() const=0;
virtual const zeus::CColor& GetTickDecoColor() const=0;
virtual const zeus::CColor& GetHelmetLightColor() const=0;
virtual const zeus::CColor& GetThreatIconSafeColor() const=0;
virtual const zeus::CColor& GetMissileIconColorInactive() const=0;
virtual const zeus::CColor& GetMissileIconColorChargedCanAlt() const=0;
virtual const zeus::CColor& GetMissileIconColorChargedNoAlt() const=0;
virtual const zeus::CColor& GetMissileIconColorDepleteAlt() const=0;
virtual const zeus::CColor& GetVisorBeamMenuLozColor() const=0;
virtual const zeus::CColor& GetEnergyWarningOutline() const=0;
virtual const zeus::CColor& GetThreatWarningOutline() const=0;
virtual const zeus::CColor& GetMissileWarningOutline() const=0;
virtual const zeus::CColor& GetDamageAmbientColor() const=0;
virtual const zeus::CColor& GetScanVisorHudLightMultiply() const=0;
virtual const zeus::CColor& GetThermalVisorHudLightMultiply() const=0;
virtual const zeus::CColor& GetDamageAmbientPulseColor() const=0;
virtual const zeus::CColor& GetEnergyBarFlashColor() const=0;
virtual const zeus::CColor& GetXRayEnergyDecoColor() const=0;
virtual const zeus::CColor& GetPowerBombDigitAvailableFont() const=0;
virtual const zeus::CColor& GetPowerBombDigitAvailableOutline() const=0;
virtual const zeus::CColor& GetBallBombFilledColor() const=0;
virtual const zeus::CColor& GetBallBombEmptyColor() const=0;
virtual const zeus::CColor& GetPowerBombIconAvailableColor() const=0;
virtual const zeus::CColor& GetBallBombEnergyColor() const=0;
virtual const zeus::CColor& GetBallBombDecoColor() const=0;
virtual const zeus::CColor& GetPowerBombDigitDelpetedFont() const=0;
virtual const zeus::CColor& GetPowerBombDigitDelpetedOutline() const=0;
virtual const zeus::CColor& GetPowerBombIconDepletedColor() const=0;
virtual const zeus::CColor& GetThreatIconWarningColor() const=0;
virtual const zeus::CColor& GetHudCounterFill() const=0;
virtual const zeus::CColor& GetHudCounterOutline() const=0;
virtual const zeus::CColor& GetThreatDigitsFont() const=0;
virtual const zeus::CColor& GetThreatDigitsOutline() const=0;
virtual const zeus::CColor& GetMissileDigitsFont() const=0;
virtual const zeus::CColor& GetMissileDigitsOutline() const=0;
virtual const zeus::CColor& GetThermalDecoColor() const=0;
virtual const zeus::CColor& GetThermalOutlinesColor() const=0;
virtual const zeus::CColor& GetThermalLockColor() const=0;
virtual VisorEnergyInitColors GetVisorEnergyInitColors(int idx) const=0;
virtual VisorEnergyBarColors GetVisorEnergyBarColors(int idx) const=0;
};

View File

@ -167,15 +167,12 @@ bool MREA::Extract(const SpecBase& dataSpec,
rs.seek(secStart + head.secSizes[curSec++], athena::Begin);
/* Dump VISI entities */
auto visiPos = rs.position();
if (head.secSizes[curSec] && rs.readUint32Big() == 'VISI')
{
athena::io::YAMLDocWriter visiWriter("VISI");
uint32_t unkCount = 0;
if (auto __vec = visiWriter.enterSubVector("entities"))
{
rs.seek(14, athena::Current);
unkCount = rs.readUint32Big();
rs.seek(18, athena::Current);
uint32_t entityCount = rs.readUint32Big();
rs.seek(8, athena::Current);
for (int i=0 ; i<entityCount ; ++i)
@ -187,14 +184,6 @@ bool MREA::Extract(const SpecBase& dataSpec,
hecl::ProjectPath visiMetadataPath(outPath.getParentPath(), _S("!visi.yaml"));
athena::io::FileWriter visiMetadata(visiMetadataPath.getAbsolutePath());
visiWriter.finish(&visiMetadata);
if (unkCount)
{
rs.seek(visiPos, athena::Begin);
auto bytes = rs.readUBytes(head.secSizes[curSec]);
athena::io::FileWriter fw(std::string("/Users/jacko/Desktop/") + pakRouter.getBestEntryName(entry, false).c_str() + ".visi");
fw.writeUBytes(bytes.get(), head.secSizes[curSec]);
}
}
/* Origins to center of mass */

View File

@ -26,10 +26,10 @@ struct CTweakGui : ITweakGui
Value<float> x38_energyBarShadowSpeed;
Value<float> x3c_energyBarDrainDelay;
Value<bool> x40_energyBarAlwaysResetDelay;
Value<float> x44_;
Value<float> x48_;
Value<float> x4c_;
Value<float> x50_;
Value<float> x44_hudDamagePracticalsGainConstant;
Value<float> x48_hudDamagePracticalsGainLinear;
Value<float> x4c_hudDamagePracticalsInitConstant;
Value<float> x50_hudDamagePracticalsInitLinear;
Value<float> x54_hudDamageLightSpotAngle;
Value<float> x58_damageLightAngleC;
Value<float> x5c_damageLightAngleL;
@ -38,15 +38,15 @@ struct CTweakGui : ITweakGui
Value<atVec3f> x70_damageLightCenterTranslate;
Value<float> x7c_damageLightXfXAngle;
Value<float> x80_damageLightXfZAngle;
Value<float> x84_;
Value<float> x88_;
Value<float> x8c_;
Value<float> x90_;
Value<float> x94_;
Value<float> x98_;
Value<float> x9c_;
Value<float> xa0_;
Value<float> xa4_;
Value<float> x84_hudDecoShakeTranslateVelConstant;
Value<float> x88_hudDecoShakeTranslateVelLinear;
Value<float> x8c_maxDecoDamageShakeTranslate;
Value<float> x90_decoDamageShakeDeceleration;
Value<float> x94_decoShakeGainConstant;
Value<float> x98_decoShakeGainLinear;
Value<float> x9c_decoShakeInitConstant;
Value<float> xa0_decoShakeInitLinear;
Value<float> xa4_maxDecoDamageShakeRotate;
Value<atUint32> xa8_hudCamFovTweak;
Value<atUint32> xac_hudCamYTweak;
Value<atUint32> xb0_hudCamZTweak;
@ -86,8 +86,8 @@ struct CTweakGui : ITweakGui
Value<float> x138_;
Value<atUint32> x13c_;
Value<atUint32> x140_;
Value<atUint32> x144_;
Value<atUint32> x148_;
Value<atUint32> x144_faceReflectionDistance;
Value<atUint32> x148_faceReflectionHeight;
Value<atUint32> x14c_;
String<-1> x150_;
String<-1> x160_;
@ -95,21 +95,21 @@ struct CTweakGui : ITweakGui
String<-1> x180_;
String<-1> x190_;
Value<float> x1a0_missileWarningPulseTime;
Value<float> x1a4_;
Value<float> x1a8_;
Value<float> x1ac_;
Value<float> x1a4_explosionLightFalloffMultConstant;
Value<float> x1a8_explosionLightFalloffMultLinear;
Value<float> x1ac_explosionLightFalloffMultQuadratic;
Value<float> x1b0_;
Value<float> x1b4_;
Value<float> x1b8_;
Value<float> x1bc_;
Value<float> x1c0_;
Value<float> x1c4_;
Value<float> x1b4_hudDamagePeakFactor;
Value<float> x1b8_hudDamageFilterGainConstant;
Value<float> x1bc_hudDamageFilterGainLinear;
Value<float> x1c0_hudDamageFilterInitConstant;
Value<float> x1c4_hudDamageFilterInitLinear;
Value<float> x1c8_;
Value<bool> x1cc_;
Value<bool> x1cd_;
Value<float> x1d0_;
Value<float> x1d4_;
Value<float> x1d8_;
Value<float> x1d0_hudDamagePulseDuration;
Value<float> x1d4_hudDamageColorGain;
Value<float> x1d8_hudDecoShakeTranslateGain;
Value<float> x1dc_hudLagOffsetScale;
Value<float> x1e0_;
Value<float> x1e4_;
@ -157,18 +157,12 @@ struct CTweakGui : ITweakGui
DNAColor x288_xrayFogColor;
Value<float> x28c_thermalVisorLevel;
DNAColor x290_thermalVisorColor;
DNAColor x294_;
DNAColor x298_;
DNAColor x29c_;
DNAColor x2a0_;
DNAColor x2a4_;
DNAColor x2a8_;
DNAColor x2ac_;
DNAColor x2b0_;
DNAColor x2b4_;
Value<float> x2b8_;
Value<float> x2bc_;
Value<float> x2c0_;
DNAColor x294_hudLightAddPerVisor[4];
DNAColor x2a4_hudLightMultiplyPerVisor[4];
DNAColor x2b4_hudReflectivityLightColor;
Value<float> x2b8_hudLightAttMulConstant;
Value<float> x2bc_hudLightAttMulLinear;
Value<float> x2c0_hudLightAttMulQuadratic;
Value<atUint32> m_scanSpeedsCount;
Vector<float, DNA_COUNT(m_scanSpeedsCount)> x2c4_scanSpeeds;
String<-1> x2d0_;
@ -203,6 +197,10 @@ struct CTweakGui : ITweakGui
float GetEnergyBarShadowSpeed() const { return x38_energyBarShadowSpeed; }
float GetEnergyBarDrainDelay() const { return x3c_energyBarDrainDelay; }
bool GetEnergyBarAlwaysResetDelay() const { return x40_energyBarAlwaysResetDelay; }
float GetHudDamagePracticalsGainConstant() const { return x44_hudDamagePracticalsGainConstant; }
float GetHudDamagePracticalsGainLinear() const { return x48_hudDamagePracticalsGainLinear; }
float GetHudDamagePracticalsInitConstant() const { return x4c_hudDamagePracticalsInitConstant; }
float GetHudDamagePracticalsInitLinear() const { return x50_hudDamagePracticalsInitLinear; }
float GetHudDamageLightSpotAngle() const { return x54_hudDamageLightSpotAngle; }
float GetDamageLightAngleC() const { return x58_damageLightAngleC; }
float GetDamageLightAngleL() const { return x5c_damageLightAngleL; }
@ -211,6 +209,15 @@ struct CTweakGui : ITweakGui
atVec3f GetDamageLightCenterTranslate() const { return x70_damageLightCenterTranslate; }
float GetDamageLightXfXAngle() const { return x7c_damageLightXfXAngle; }
float GetDamageLightXfZAngle() const { return x80_damageLightXfZAngle; }
float GetHudDecoShakeTranslateVelConstant() const { return x84_hudDecoShakeTranslateVelConstant; }
float GetHudDecoShakeTranslateVelLinear() const { return x88_hudDecoShakeTranslateVelLinear; }
float GetMaxDecoDamageShakeTranslate() const { return x8c_maxDecoDamageShakeTranslate; }
float GetDecoDamageShakeDeceleration() const { return x90_decoDamageShakeDeceleration; }
float GetDecoShakeGainConstant() const { return x94_decoShakeGainConstant; }
float GetDecoShakeGainLinear() const { return x98_decoShakeGainLinear; }
float GetDecoShakeInitConstant() const { return x9c_decoShakeInitConstant; }
float GetDecoShakeInitLinear() const { return xa0_decoShakeInitLinear; }
float GetMaxDecoDamageShakeRotate() const { return xa4_maxDecoDamageShakeRotate; }
atUint32 GetHudCamFovTweak() const { return xa8_hudCamFovTweak; }
atUint32 GetHudCamYTweak() const { return xac_hudCamYTweak; }
atUint32 GetHudCamZTweak() const { return xb0_hudCamZTweak; }
@ -233,7 +240,20 @@ struct CTweakGui : ITweakGui
float GetFreeLookFadeTime() const { return x118_freeLookFadeTime; }
float GetFreeLookSfxPitchScale() const { return x12c_freeLookSfxPitchScale; }
bool GetNoAbsoluteFreeLookSfxPitch() const { return x130_noAbsoluteFreeLookSfxPitch; }
float GetFaceReflectionDistance() const { return x144_faceReflectionDistance; }
float GetFaceReflectionHeight() const { return x148_faceReflectionHeight; }
float GetMissileWarningPulseTime() const { return x1a0_missileWarningPulseTime; }
float GetExplosionLightFalloffMultConstant() const { return x1a4_explosionLightFalloffMultConstant; }
float GetExplosionLightFalloffMultLinear() const { return x1a8_explosionLightFalloffMultLinear; }
float GetExplosionLightFalloffMultQuadratic() const { return x1ac_explosionLightFalloffMultQuadratic; }
float GetHudDamagePeakFactor() const { return x1b4_hudDamagePeakFactor; }
float GetHudDamageFilterGainConstant() const { return x1b8_hudDamageFilterGainConstant; }
float GetHudDamageFilterGainLinear() const { return x1bc_hudDamageFilterGainLinear; }
float GetHudDamageFilterInitConstant() const { return x1c0_hudDamageFilterInitConstant; }
float GetHudDamageFilterInitLinear() const { return x1c4_hudDamageFilterInitLinear; }
float GetHudDamagePulseDuration() const { return x1d0_hudDamagePulseDuration; }
float GetHudDamageColorGain() const { return x1d4_hudDamageColorGain; }
float GetHudDecoShakeTranslateGain() const { return x1d8_hudDecoShakeTranslateGain; }
float GetHudLagOffsetScale() const { return x1dc_hudLagOffsetScale; }
float GetScanAppearanceOffset() const { return x244_scanAppearanceOffset; }
float GetBallViewportYReduction() const { return x254_ballViewportYReduction; }
@ -253,6 +273,12 @@ struct CTweakGui : ITweakGui
const zeus::CColor& GetXRayFogColor() const { return x288_xrayFogColor; }
float GetThermalVisorLevel() const { return x28c_thermalVisorLevel; }
const zeus::CColor& GetThermalVisorColor() const { return x290_thermalVisorColor; }
const zeus::CColor& GetVisorHudLightAdd(int v) const { return x294_hudLightAddPerVisor[v]; }
const zeus::CColor& GetVisorHudLightMultiply(int v) const { return x2a4_hudLightMultiplyPerVisor[v]; }
const zeus::CColor& GetHudReflectivityLightColor() const { return x2b4_hudReflectivityLightColor; }
float GetHudLightAttMulConstant() const { return x2b8_hudLightAttMulConstant; }
float GetHudLightAttMulLinear() const { return x2bc_hudLightAttMulLinear; }
float GetHudLightAttMulQuadratic() const { return x2c0_hudLightAttMulQuadratic; }
float GetScanSpeed(int idx) const
{
@ -282,7 +308,7 @@ struct CTweakGui : ITweakGui
else
x27c_xrayFogMode = 0;
x84_ *= 2.0f;
x84_hudDecoShakeTranslateVelConstant *= 2.0f;
}
};

View File

@ -58,15 +58,15 @@ struct CTweakGuiColors : public ITweakGuiColors
DNAColor xb8_threatWarningOutline;
DNAColor xbc_missileWarningOutline;
DNAColor xc0_;
DNAColor xc4_;
DNAColor xc4_damageAmbientColor;
DNAColor xc8_;
DNAColor xcc_;
DNAColor xd0_;
DNAColor xd4_;
DNAColor xd4_scanVisorHudLightMultiply;
DNAColor xd8_;
DNAColor xdc_;
DNAColor xdc_thermalVisorHudLightMultiply;
DNAColor xe0_;
DNAColor xe4_;
DNAColor xe4_damageAmbientPulseColor;
DNAColor xe8_energyBarFlashColor;
DNAColor xec_;
DNAColor xf0_;
@ -140,66 +140,70 @@ struct CTweakGuiColors : public ITweakGuiColors
CTweakGuiColors() = default;
CTweakGuiColors(athena::io::IStreamReader& r) { this->read(r); }
zeus::CColor GetRadarStuffColor() const { return x8_radarStuffColor; }
zeus::CColor GetRadarPlayerPaintColor() const { return xc_radarPlayerPaintColor; }
zeus::CColor GetRadarEnemyPaintColor() const { return x10_radarEnemyPaintColor; }
zeus::CColor GetHudMessageFill() const { return x14_hudMessageFill; }
zeus::CColor GetHudMessageOutline() const { return x18_hudMessageOutline; }
zeus::CColor GetHudFrameColor() const { return x1c_hudFrameColor; }
zeus::CColor GetMissileIconColorActive() const { return x28_missileIconColorActive; }
zeus::CColor GetVisorBeamMenuItemActive() const { return x2c_visorBeamMenuItemActive; }
zeus::CColor GetVisorBeamMenuItemInactive() const { return x30_visorBeamMenuColorInactive; }
zeus::CColor GetEnergyBarFilledLowEnergy() const { return x34_energyBarFilledLowEnergy; }
zeus::CColor GetEnergyBarShadowLowEnergy() const { return x38_energyBarShadowLowEnergy; }
zeus::CColor GetEnergyBarEmptyLowEnergy() const { return x3c_energyBarEmptyLowEnergy; }
zeus::CColor GetHudDamageLightColor() const { return x40_hudDamageLightColor; }
zeus::CColor GetVisorMenuTextFont() const { return x4c_visorMenuTextFont; }
zeus::CColor GetVisorMenuTextOutline() const { return x50_visorMenuTextOutline; }
zeus::CColor GetBeamMenuTextFont() const { return x54_beamMenuTextFont; }
zeus::CColor GetBeamMenuTextOutline() const { return x58_beamMenuTextOutline; }
zeus::CColor GetEnergyWarningFont() const { return x5c_energyWarningFont; }
zeus::CColor GetThreatWarningFont() const { return x60_threatWarningFont; }
zeus::CColor GetMissileWarningFont() const { return x64_missileWarningFont; }
zeus::CColor GetThreatBarFilled() const { return x68_threatBarFilled; }
zeus::CColor GetThreatBarShadow() const { return x6c_threatBarShadow; }
zeus::CColor GetThreatBarEmpty() const { return x70_threatBarEmpty; }
zeus::CColor GetMissileBarFilled() const { return x74_missileBarFilled; }
zeus::CColor GetMissileBarShadow() const { return x78_missileBarShadow; }
zeus::CColor GetMissileBarEmpty() const { return x7c_missileBarEmpty; }
zeus::CColor GetThreatIconColor() const { return x80_threatIconColor; }
zeus::CColor GetTickDecoColor() const { return x88_tickDecoColor; }
zeus::CColor GetHelmetLightColor() const { return x8c_helmetLightColor; }
zeus::CColor GetThreatIconSafeColor() const { return x90_threatIconSafeColor; }
zeus::CColor GetMissileIconColorInactive() const { return x94_missileIconColorInactive; }
zeus::CColor GetMissileIconColorChargedCanAlt() const { return x98_missileIconColorChargedCanAlt; }
zeus::CColor GetMissileIconColorChargedNoAlt() const { return x9c_missileIconColorChargedNoAlt; }
zeus::CColor GetMissileIconColorDepleteAlt() const { return xa0_missileIconColorDepleteAlt; }
zeus::CColor GetVisorBeamMenuLozColor() const { return xb0_visorBeamMenuLozColor; }
zeus::CColor GetEnergyWarningOutline() const { return xb4_energyWarningOutline; }
zeus::CColor GetThreatWarningOutline() const { return xb8_threatWarningOutline; }
zeus::CColor GetMissileWarningOutline() const { return xbc_missileWarningOutline; }
zeus::CColor GetEnergyBarFlashColor() const { return xe8_energyBarFlashColor; }
zeus::CColor GetXRayEnergyDecoColor() const { return x100_xrayEnergyDecoColor; }
zeus::CColor GetPowerBombDigitAvailableFont() const { return x13c_powerBombDigitAvailableFont; }
zeus::CColor GetPowerBombDigitAvailableOutline() const { return x140_powerBombDigitAvailableOutline; }
zeus::CColor GetBallBombFilledColor() const { return x148_ballBombFilled; }
zeus::CColor GetBallBombEmptyColor() const { return x14c_ballBombEmpty; }
zeus::CColor GetPowerBombIconAvailableColor() const { return x150_powerBombIconAvailable; }
zeus::CColor GetBallBombEnergyColor() const { return x158_ballEnergyDeco; }
zeus::CColor GetBallBombDecoColor() const { return x15c_ballBombDeco; }
zeus::CColor GetPowerBombDigitDelpetedFont() const { return x160_powerBombDigitDepletedFont; }
zeus::CColor GetPowerBombDigitDelpetedOutline() const { return x164_powerBombDigitDepletedOutline; }
zeus::CColor GetPowerBombIconDepletedColor() const { return x168_powerBombIconUnavailable; }
zeus::CColor GetThreatIconWarningColor() const { return x17c_threatIconWarningColor; }
zeus::CColor GetHudCounterFill() const { return x180_hudCounterFill; }
zeus::CColor GetHudCounterOutline() const { return x184_hudCounterOutline; }
zeus::CColor GetThreatDigitsFont() const { return x19c_threatDigitsFont; }
zeus::CColor GetThreatDigitsOutline() const { return x1a0_threatDigitsOutline; }
zeus::CColor GetMissileDigitsFont() const { return x1a4_missileDigitsFont; }
zeus::CColor GetMissileDigitsOutline() const { return x1a8_missileDigitsOutline; }
zeus::CColor GetThermalDecoColor() const { return x1ac_thermalDecoColor; }
zeus::CColor GetThermalOutlinesColor() const { return x1b0_thermalOutlinesColor; }
zeus::CColor GetThermalLockColor() const { return x1b8_thermalLockColor; }
const zeus::CColor& GetRadarStuffColor() const { return x8_radarStuffColor; }
const zeus::CColor& GetRadarPlayerPaintColor() const { return xc_radarPlayerPaintColor; }
const zeus::CColor& GetRadarEnemyPaintColor() const { return x10_radarEnemyPaintColor; }
const zeus::CColor& GetHudMessageFill() const { return x14_hudMessageFill; }
const zeus::CColor& GetHudMessageOutline() const { return x18_hudMessageOutline; }
const zeus::CColor& GetHudFrameColor() const { return x1c_hudFrameColor; }
const zeus::CColor& GetMissileIconColorActive() const { return x28_missileIconColorActive; }
const zeus::CColor& GetVisorBeamMenuItemActive() const { return x2c_visorBeamMenuItemActive; }
const zeus::CColor& GetVisorBeamMenuItemInactive() const { return x30_visorBeamMenuColorInactive; }
const zeus::CColor& GetEnergyBarFilledLowEnergy() const { return x34_energyBarFilledLowEnergy; }
const zeus::CColor& GetEnergyBarShadowLowEnergy() const { return x38_energyBarShadowLowEnergy; }
const zeus::CColor& GetEnergyBarEmptyLowEnergy() const { return x3c_energyBarEmptyLowEnergy; }
const zeus::CColor& GetHudDamageLightColor() const { return x40_hudDamageLightColor; }
const zeus::CColor& GetVisorMenuTextFont() const { return x4c_visorMenuTextFont; }
const zeus::CColor& GetVisorMenuTextOutline() const { return x50_visorMenuTextOutline; }
const zeus::CColor& GetBeamMenuTextFont() const { return x54_beamMenuTextFont; }
const zeus::CColor& GetBeamMenuTextOutline() const { return x58_beamMenuTextOutline; }
const zeus::CColor& GetEnergyWarningFont() const { return x5c_energyWarningFont; }
const zeus::CColor& GetThreatWarningFont() const { return x60_threatWarningFont; }
const zeus::CColor& GetMissileWarningFont() const { return x64_missileWarningFont; }
const zeus::CColor& GetThreatBarFilled() const { return x68_threatBarFilled; }
const zeus::CColor& GetThreatBarShadow() const { return x6c_threatBarShadow; }
const zeus::CColor& GetThreatBarEmpty() const { return x70_threatBarEmpty; }
const zeus::CColor& GetMissileBarFilled() const { return x74_missileBarFilled; }
const zeus::CColor& GetMissileBarShadow() const { return x78_missileBarShadow; }
const zeus::CColor& GetMissileBarEmpty() const { return x7c_missileBarEmpty; }
const zeus::CColor& GetThreatIconColor() const { return x80_threatIconColor; }
const zeus::CColor& GetTickDecoColor() const { return x88_tickDecoColor; }
const zeus::CColor& GetHelmetLightColor() const { return x8c_helmetLightColor; }
const zeus::CColor& GetThreatIconSafeColor() const { return x90_threatIconSafeColor; }
const zeus::CColor& GetMissileIconColorInactive() const { return x94_missileIconColorInactive; }
const zeus::CColor& GetMissileIconColorChargedCanAlt() const { return x98_missileIconColorChargedCanAlt; }
const zeus::CColor& GetMissileIconColorChargedNoAlt() const { return x9c_missileIconColorChargedNoAlt; }
const zeus::CColor& GetMissileIconColorDepleteAlt() const { return xa0_missileIconColorDepleteAlt; }
const zeus::CColor& GetVisorBeamMenuLozColor() const { return xb0_visorBeamMenuLozColor; }
const zeus::CColor& GetEnergyWarningOutline() const { return xb4_energyWarningOutline; }
const zeus::CColor& GetThreatWarningOutline() const { return xb8_threatWarningOutline; }
const zeus::CColor& GetMissileWarningOutline() const { return xbc_missileWarningOutline; }
const zeus::CColor& GetDamageAmbientColor() const { return xc4_damageAmbientColor; }
const zeus::CColor& GetScanVisorHudLightMultiply() const { return xd4_scanVisorHudLightMultiply; }
const zeus::CColor& GetThermalVisorHudLightMultiply() const { return xdc_thermalVisorHudLightMultiply; }
const zeus::CColor& GetDamageAmbientPulseColor() const { return xe4_damageAmbientPulseColor; }
const zeus::CColor& GetEnergyBarFlashColor() const { return xe8_energyBarFlashColor; }
const zeus::CColor& GetXRayEnergyDecoColor() const { return x100_xrayEnergyDecoColor; }
const zeus::CColor& GetPowerBombDigitAvailableFont() const { return x13c_powerBombDigitAvailableFont; }
const zeus::CColor& GetPowerBombDigitAvailableOutline() const { return x140_powerBombDigitAvailableOutline; }
const zeus::CColor& GetBallBombFilledColor() const { return x148_ballBombFilled; }
const zeus::CColor& GetBallBombEmptyColor() const { return x14c_ballBombEmpty; }
const zeus::CColor& GetPowerBombIconAvailableColor() const { return x150_powerBombIconAvailable; }
const zeus::CColor& GetBallBombEnergyColor() const { return x158_ballEnergyDeco; }
const zeus::CColor& GetBallBombDecoColor() const { return x15c_ballBombDeco; }
const zeus::CColor& GetPowerBombDigitDelpetedFont() const { return x160_powerBombDigitDepletedFont; }
const zeus::CColor& GetPowerBombDigitDelpetedOutline() const { return x164_powerBombDigitDepletedOutline; }
const zeus::CColor& GetPowerBombIconDepletedColor() const { return x168_powerBombIconUnavailable; }
const zeus::CColor& GetThreatIconWarningColor() const { return x17c_threatIconWarningColor; }
const zeus::CColor& GetHudCounterFill() const { return x180_hudCounterFill; }
const zeus::CColor& GetHudCounterOutline() const { return x184_hudCounterOutline; }
const zeus::CColor& GetThreatDigitsFont() const { return x19c_threatDigitsFont; }
const zeus::CColor& GetThreatDigitsOutline() const { return x1a0_threatDigitsOutline; }
const zeus::CColor& GetMissileDigitsFont() const { return x1a4_missileDigitsFont; }
const zeus::CColor& GetMissileDigitsOutline() const { return x1a8_missileDigitsOutline; }
const zeus::CColor& GetThermalDecoColor() const { return x1ac_thermalDecoColor; }
const zeus::CColor& GetThermalOutlinesColor() const { return x1b0_thermalOutlinesColor; }
const zeus::CColor& GetThermalLockColor() const { return x1b8_thermalLockColor; }
VisorEnergyInitColors GetVisorEnergyInitColors(int idx) const
{
const PerVisorColors& colors = x1c4_perVisorColors[idx];

View File

@ -371,6 +371,27 @@ CSfxHandle CSfxManager::SfxStart(u16 id, float vol, float pan, bool useAcoustics
return wrapper;
}
void CSfxManager::RemoveEmitter(const CSfxHandle& handle)
{
StopSound(handle);
}
void CSfxManager::UpdateEmitter(const CSfxHandle& handle, const zeus::CVector3f& pos,
const zeus::CVector3f& dir, float maxVol)
{
if (!handle || !handle->IsEmitter() || !handle->IsPlaying())
return;
m_doUpdate = true;
CSfxEmitterWrapper& emitter = static_cast<CSfxEmitterWrapper&>(*handle);
emitter.GetEmitterData().x0_pos = pos;
emitter.GetEmitterData().xc_dir = dir;
emitter.GetEmitterData().x26_maxVol = maxVol;
amuse::Emitter& h = *emitter.GetHandle();
h.setPos(pos.v);
h.setDir(dir.v);
h.setMaxVol(maxVol);
}
CSfxHandle CSfxManager::AddEmitter(u16 id, const zeus::CVector3f& pos, const zeus::CVector3f& dir, float vol,
bool useAcoustics, bool looped, s16 prio, s32 areaId)
{

View File

@ -128,6 +128,7 @@ public:
void UpdateEmitterSilent();
void UpdateEmitter();
void SetReverb(float rev);
CAudioSys::C3DEmitterParmData& GetEmitterData() { return x24_parmData; }
const std::shared_ptr<amuse::Emitter>& GetHandle() const { return x50_emitterHandle; }
@ -203,12 +204,14 @@ public:
static s16 GetRank(CBaseSfxWrapper* sfx);
static void ApplyReverb();
static float GetReverbAmount();
static void RemoveEmitter(const CSfxHandle&) {}
static void PitchBend(const CSfxHandle& handle, float pitch);
static void SfxVolume(const CSfxHandle& handle, float vol);
static u16 TranslateSFXID(u16);
static void SfxStop(const CSfxHandle& handle);
static CSfxHandle SfxStart(u16 id, float vol, float pan, bool useAcoustics, s16 prio, bool looped, s32 areaId);
static void RemoveEmitter(const CSfxHandle& handle);
static void UpdateEmitter(const CSfxHandle& handle, const zeus::CVector3f& pos, const zeus::CVector3f& dir,
float maxVol);
static CSfxHandle AddEmitter(u16 id, const zeus::CVector3f& pos, const zeus::CVector3f& dir, float vol,
bool useAcoustics, bool looped, s16 prio, s32 areaId);
static CSfxHandle AddEmitter(const CAudioSys::C3DEmitterParmData& parmData,

View File

@ -507,11 +507,6 @@ bool CStateManager::CanCreateProjectile(TUniqueId uid, EWeaponType type, int tes
return ((xorv >> 1) - xorv & test) >> 31;
}
const std::vector<CLight>& CStateManager::GetDynamicLightList() const
{
return x8e0_dynamicLights;
}
void CStateManager::BuildDynamicLightListForWorld()
{
if (x8b8_playerState->GetActiveVisor(*this) == CPlayerState::EPlayerVisor::Thermal)
@ -1975,7 +1970,7 @@ void CStateManager::UpdateHintState(float dt)
CHintOptions& ho = g_GameState->HintOptions();
ho.Update(dt, *this);
u32 nextHintIdx = -1;
u32 hintPeriods = -1;
u32 pageIdx = -1;
if (const CHintOptions::SHintState* state = ho.GetCurrentDisplayedHint())
{
const CGameHintInfo::CGameHint& next = g_MemoryCardSys->GetHints()[ho.GetNextHintIdx()];
@ -1987,11 +1982,11 @@ void CStateManager::UpdateHintState(float dt)
if (state->x4_time < next.GetTextTime())
{
nextHintIdx = ho.GetNextHintIdx();
hintPeriods = state->x4_time / 3.f;
pageIdx = state->x4_time / 3.f;
}
}
if (xeec_hintIdx != nextHintIdx || xef0_hintPeriods != hintPeriods)
if (xeec_hintIdx != nextHintIdx || xef0_hintPeriods != pageIdx)
{
if (nextHintIdx == -1)
{
@ -2002,10 +1997,10 @@ void CStateManager::UpdateHintState(float dt)
{
const CGameHintInfo::CGameHint& data = g_MemoryCardSys->GetHints()[nextHintIdx];
CHUDMemoParms memoInfo = {0.f, true, false, true};
MP1::CSamusHud::DeferHintMemo(data.GetStringID(), hintPeriods, memoInfo);
MP1::CSamusHud::DeferHintMemo(data.GetStringID(), pageIdx, memoInfo);
}
xeec_hintIdx = nextHintIdx;
xef0_hintPeriods = hintPeriods;
xef0_hintPeriods = pageIdx;
}
}

View File

@ -284,7 +284,7 @@ public:
static void ReflectionDrawer(void*, const zeus::CVector3f&);
void CacheReflection();
bool CanCreateProjectile(TUniqueId, EWeaponType, int) const;
const std::vector<CLight>& GetDynamicLightList() const;
const std::vector<CLight>& GetDynamicLightList() const { return x8e0_dynamicLights; }
void BuildDynamicLightListForWorld();
void DrawDebugStuff() const;
void RenderCamerasAndAreaLights() const;

View File

@ -3,6 +3,12 @@
#include "World/CGameArea.hpp"
#include "CStateManager.hpp"
#include "Collision/CGameCollision.hpp"
#include "Camera/CFirstPersonCamera.hpp"
#include "World/CGameLight.hpp"
#include "TCastTo.hpp"
#include "GameGlobalObjects.hpp"
#include "World/CExplosion.hpp"
#include "Graphics/CBooRenderer.hpp"
namespace urde
{
@ -50,11 +56,59 @@ void CActorLights::BuildConstantAmbientLighting(const zeus::CColor& color)
void CActorLights::BuildFakeLightList(const std::vector<CLight>& lights, const zeus::CColor& color)
{
BuildConstantAmbientLighting(color);
x0_areaLights.clear();
x144_dynamicLights = lights;
}
void CActorLights::BuildFaceLightList(CStateManager& mgr, const CGameArea& area, const zeus::CAABox& aabb)
void CActorLights::BuildFaceLightList(const CStateManager& mgr, const CGameArea& area, const zeus::CAABox& aabb)
{
zeus::CTransform fpTransform = mgr.GetCameraManager()->GetFirstPersonCamera()->GetTransform();
x288_ambientColor = zeus::CColor::skBlack;
x144_dynamicLights.clear();
zeus::CColor accumColor = zeus::CColor::skBlack;
for (CEntity* light : mgr.GetLightObjectList())
{
if (!light || !light->GetActive())
continue;
CGameLight* castLight = static_cast<CGameLight*>(light);
if (TCastToConstPtr<CExplosion> explosion = mgr.GetObjectById(castLight->GetParentId()))
{
CLight originalLight = castLight->GetLight();
CLight explosionLight = originalLight;
explosionLight.SetAttenuation(explosionLight.GetAttenuationConstant() * g_tweakGui->GetExplosionLightFalloffMultConstant(),
explosionLight.GetAttenuationLinear() * g_tweakGui->GetExplosionLightFalloffMultLinear(),
explosionLight.GetAttenuationQuadratic() * g_tweakGui->GetExplosionLightFalloffMultQuadratic());
zeus::CVector3f camToExplo = explosion->GetTranslation() - fpTransform.origin;
if (fpTransform.transposeRotate(camToExplo).dot(zeus::CVector3f::skForward) >= 0.f)
{
camToExplo.y = -camToExplo.y + ITweakGui::FaceReflectionDistanceDebugValueToActualValue(
g_tweakGui->GetFaceReflectionDistance());
camToExplo.z = -camToExplo.z + ITweakGui::FaceReflectionHeightDebugValueToActualValue(
g_tweakGui->GetFaceReflectionHeight());
explosionLight.SetPosition(fpTransform * camToExplo);
zeus::CSphere sphere(originalLight.GetPosition(), originalLight.GetRadius());
if (aabb.intersects(sphere))
{
accumColor += explosionLight.GetNormalIndependentLightingAtPoint(fpTransform.origin);
if (originalLight.GetIntensity() > FLT_EPSILON && originalLight.GetRadius() > FLT_EPSILON)
x144_dynamicLights.push_back(explosionLight);
}
}
}
}
float greyscale = accumColor.rgbDot(zeus::CColor(0.3f, 0.6f, 0.1f));
if (greyscale < 0.012f)
x144_dynamicLights.clear();
if (greyscale > 0.03f)
{
float attMul = 1.f / (0.03f / greyscale);
for (CLight& light : x144_dynamicLights)
light.SetAttenuation(light.GetAttenuationConstant() * attMul,
light.GetAttenuationLinear() * attMul,
light.GetAttenuationQuadratic() * attMul);
}
}
struct SLightValue
@ -68,25 +122,73 @@ struct SLightValue
void CActorLights::MergeOverflowLight(CLight& out, zeus::CColor& color, const CLight& in, float colorMag)
{
color += in.GetColor() * colorMag;
out.SetAngleAttenuation(in.GetAngleAttenuationConstant() * colorMag + out.GetAngleAttenuationConstant(),
in.GetAngleAttenuationLinear() * colorMag + out.GetAngleAttenuationLinear(),
in.GetAngleAttenuationQuadratic() * colorMag + out.GetAngleAttenuationQuadratic());
out.SetAttenuation(in.GetAttenuationConstant() * colorMag + out.GetAttenuationConstant(),
in.GetAttenuationLinear() * colorMag + out.GetAttenuationLinear(),
in.GetAttenuationQuadratic() * colorMag + out.GetAttenuationQuadratic());
out.SetPosition(in.GetPosition() * colorMag + out.GetPosition());
out.SetDirection(in.GetDirection() * colorMag + out.GetDirection());
}
void CActorLights::AddOverflowToLights(const CLight& light, const zeus::CColor& color, float mag)
{
if (mag < 0.001f || x2b8_maxAreaLights < 1)
return;
mag = 1.f / mag;
zeus::CColor useColor = color * mag;
useColor.a = 1.f;
x0_areaLights.push_back(CLight::BuildCustom(light.GetPosition() * mag, light.GetDirection() * mag, useColor,
light.GetAttenuationConstant() * mag,
light.GetAttenuationLinear() * mag,
light.GetAttenuationQuadratic() * mag,
light.GetAngleAttenuationConstant() * mag,
light.GetAngleAttenuationLinear() * mag,
light.GetAngleAttenuationQuadratic() * mag));
}
void CActorLights::MoveAmbienceToLights(const zeus::CColor& color)
{
if (x298_29_ambientChannelOverflow)
{
x288_ambientColor += color * 0.333333f;
x288_ambientColor.a = 1.f;
return;
}
zeus::CColor useColor = x0_areaLights[0].GetColor() + color;
float maxComponent = std::max(useColor.r, std::max(useColor.g, useColor.b));
if (maxComponent > FLT_EPSILON)
useColor *= (1.f / maxComponent);
useColor.a = 1.f;
x0_areaLights[0].SetColor(useColor);
}
void CActorLights::MultiplyLightingLevels(float level)
{
x288_ambientColor *= level;
for (CLight& light : x0_areaLights)
{
zeus::CColor color = light.GetColor();
color *= level;
color.a = 1.f;
light.SetColor(color);
}
}
bool CActorLights::BuildAreaLightList(CStateManager& mgr, const CGameArea& area, const zeus::CAABox& aabb)
void CActorLights::UpdateBrightLight()
{
if (x2dc_brightLightLag > 0 && x299_24_inBrightLight)
--x2dc_brightLightLag;
else if (x2dc_brightLightLag < 15 && !x299_24_inBrightLight)
++x2dc_brightLightLag;
x299_25_useBrightLightLag = true;
}
bool CActorLights::BuildAreaLightList(const CStateManager& mgr, const CGameArea& area, const zeus::CAABox& aabb)
{
const std::vector<CWorldLight>& lightList = x298_30_layer2 ? area.GetPostConstructed()->x80_lightsB :
area.GetPostConstructed()->x60_lightsA;
@ -294,10 +396,10 @@ bool CActorLights::BuildAreaLightList(CStateManager& mgr, const CGameArea& area,
x299_24_inBrightLight = actorToLightContact;
if (x2d8_brightLightIdx != value.x0_areaLightIdx)
{
x2dc_overrideDist = actorToLightContact ? 0 : 15;
x2dc_brightLightLag = actorToLightContact ? 0 : 15;
x2d8_brightLightIdx = value.x0_areaLightIdx;
}
x299_25_overrideFirstDist = false;
x299_25_useBrightLightLag = false;
actorToLightContact = true;
}
}
@ -349,8 +451,56 @@ bool CActorLights::BuildAreaLightList(CStateManager& mgr, const CGameArea& area,
return true;
}
void CActorLights::BuildDynamicLightList(CStateManager& mgr, const zeus::CAABox& aabb)
void CActorLights::BuildDynamicLightList(const CStateManager& mgr, const zeus::CAABox& aabb)
{
UpdateBrightLight();
x299_26_ = false;
x144_dynamicLights.clear();
if (!x29a_)
{
for (const CLight& light : mgr.GetDynamicLightList())
{
zeus::CSphere sphere(light.GetPosition(), light.GetRadius());
if (aabb.intersects(sphere))
x144_dynamicLights.push_back(light);
if (x144_dynamicLights.size() >= x2bc_maxDynamicLights)
break;
}
}
else
{
const CLight* addedLights[8] = {};
for (int i=0 ; i<x2bc_maxDynamicLights && i<8 ; ++i)
{
float minRad = FLT_MAX;
for (const CLight& light : mgr.GetDynamicLightList())
{
zeus::CSphere sphere(light.GetPosition(), light.GetRadius());
float intRadius = aabb.intersectionRadius(sphere);
if (intRadius >= 0.f && intRadius < minRad)
{
bool alreadyIn = false;
for (int j=0 ; j<i ; ++j)
{
if (&light == addedLights[j])
{
alreadyIn = true;
break;
}
}
if (alreadyIn)
continue;
addedLights[i] = &light;
minRad = intRadius;
}
}
if (addedLights[i])
x144_dynamicLights.push_back(*addedLights[i]);
if (x144_dynamicLights.size() >= x2bc_maxDynamicLights)
break;
}
}
}
void CActorLights::ActivateLights(CBooModel& model) const
@ -360,8 +510,9 @@ void CActorLights::ActivateLights(CBooModel& model) const
{
if (!x298_26_hasAreaLights || !x299_26_)
{
g_Renderer->SetAmbientColor(zeus::CColor::skWhite);
model.ActivateLights(lights);
//return;
return;
}
}
@ -369,10 +520,10 @@ void CActorLights::ActivateLights(CBooModel& model) const
if (x0_areaLights.size())
{
if (x2dc_overrideDist && x299_25_overrideFirstDist)
if (x2dc_brightLightLag && x299_25_useBrightLightLag)
{
CLight overrideLight = x0_areaLights[0];
overrideLight.SetColor(overrideLight.GetColor() * (1.f - x2dc_overrideDist / 15.f));
overrideLight.SetColor(overrideLight.GetColor() * (1.f - x2dc_brightLightLag / 15.f));
lights.push_back(overrideLight);
}
else
@ -388,6 +539,12 @@ void CActorLights::ActivateLights(CBooModel& model) const
lights.push_back(light);
model.ActivateLights(lights);
if (x298_31_disableWorldLights)
{
zeus::CColor color(x2d4_worldLightingLevel);
g_Renderer->SetWorldLightMultiplyColor(color);
}
}
const CLight& CActorLights::GetLight(u32 idx) const

View File

@ -34,7 +34,7 @@ class CActorLights
bool x298_30_layer2 : 1;
bool x298_31_disableWorldLights : 1;
bool x299_24_inBrightLight : 1;
bool x299_25_overrideFirstDist : 1;
bool x299_25_useBrightLightLag : 1;
bool x299_26_ : 1;
};
u16 _dummy = 0;
@ -52,12 +52,13 @@ class CActorLights
float x2d0_shadowDynamicRangeThreshold = 0.f;
float x2d4_worldLightingLevel = 1.f;
u32 x2d8_brightLightIdx = -1;
u32 x2dc_overrideDist = 0;
u32 x2dc_brightLightLag = 0;
static void MergeOverflowLight(CLight& out, zeus::CColor& color, const CLight& in, float colorMag);
void AddOverflowToLights(const CLight& light, const zeus::CColor& color, float mag);
void MoveAmbienceToLights(const zeus::CColor& color);
void MultiplyLightingLevels(float level);
void UpdateBrightLight();
public:
CActorLights(u32 areaUpdateFramePeriod, const zeus::CVector3f& actorPosBias,
@ -67,15 +68,18 @@ public:
void BuildConstantAmbientLighting();
void BuildConstantAmbientLighting(const zeus::CColor& color);
void BuildFakeLightList(const std::vector<CLight>& lights, const zeus::CColor& color);
void BuildFaceLightList(CStateManager& mgr, const CGameArea& area, const zeus::CAABox& aabb);
bool BuildAreaLightList(CStateManager& mgr, const CGameArea& area, const zeus::CAABox& aabb);
void BuildDynamicLightList(CStateManager& mgr, const zeus::CAABox& aabb);
void BuildFaceLightList(const CStateManager& mgr, const CGameArea& area, const zeus::CAABox& aabb);
bool BuildAreaLightList(const CStateManager& mgr, const CGameArea& area, const zeus::CAABox& aabb);
void BuildDynamicLightList(const CStateManager& mgr, const zeus::CAABox& aabb);
void ActivateLights(CBooModel& model) const;
void SetCastShadows(bool v) { x298_25_castShadows = v; }
void SetAmbientColor(const zeus::CColor& color) { x288_ambientColor = color; }
const zeus::CColor& GetAmbientColor() const { return x288_ambientColor; }
const CLight& GetLight(u32 idx) const;
u32 GetActiveLightCount() const;
const std::vector<CLight>& GetAreaLights() const { return x0_areaLights; }
const std::vector<CLight>& GetDynamicLights() const { return x144_dynamicLights; }
};
}

View File

@ -237,6 +237,7 @@ void CBooRenderer::RenderBucketItems(CAreaListItem* item)
}
case EDrawableType::WorldSurface:
{
SetupRendererStates();
CBooSurface* surf = static_cast<CBooSurface*>((void*)drawable->GetData());
CBooModel* model = surf->m_parent;
if (model)
@ -465,6 +466,12 @@ void CBooRenderer::RenderFogVolumeModel(const zeus::CAABox& aabb, const CModel*
}
}
void CBooRenderer::SetupRendererStates() const
{
CGraphics::SetModelMatrix(zeus::CTransform::Identity());
CGraphics::g_ColorRegs[1] = x2fc_tevReg1Color;
}
void CBooRenderer::ReallyRenderFogVolume(const zeus::CColor& color, const zeus::CAABox& aabb,
const CModel* model, const CSkinnedModel* sModel)
{
@ -708,6 +715,7 @@ void CBooRenderer::RemoveStaticGeometry(const std::vector<CMetroidModelInstance>
void CBooRenderer::DrawAreaGeometry(int areaIdx, int mask, int targetMask)
{
x318_30_inAreaDraw = true;
SetupRendererStates();
CModelFlags flags;
for (CAreaListItem& item : x1c_areaListItems)
@ -745,7 +753,7 @@ void CBooRenderer::DrawAreaGeometry(int areaIdx, int mask, int targetMask)
void CBooRenderer::DrawUnsortedGeometry(int areaIdx, int mask, int targetMask)
{
//SetupRendererStates(true);
SetupRendererStates();
CAreaListItem* lastOctreeItem = nullptr;
@ -823,7 +831,7 @@ void CBooRenderer::DrawUnsortedGeometry(int areaIdx, int mask, int targetMask)
void CBooRenderer::DrawSortedGeometry(int areaIdx, int mask, int targetMask)
{
//SetupRendererStates(true);
SetupRendererStates();
CAreaListItem* lastOctreeItem = nullptr;
@ -1157,6 +1165,11 @@ void CBooRenderer::PrepareDynamicLights(const std::vector<CLight>& lights)
}
}
void CBooRenderer::SetWorldLightMultiplyColor(const zeus::CColor& color)
{
CGraphics::g_ColorRegs[1] = color;
}
void CBooRenderer::SetWorldLightFadeLevel(float level)
{
x2fc_tevReg1Color = zeus::CColor(level, level, level, 1.f);
@ -1210,6 +1223,8 @@ void CBooRenderer::FindOverlappingWorldModels(std::vector<u32>& modelBits, const
int CBooRenderer::DrawOverlappingWorldModelIDs(int alphaVal, const std::vector<u32>& modelBits,
const zeus::CAABox& aabb) const
{
SetupRendererStates();
CModelFlags flags;
flags.m_extendedShader = EExtendedShader::SolidColor; // Do solid color draw

View File

@ -180,6 +180,7 @@ class CBooRenderer : public IRenderer
static void RenderFogVolumeModel(const zeus::CAABox& aabb, const CModel* model, const zeus::CTransform& modelMtx,
const zeus::CTransform& viewMtx, const CSkinnedModel* sModel, int pass,
CFogVolumePlaneShader* fvs);
void SetupRendererStates() const;
public:
CBooRenderer(IObjectStore& store, IFactory& resFac);
@ -245,6 +246,7 @@ public:
void DoThermalBlendHot();
u32 GetStaticWorldDataSize();
void PrepareDynamicLights(const std::vector<CLight>& lights);
void SetWorldLightMultiplyColor(const zeus::CColor& color);
void SetWorldLightFadeLevel(float level);
void ReallyRenderFogVolume(const zeus::CColor& color, const zeus::CAABox& aabb,

View File

@ -10,6 +10,7 @@ namespace urde
CGraphics::CProjectionState CGraphics::g_Proj;
CGraphics::CFogState CGraphics::g_Fog;
zeus::CColor CGraphics::g_ColorRegs[3] = {};
float CGraphics::g_ProjAspect = 1.f;
u32 CGraphics::g_NumLightsActive = 0;
u32 CGraphics::g_NumBreakpointsWaiting = 0;

View File

@ -222,6 +222,7 @@ public:
static CProjectionState g_Proj;
static zeus::CVector2f g_CachedDepthRange;
static CFogState g_Fog;
static zeus::CColor g_ColorRegs[3];
static float g_ProjAspect;
static u32 g_NumLightsActive;
static u32 g_NumBreakpointsWaiting;

View File

@ -92,6 +92,9 @@ public:
x4c_24_intensityDirty = true;
x4c_25_radiusDirty = true;
}
float GetAttenuationConstant() const { return x24_distC; }
float GetAttenuationLinear() const { return x28_distL; }
float GetAttenuationQuadratic() const { return x2c_distQ; }
void SetAngleAttenuation(float constant, float linear, float quadratic)
{
@ -101,6 +104,9 @@ public:
x4c_24_intensityDirty = true;
x4c_25_radiusDirty = true;
}
float GetAngleAttenuationConstant() const { return x30_angleC; }
float GetAngleAttenuationLinear() const { return x34_angleL; }
float GetAngleAttenuationQuadratic() const { return x38_angleQ; }
float GetRadius() const
{

View File

@ -29,7 +29,6 @@ struct CModelFlags
u16 x2_flags = 0; /* Flags */
zeus::CColor x4_color; /* Set into kcolor slot specified by material */
zeus::CColor addColor = zeus::CColor::skClear;
zeus::CColor regColors[3];
zeus::CAABox mbShadowBox;
CModelFlags() = default;

View File

@ -807,9 +807,9 @@ void CBooModel::UpdateUniformData(const CModelFlags& flags,
{
CModelShaders::LightingUniform& lightingOut = *reinterpret_cast<CModelShaders::LightingUniform*>(dataCur);
lightingOut = m_lightingData;
lightingOut.colorRegs[0] = flags.regColors[0];
lightingOut.colorRegs[1] = flags.regColors[1];
lightingOut.colorRegs[2] = flags.regColors[2];
lightingOut.colorRegs[0] = CGraphics::g_ColorRegs[0];
lightingOut.colorRegs[1] = CGraphics::g_ColorRegs[1];
lightingOut.colorRegs[2] = CGraphics::g_ColorRegs[2];
lightingOut.mulColor = flags.x4_color;
lightingOut.fog = CGraphics::g_Fog;
}

View File

@ -101,6 +101,7 @@ public:
virtual void DoThermalBlendHot()=0;
virtual u32 GetStaticWorldDataSize()=0;
virtual void PrepareDynamicLights(const std::vector<CLight>& lights)=0;
virtual void SetWorldLightMultiplyColor(const zeus::CColor& color)=0;
virtual void SetWorldLightFadeLevel(float level)=0;
};

View File

@ -8,6 +8,7 @@
#include "Input/CFinalInput.hpp"
#include "zeus/CColor.hpp"
#include "CSimplePool.hpp"
#include "Graphics/CModel.hpp"
namespace urde
{
@ -51,15 +52,18 @@ void CGuiFrame::SortDrawOrder()
});
}
void CGuiFrame::EnableLights(u32 lights) const
void CGuiFrame::EnableLights(u32 lights, CBooModel& model) const
{
std::vector<CLight> lightsOut;
lightsOut.reserve(m_indexedLights.size() + 1);
CGraphics::DisableAllLights();
zeus::CColor accumColor(zeus::CColor::skBlack);
zeus::CColor ambColor(zeus::CColor::skBlack);
ERglLight lightId = ERglLight::Zero;
int idx = 0;
for (auto& light : m_indexedLights)
for (CGuiLight* light : m_indexedLights)
{
if (!light)
if (!light || !light->GetIsVisible())
{
++reinterpret_cast<std::underlying_type_t<ERglLight>&>(lightId);
++idx;
@ -67,18 +71,31 @@ void CGuiFrame::EnableLights(u32 lights) const
}
if ((lights & (1 << idx)) != 0)
{
// accumulate color
accumColor += light->GetColor();
CGraphics::LoadLight(lightId, light->BuildLight());
CGraphics::EnableLight(lightId);
const zeus::CColor& geomCol = light->GetGeometryColor();
if (geomCol.r || geomCol.g || geomCol.b)
{
//CGraphics::LoadLight(lightId, light->BuildLight());
lightsOut.push_back(light->BuildLight());
CGraphics::EnableLight(lightId);
}
// accumulate ambient color
ambColor += light->GetAmbientLightColor();
}
++reinterpret_cast<std::underlying_type_t<ERglLight>&>(lightId);
++idx;
}
if (m_indexedLights.empty())
CGraphics::SetAmbientColor(zeus::CColor::skWhite);
{
//CGraphics::SetAmbientColor(zeus::CColor::skWhite);
lightsOut.push_back(CLight::BuildLocalAmbient(zeus::CVector3f::skZero, zeus::CColor::skWhite));
}
else
CGraphics::SetAmbientColor(accumColor);
{
//CGraphics::SetAmbientColor(ambColor);
lightsOut.push_back(CLight::BuildLocalAmbient(zeus::CVector3f::skZero, ambColor));
}
model.ActivateLights(lightsOut);
}
void CGuiFrame::DisableLights() const

View File

@ -17,6 +17,7 @@ class CGuiLight;
class CVParamTransfer;
class CObjectReference;
class CSimplePool;
class CBooModel;
class CGuiFrame
{
@ -54,7 +55,7 @@ public:
void SetHeadWidget(std::shared_ptr<CGuiHeadWidget>&& hwig) { xc_headWidget = std::move(hwig); }
CGuiHeadWidget* GetHeadWidget() const { return xc_headWidget.get(); }
void SortDrawOrder();
void EnableLights(u32 lights) const;
void EnableLights(u32 lights, CBooModel& model) const;
void DisableLights() const;
void RemoveLight(CGuiLight* light);
void AddLight(CGuiLight* light);

View File

@ -19,7 +19,7 @@ class CGuiLight : public CGuiWidget
float xd0_angleL;
float xd4_angleQ;
u32 xd8_loadedIdx;
zeus::CColor xdc_color = zeus::CColor::skBlack;
zeus::CColor xdc_ambColor = zeus::CColor::skBlack;
public:
~CGuiLight();
CGuiLight(const CGuiWidgetParms& parms, const CLight& light);
@ -28,7 +28,7 @@ public:
CLight BuildLight() const;
void SetIsVisible(bool vis);
u32 GetLoadedIdx() const {return xd8_loadedIdx;}
const zeus::CColor& GetColor() const {return xdc_color;}
const zeus::CColor& GetAmbientLightColor() const {return xdc_ambColor;}
void SetSpotCutoff(float v) {xbc_spotCutoff = v;}
void SetDistC(float v) {xc0_distC = v;}
void SetDistL(float v) {xc4_distL = v;}
@ -37,7 +37,7 @@ public:
void SetAngleL(float v) {xd0_angleL = v;}
void SetAngleQ(float v) {xd4_angleQ = v;}
void SetLoadedIdx(u32 idx) {xd8_loadedIdx = idx;}
void SetColor(const zeus::CColor& color) {xdc_color = color;}
void SetAmbientLightColor(const zeus::CColor& color) {xdc_ambColor = color;}
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);

View File

@ -56,7 +56,7 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) const
{
zeus::CColor moduCol = xa8_color2;
moduCol.a *= parms.x0_alphaMod;
xb0_frame->EnableLights(x10c_lightMask);
xb0_frame->EnableLights(x10c_lightMask, const_cast<CBooModel&>(model->GetInstance()));
if (xb6_29_cullFaces)
CGraphics::SetCullMode(ERglCullMode::Front);

View File

@ -138,6 +138,8 @@ public:
void SetImageBaseline(bool b);
bool GetIsTextSupportFinishedLoading() const;
float GetCurTime() const { return x3c_curTime; }
void SetCurTime(float t) { x3c_curTime = t; }
const std::u16string& GetString() const { return x0_string; }
void SetScanStates(const std::vector<CSaveWorld::SScanState>* scanStates);
};

View File

@ -114,6 +114,7 @@ public:
zeus::CTransform& GetTransform() {return x74_transform;}
const zeus::CVector3f& GetIdlePosition() const {return x74_transform.origin;}
void SetTransform(const zeus::CTransform& xf);
const zeus::CColor& GetIntermediateColor() const { return xa4_color; }
const zeus::CColor& GetGeometryColor() const { return xa8_color2; }
void SetIdlePosition(const zeus::CVector3f& pos, bool reapply);
void ReapplyXform();

View File

@ -10,6 +10,7 @@
#include "GuiSys/CGuiCamera.hpp"
#include "Camera/CFirstPersonCamera.hpp"
#include "TCastTo.hpp"
#include "World/CGameLight.hpp"
namespace urde
{
@ -323,7 +324,7 @@ void CSamusHud::InitializeDamageLight()
lightColor.g *= lightColor.a;
lightColor.b *= lightColor.a;
lightColor.a = 1.f;
x3d4_damageLight->SetColor(lightColor);
x3d4_damageLight->SetAmbientLightColor(lightColor);
x3d4_damageLight->SetDistC(1.f);
x3d4_damageLight->SetDistL(0.f);
@ -734,8 +735,8 @@ void CSamusHud::UpdateHudLag(float dt, const CStateManager& mgr)
zeus::CVector3f bobTranslation = player.GetCameraBob()->GetHelmetBobTranslation();
zeus::CQuaternion lagRot = x44c_ * x31c_hudLag;
zeus::CVector3f lagOff = x41c_ * g_tweakGui->GetHudLagOffsetScale();
zeus::CQuaternion lagRot = x44c_hudLagShakeRot * x31c_hudLag;
zeus::CVector3f lagOff = x41c_decoShakeTranslate * g_tweakGui->GetHudLagOffsetScale();
lagOff.z += bobTranslation.z;
if (x2a0_helmetIntf)
{
@ -755,21 +756,316 @@ void CSamusHud::UpdateHudLag(float dt, const CStateManager& mgr)
}
}
bool CSamusHud::IsCachedLightInAreaLights(const SCachedHudLight& light, const CActorLights& areaLights) const
{
for (const CLight& l : areaLights.GetAreaLights())
{
if (l.GetColor() != light.xc_color || l.GetPosition() != light.x0_pos)
continue;
return true;
}
return false;
}
bool CSamusHud::IsAreaLightInCachedLights(const CLight& light) const
{
for (const SCachedHudLight& l : x340_hudLights)
{
if (l.x1c_fader == 0.f)
continue;
if (l.xc_color != light.GetColor() || l.x0_pos != light.GetPosition())
continue;
return true;
}
return false;
}
int CSamusHud::FindEmptyHudLightSlot(const CLight& light) const
{
for (int i=0 ; i<3 ; ++i)
if (x340_hudLights[i].x1c_fader == 0.f)
return i;
return -1;
}
zeus::CColor CSamusHud::GetVisorHudLightColor(const zeus::CColor& color, const CStateManager& mgr) const
{
zeus::CColor ret = color;
const CPlayerState& playerState = *mgr.GetPlayerState();
float t = playerState.GetVisorTransitionFactor();
switch (playerState.GetCurrentVisor())
{
case CPlayerState::EPlayerVisor::Scan:
ret *= zeus::CColor::lerp(zeus::CColor::skWhite, g_tweakGuiColors->GetScanVisorHudLightMultiply(), t);
break;
case CPlayerState::EPlayerVisor::Thermal:
ret *= g_tweakGuiColors->GetThermalVisorHudLightMultiply();
break;
case CPlayerState::EPlayerVisor::XRay:
ret = zeus::CColor(zeus::CColor(0.3f, 0.6f, 0.1f).rgbDot(ret));
break;
default: break;
}
return ret;
}
void CSamusHud::UpdateHudDynamicLights(float dt, const CStateManager& mgr)
{
if (TCastToConstPtr<CFirstPersonCamera> fpCam = mgr.GetCameraManager()->GetCurrentCamera(mgr))
{
zeus::CVector3f lookDir = fpCam->GetTransform().basis[1];
zeus::CAABox camAABB(fpCam->GetTranslation() - 0.125f, fpCam->GetTranslation() + 0.125f);
if (mgr.GetPlayer().GetAreaIdAlways() == kInvalidAreaId)
TAreaId playerArea = mgr.GetPlayer().GetAreaIdAlways();
if (playerArea == kInvalidAreaId)
return;
//x33c_lights->
x33c_lights->BuildAreaLightList(mgr, *mgr.GetWorld()->GetAreaAlways(playerArea), camAABB);
for (SCachedHudLight& light : x340_hudLights)
if ((light.x0_pos - fpCam->GetTranslation()).normalized().dot(lookDir) > 0.15707964f)
if (!IsCachedLightInAreaLights(light, *x33c_lights))
light.x1c_fader *= -1.f;
int negCount = 0;
for (SCachedHudLight& light : x340_hudLights)
if (light.x1c_fader <= 0.f)
++negCount;
--negCount;
for (const CLight& light : x33c_lights->GetAreaLights())
{
if (IsAreaLightInCachedLights(light))
continue;
if ((light.GetPosition() - fpCam->GetTranslation()).normalized().dot(lookDir) > 0.15707964f)
{
int slot = FindEmptyHudLightSlot(light);
if (slot == -1)
continue;
SCachedHudLight& cachedLight = x340_hudLights[slot];
cachedLight.x0_pos = light.GetPosition();
cachedLight.xc_color = light.GetColor();
cachedLight.x10_distC = light.GetAttenuationConstant();
cachedLight.x14_distL = light.GetAttenuationLinear();
cachedLight.x18_distQ = light.GetAttenuationQuadratic();
cachedLight.x1c_fader = 0.001f;
}
}
float dt2 = 2.f * dt;
for (SCachedHudLight& light : x340_hudLights)
{
if (light.x1c_fader < 0.f)
light.x1c_fader = std::max(0.f, light.x1c_fader + dt2);
else if (light.x1c_fader < 1.f && light.x1c_fader != 0)
light.x1c_fader = std::min(light.x1c_fader + dt2, 1.f);
}
CPlayerState& playerState = *mgr.GetPlayerState();
CPlayerState::EPlayerVisor visor = playerState.GetCurrentVisor();
float visorT = playerState.GetVisorTransitionFactor();
zeus::CColor lightAdd =
zeus::CColor::lerp(g_tweakGui->GetVisorHudLightAdd(0),
g_tweakGui->GetVisorHudLightAdd(int(visor)),
visorT);
zeus::CColor lightMul =
zeus::CColor::lerp(g_tweakGui->GetVisorHudLightMultiply(0),
g_tweakGui->GetVisorHudLightMultiply(int(visor)),
visorT);
auto lightIt = x5d8_guiLights.begin();
float maxIntensity = 0.f;
int maxIntensityIdx = 0;
for (int i=0 ; i<3 ; ++i)
{
SCachedHudLight& light = x340_hudLights[i];
CGuiLight* lightWidget = *lightIt;
zeus::CVector3f lightToCam = fpCam->GetTranslation() - light.x0_pos;
zeus::CVector3f lightNormal = fpCam->GetTransform().buildMatrix3f() * lightToCam.normalized();
float dist = std::max(lightToCam.magnitude(), FLT_EPSILON);
float falloffMul = 1.f /
(dist * dist * light.x18_distQ * g_tweakGui->GetHudLightAttMulQuadratic() +
dist * light.x14_distL * g_tweakGui->GetHudLightAttMulLinear() +
light.x10_distC * g_tweakGui->GetHudLightAttMulConstant());
falloffMul = std::min(falloffMul, 1.f);
lightWidget->SetO2WTransform(zeus::lookAt(zeus::CVector3f::skZero, lightNormal));
float fadedFalloff = falloffMul * std::fabs(light.x1c_fader);
zeus::CColor lightColor = GetVisorHudLightColor(light.xc_color * zeus::CColor(fadedFalloff), mgr);
lightWidget->SetColor(lightColor);
lightAdd += lightColor * lightMul;
float greyscale = fadedFalloff * zeus::CVector3f::skForward.dot(-lightNormal) *
lightAdd.rgbDot(zeus::CColor(0.3f, 0.6f, 0.1f));
if (greyscale > maxIntensity)
{
maxIntensity = greyscale;
maxIntensityIdx = i;
}
}
CLight brightestGameLight = CLight::BuildPoint(zeus::CVector3f::skZero, zeus::CColor::skBlack);
for (CEntity* ent : mgr.GetLightObjectList())
{
if (!ent || !ent->GetActive())
continue;
CGameLight& gameLight = static_cast<CGameLight&>(*ent);
if (TCastToConstPtr<CGameProjectile>(mgr.GetObjectById(gameLight.GetParentId())))
continue;
CLight thisLight = gameLight.GetLight();
if (thisLight.GetIntensity() > brightestGameLight.GetIntensity())
{
zeus::CSphere sphere(thisLight.GetPosition(), thisLight.GetRadius());
if (camAABB.intersects(sphere))
brightestGameLight = thisLight;
}
}
if (brightestGameLight.GetIntensity() > FLT_EPSILON)
{
zeus::CVector3f lightToCam = fpCam->GetTranslation() - brightestGameLight.GetPosition();
float dist = std::max(lightToCam.magnitude(), FLT_EPSILON);
float falloffMul = 1.f /
(dist * dist * brightestGameLight.GetAttenuationQuadratic() * g_tweakGui->GetHudLightAttMulQuadratic() +
dist * brightestGameLight.GetAttenuationLinear() * g_tweakGui->GetHudLightAttMulLinear() +
brightestGameLight.GetAttenuationConstant() * g_tweakGui->GetHudLightAttMulConstant());
falloffMul = std::min(falloffMul, 1.f);
zeus::CColor falloffColor = brightestGameLight.GetColor() * zeus::CColor(falloffMul);
falloffColor = GetVisorHudLightColor(falloffColor, mgr);
if (brightestGameLight.GetType() == ELightType::Spot)
{
float quarterCicleFactor = zeus::clamp(0.f, std::asin(std::max(0.f, fpCam->GetTransform().basis[1].
dot(brightestGameLight.GetDirection()))) * (M_PIF / 2.f), 1.f);
falloffColor *= zeus::CColor(quarterCicleFactor);
}
lightAdd += falloffColor;
}
const CGuiLight& brightestLight = *x5d8_guiLights[maxIntensityIdx];
lightAdd += x33c_lights->GetAmbientColor() * zeus::CColor(0.25f, 1.f);
zeus::CVector3f revDir = -brightestLight.GetWorldTransform().basis[1];
float foreDot = revDir.dot(zeus::CVector3f::skForward);
x5d8_guiLights[3]->SetO2WTransform(
zeus::lookAt(zeus::CVector3f::skZero, zeus::CVector3f::skForward * 2.f * foreDot - revDir));
x5d8_guiLights[3]->SetColor(g_tweakGui->GetHudReflectivityLightColor() * brightestLight.GetIntermediateColor());
x5d8_guiLights[3]->SetAmbientLightColor(lightAdd);
}
}
void CSamusHud::UpdateHudDamage(float dt, const CStateManager& mgr,
DataSpec::ITweakGui::EHelmetVisMode helmetVis)
{
CPlayer& player = mgr.GetPlayer();
if (player.WasDamaged() && mgr.GetGameState() == CStateManager::EGameState::Running)
x3e8_damageTIme += dt;
else
x3e8_damageTIme = 0.f;
float pulseDur = g_tweakGui->GetHudDamagePulseDuration();
float pulseTime = std::fabs(std::fmod(x3e8_damageTIme, pulseDur));
if (pulseTime < 0.5f * pulseDur)
x3ec_damageLightPulser = pulseTime / (0.5f * pulseDur);
else
x3ec_damageLightPulser = (pulseDur - pulseTime) / (0.5f * pulseDur);
x3ec_damageLightPulser = zeus::clamp(0.f, g_tweakGui->GetHudDamageColorGain() * x3ec_damageLightPulser * std::min(0.5f, player.GetDamageAmount()), 1.f);
zeus::CColor damageAmbColor = g_tweakGuiColors->GetHudFrameColor();
damageAmbColor.r *= damageAmbColor.a;
damageAmbColor.g *= damageAmbColor.a;
damageAmbColor.b *= damageAmbColor.a;
damageAmbColor += zeus::CColor(x3ec_damageLightPulser);
damageAmbColor.a = 1.f;
if (x3d4_damageLight)
x3d4_damageLight->SetAmbientLightColor(damageAmbColor);
if (x3f4_damageFilterAmt > 0.f)
{
x3f4_damageFilterAmt = std::max(0.f, x3f4_damageFilterAmt - dt);
if (x3f4_damageFilterAmt == 0.f)
{
CSfxManager::RemoveEmitter(x3a4_damageSfx);
x3a4_damageSfx.reset();
}
}
float tmp = x3f0_damageFilterAmtInit * g_tweakGui->GetHudDamagePeakFactor();
float colorGain;
if (x3f4_damageFilterAmt > tmp)
colorGain = (x3f0_damageFilterAmtInit - x3f4_damageFilterAmt) / (x3f0_damageFilterAmtInit - tmp);
else
colorGain = x3f4_damageFilterAmt / tmp;
colorGain = zeus::clamp(0.f, colorGain * x3f8_damageFilterAmtGain, 1.f);
zeus::CColor color0 = g_tweakGuiColors->GetDamageAmbientColor();
color0.a *= colorGain;
zeus::CColor color1 = g_tweakGuiColors->GetDamageAmbientPulseColor();
color1.a *= x3ec_damageLightPulser;
zeus::CColor color2 = color0 + color1;
if (color2.a)
{
if (player.GetMorphballTransitionState() != CPlayer::EPlayerMorphBallState::Unmorphed)
color2.a *= 0.75f;
x3a8_camFilter.SetFilter(CCameraFilterPass::EFilterType::Add, CCameraFilterPass::EFilterShape::Fullscreen,
0.f, color2, -1);
}
else
{
x3a8_camFilter.DisableFilter(0.f);
}
if (x3a4_damageSfx)
CSfxManager::UpdateEmitter(x3a4_damageSfx, player.GetTranslation(), player.GetTransform().basis[1], 1.f);
if (x400_hudDamagePracticals > 0.f)
{
x400_hudDamagePracticals = std::max(0.f, x400_hudDamagePracticals - dt);
float practicals = x400_hudDamagePracticals / x3fc_hudDamagePracticalsInit;
if (x28c_energyIntf)
x28c_energyIntf->SetFlashMagnitude(practicals);
practicals = std::min(practicals * x404_hudDamagePracticalsGain, 1.f);
x2a0_helmetIntf->AddHelmetLightValue(practicals);
if (x29c_decoIntf)
x29c_decoIntf->SetFrameColorValue(practicals);
if (practicals > 0.f)
{
x3d4_damageLight->SetColor(g_tweakGuiColors->GetHudDamageLightColor() * zeus::CColor(practicals));
x3d4_damageLight->SetIsVisible(true);
}
else
{
x3d4_damageLight->SetIsVisible(false);
}
}
bool transformUpdate = false;
if (x414_decoShakeTranslateAmt > 0.f)
{
x418_decoShakeTranslateAmtVel -= g_tweakGui->GetDecoDamageShakeDeceleration() * 60.f * dt;
x414_decoShakeTranslateAmt = std::max(0.f, x414_decoShakeTranslateAmt + x418_decoShakeTranslateAmtVel);
transformUpdate = true;
}
if (x460_decoShakeAmt > 0.f)
{
x460_decoShakeAmt = std::max(0.f, x460_decoShakeAmt - dt);
x44c_hudLagShakeRot = zeus::CQuaternion::skNoRotation;
float rotMul = std::min(g_tweakGui->GetMaxDecoDamageShakeRotate(),
x460_decoShakeAmt / x45c_decoShakeAmtInit * x464_decoShakeAmtGain);
float rotAng = rotMul * (2.f * M_PIF / 10.f);
x44c_hudLagShakeRot.rotateX(rand() / float(RAND_MAX) * rotAng);
x44c_hudLagShakeRot.rotateZ(rand() / float(RAND_MAX) * rotAng);
zeus::CVector3f vecs[] = {zeus::CVector3f::skRight,
zeus::CVector3f::skForward,
zeus::CVector3f::skUp};
for (int i=0 ; i<4 ; ++i)
vecs[int(rand() / float(RAND_MAX) * 4.f) & 0x3] += (rand() / float(RAND_MAX) - dt) * rotMul;
x428_decoShakeRotate = zeus::CMatrix3f(vecs[0], vecs[1], vecs[2]).transposed();
transformUpdate = true;
}
if (transformUpdate)
{
x41c_decoShakeTranslate = x408_damagerToPlayerNorm * std::min(g_tweakGui->GetMaxDecoDamageShakeTranslate(),
x414_decoShakeTranslateAmt);
if (x29c_decoIntf)
x29c_decoIntf->SetDamageTransform(x428_decoShakeRotate, x41c_decoShakeTranslate *
g_tweakGui->GetHudDecoShakeTranslateGain());
}
}
void CSamusHud::UpdateStaticSfx(CSfxHandle& handle, float& cycleTimer, u16 sfxId, float dt,
@ -825,10 +1121,76 @@ void CSamusHud::UpdateStaticInterference(float dt, const CStateManager& mgr)
}
}
int CSamusHud::GetRelativeDirection(const zeus::CVector3f& position, const CStateManager& mgr)
{
TCastToConstPtr<CFirstPersonCamera> fpCam = mgr.GetCameraManager()->GetCurrentCamera(mgr);
if (!fpCam)
return 0;
zeus::CVector3f camToPosLocal = fpCam->GetTransform().transposeRotate(position - fpCam->GetTranslation());
if (camToPosLocal == position)
return 0;
float y = std::cos(2.f * M_PIF * 0.0027777778f * 0.5f * fpCam->GetFov());
float x = std::cos(2.f * M_PIF * 0.0027777778f * 0.5f * fpCam->GetFov() * fpCam->GetAspectRatio());
zeus::CVector2f camToPosXY = zeus::CVector2f(camToPosLocal.x, camToPosLocal.y).normalized();
zeus::CVector2f camToPosYZ = zeus::CVector2f(camToPosLocal.y, camToPosLocal.z).normalized();
if (camToPosXY.dot(zeus::CVector2f(0.f, 1.f)) > x && camToPosYZ.dot(zeus::CVector2f(1.f, 0.f)) > y)
return 0;
if (camToPosXY.dot(zeus::CVector2f(0.f, -1.f)) > x && camToPosYZ.dot(zeus::CVector2f(-1.f, 0.f)) > y)
return 1;
zeus::CVector3f camToPosNorm = camToPosLocal.normalized();
zeus::CQuaternion quat;
quat.rotateY(2.f * M_PIF / 8.f);
zeus::CVector3f vec = zeus::CVector3f::skUp;
float maxDot = -1.f;
int ret = -1;
for (int i=0 ; i<8 ; ++i)
{
float dot = camToPosNorm.dot(vec);
if (dot > maxDot)
{
maxDot = dot;
ret = i + 2;
}
vec = quat.transform(vec);
}
return ret;
}
void CSamusHud::ShowDamage(const zeus::CVector3f& position, float dam, float prevDam,
const CStateManager& mgr)
{
CPlayer& player = mgr.GetPlayer();
int dir = GetRelativeDirection(position, mgr);
TCastToConstPtr<CFirstPersonCamera> fpCam = mgr.GetCameraManager()->GetCurrentCamera(mgr);
x404_hudDamagePracticalsGain = g_tweakGui->GetHudDamagePracticalsGainLinear() * dam +
g_tweakGui->GetHudDamagePracticalsGainConstant();
x3fc_hudDamagePracticalsInit = std::max(FLT_EPSILON, g_tweakGui->GetHudDamagePracticalsInitLinear() * dam +
g_tweakGui->GetHudDamagePracticalsInitConstant());
x400_hudDamagePracticals = x3fc_hudDamagePracticalsInit;
if (x3d4_damageLight)
x3d4_damageLight->SetLocalTransform(x3d8_lightTransforms[dir]);
x3f8_damageFilterAmtGain = g_tweakGui->GetHudDamageFilterGainLinear() * dam +
g_tweakGui->GetHudDamageFilterGainConstant();
x3f0_damageFilterAmtInit = g_tweakGui->GetHudDamageFilterInitLinear() * dam +
g_tweakGui->GetHudDamageFilterInitConstant();
x3f4_damageFilterAmt = x3f0_damageFilterAmtInit;
if (!x3a4_damageSfx)
{
x3a4_damageSfx = CSfxManager::AddEmitter(1385, player.GetTranslation(), player.GetTransform().basis[1],
0.f, false, true, 0xff, kInvalidAreaId);
}
if (fpCam)
{
x418_decoShakeTranslateAmtVel = g_tweakGui->GetHudDecoShakeTranslateVelLinear() * prevDam +
g_tweakGui->GetHudDecoShakeTranslateVelConstant();
x414_decoShakeTranslateAmt = x418_decoShakeTranslateAmtVel;
x408_damagerToPlayerNorm = -(fpCam->GetTransform().inverse() * position).normalized();
x464_decoShakeAmtGain = g_tweakGui->GetDecoShakeGainLinear() * prevDam +
g_tweakGui->GetDecoShakeGainConstant();
x45c_decoShakeAmtInit = g_tweakGui->GetDecoShakeInitLinear() * prevDam +
g_tweakGui->GetDecoShakeInitConstant();
x460_decoShakeAmt = x45c_decoShakeAmtInit;
}
}
void CSamusHud::EnterFirstPerson(const CStateManager& mgr)
@ -1293,12 +1655,59 @@ zeus::CTransform CSamusHud::BuildFinalCameraTransform(const zeus::CQuaternion& r
void CSamusHud::SetMessage(const std::u16string& text, const CHUDMemoParms& info)
{
bool isWidgetVisible = x598_base_basewidget_message->GetIsVisible();
if (!isWidgetVisible || info.x6_hintMemo)
{
if (info.x5_hintDismissSound)
{
if (!info.x6_hintMemo || !isWidgetVisible)
return;
CSfxManager::SfxStart(1449, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
return;
}
x598_base_basewidget_message->SetColor(zeus::CColor::skWhite);
x598_base_basewidget_message->SetVisibility(false, ETraversalMode::Children);
CGuiWidget* pane = info.x6_hintMemo ? x598_base_basewidget_message : x59c_base_textpane_message;
pane->SetVisibility(true, ETraversalMode::Children);
x59c_base_textpane_message->TextSupport()->SetTypeWriteEffectOptions(true, 0.1f, 40.f);
if (info.x4_initializeMemo)
{
x55c_lastSfxChars = 0.f;
x59c_base_textpane_message->TextSupport()->SetCurTime(0.f);
x59c_base_textpane_message->TextSupport()->SetText(text);
}
else if (x59c_base_textpane_message->TextSupport()->GetString().empty())
{
x55c_lastSfxChars = 0.f;
x59c_base_textpane_message->TextSupport()->AddText(text);
}
else
{
x59c_base_textpane_message->TextSupport()->AddText(std::u16string(u"\n") + text);
}
x59c_base_textpane_message->SetColor(zeus::CColor::skWhite);
x598_base_basewidget_message->SetColor(zeus::CColor::skWhite);
x558_messageTextAlpha = info.x0_alpha;
if (info.x6_hintMemo)
{
if (!isWidgetVisible)
{
CSfxManager::SfxStart(1443, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
}
}
else
{
x598_base_basewidget_message->SetLocalTransform(x598_base_basewidget_message->GetTransform());
}
}
}
void CSamusHud::InternalDeferHintMemo(ResId strg, u32 timePeriods, const CHUDMemoParms& info)
void CSamusHud::InternalDeferHintMemo(ResId strg, u32 strgIdx, const CHUDMemoParms& info)
{
x548_hudMemoParms = info;
x550_hudMemoString = g_SimplePool->GetObj(SObjectTag{FOURCC('STRG'), strg});
x554_hudMemoIdx = strgIdx;
}
}

View File

@ -22,17 +22,18 @@ class CGuiLight;
struct CHUDMemoParms
{
float x0_ = 0.f;
bool x4_ = false;
bool x5_ = false;
bool x6_ = false;
float x0_alpha = 0.f;
bool x4_initializeMemo = false;
bool x5_hintDismissSound = false;
bool x6_hintMemo = false;
CHUDMemoParms() = default;
CHUDMemoParms(float f1, bool b1, bool b2, bool b3)
: x0_(f1), x4_(b1), x5_(b2), x6_(b3) {}
CHUDMemoParms(float alpha, bool initializeMemo, bool hintDismissSound, bool hintMemo)
: x0_alpha(alpha), x4_initializeMemo(initializeMemo),
x5_hintDismissSound(hintDismissSound), x6_hintMemo(hintMemo) {}
CHUDMemoParms(CInputStream& in)
{
x0_ = in.readFloatBig();
x4_ = in.readBool();
x0_alpha = in.readFloatBig();
x4_initializeMemo = in.readBool();
}
};
@ -71,13 +72,13 @@ class CSamusHud
{
zeus::CVector3f x0_pos;
zeus::CColor xc_color;
float x10_ = 0.f;
float x14_ = 0.f;
float x18_ = 0.f;
float x1c_ = 0.f;
float x10_distC = 0.f;
float x14_distL = 0.f;
float x18_distQ = 0.f;
float x1c_fader = 0.f;
SCachedHudLight(const zeus::CVector3f& pos, const zeus::CColor& color,
float f1, float f2, float f3, float f4)
: x0_pos(pos), xc_color(color), x10_(f1), x14_(f2), x18_(f3), x1c_(f4) {}
: x0_pos(pos), xc_color(color), x10_distC(f1), x14_distL(f2), x18_distQ(f3), x1c_fader(f4) {}
};
struct SVideoBand
@ -154,23 +155,23 @@ class CSamusHud
CCameraFilterPass x3a8_camFilter;
CGuiLight* x3d4_damageLight = nullptr;
std::vector<zeus::CTransform> x3d8_lightTransforms;
float x3e8_ = 0.f;
float x3ec_ = 0.f;
float x3f0_ = 1.f;
float x3f4_ = 0.f;
float x3f8_ = 0.f;
float x3fc_ = 0.f;
float x400_ = 0.f;
float x404_ = 0.f;
zeus::CVector3f x408_;
float x414_ = 0.f;
float x418_ = 0.f;
zeus::CVector3f x41c_;
zeus::CMatrix3f x428_;
zeus::CQuaternion x44c_;
float x45c_ = 0.f;
float x460_ = 0.f;
float x464_ = 0.f;
float x3e8_damageTIme = 0.f;
float x3ec_damageLightPulser = 0.f;
float x3f0_damageFilterAmtInit = 1.f;
float x3f4_damageFilterAmt = 0.f;
float x3f8_damageFilterAmtGain = 0.f;
float x3fc_hudDamagePracticalsInit = 0.f;
float x400_hudDamagePracticals = 0.f;
float x404_hudDamagePracticalsGain = 0.f;
zeus::CVector3f x408_damagerToPlayerNorm;
float x414_decoShakeTranslateAmt = 0.f;
float x418_decoShakeTranslateAmtVel = 0.f;
zeus::CVector3f x41c_decoShakeTranslate;
zeus::CMatrix3f x428_decoShakeRotate;
zeus::CQuaternion x44c_hudLagShakeRot;
float x45c_decoShakeAmtInit = 0.f;
float x460_decoShakeAmt = 0.f;
float x464_decoShakeAmtGain = 0.f;
rstl::reserved_vector<zeus::CTransform, 3> x46c_;
zeus::CVector2f x500_viewportScale = {1.f, 1.f};
CSfxHandle x508_staticSfxHi;
@ -225,12 +226,17 @@ class CSamusHud
void ApplyClassicLag(const zeus::CUnitVector3f& lookDir, zeus::CQuaternion& rot,
const CStateManager& mgr, float dt, bool invert);
void UpdateHudLag(float dt, const CStateManager& mgr);
bool IsCachedLightInAreaLights(const SCachedHudLight& light, const CActorLights& areaLights) const;
bool IsAreaLightInCachedLights(const CLight& light) const;
int FindEmptyHudLightSlot(const CLight& light) const;
zeus::CColor GetVisorHudLightColor(const zeus::CColor& color, const CStateManager& mgr) const;
void UpdateHudDynamicLights(float dt, const CStateManager& mgr);
void UpdateHudDamage(float dt, const CStateManager& mgr,
DataSpec::ITweakGui::EHelmetVisMode helmetVis);
void UpdateStaticSfx(CSfxHandle& handle, float& cycleTimer, u16 sfxId, float dt,
float oldStaticInterp, float staticThreshold);
void UpdateStaticInterference(float dt, const CStateManager& mgr);
int GetRelativeDirection(const zeus::CVector3f& position, const CStateManager& mgr);
void ShowDamage(const zeus::CVector3f& position, float dam, float prevDam, const CStateManager& mgr);
void EnterFirstPerson(const CStateManager& mgr);
void LeaveFirstPerson(const CStateManager& mgr);
@ -260,12 +266,12 @@ public:
SetMessage(text, info);
}
void SetMessage(const std::u16string& text, const CHUDMemoParms& info);
static void DeferHintMemo(ResId strg, u32 timePeriods, const CHUDMemoParms& info)
static void DeferHintMemo(ResId strg, u32 strgIdx, const CHUDMemoParms& info)
{
if (g_SamusHud)
g_SamusHud->InternalDeferHintMemo(strg, timePeriods, info);
g_SamusHud->InternalDeferHintMemo(strg, strgIdx, info);
}
void InternalDeferHintMemo(ResId strg, u32 timePeriods, const CHUDMemoParms& info);
void InternalDeferHintMemo(ResId strg, u32 strgIdx, const CHUDMemoParms& info);
};
}

13
Runtime/World/CEffect.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "CEffect.hpp"
#include "CActorParameters.hpp"
namespace urde
{
CEffect::CEffect(TUniqueId uid, const CEntityInfo& info, bool active, const std::string& name, const zeus::CTransform& xf)
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(EMaterialTypes::Unknown),
CActorParameters::None(), kInvalidUniqueId)
{
}
}

17
Runtime/World/CEffect.hpp Normal file
View File

@ -0,0 +1,17 @@
#ifndef __URDE_CEFFECT_HPP__
#define __URDE_CEFFECT_HPP__
#include "CActor.hpp"
namespace urde
{
class CEffect : public CActor
{
public:
CEffect(TUniqueId uid, const CEntityInfo& info, bool active, const std::string& name, const zeus::CTransform& xf);
};
}
#endif // __URDE_CEFFECT_HPP__

View File

@ -0,0 +1,25 @@
#include "CExplosion.hpp"
namespace urde
{
CExplosion::CExplosion(const TLockedToken<CGenDescription>& particle, TUniqueId uid, bool active,
const CEntityInfo& info, const std::string& name, const zeus::CTransform& xf,
u32 flags, const zeus::CVector3f& scale, const zeus::CColor& color)
: CEffect(uid, info, active, name, xf)
{
xe8_particleGen = std::make_unique<CElementGen>(particle, CElementGen::EModelOrientationType::Normal,
flags & 0x2 ? CElementGen::EOptionalSystemFlags::Two :
CElementGen::EOptionalSystemFlags::One);
xf0_particleDesc = particle.GetObj();
xf4_24_ = flags & 0x4;
xf4_25_ = true;
xf4_26_ = flags & 0x8;
xe6_27_ = flags & 0x1 ? 1 : 2;
xe8_particleGen->SetGlobalTranslation(xf.origin);
xe8_particleGen->SetOrientation(xf.getRotation());
xe8_particleGen->SetGlobalScale(scale);
xe8_particleGen->SetModulationColor(color);
}
}

View File

@ -0,0 +1,28 @@
#ifndef __URDE_CEXPLOSION_HPP__
#define __URDE_CEXPLOSION_HPP__
#include "CEffect.hpp"
#include "Particle/CElementGen.hpp"
namespace urde
{
class CExplosion : public CEffect
{
std::unique_ptr<CElementGen> xe8_particleGen;
TUniqueId xec_ = kInvalidUniqueId;
const CGenDescription* xf0_particleDesc;
bool xf4_24_:1;
bool xf4_25_:1;
bool xf4_26_:1;
float xf8_ = 0.f;
public:
CExplosion(const TLockedToken<CGenDescription>& particle, TUniqueId uid, bool active,
const CEntityInfo& info, const std::string& name, const zeus::CTransform& xf,
u32, const zeus::CVector3f& scale, const zeus::CColor& color);
};
}
#endif // __URDE_CEXPLOSION_HPP__

View File

@ -259,7 +259,7 @@ private:
CGameArea* x130_next = nullptr;
CGameArea* x134_prev = nullptr;
EChain x138_curChain = EChain::Zero;
EChain x138_curChain = EChain::ToDeallocate;
void UpdateFog(float dt);
void UpdateThermalVisor(float dt);

View File

@ -56,9 +56,4 @@ CLight CGameLight::GetLight() const
return ret;
}
TUniqueId CGameLight::GetParentId() const
{
return xe8_parentId;
}
}

View File

@ -22,7 +22,7 @@ public:
void SetLightPriorityAndId();
void SetLight(const CLight&);
CLight GetLight() const;
TUniqueId GetParentId() const;
TUniqueId GetParentId() const { return xe8_parentId; }
};
}
#endif // __URDE_CGAMELIGHT_HPP__

View File

View File

View File

@ -115,7 +115,10 @@ set(WORLD_SOURCES
CRippleManager.hpp CRippleManager.cpp
CRipple.hpp CRipple.cpp
CDestroyableRock.hpp CDestroyableRock.cpp
CEffect.hpp CEffect.cpp
CHUDBillboardEffect.hpp CHUDBillboardEffect.cpp
CExplosion.hpp CExplosion.cpp
CIceImpact.hpp CIceImpact.cpp
CEntityInfo.hpp)
runtime_add_list(World WORLD_SOURCES)

View File

@ -184,7 +184,6 @@ void CScriptDock::Touch(CActor& act, CStateManager&)
zeus::CPlane CScriptDock::GetPlane(const CStateManager& mgr) const
{
const IGameArea::Dock* dock = mgr.GetWorld()->GetAreaAlways(x260_area)->GetDock(x25c_dock);
return zeus::CPlane(dock->GetPoint(0), dock->GetPoint(1), dock->GetPoint(2));
}
@ -237,7 +236,6 @@ void CScriptDock::UpdateAreaActivateFlags(CStateManager& mgr)
bool CScriptDock::HasPointCrossedDock(const CStateManager& mgr, const zeus::CVector3f& point) const
{
const zeus::CPlane plane = GetPlane(mgr);
return (plane.vec.dot(point) >= plane.d);
}

View File

@ -186,7 +186,7 @@ int CDummyWorld::IGetAreaCount() const { return x18_areas.size(); }
CWorld::CWorld(IObjectStore& objStore, IFactory& resFactory, ResId mlvlId)
: x8_mlvlId(mlvlId), x60_objectStore(objStore), x64_resFactory(resFactory)
{
x70_24_ = true;
x70_24_currentAreaNeedsAllocation = true;
SObjectTag tag{FOURCC('MLVL'), mlvlId};
static_cast<ProjectResourceFactoryBase&>(resFactory).LoadResourceAsync(tag, x40_loadBuf);
}
@ -301,7 +301,7 @@ bool CWorld::CheckWorldComplete(CStateManager* mgr, TAreaId id, ResId mreaId)
}
for (std::unique_ptr<CGameArea>& area : x18_areas)
MoveToChain(area.get(), EChain::One);
MoveToChain(area.get(), EChain::Deallocated);
x24_mapwId = r.readUint32Big();
x28_mapWorld = g_SimplePool->GetObj(SObjectTag{FOURCC('MAPW'), x24_mapwId});
@ -412,16 +412,16 @@ bool CWorld::ScheduleAreaToLoad(CGameArea* area, CStateManager& mgr)
{
if (!area->xf0_24_postConstructed)
{
MoveToChain(area, EChain::Two);
MoveToChain(area, EChain::Loading);
return true;
}
else
{
if (area->x138_curChain != EChain::Alive)
{
if (area->x138_curChain != EChain::Four)
if (area->x138_curChain != EChain::AliveJudgement)
{
x70_24_ = true;
x70_24_currentAreaNeedsAllocation = true;
}
MoveToChain(area, EChain::Alive);
}
@ -433,37 +433,37 @@ void CWorld::TravelToArea(TAreaId aid, CStateManager& mgr, bool skipLoadOther)
{
if (aid < 0 || aid >= x18_areas.size())
return;
x70_24_ = false;
x70_24_currentAreaNeedsAllocation = false;
x68_curAreaId = aid;
CGameArea* chain0 = x4c_chainHeads[0];
while (chain0)
CGameArea* toDeallocateAreas = x4c_chainHeads[0];
while (toDeallocateAreas)
{
if (chain0->Invalidate(mgr))
if (toDeallocateAreas->Invalidate(mgr))
{
MoveToChain(chain0, EChain::One);
MoveToChain(toDeallocateAreas, EChain::Deallocated);
break;
}
chain0 = chain0->x130_next;
toDeallocateAreas = toDeallocateAreas->x130_next;
}
CGameArea* chain3 = x4c_chainHeads[3];
while (chain3)
CGameArea* aliveAreas = x4c_chainHeads[3];
while (aliveAreas)
{
MoveToChain(chain3, EChain::Four);
chain3 = chain3->x130_next;
MoveToChain(aliveAreas, EChain::AliveJudgement);
aliveAreas = aliveAreas->x130_next;
}
CGameArea* chain2 = x4c_chainHeads[2];
while (chain2)
CGameArea* loadingAreas = x4c_chainHeads[2];
while (loadingAreas)
{
MoveToChain(chain2, EChain::Zero);
chain2 = chain2->x130_next;
MoveToChain(loadingAreas, EChain::ToDeallocate);
loadingAreas = loadingAreas->x130_next;
}
CGameArea* area = x18_areas[aid].get();
if (area->x138_curChain != EChain::Four)
x70_24_ = true;
if (area->x138_curChain != EChain::AliveJudgement)
x70_24_currentAreaNeedsAllocation = true;
area->Validate(mgr);
MoveToChain(area, EChain::Alive);
area->SetOcclusionState(CGameArea::EOcclusionState::Visible);
@ -496,19 +496,19 @@ void CWorld::TravelToArea(TAreaId aid, CStateManager& mgr, bool skipLoadOther)
}
}
CGameArea* chain4 = x4c_chainHeads[4];
while (chain4)
CGameArea* judgementArea = x4c_chainHeads[4];
while (judgementArea)
{
MoveToChain(chain4, EChain::Zero);
chain4 = chain4->x130_next;
MoveToChain(judgementArea, EChain::ToDeallocate);
judgementArea = judgementArea->x130_next;
}
size_t toStreamCount = 0;
chain0 = x4c_chainHeads[0];
while (chain0)
toDeallocateAreas = x4c_chainHeads[0];
while (toDeallocateAreas)
{
chain0->RemoveStaticGeometry();
chain0 = chain0->x130_next;
toDeallocateAreas->RemoveStaticGeometry();
toDeallocateAreas = toDeallocateAreas->x130_next;
++toStreamCount;
}
@ -520,7 +520,7 @@ void CWorld::TravelToArea(TAreaId aid, CStateManager& mgr, bool skipLoadOther)
void CWorld::SetPauseState(bool paused)
{
for (auto it = GetChainHead(EChain::Two) ; it != AliveAreasEnd() ; ++it)
for (auto it = GetChainHead(EChain::Loading) ; it != AliveAreasEnd() ; ++it)
it->SetPauseState(paused);
x70_25_paused = paused;
}

View File

@ -134,7 +134,7 @@ private:
{
struct
{
bool x70_24_ : 1;
bool x70_24_currentAreaNeedsAllocation : 1;
bool x70_25_paused : 1;
bool x70_26_ : 1;
bool x70_27_ : 1;

View File

@ -55,11 +55,11 @@ public:
enum class EChain
{
Invalid = -1,
Zero,
One,
Two,
ToDeallocate,
Deallocated,
Loading,
Alive,
Four
AliveJudgement
};
}

@ -1 +1 @@
Subproject commit ce3b1c7399061d0199268a8da1ec3fdfa15c51a2
Subproject commit 0badca1998a07b8ac1c99c103e9f9b97daee9c60