osgearth icon indicating copy to clipboard operation
osgearth copied to clipboard

OsgEarth-Triton: integrating wake effect

Open marcoma9023 opened this issue 2 years ago • 0 comments

from the ticked https://github.com/gwaldron/osgearth/issues/1265 I integrated the code for wake effect for Triton in OSGEarth.

Then, with method:

void Ocean::AddShipWakeGenerator(uintptr_t param_handle)
{
    ShipDatas sd;

    if (param_handle == 0)
    {
        ::Triton::WakeGeneratorParameters params;
        params.bowSprayOffset = 110.0;
        params.bowWaveOffset = 110.0;
        params.beamWidth = 20.0;
        params.sternWaveOffset = 0;
        params.propWashOffset = 50;
        params.sprayEffects = true;
        params.length = 110.0;
        params.propWash = true;
        params.numHullSprays = 0;

        sd._wakeGenerator = new ::Triton::WakeGenerator(HANDLE, params);
    }
    else
    {
        ::Triton::WakeGeneratorParameters* wg_parameters = ((::Triton::WakeGeneratorParameters*)param_handle);
        sd._wakeGenerator = new ::Triton::WakeGenerator(HANDLE, *wg_parameters);
    }

    _wakeGenerators.push_back(sd);
}

and

void Ocean::UpdateShipWakeGenerator(const int i, const osg::Vec3& pos, const osg::Vec3& dir, double vel)
{
    if (i >= _wakeGenerators.size())
        return;
    ShipDatas& wg(_wakeGenerators[i]);
    wg.pos = pos;
    wg.dir = dir;
    wg.vel = vel;
}

::Triton::Vector3 toVector3(const osg::Vec3d in) { return ::Triton::Vector3(in.x(), in.y(), in.z()); }

void Ocean::UpdateShipWakeGenerator(const double simuTime)
{
    for (auto & sd : _wakeGenerators)
    {
        ::Triton::WakeGenerator* wg = static_cast<::Triton::WakeGenerator*>(sd._wakeGenerator);
        if (wg) {
            wg->Update(toVector3(sd.pos), toVector3(sd.dir), sd.vel, simuTime);
        }
    }
}

on the ocean the effect is applied by passing the world position, direction and speed(m/s)...

Unfortunately, however, the effect is not applied to the ocean ....

marcoma9023 avatar Jul 19 '21 09:07 marcoma9023