Special Aircraft Service

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Creating a new effect for splash when crashing on water  (Read 303 times)

0 Members and 1 Guest are viewing this topic.

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 6040
Creating a new effect for splash when crashing on water
« on: May 06, 2024, 01:40:10 AM »

The effect for the water splash when crashing onto water is shared with the spray for seaplanes when running on the surface above a threshold speed. This has never satisfied me because float spray is not as 'violent' as spray kicked up during a crash, and sharing the one effect for both situations is not ideal. And so I've added a bit of code to Gear.drawEffects() which generates a new effect for crash splash for non-seaplanes. This 2-panel screenshot shows the difference; the crash effect particles are notably larger.




Here's my full code which generates the effects for gear (and floats) when the plane is running along the surface. The relevant part here is identified by the remark, "//NEW for water crashes". Formerly the effect SmokeAirSplat.eff was used when other non-gear hooks contacted the water; the new effect is SmokeAirSplatCrash.eff.

Incidentally, other new stuff is present here which handles different gear effects for certain maps and by weather conditions. (Compare to the stock code shown farther below...)

Code: [Select]
for(int j = 0; j < pnti.length; j++)
{
if(isWater && !bIsSail && clp[j] && FM.Vrel.length() > 12.0D && !isUnderDeck())  //NEW for water crashes
{
if(clpEff[j] != null)
continue;
clpEff[j] = Eff3DActor.New(FM.actor, null, new Loc(new Point3d(Pnt[j]), new Orient(0.0F, 90F, 0.0F)), 1.0F, "Effects/Smokes/SmokeAirSplatCrash.eff", -1F);  //NEW effect
continue;
}
if(clp[j] && FM.Vrel.length() > 12.0D && !isUnderDeck())  //original!; was 16.667, or about 32 kt; had as 9, but might be a bit slow
{
int criticalSpeedThreshold = bIsAboveCriticalSpeed?ABOVE_CRITICAL_SPEED:BELOW_CRITICAL_SPEED;  //NEW
if(clpEff[j] != null)
{
if((bIsAboveCriticalSpeed && oldCriticalSpeedThreshold == 1) || (!bIsAboveCriticalSpeed && oldCriticalSpeedThreshold == 0))
continue;
else
{
Eff3DActor.finish(clpEff[j]);
clpEff[j] = null;
continue;
}
}
if(isWater && !bIsAboveCriticalSpeed)
{
sizeScale = 1.0F;  //to not use reduced scale, due to NEW dedicated effect now in use
effectName = "Effects/Smokes/SmokeAirSplatSmall.eff";  //NEW, smaller float spray (serves also as crash splash); for use at low speed
}
else
if(isWater && bIsAboveCriticalSpeed)
effectName = "Effects/Smokes/SmokeAirSplat.eff";  //'normal' float spray (serves also as crash splash), now for use at higher speed
else

if((World.cur().camouflage == World.CAMOUFLAGE_PACIFIC || World.cur().camouflage == World.CAMOUFLAGE_CBI || World.cur().camouflage == World.CAMOUFLAGE_DESERT) && bPlateCoral)  //NEW property; coral strips on PACIFIC maps
{
if(effclouds != null && effclouds.type() >= 5)  //if raining
effectName = "Effects/Explodes/_Miniscule.eff";  //invisible
else
effectName = "Effects/Smokes/SmokeAirTouchC.eff";  //NEW effect; kicked up by rolling wheels on coral
}
else
if(World.cur().camouflage == World.CAMOUFLAGE_WINTER)
{
if(bPlateConcrete && (effclouds == null || (effclouds != null && effclouds.type() <= 4)))  //if concrete (incl. PCP) or raining
effectName = "Effects/Explodes/_Miniscule.eff";  //invisible, to simulate cleared surface, with no snow falling
else
effectName = "Effects/Smokes/SmokeAirTouchW.eff";  //kicked up by rolling wheels, winter
}
else
if(World.cur().camouflage == World.CAMOUFLAGE_DESERT || bPlateSand)
{
if(bPlateConcrete)
effectName = "Effects/Smokes/SmokeAirTouch.eff";  //subtler wheel dust
else
effectName = "Effects/Smokes/SmokeAirTouchD.eff";  //heavier dust kicked up by rolling wheels, desert; NEW!!!!
if(effclouds != null && effclouds.type() >= 5)  //i.e., if raining
effectName = "Effects/Explodes/_Miniscule.eff";  //invisible
}
else  //all but Pacific coral, winter and desert
{
effectName = "Effects/Smokes/SmokeAirTouch.eff";  //kicked up by rolling wheels
if(bPlateConcrete || (effclouds != null && effclouds.type() >= 5))  //if concrete (incl. PCP) or raining
effectName = "Effects/Explodes/_Miniscule.eff";  //invisible
}
clpEff[j] = Eff3DActor.New(FM.actor, null, new Loc(new Point3d(Pnt[j]), new Orient(0.0F, 90F, 0.0F)), sizeScale, effectName, -1F);
oldCriticalSpeedThreshold = criticalSpeedThreshold;  //NEW
continue;
}
if(flag && clpEff[j] != null)  //original
{
Eff3DActor.finish(clpEff[j]);
clpEff[j] = null;
}
}

For comparison, here's the stock code:

Code: [Select]
for(int j = 0; j < pnti.length; j++)
{
if(clp[j] && FM.Vrel.length() > 16.667D && !isUnderDeck())
{
if(clpEff[j] != null)
continue;
if(isWater)
effectName = "EFFECTS/Smokes/SmokeAirSplat.eff";
else
if(World.cur().camouflage == 1)
effectName = "EFFECTS/Smokes/SmokeAirTouchW.eff";
else
effectName = "EFFECTS/Smokes/SmokeAirTouch.eff";
clpEff[j] = Eff3DActor.New(FM.actor, null, new Loc(new Point3d(Pnt[j]), new Orient(0.0F, 90F, 0.0F)), 1.0F, effectName, -1F);
continue;
}
if(flag && clpEff[j] != null)
{
Eff3DActor.finish(clpEff[j]);
clpEff[j] = null;
}
}
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)

Epervier

  • 4.09 Guardian Angel !
  • SAS Team
  • member
  • Offline Offline
  • Posts: 9540
  • I'm French and Rebel_409! Nobody is perfect!
    • Some tinkering here
Re: Creating a new effect for splash when crashing on water
« Reply #1 on: May 06, 2024, 02:47:24 AM »

Too bad, this code is not 409 compatible.  :(
Logged
If your results do not live up to your expectations, tell yourself that the great oak was once an acorn too. - Lao Zi -

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 6040
Re: Creating a new effect for splash when crashing on water
« Reply #2 on: May 06, 2024, 06:22:44 AM »

Gabriel,
Did you try using the ENTIRE code I posted previously? If so, you will need this (which I placed just preceding the drawEffects() method, but which can be placed anywhere inside public class Gear):

Code: [Select]
    private boolean bIsAboveCriticalSpeed;  //NEW
    private static final int UNINITIALIZED             = -1;  //NEW
    private static final int BELOW_CRITICAL_SPEED      = 0;  //NEW
    private static final int ABOVE_CRITICAL_SPEED      = 1;  //NEW
    private int              oldCriticalSpeedThreshold = UNINITIALIZED;  //NEW


Below is the full stock 4.09 Gear.drawEffects() method. The new code for ONLY the crash splash effect under discussion here is the 7 lines bounded by the "//==============" lines. Copy just that small block into your existing code. If this works, and you want to proceed to adapting the additional effects, then add the 5 lines in the code window above. I haven't looked into the compatibility of the World.CAMOUFLAGE useage
here; does 4.09 require to use the number values? And are sand runway plates (via boolean bPlateSand) supported? Things to keep in mind. ;)

Code: [Select]
private void drawEffects()
{
boolean flag = FM.isTick(16, 0);
for(int i = 0; i < 3; i++)
if(bIsSail && flag && isWater && clp[i] && FM.getSpeedKMH() > 10F)
{
if(clpGearEff[i][0] == null)
{
clpGearEff[i][0] = Eff3DActor.New(FM.actor, null, new Loc(new Point3d(Pnt[i]), new Orient(0.0F, 0.0F, 0.0F)), 1.0F, "3DO/Effects/Tracers/ShipTrail/WakeSmaller.eff", -1F);
clpGearEff[i][1] = Eff3DActor.New(FM.actor, null, new Loc(new Point3d(Pnt[i]), new Orient(0.0F, 0.0F, 0.0F)), 1.0F, "3DO/Effects/Tracers/ShipTrail/WaveSmaller.eff", -1F);
}
} else
if(flag && clpGearEff[i][0] != null)
{
Eff3DActor.finish(clpGearEff[i][0]);
Eff3DActor.finish(clpGearEff[i][1]);
clpGearEff[i][0] = null;
clpGearEff[i][1] = null;
}

for(int j = 0; j < pnti.length; j++)
{
//===============================NEW by WxTech; to generate a separate effect for water crashes, instead of sharing the float spray effect==========================================
if(isWater && !bIsSail && clp[j] && FM.Vrel.length() > 12.0D && !isUnderDeck())
{
if(clpEff[j] != null)
continue;
clpEff[j] = Eff3DActor.New(FM.actor, null, new Loc(new Point3d(Pnt[j]), new Orient(0.0F, 90F, 0.0F)), 1.0F, "Effects/Smokes/SmokeAirSplatCrash.eff", -1F);  //NEW effect
continue;
}
//==================================================================================================================================================================================
if(clp[j] && FM.Vrel.length() > 16.66666667D && !isUnderDeck())
{
if(clpEff[j] == null)
{
if(isWater)
effectName = "EFFECTS/Smokes/SmokeAirSplat.eff";
else
if(World.cur().camouflage == 1)
effectName = "EFFECTS/Smokes/SmokeAirTouchW.eff";
else
effectName = "EFFECTS/Smokes/SmokeAirTouch.eff";
clpEff[j] = Eff3DActor.New(FM.actor, null, new Loc(new Point3d(Pnt[j]), new Orient(0.0F, 90F, 0.0F)), 1.0F, effectName, -1F);
}
} else
if(flag && clpEff[j] != null)
{
Eff3DActor.finish(clpEff[j]);
clpEff[j] = null;
}
}

if(FM.EI.getNum() > 0)
{
for(int k = 0; k < FM.EI.getNum(); k++)
{
FM.actor.pos.getAbs(Aircraft.tmpLoc1);
Pn.set(FM.EI.engines[k].getPropPos());
Aircraft.tmpLoc1.transform(Pn, PnT);
float f = (float)(PnT.z - Engine.cur.land.HQ(PnT.x, PnT.y));
if(f < 16.2F && FM.EI.engines[k].getThrustOutput() > 0.5F)
{
Pn.x -= f * Aircraft.cvt(FM.Or.getTangage(), -30F, 30F, 8F, 2.0F);
Aircraft.tmpLoc1.transform(Pn, PnT);
PnT.z = Engine.cur.land.HQ(PnT.x, PnT.y);
if(clpEngineEff[k][0] == null)
{
Aircraft.tmpLoc1.transformInv(PnT);
if(isWater)
{
clpEngineEff[k][0] = Eff3DActor.New(FM.actor, null, new Loc(PnT), 1.0F, "3DO/Effects/Aircraft/GrayGroundDust2.eff", -1F);
clpEngineEff[k][1] = Eff3DActor.New(new Loc(PnT), 1.0F, "3DO/Effects/Aircraft/WhiteEngineWaveTSPD.eff", -1F);
} else
{
clpEngineEff[k][0] = Eff3DActor.New(FM.actor, null, new Loc(PnT), 1.0F, "3DO/Effects/Aircraft/GrayGroundDust" + (World.cur().camouflage != 1 ? "1" : "2") + ".eff", -1F);
}
continue;
}
if(isWater)
{
if(clpEngineEff[k][1] == null)
{
Eff3DActor.finish(clpEngineEff[k][0]);
clpEngineEff[k][0] = null;
continue;
}
} else
if(clpEngineEff[k][1] != null)
{
Eff3DActor.finish(clpEngineEff[k][0]);
clpEngineEff[k][0] = null;
Eff3DActor.finish(clpEngineEff[k][1]);
clpEngineEff[k][1] = null;
continue;
}
Aircraft.tmpOr.set(FM.Or.getAzimut() + 180F, 0.0F, 0.0F);
clpEngineEff[k][0].pos.setAbs(PnT);
clpEngineEff[k][0].pos.setAbs(Aircraft.tmpOr);
clpEngineEff[k][0].pos.resetAsBase();
if(clpEngineEff[k][1] != null)
{
PnT.z = 0.0D;
clpEngineEff[k][1].pos.setAbs(PnT);
}
} else
{
if(clpEngineEff[k][0] != null)
{
Eff3DActor.finish(clpEngineEff[k][0]);
clpEngineEff[k][0] = null;
}
if(clpEngineEff[k][1] != null)
{
Eff3DActor.finish(clpEngineEff[k][1]);
clpEngineEff[k][1] = null;
}
}
}

}
}

The new crash splash effect to create:  Effects/Smokes/SmokeAirSplatCrash.eff. Write into that new .eff file the contents in the code box below. My MatName is new. The MatName you will use for initial experimentation could be the same as found in SmokeAirSplat.eff, or as used by another water splash effect. I find that a good texture is a vertically oriented splash shaped rather like an onion; not too skinny!

Code: [Select]
[ClassInfo]
  ClassName TParticlesSystemParams
[General]
  MatName ../Materials/WaterCrash.mat  // <----make this the same as for an existing splash effect for testing
  Color0 0.9 0.9 0.9 0.6
  Color1 0.7 0.7 0.7 0.0
  nParticles 40
  FinishTime -1
  MaxR 0
  PhiN 0
  PsiN 0
  LiveTime 5
  EmitFrq 8
  EmitVelocity 10 40
  EmitTheta 0 180
  GasResist 0.2
  VertAccel -10
  Wind 0
  Size 7 80
  Rnd 0.2


For quick reference, Here are the map CAMOUFLAGE names and equivalent numerical value:
Code: [Select]
// CAMOUFLAGE_SUMMER = 0;
  CAMOUFLAGE_WINTER = 1;
  CAMOUFLAGE_DESERT = 2;
  CAMOUFLAGE_PACIFIC = 3;
  CAMOUFLAGE_ETO = 4;
  CAMOUFLAGE_MTO = 5;
  CAMOUFLAGE_CBI = 6;
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)

Draken

  • member
  • Offline Offline
  • Posts: 1124
Re: Creating a new effect for splash when crashing on water
« Reply #3 on: May 06, 2024, 08:25:36 AM »

Nice addition !
Thanks !
Logged

RABIZO

  • member
  • Offline Offline
  • Posts: 512
Re: Creating a new effect for splash when crashing on water
« Reply #4 on: May 06, 2024, 08:49:56 AM »

I'm looking forward to new effects.
Logged
Pages: [1]   Go Up
 

Page created in 0.032 seconds with 20 queries.