Files
firestorm/Gameleap/code/mw4/Code/MW4/Blanderizer.hpp
T
Cyd 2b8ca921cb Initial full mirror of c:\VWE (source + assets + toolchain + outputs) via Git LFS
Complete disaster-recovery snapshot: engine/game source, game data assets,
VC6 toolchain + DX SDKs, build outputs, deployed game, and _UNUSED archive.
Large binaries in Git LFS; text preserved byte-for-byte (core.autocrlf=false,
no eol attributes). See RECOVERY.md for the one-clone rebuild procedure.
2026-06-24 21:28:16 -05:00

105 lines
2.6 KiB
C++

//===========================================================================//
// File: Blanderizer.hpp
// Project: MechWarrior 4
// Contents:
// AngleAxis class for animation. This is just an unlimited rotation
// quaternion
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 06/02/99 JSE Initial coding,
//---------------------------------------------------------------------------//
// Copyright (C) 1998, Fasa Interactive, Inc.
// All Rights reserved worldwide
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL
//===========================================================================//
#pragma once
namespace MechWarrior4 {
//##########################################################################
//######################### Blanderizer ###############################
//##########################################################################
template <class T> class BlanderizerOf
{
public:
BlanderizerOf()
{
currentTime = 0.0f;
fadeTime = 0.0f;
targetDampen = 1.0f;
lastDampen = 1.0f;
};
~BlanderizerOf()
{};
void FadeToNewDampen(Stuff::Scalar dampen_amount, Scalar fade_time)
{
Verify(fadeTime >= 0.0f);
Verify(dampen_amount >= 0.0f);
Verify(dampen_amount <= 1.0f);
lastDampen = GetCurrentDampenValue();
fadeTime = fade_time;
currentTime = 0.0f;
targetDampen = dampen_amount;
}
void SetNewDampen(Stuff::Scalar dampen_amount)
{
fadeTime = 0.0f;
currentTime = 0.0f;
lastDampen = dampen_amount;
targetDampen = dampen_amount;
}
T DampenValue(T &home_position, T& value_position)
{
Scalar lerp_value = GetCurrentDampenValue();
T new_value;
return new_value.Lerp(value_position, home_position, lerp_value);
}
Scalar GetCurrentDampenValue()
{
Stuff::Scalar lerp_value = lastDampen;
if (currentTime >= fadeTime)
{
lerp_value = targetDampen;
}
else if (currentTime != 0.0f)
{
Stuff::Scalar to_fade_ratio = currentTime / fadeTime;
lerp_value = Stuff::Lerp(lastDampen, targetDampen, to_fade_ratio);
}
return lerp_value;
}
void AdvanceTime(Scalar time_slice)
{
if (currentTime < fadeTime)
{
currentTime += time_slice;
}
}
Scalar fadeTime;
Scalar currentTime;
Scalar lastDampen;
Scalar targetDampen;
};
}