Fixed OpenTK issues when rendering models in StorageSystemScreen

This commit is contained in:
CaptainSegis 2017-07-26 02:07:37 -05:00
parent 82f0ae68cd
commit af3fc02c0a
2 changed files with 6 additions and 3 deletions

View File

@ -47,8 +47,8 @@ Public Class ModelManager
ModelList.Clear() ModelList.Clear()
End Sub End Sub
Public Shared Function DrawModelToTexture(ByVal modelName As String, ByVal texSize As Vector2, ByVal modelPosition As Vector3, ByVal cameraPosition As Vector3, ByVal cameraRotation As Vector3, ByVal Scale As Single, ByVal enableLight As Boolean) As Texture2D Public Shared Function DrawModelToTexture(ByVal modelName As String, ByVal renderTarget As RenderTarget2D, ByVal modelPosition As Vector3, ByVal cameraPosition As Vector3, ByVal cameraRotation As Vector3, ByVal Scale As Single, ByVal enableLight As Boolean) As Texture2D
Dim renderTarget As RenderTarget2D = New RenderTarget2D(Core.GraphicsDevice, CInt(texSize.X), CInt(texSize.Y), False, SurfaceFormat.Color, DepthFormat.Depth24Stencil8)
Core.GraphicsDevice.SetRenderTarget(renderTarget) Core.GraphicsDevice.SetRenderTarget(renderTarget)
Core.GraphicsDevice.Clear(Color.Transparent) Core.GraphicsDevice.Clear(Color.Transparent)

View File

@ -4,6 +4,8 @@ Public Class StorageSystemScreen
Public Shared TileOffset As Integer = 0 Public Shared TileOffset As Integer = 0
Private renderTarget As RenderTarget2D
Public Enum FeatureTypes Public Enum FeatureTypes
Deposit Deposit
Withdraw Withdraw
@ -73,6 +75,7 @@ Public Class StorageSystemScreen
Dim modelPan As Single = 0.0F Dim modelPan As Single = 0.0F
Public Sub New(ByVal currentScreen As Screen) Public Sub New(ByVal currentScreen As Screen)
Me.renderTarget = New RenderTarget2D(Core.GraphicsDevice, 1200, 680, False, SurfaceFormat.Color, DepthFormat.Depth24Stencil8)
Me.PreScreen = currentScreen Me.PreScreen = currentScreen
Me.Identification = Identifications.StorageSystemScreen Me.Identification = Identifications.StorageSystemScreen
Me.MouseVisible = True Me.MouseVisible = True
@ -1370,7 +1373,7 @@ Public Class StorageSystemScreen
Dim roll As Single = propList.Item5 Dim roll As Single = propList.Item5
Dim t As Texture2D = ModelManager.DrawModelToTexture(modelName, New Vector2(1200, 680), New Vector3(x, y, z), New Vector3(0.0F, 50.0F, 10.0F), New Vector3(0.0F, 0.2F, roll + modelRoll), scale, True) Dim t As Texture2D = ModelManager.DrawModelToTexture(modelName, renderTarget, New Vector3(x, y, z), New Vector3(0.0F, 50.0F, 10.0F), New Vector3(0.0F, 0.2F, roll + modelRoll), scale, True)
Core.SpriteBatch.Draw(t, New Rectangle(160, 50, 1200, 680), Color.White) Core.SpriteBatch.Draw(t, New Rectangle(160, 50, 1200, 680), Color.White)
End Sub End Sub