Jump to content
Sign in to follow this  
Guest

Dear bis...time & tides formula please :)

Recommended Posts

Guest

To the OFP makers,

Can you release the formulas for sunrise/sunset, moonrise/moonset and high/low tides? It would be very useful in both Map and Mission making to have this information readily available, and surely it doesn't compromise your long hard work in making OFP? This is one of the best features of OFP, and it would be nice to be able to exploit it a bit more fully and easier. Already I have seen a very nice map made for one of the larger Mods that at certain times of the year has a main town 1.5m underwater because of surge tides (nice feature though). Please please please? biggrin.gif

Leone

Share this post


Link to post
Share on other sites

Here you are. Enjoy.

Tides formula:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">

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;

<span id='postcolor'>

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:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">

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[0]=-_direction[0];

_direction[2]=-_direction[2];

_moonDirection[0]=-_moonDirection[0];

_moonDirection[2]=-_moonDirection[2];

_direction.Normalize();

_sunDirection=_direction;

<span id='postcolor'>

Share this post


Link to post
Share on other sites

I presume this is for an add-on, because i've seen nothing like this in mission editing tounge.gif

wow.gif PEACE

Share this post


Link to post
Share on other sites

I understand that the default can't be changed so as not to break existing missions, but it might be nice to be able to select the corrected tide formula through a setting in the DESCRIPTION.EXT file or a trigger.

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (GAMEER_77 @ Oct. 09 2002,20:39)</td></tr><tr><td id="QUOTE">I presume this is for an add-on, because i've seen nothing like this in mission editing  tounge.gif

wow.gif PEACE<span id='postcolor'>

That's a piece of something top secret, called OFP source code in C++. biggrin.gif

Share this post


Link to post
Share on other sites

Yeah,

I noticed this too with 1.75 and we have made use of it in a few of the maps we have on our server, and seen it on others. one of the easiest place to see the dramatic effect of tides is the twin little islands to the south of Nogavo. The tides can make them 1 big island joined by a sand bank or two little ones... and yes its stuff like this that makes us all love OFP and those wonderful guys at BIS

Share this post


Link to post
Share on other sites

Hi all

Has anyone produced tide tables for the islands in OFP?

It would be useful particlarly for use with the new LSD and forces doing an sea-bourne invasion.

Regards walker

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (walker @ Oct. 09 2002,16:20)</td></tr><tr><td id="QUOTE">Hi all

Has anyone produced tide tables for the islands in OFP?

It would be useful particlarly for use with the new LSD and forces doing an sea-bourne invasion.

Regards walker<span id='postcolor'>

You'd have to know the location of the islands in order to produce the tide tables.

Share this post


Link to post
Share on other sites
Guest

Thank you Suma....excellent stuff biggrin.gifbiggrin.gifbiggrin.gif As someone else said....this is why we love BIS and OFP. Hopefully some clever boffin will have the calculator soon (I can barely program a VCR).

As to which forum this should be in...I did check posts...and most that were to do with tides/times were in General....so I thought when in Rome.....(it was only my first post). confused.gif

From a very grateful Leone

Share this post


Link to post
Share on other sites

I think this belongs to mission editing.

Share this post


Link to post
Share on other sites

well, now that they've done the patch they've got time for playing moderator and moving threads, lol

smile.gif

anyway, hey BIS guys, you're the best!

Share this post


Link to post
Share on other sites

and if you continue spamming this topic it will be closed smile.gif

Share this post


Link to post
Share on other sites

The above looks useful but.....

Can you set the max tide height for a specific island within its cpp?

Share this post


Link to post
Share on other sites

Are the world coordinates (latitude) stored in the config.cpp?

What's their format?

Found them... post can be deleted.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×