mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-10 09:07:42 +00:00
Nearly finish CScriptWater
This commit is contained in:
@@ -4,58 +4,69 @@
|
||||
namespace urde
|
||||
{
|
||||
|
||||
CFluidUVMotion::CFluidUVMotion(float a, float b, const CFluidUVMotion::SFluidLayerMotion& c,
|
||||
const CFluidUVMotion::SFluidLayerMotion& d, const CFluidUVMotion::SFluidLayerMotion& e)
|
||||
: x4c_(1.f/a)
|
||||
, x50_(b)
|
||||
CFluidUVMotion::CFluidUVMotion(float timeToWrap, float orientation,
|
||||
const CFluidUVMotion::SFluidLayerMotion& colorLayer,
|
||||
const CFluidUVMotion::SFluidLayerMotion& pattern1Layer,
|
||||
const CFluidUVMotion::SFluidLayerMotion& pattern2Layer)
|
||||
: x4c_ooTimeToWrap(1.f / timeToWrap)
|
||||
, x50_orientation(orientation)
|
||||
{
|
||||
x0_fluidLayers.resize(3);
|
||||
x0_fluidLayers[0] = c;
|
||||
x0_fluidLayers[1] = d;
|
||||
x0_fluidLayers[2] = e;
|
||||
x0_fluidLayers[0] = colorLayer;
|
||||
x0_fluidLayers[1] = pattern1Layer;
|
||||
x0_fluidLayers[2] = pattern2Layer;
|
||||
}
|
||||
|
||||
CFluidUVMotion::CFluidUVMotion(float, float)
|
||||
{}
|
||||
|
||||
void CFluidUVMotion::CalculateFluidTextureOffset(float f31, float offsets[3][2]) const
|
||||
CFluidUVMotion::CFluidUVMotion(float timeToWrap, float orientation)
|
||||
: x4c_ooTimeToWrap(1.f / timeToWrap), x50_orientation(orientation)
|
||||
{
|
||||
float f28 = (f31 * x4c_) * zeus::fastCosF(x50_);
|
||||
float f29 = (f31 * x4c_) / zeus::fastSinF(x50_);
|
||||
x0_fluidLayers.resize(3);
|
||||
x0_fluidLayers[0].x4_ooTimeToWrap = 0.001f;
|
||||
x0_fluidLayers[1].x4_ooTimeToWrap = 0.33333334f;
|
||||
x0_fluidLayers[2].x4_ooTimeToWrap = 0.2f;
|
||||
x0_fluidLayers[2].x8_orientation = 0.78539819f;
|
||||
}
|
||||
|
||||
void CFluidUVMotion::CalculateFluidTextureOffset(float t, float offsets[3][2]) const
|
||||
{
|
||||
float totalYOffset = (t * x4c_ooTimeToWrap) * zeus::fastCosF(x50_orientation);
|
||||
float totalXOffset = (t * x4c_ooTimeToWrap) * zeus::fastSinF(x50_orientation);
|
||||
|
||||
for (u32 i = 0 ; i<x0_fluidLayers.size() ; ++i)
|
||||
{
|
||||
const SFluidLayerMotion& layer = x0_fluidLayers[i];
|
||||
|
||||
float f30 = f31 * layer.x4_a;
|
||||
float f1 = f30 - std::floor(f30);
|
||||
float f27;
|
||||
float f26;
|
||||
float speedT = t * layer.x4_ooTimeToWrap;
|
||||
float cycleT = speedT - std::floor(speedT);
|
||||
float localY;
|
||||
float localX;
|
||||
switch(layer.x0_motion)
|
||||
{
|
||||
case EFluidUVMotion::One:
|
||||
{
|
||||
f30 = (M_PIF * 2) * f1;
|
||||
f27 = layer.xc_c * zeus::fastSinF(f30);
|
||||
f26 = layer.xc_c * zeus::fastCosF(f30);
|
||||
float angle = (M_PIF * 2) * cycleT;
|
||||
localY = layer.xc_magnitude * zeus::fastSinF(angle);
|
||||
localX = layer.xc_magnitude * zeus::fastCosF(angle);
|
||||
}
|
||||
break;
|
||||
case EFluidUVMotion::Two:
|
||||
{
|
||||
f27 = 0.f;
|
||||
f26 = layer.xc_c * zeus::fastCosF((M_PIF * 2) * f1);
|
||||
localY = 0.f;
|
||||
localX = layer.xc_magnitude * zeus::fastCosF((M_PIF * 2) * cycleT);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
f27 = f26 = 0.f;
|
||||
localY = localX = 0.f;
|
||||
break;
|
||||
}
|
||||
|
||||
float x = f26 * zeus::fastSinF(layer.x8_b) + (f27 * zeus::fastCosF(layer.x8_b) + f29);
|
||||
float y = f27 * zeus::fastSinF(layer.x8_b) + (f26 * zeus::fastCosF(layer.x8_b) + f28);
|
||||
float x = localX * zeus::fastSinF(layer.x8_orientation) +
|
||||
localY * zeus::fastCosF(layer.x8_orientation) + totalXOffset;
|
||||
float y = localY * zeus::fastSinF(layer.x8_orientation) +
|
||||
localX * zeus::fastCosF(layer.x8_orientation) + totalYOffset;
|
||||
|
||||
offsets[i][0] = float(x - floor(x));
|
||||
offsets[i][1] = float(y - floor(y));
|
||||
offsets[i][0] = x - std::floor(x);
|
||||
offsets[i][1] = y - std::floor(y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user