Merge branch 'master' of https://github.com/P3D-Legacy/P3D-Legacy
This commit is contained in:
commit
e4db4b6751
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 167 B |
Binary file not shown.
After Width: | Height: | Size: 697 B |
Binary file not shown.
After Width: | Height: | Size: 160 B |
|
@ -14095,6 +14095,15 @@
|
||||||
<Content Include="Content\SkyDomeResource\Clouds_Weather.png">
|
<Content Include="Content\SkyDomeResource\Clouds_Weather.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="Content\SkyDomeResource\FogColors.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="Content\SkyDomeResource\Inside.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="Content\SkyDomeResource\LightingColors.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="Content\SkyDomeResource\Sky_Day.png">
|
<Content Include="Content\SkyDomeResource\Sky_Day.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
|
@ -15,10 +15,7 @@
|
||||||
Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0), Core.GraphicsDevice.Viewport.AspectRatio, 0.01, 16)
|
Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0), Core.GraphicsDevice.Viewport.AspectRatio, 0.01, 16)
|
||||||
FOV = 45
|
FOV = 45
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CreateProjectionMatrix()
|
CreateProjectionMatrix()
|
||||||
Update()
|
|
||||||
Me._canToggleThirdPerson = False
|
Me._canToggleThirdPerson = False
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
|
@ -3,28 +3,84 @@
|
||||||
''' </summary>
|
''' </summary>
|
||||||
Public Class Lighting
|
Public Class Lighting
|
||||||
|
|
||||||
#Region "Enums"
|
Shared LightingColorTexture As Texture2D = TextureManager.GetTexture("SkyDomeResource\LightingColors")
|
||||||
|
Shared FogColorTexture As Texture2D = TextureManager.GetTexture("SkyDomeResource\FogColors")
|
||||||
#End Region
|
|
||||||
|
|
||||||
#Region "Fields and Constants"
|
|
||||||
|
|
||||||
#End Region
|
|
||||||
|
|
||||||
#Region "Properties"
|
|
||||||
|
|
||||||
#End Region
|
|
||||||
|
|
||||||
#Region "Delegates"
|
|
||||||
|
|
||||||
#End Region
|
|
||||||
|
|
||||||
#Region "Constructors"
|
|
||||||
|
|
||||||
#End Region
|
|
||||||
|
|
||||||
#Region "Methods"
|
#Region "Methods"
|
||||||
|
Public Shared Function GetEnvironmentColor(TextureType As Integer) As Vector3 '0 = Directional light, 1 = Ambient light, 2 = Fog color
|
||||||
|
Dim ColorTexture As Texture2D
|
||||||
|
Dim EnvironmentColor As Vector3 = Nothing
|
||||||
|
|
||||||
|
Dim x As Integer = 0
|
||||||
|
Dim y As Integer = 0
|
||||||
|
|
||||||
|
Select Case TextureType
|
||||||
|
Case 0
|
||||||
|
x = Screen.Level.DayTime - 1
|
||||||
|
If x >= 0 AndAlso x <= 3 Then
|
||||||
|
ColorTexture = LightingColorTexture
|
||||||
|
Dim ColorData(0) As Color
|
||||||
|
ColorTexture.GetData(0, New Rectangle(x, 0, 1, 1), ColorData, 0, 1)
|
||||||
|
|
||||||
|
Dim DarkOrBrightData(0) As Color
|
||||||
|
ColorTexture.GetData(0, New Rectangle(x, 1, 1, 1), DarkOrBrightData, 0, 1)
|
||||||
|
EnvironmentColor = ColorData(0).ToVector3
|
||||||
|
If DarkOrBrightData(0) = Color.Black Then
|
||||||
|
EnvironmentColor = New Vector3(0.0F) - EnvironmentColor
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
EnvironmentColor = New Vector3(0.0F)
|
||||||
|
End If
|
||||||
|
Case 1
|
||||||
|
x = Screen.Level.DayTime - 1
|
||||||
|
If x >= 0 AndAlso x <= 3 Then
|
||||||
|
ColorTexture = LightingColorTexture
|
||||||
|
|
||||||
|
Dim ColorData(0) As Color
|
||||||
|
ColorTexture.GetData(0, New Rectangle(x, 2, 1, 1), ColorData, 0, 1)
|
||||||
|
|
||||||
|
Dim DarkOrBrightData(0) As Color
|
||||||
|
ColorTexture.GetData(0, New Rectangle(x, 3, 1, 1), DarkOrBrightData, 0, 1)
|
||||||
|
|
||||||
|
EnvironmentColor = ColorData(0).ToVector3
|
||||||
|
If DarkOrBrightData(0) = Color.Black Then
|
||||||
|
EnvironmentColor = New Vector3(0.0F) - EnvironmentColor
|
||||||
|
End If
|
||||||
|
|
||||||
|
Else
|
||||||
|
EnvironmentColor = New Vector3(0.0F)
|
||||||
|
End If
|
||||||
|
Case 2
|
||||||
|
ColorTexture = FogColorTexture
|
||||||
|
Select Case Screen.Level.EnvironmentType
|
||||||
|
Case 0
|
||||||
|
x = GetLightingType()
|
||||||
|
If x > 2 Then
|
||||||
|
x = 0
|
||||||
|
y += 1
|
||||||
|
End If
|
||||||
|
Case 1
|
||||||
|
x = 1
|
||||||
|
y = 1
|
||||||
|
Case 2
|
||||||
|
x = 2
|
||||||
|
y = 1
|
||||||
|
Case 3
|
||||||
|
x = 0
|
||||||
|
y = 2
|
||||||
|
Case 4
|
||||||
|
x = 1
|
||||||
|
y = 2
|
||||||
|
Case 5
|
||||||
|
x = 2
|
||||||
|
y = 2
|
||||||
|
End Select
|
||||||
|
Dim ColorData(0) As Color
|
||||||
|
ColorTexture.GetData(0, New Rectangle(x, y, 1, 1), ColorData, 0, 1)
|
||||||
|
EnvironmentColor = ColorData(0).ToVector3
|
||||||
|
End Select
|
||||||
|
Return EnvironmentColor
|
||||||
|
End Function
|
||||||
''' <summary>
|
''' <summary>
|
||||||
''' Updates the lighting values of a BasicEffect instance.
|
''' Updates the lighting values of a BasicEffect instance.
|
||||||
''' </summary>
|
''' </summary>
|
||||||
|
@ -38,39 +94,39 @@ Public Class Lighting
|
||||||
refEffect.SpecularPower = 2000.0F
|
refEffect.SpecularPower = 2000.0F
|
||||||
|
|
||||||
' LightType results:
|
' LightType results:
|
||||||
' 0 = Night
|
' 0 = Day
|
||||||
' 1 = Morning
|
' 1 = Night
|
||||||
' 2 = Day
|
' 2 = Morning
|
||||||
' 3 = Evening
|
' 3 = Evening
|
||||||
' Anything higher than 3 = No Lighting
|
' Anything higher than 3 = No Lighting
|
||||||
|
|
||||||
Select Case GetLightingType()
|
Select Case GetLightingType()
|
||||||
Case 0 ' Night
|
Case 0 ' Day
|
||||||
refEffect.AmbientLightColor = New Vector3(0.8F)
|
refEffect.AmbientLightColor = GetEnvironmentColor(1)
|
||||||
|
|
||||||
refEffect.DirectionalLight0.DiffuseColor = New Vector3(-0.2F)
|
refEffect.DirectionalLight0.DiffuseColor = GetEnvironmentColor(0)
|
||||||
refEffect.DirectionalLight0.Direction = Vector3.Normalize(New Vector3(-1.0F, 0.0F, 1.0F))
|
refEffect.DirectionalLight0.Direction = Vector3.Normalize(New Vector3(-1.0F, 0.0F, 1.0F))
|
||||||
refEffect.DirectionalLight0.SpecularColor = New Vector3(0.0F)
|
refEffect.DirectionalLight0.SpecularColor = New Vector3(0.0F)
|
||||||
refEffect.DirectionalLight0.Enabled = True
|
refEffect.DirectionalLight0.Enabled = True
|
||||||
Case 1 ' Morning
|
Case 1 ' Night
|
||||||
refEffect.AmbientLightColor = New Vector3(0.8F)
|
refEffect.AmbientLightColor = GetEnvironmentColor(1)
|
||||||
|
|
||||||
refEffect.DirectionalLight0.DiffuseColor = New Vector3(-0.45F)
|
refEffect.DirectionalLight0.DiffuseColor = GetEnvironmentColor(0)
|
||||||
refEffect.DirectionalLight0.Direction = Vector3.Normalize(New Vector3(1.0F, -1.0F, -1.0F))
|
refEffect.DirectionalLight0.Direction = Vector3.Normalize(New Vector3(1.0F, 1.0F, -1.0F))
|
||||||
refEffect.DirectionalLight0.SpecularColor = New Vector3(0.0F)
|
refEffect.DirectionalLight0.SpecularColor = New Vector3(0.0F)
|
||||||
refEffect.DirectionalLight0.Enabled = True
|
refEffect.DirectionalLight0.Enabled = True
|
||||||
Case 2 ' Day
|
Case 2 ' Morning
|
||||||
refEffect.AmbientLightColor = New Vector3(1.0F)
|
refEffect.AmbientLightColor = GetEnvironmentColor(1)
|
||||||
|
|
||||||
refEffect.DirectionalLight0.DiffuseColor = New Vector3(-0.3F)
|
refEffect.DirectionalLight0.DiffuseColor = GetEnvironmentColor(0)
|
||||||
refEffect.DirectionalLight0.Direction = Vector3.Normalize(New Vector3(1.0F, 1.0F, 1.0F))
|
refEffect.DirectionalLight0.Direction = Vector3.Normalize(New Vector3(-1.0F, 0.0F, 1.0F))
|
||||||
refEffect.DirectionalLight0.SpecularColor = New Vector3(0.0F)
|
refEffect.DirectionalLight0.SpecularColor = New Vector3(0.0F)
|
||||||
refEffect.DirectionalLight0.Enabled = True
|
refEffect.DirectionalLight0.Enabled = True
|
||||||
Case 3 ' Evening
|
Case 3 ' Evening
|
||||||
refEffect.AmbientLightColor = New Vector3(0.8F)
|
refEffect.AmbientLightColor = GetEnvironmentColor(1)
|
||||||
|
|
||||||
refEffect.DirectionalLight0.DiffuseColor = New Vector3(-0.45F)
|
refEffect.DirectionalLight0.DiffuseColor = GetEnvironmentColor(0)
|
||||||
refEffect.DirectionalLight0.Direction = Vector3.Normalize(New Vector3(-1.0F, 0.0F, 1.0F))
|
refEffect.DirectionalLight0.Direction = Vector3.Normalize(New Vector3(1.0F, 1.0F, -1.0F))
|
||||||
refEffect.DirectionalLight0.SpecularColor = New Vector3(0.0F)
|
refEffect.DirectionalLight0.SpecularColor = New Vector3(0.0F)
|
||||||
refEffect.DirectionalLight0.Enabled = True
|
refEffect.DirectionalLight0.Enabled = True
|
||||||
Case Else 'Disable lighting on the effect
|
Case Else 'Disable lighting on the effect
|
||||||
|
@ -88,9 +144,9 @@ Public Class Lighting
|
||||||
' Level's lighttype values:
|
' Level's lighttype values:
|
||||||
' 0 = Get lighting from the current time of day.
|
' 0 = Get lighting from the current time of day.
|
||||||
' 1 = Disable lighting
|
' 1 = Disable lighting
|
||||||
' 2 = Always Night
|
' 2 = Always Day
|
||||||
' 3 = Always Morning
|
' 3 = Always Night
|
||||||
' 4 = Always Day
|
' 4 = Always Morning
|
||||||
' 5 = Always Evening
|
' 5 = Always Evening
|
||||||
|
|
||||||
If Screen.Level.LightingType = 1 Then ' If the level lighting type is 1, disable lighting (set index to 99).
|
If Screen.Level.LightingType = 1 Then ' If the level lighting type is 1, disable lighting (set index to 99).
|
||||||
|
@ -99,11 +155,11 @@ Public Class Lighting
|
||||||
If Screen.Level.EnvironmentType = World.EnvironmentTypes.Outside Then
|
If Screen.Level.EnvironmentType = World.EnvironmentTypes.Outside Then
|
||||||
Select Case Screen.Level.DayTime
|
Select Case Screen.Level.DayTime
|
||||||
Case 1
|
Case 1
|
||||||
LightType = 2
|
|
||||||
Case 2
|
|
||||||
LightType = 0
|
LightType = 0
|
||||||
Case 3
|
Case 2
|
||||||
LightType = 1
|
LightType = 1
|
||||||
|
Case 3
|
||||||
|
LightType = 2
|
||||||
Case 4
|
Case 4
|
||||||
LightType = 3
|
LightType = 3
|
||||||
End Select
|
End Select
|
||||||
|
@ -111,23 +167,9 @@ Public Class Lighting
|
||||||
If Screen.Level.LightingType > 1 And Screen.Level.LightingType < 6 Then ' If the level's lighting type is 2, 3, 4 or 5, set to the respective LightType (set time of day).
|
If Screen.Level.LightingType > 1 And Screen.Level.LightingType < 6 Then ' If the level's lighting type is 2, 3, 4 or 5, set to the respective LightType (set time of day).
|
||||||
LightType = Screen.Level.LightingType - 2
|
LightType = Screen.Level.LightingType - 2
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Return LightType
|
Return LightType
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Shared Function GetLightingColor(ByVal LightType As Integer) As Vector3
|
|
||||||
Select Case LightType
|
|
||||||
Case 0
|
|
||||||
Return New Vector3(0.4F, 0.4F, 0.6F)
|
|
||||||
Case 1
|
|
||||||
Return Color.Orange.ToVector3()
|
|
||||||
Case 2
|
|
||||||
Return New Vector3(-0.3F)
|
|
||||||
Case 3
|
|
||||||
Return New Vector3(-0.45F)
|
|
||||||
End Select
|
|
||||||
End Function
|
|
||||||
|
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
End Class
|
End Class
|
|
@ -40,9 +40,9 @@ Public Class World
|
||||||
End Enum
|
End Enum
|
||||||
|
|
||||||
Public Enum DayTimes As Integer
|
Public Enum DayTimes As Integer
|
||||||
Night = 0
|
Day = 0
|
||||||
Morning = 1
|
Night = 1
|
||||||
Day = 2
|
Morning = 2
|
||||||
Evening = 3
|
Evening = 3
|
||||||
End Enum
|
End Enum
|
||||||
|
|
||||||
|
@ -594,50 +594,35 @@ endsub:
|
||||||
Private Sub ChangeEnvironment()
|
Private Sub ChangeEnvironment()
|
||||||
Select Case Me.EnvironmentType
|
Select Case Me.EnvironmentType
|
||||||
Case EnvironmentTypes.Outside
|
Case EnvironmentTypes.Outside
|
||||||
Dim _fogColor As Color
|
Dim multiplier As Vector3 = New Vector3(1.0F)
|
||||||
Dim v As Single = 1.0F
|
|
||||||
Dim nightFog As Integer = 64
|
|
||||||
Dim dayFog As Integer = 168
|
|
||||||
Select Case CurrentMapWeather
|
Select Case CurrentMapWeather
|
||||||
Case World.Weathers.Clear, Weathers.Sunny
|
Case World.Weathers.Clear, Weathers.Sunny
|
||||||
v = 1.0F
|
multiplier = New Vector3(1.0F)
|
||||||
Case World.Weathers.Rain, Weathers.Thunderstorm, World.Weathers.Fog
|
Case World.Weathers.Rain, Weathers.Thunderstorm, World.Weathers.Fog
|
||||||
v = 0.7F
|
multiplier = New Vector3(0.7F)
|
||||||
Case World.Weathers.Snow
|
Case World.Weathers.Snow
|
||||||
v = 0.8F
|
multiplier = New Vector3(0.8F)
|
||||||
End Select
|
End Select
|
||||||
Select Case Screen.Level.DayTime
|
Screen.Effect.FogColor = Lighting.GetEnvironmentColor(2) * multiplier
|
||||||
Case 1, 3
|
|
||||||
_fogColor = New Color(CInt(v * dayFog), CInt(v * dayFog), CInt(v * dayFog))
|
|
||||||
Case 2, 4
|
|
||||||
_fogColor = New Color(CInt(v * nightFog), CInt(v * nightFog), CInt(v * nightFog))
|
|
||||||
End Select
|
|
||||||
Core.BackgroundColor = GetWeatherBackgroundColor(SkyDome.GetDaytimeColor(False))
|
|
||||||
Screen.Effect.FogColor = _fogColor.ToVector3()
|
|
||||||
Screen.SkyDome.TextureDown = TextureManager.GetTexture("SkyDomeResource\Stars")
|
Screen.SkyDome.TextureDown = TextureManager.GetTexture("SkyDomeResource\Stars")
|
||||||
Case EnvironmentTypes.Inside
|
Case EnvironmentTypes.Inside
|
||||||
Core.BackgroundColor = New Color(57, 57, 57)
|
Screen.Effect.FogColor = Lighting.GetEnvironmentColor(2)
|
||||||
Screen.Effect.FogColor = Core.BackgroundColor.ToVector3()
|
Screen.SkyDome.TextureUp = TextureManager.GetTexture("SkyDomeResource\Inside")
|
||||||
Screen.SkyDome.TextureUp = Nothing
|
|
||||||
Screen.SkyDome.TextureDown = Nothing
|
Screen.SkyDome.TextureDown = Nothing
|
||||||
Case EnvironmentTypes.Dark
|
Case EnvironmentTypes.Dark
|
||||||
Core.BackgroundColor = GetWeatherBackgroundColor(New Color(29, 29, 50))
|
Screen.Effect.FogColor = Lighting.GetEnvironmentColor(2)
|
||||||
Screen.Effect.FogColor = Core.BackgroundColor.ToVector3()
|
|
||||||
Screen.SkyDome.TextureUp = TextureManager.GetTexture("SkyDomeResource\Dark")
|
Screen.SkyDome.TextureUp = TextureManager.GetTexture("SkyDomeResource\Dark")
|
||||||
Screen.SkyDome.TextureDown = Nothing
|
Screen.SkyDome.TextureDown = Nothing
|
||||||
Case EnvironmentTypes.Cave
|
Case EnvironmentTypes.Cave
|
||||||
Core.BackgroundColor = GetWeatherBackgroundColor(New Color(72, 64, 64))
|
Screen.Effect.FogColor = Lighting.GetEnvironmentColor(2)
|
||||||
Screen.Effect.FogColor = Core.BackgroundColor.ToVector3()
|
|
||||||
Screen.SkyDome.TextureUp = TextureManager.GetTexture("SkyDomeResource\Cave")
|
Screen.SkyDome.TextureUp = TextureManager.GetTexture("SkyDomeResource\Cave")
|
||||||
Screen.SkyDome.TextureDown = Nothing
|
Screen.SkyDome.TextureDown = Nothing
|
||||||
Case EnvironmentTypes.Underwater
|
Case EnvironmentTypes.Underwater
|
||||||
Core.BackgroundColor = GetWeatherBackgroundColor(New Color(40, 88, 128))
|
Screen.Effect.FogColor = Lighting.GetEnvironmentColor(2)
|
||||||
Screen.Effect.FogColor = Core.BackgroundColor.ToVector3()
|
|
||||||
Screen.SkyDome.TextureUp = TextureManager.GetTexture("SkyDomeResource\Underwater")
|
Screen.SkyDome.TextureUp = TextureManager.GetTexture("SkyDomeResource\Underwater")
|
||||||
Screen.SkyDome.TextureDown = Nothing
|
Screen.SkyDome.TextureDown = Nothing
|
||||||
Case EnvironmentTypes.Forest
|
Case EnvironmentTypes.Forest
|
||||||
Core.BackgroundColor = GetWeatherBackgroundColor(New Color(48, 80, 48))
|
Screen.Effect.FogColor = Lighting.GetEnvironmentColor(2)
|
||||||
Screen.Effect.FogColor = Core.BackgroundColor.ToVector3()
|
|
||||||
Screen.SkyDome.TextureUp = TextureManager.GetTexture("SkyDomeResource\Forest")
|
Screen.SkyDome.TextureUp = TextureManager.GetTexture("SkyDomeResource\Forest")
|
||||||
Screen.SkyDome.TextureDown = Nothing
|
Screen.SkyDome.TextureDown = Nothing
|
||||||
End Select
|
End Select
|
||||||
|
|
Loading…
Reference in New Issue