190811 c2
- Optimized code layout of changes of last merge request
This commit is contained in:
@@ -3,45 +3,42 @@ Imports Assimp
|
||||
Imports Assimp.Unmanaged
|
||||
|
||||
Namespace AssimpModule
|
||||
Structure ConversionContext
|
||||
|
||||
Friend Class ConversionContext
|
||||
|
||||
Public Property DaeMdl As Scene
|
||||
Public Property UpAxis As UpAxis
|
||||
Public Property NewMesh As New Mesh
|
||||
Public Property NewObj As New Object3D
|
||||
Public Property ChannelIndicies As New Dictionary(Of Material, Integer)
|
||||
|
||||
Public Sub New(daeMdlP As Scene, upAxis As UpAxis)
|
||||
daeMdl = daeMdlP
|
||||
upAxis = upAxis
|
||||
newMesh = New Mesh
|
||||
newObj = New Object3D
|
||||
DaeMdl = daeMdlP
|
||||
Me.UpAxis = upAxis
|
||||
|
||||
newObj.Meshes.Add(newMesh)
|
||||
|
||||
channelIndicies = New Dictionary(Of Material, Integer)
|
||||
NewObj.Meshes.Add(NewMesh)
|
||||
End Sub
|
||||
|
||||
Dim daeMdl As Scene
|
||||
Dim UpAxis As UpAxis
|
||||
Dim newMesh As Mesh
|
||||
Dim newObj As Object3D
|
||||
Dim channelIndicies As Dictionary(Of Material, Integer)
|
||||
End Structure
|
||||
End Class
|
||||
|
||||
Friend Class ParsingContext
|
||||
|
||||
Public ReadOnly Property ConversionContext As ConversionContext
|
||||
Public Property DicVertices As New Dictionary(Of Vector3D, Vertex)
|
||||
Public Property DicNormals As New Dictionary(Of Vector3D, Normal)
|
||||
Public Property DicUVs As New Dictionary(Of Vector3D, UV)
|
||||
Public Property DicVertexColors As New Dictionary(Of Color4D, VertexColor)
|
||||
|
||||
Structure ParsingContext
|
||||
Public Sub New(ctx As ConversionContext)
|
||||
cc = ctx
|
||||
dicVertices = New Dictionary(Of Vector3D, Vertex)
|
||||
dicNormals = New Dictionary(Of Vector3D, Normal)
|
||||
dicUVs = New Dictionary(Of Vector3D, UV)
|
||||
dicVertexColors = New Dictionary(Of Color4D, VertexColor)
|
||||
ConversionContext = ctx
|
||||
End Sub
|
||||
|
||||
ReadOnly cc As ConversionContext
|
||||
Dim dicVertices As Dictionary(Of Vector3D, Vertex)
|
||||
Dim dicNormals As Dictionary(Of Vector3D, Normal)
|
||||
Dim dicUVs As Dictionary(Of Vector3D, UV)
|
||||
Dim dicVertexColors As Dictionary(Of Color4D, VertexColor)
|
||||
End Structure
|
||||
End Class
|
||||
|
||||
Public Class AssimpLoader
|
||||
|
||||
Public Shared PathToAssimpLib32 As String = "Assimp32.dll"
|
||||
Public Shared PathToAssimpLib64 As String = "Assimp64.dll"
|
||||
Public Shared Property PathToAssimpLib32 As String = "Assimp32.dll"
|
||||
Public Shared Property PathToAssimpLib64 As String = "Assimp64.dll"
|
||||
|
||||
Friend Shared Sub LoadAssimpLibs()
|
||||
If Not AssimpLibrary.Instance.IsLibraryLoaded Then
|
||||
@@ -51,19 +48,19 @@ Namespace AssimpModule
|
||||
|
||||
Private Shared Sub ComputeNewObj(cc As ConversionContext)
|
||||
Dim identity As Matrix4x4 = Matrix4x4.Identity
|
||||
ComputeNode(cc.daeMdl.RootNode, identity, New ParsingContext(cc))
|
||||
ComputeNode(cc.DaeMdl.RootNode, identity, New ParsingContext(cc))
|
||||
End Sub
|
||||
|
||||
Private Shared Sub ComputeNode(node As Node, trafo As Matrix4x4, ByRef pc As ParsingContext)
|
||||
Dim newObj = pc.cc.newObj
|
||||
Dim newMesh = pc.cc.newMesh
|
||||
Dim daeMdl = pc.cc.daeMdl
|
||||
Dim channelIndicies = pc.cc.channelIndicies
|
||||
Dim UpAxis = pc.cc.UpAxis
|
||||
Dim dicVertices = pc.dicVertices
|
||||
Dim dicNormals = pc.dicNormals
|
||||
Dim dicUVs = pc.dicUVs
|
||||
Dim dicVertexColors = pc.dicVertexColors
|
||||
Private Shared Sub ComputeNode(node As Node, trafo As Matrix4x4, pc As ParsingContext)
|
||||
Dim newObj = pc.ConversionContext.NewObj
|
||||
Dim newMesh = pc.ConversionContext.NewMesh
|
||||
Dim daeMdl = pc.ConversionContext.DaeMdl
|
||||
Dim channelIndicies = pc.ConversionContext.ChannelIndicies
|
||||
Dim UpAxis = pc.ConversionContext.UpAxis
|
||||
Dim dicVertices = pc.DicVertices
|
||||
Dim dicNormals = pc.DicNormals
|
||||
Dim dicUVs = pc.DicUVs
|
||||
Dim dicVertexColors = pc.DicVertexColors
|
||||
|
||||
trafo = trafo * node.Transform
|
||||
|
||||
|
||||
Reference in New Issue
Block a user