replace sun module

This commit is contained in:
UbitUmarov
2020-06-11 00:01:43 +01:00
parent 9ce70be5ce
commit 13ed40d9f6
10 changed files with 159 additions and 689 deletions

View File

@@ -1295,8 +1295,9 @@ namespace OpenSim.Framework
/// <param name="SecondsPerSunCycle"></param>
/// <param name="SecondsPerYear"></param>
/// <param name="OrbitalPosition">The orbital position is given in radians, and must be "adjusted" for the linden client, see LLClientView</param>
void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear,
float OrbitalPosition);
//void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear,
// float OrbitalPosition);
void SendSunPos(Vector3 sunPos, Vector3 sunVel, float sunAngle);
void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks);
void SendViewerTime(int phase);

View File

@@ -1058,7 +1058,14 @@ namespace OpenSim.Framework
public static int UnixTimeSinceEpoch()
{
return ToUnixTime(DateTime.UtcNow);
TimeSpan t = DateTime.UtcNow - UnixEpoch;
return (int)t.TotalSeconds;
}
public static ulong UnixTimeSinceEpoch_uS()
{
TimeSpan t = DateTime.UtcNow - UnixEpoch;
return (uint)(t.TotalMilliseconds * 1000);
}
public static int ToUnixTime(DateTime stamp)

View File

@@ -1229,5 +1229,61 @@ namespace OpenSim.Framework
top["success"] = true;
return top;
}
public bool getPositions(float altitude, float dayfrac, out Vector3 sundir, out Vector3 moondir, out Vector3 sunvel,
out Quaternion sunrot, out Quaternion moonrot)
{
sundir = Vector3.Zero;
moondir = Vector3.Zero;
sunvel = Vector3.Zero;
sunrot = Quaternion.Identity;
moonrot = Quaternion.Identity;
List<DayCycle.TrackEntry> track = null;
if(altitude < Altitudes[0])
track = Cycle.skyTrack0;
else
{
int altindx = 2;
for(;altindx > 0; --altindx)
{
if(Altitudes[altindx] < altitude)
break;
}
while(altindx >= 0)
{
switch(altindx)
{
case 2:
track = Cycle.skyTrack3;
break;
case 1:
track = Cycle.skyTrack2;
break;
case 0:
track = Cycle.skyTrack1;
break;
}
if(track != null)
break;
--altindx;
}
}
if(track == null || track.Count == 0)
return false;
if(track.Count == 1)
{
if(!Cycle.skyframes.TryGetValue(track[0].frameName, out SkyData sky) || sky == null)
return false;
moonrot = sky.moon_rotation;
moondir = Xrot(moonrot);
sunrot = sky.sun_rotation;
sundir = Xrot(sunrot);
}
return true;
}
}
}