Tide setting

WrpTool island creator utility

Moderators: Lone Wolf, Snake Man

Post Reply
MAB
Newbie
Posts: 1
Joined: 2004-04-30 03:05:30

Tide setting

Post by MAB » 2004-04-29 23:10:23

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
Last edited by MAB on 1970-01-01 00:00:00, edited 1 time in total.

User avatar
Gnat
1st Lt
Posts: 120
Joined: 2004-01-07 08:46:56

Re: Tide setting

Post by Gnat » 2004-04-30 01:45:50

From memory of discussions I've seen on the subject it is impossible to change the tides.

Dschulle
Captain
Posts: 162
Joined: 2003-05-18 02:00:14
Contact:

Re: Tide setting

Post by Dschulle » 2004-04-30 17:24:20

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]

User avatar
shinRaiden
Captain
Posts: 176
Joined: 2004-02-27 18:29:53
Contact:

Re: Tide setting

Post by shinRaiden » 2004-04-30 22:14:09

And where does that code come from? I can't find it anywhere in the commented configs of 1.91.

User avatar
Gnat
1st Lt
Posts: 120
Joined: 2004-01-07 08:46:56

Re: Tide setting

Post by Gnat » 2004-05-01 01:28:22

Thats actually OFP Source Code ..... provided by BIS

There is a Thread in the BI Forum that has this/discusses this.

User avatar
shinRaiden
Captain
Posts: 176
Joined: 2004-02-27 18:29:53
Contact:

Re: Tide setting

Post by shinRaiden » 2004-05-02 04:11:31

Argh :o Reel code! :o My eyes, the innocence is gone! :-[

Ooo, lookie, "we fubar'd this but it's too late now" comments too. :P

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 8 guests