It is not exactly a WrpTool topic, but face to the
tide nightmare (eg to fit harbour) I would like to change level from 5m to 2m or even no tide (for island with only rivers and rice paddy fields).
It is possible ?
Thank you for your answer.
MAB
Tide setting
Moderators: Lone Wolf, Snake Man
Tide setting
Last edited by MAB on 1970-01-01 00:00:00, edited 1 time in total.
Re: Tide setting
From memory of discussions I've seen on the subject it is impossible to change the tides.
Re: Tide setting
That's the function OFP uses to calculate the tides, while maxTide seams to be fixed, you can adjust the Latitude via world config.
[tt]
const float maxTide=5;
Vector3 sunDir = sun->SunDirection();
Vector3 moonDir = sun->MoonDirection();
Vector3 sunTide = sunDir[1]*sunDir;
Vector3 moonTide = moonDir[1]*moonDir;
float tide01 = (sunTide.Y()+moonTide.Y())*0.5;
float tideAbs =maxTide*tide01;
Note: we are aware the tide formula contains a bug. Correct should be:
float tide=(fabs(sunTide.Y())+fabs(moonTide.Y())*0.5;
We did not fix this bug as it would make many older mission unplayable.
Sun & moon position formula:
Code Sample
float latitudeCoord = world ? world->GetLatitude() : -40*H_PI/180;
Matrix3 moonOrbitAngle(MRotationZ,5*H_PI/180);
Matrix3 earthAxis=Matrix3(MRotationX,23*H_PI/180);
Matrix3 latitude(MRotationX,latitudeCoord); // -40 - Croatia, -90 - north pole
const float initMoonOnOrbitPos=0.5;
const float day=1.0/365;
const float lunarMonth=28*day;
float timeInYear = Glob.clock.GetTimeInYear();
float timeOfDay = Glob.clock.GetTimeOfDay();
float moonOnOrbitPos=initMoonOnOrbitPos+timeInYear*(1.0/lunarMonth);
Matrix3 moonOnOrbit=moonOrbitAngle*Matrix3(MRotationY,moonOnOrbitPos*(H_PI*2));
Matrix3 earthOnOrbit=Matrix3(MRotationY,timeInYear*(H_PI*2));
// note - midnight is on the point furthest from the sun
Matrix3 midnightToCurrent=Matrix3(MRotationY,timeOfDay*(H_PI*2));
// calculate sun and moon position relative to current postion
Matrix3 cameraToCosmos=earthAxis*midnightToCurrent*earthOnOrbit*latitude;
Matrix3 cosmosToCamera=cameraToCosmos.InverseRotation();
// use rotation of PI/2 to achieve this
Matrix3 normalDirection(MRotationX,-H_PI/2);
Matrix3 convert=normalDirection*cosmosToCamera;
_direction=convert*earthOnOrbit.Direction();
_moonDirection=convert*moonOnOrbit.Direction();
// reverse N-S, W-W
_direction
=-_direction
;
_direction[2]=-_direction[2];
_moonDirection
=-_moonDirection
;
_moonDirection[2]=-_moonDirection[2];
_direction.Normalize();
_sunDirection=_direction;
[/tt]
[tt]
const float maxTide=5;
Vector3 sunDir = sun->SunDirection();
Vector3 moonDir = sun->MoonDirection();
Vector3 sunTide = sunDir[1]*sunDir;
Vector3 moonTide = moonDir[1]*moonDir;
float tide01 = (sunTide.Y()+moonTide.Y())*0.5;
float tideAbs =maxTide*tide01;
Note: we are aware the tide formula contains a bug. Correct should be:
float tide=(fabs(sunTide.Y())+fabs(moonTide.Y())*0.5;
We did not fix this bug as it would make many older mission unplayable.
Sun & moon position formula:
Code Sample
float latitudeCoord = world ? world->GetLatitude() : -40*H_PI/180;
Matrix3 moonOrbitAngle(MRotationZ,5*H_PI/180);
Matrix3 earthAxis=Matrix3(MRotationX,23*H_PI/180);
Matrix3 latitude(MRotationX,latitudeCoord); // -40 - Croatia, -90 - north pole
const float initMoonOnOrbitPos=0.5;
const float day=1.0/365;
const float lunarMonth=28*day;
float timeInYear = Glob.clock.GetTimeInYear();
float timeOfDay = Glob.clock.GetTimeOfDay();
float moonOnOrbitPos=initMoonOnOrbitPos+timeInYear*(1.0/lunarMonth);
Matrix3 moonOnOrbit=moonOrbitAngle*Matrix3(MRotationY,moonOnOrbitPos*(H_PI*2));
Matrix3 earthOnOrbit=Matrix3(MRotationY,timeInYear*(H_PI*2));
// note - midnight is on the point furthest from the sun
Matrix3 midnightToCurrent=Matrix3(MRotationY,timeOfDay*(H_PI*2));
// calculate sun and moon position relative to current postion
Matrix3 cameraToCosmos=earthAxis*midnightToCurrent*earthOnOrbit*latitude;
Matrix3 cosmosToCamera=cameraToCosmos.InverseRotation();
// use rotation of PI/2 to achieve this
Matrix3 normalDirection(MRotationX,-H_PI/2);
Matrix3 convert=normalDirection*cosmosToCamera;
_direction=convert*earthOnOrbit.Direction();
_moonDirection=convert*moonOnOrbit.Direction();
// reverse N-S, W-W
_direction
=-_direction
;
_direction[2]=-_direction[2];
_moonDirection
=-_moonDirection
;
_moonDirection[2]=-_moonDirection[2];
_direction.Normalize();
_sunDirection=_direction;
[/tt]
- shinRaiden
- Captain
- Posts: 176
- Joined: 2004-02-27 18:29:53
- Contact:
Re: Tide setting
And where does that code come from? I can't find it anywhere in the commented configs of 1.91.
Re: Tide setting
Thats actually OFP Source Code ..... provided by BIS
There is a Thread in the BI Forum that has this/discusses this.
There is a Thread in the BI Forum that has this/discusses this.
- shinRaiden
- Captain
- Posts: 176
- Joined: 2004-02-27 18:29:53
- Contact:
Re: Tide setting
Argh Reel code! My eyes, the innocence is gone!
Ooo, lookie, "we fubar'd this but it's too late now" comments too.
Ooo, lookie, "we fubar'd this but it's too late now" comments too.
Who is online
Users browsing this forum: Google [Bot] and 8 guests