Hi leute ich habe ein kleines problem den ich mache grade meinen eigenen obj loader ich bin
fast fertig mit dem laden der Vectoren aber ich kann sie nicht anzeigen lassen ...
ich habe folgenden Code
sorry wegen der formatierung editor ist grade weg :omg:
ich kann sie nicht mit :
anzeigen lassen was mache ich falsch ( ich habe alles richtig defieniert)#
mfg blacknetworkbit
Edit by ~blaze~:
*vb-Tag eingefügtt, Thema aus Hauptforum verschoben*
fast fertig mit dem laden der Vectoren aber ich kann sie nicht anzeigen lassen ...
ich habe folgenden Code
sorry wegen der formatierung editor ist grade weg :omg:
VB.NET-Quellcode
- Public Class loader_obj
- Public Normal As Vector3()
- Public vertrexe As CustomVertex()
- Public texturevertext As VertexTextureCoordinate()
- Public test() As CustomVertex.PositionColored
- Public f_feld, v_feld, object_name, obj_file, mtl_name As String
- Public f_felder(9999), v_felder(9999) As String
- Public counter_f, counter_v As Integer
- Public Vertice(99999) As Vector3
- Public list_of(99999) As list_of_Vertice
- Public position As Vector3
- Public Function OBJ_Loader(ByVal file As String, ByVal pos As Vector3) As String
- position = pos
- Dim backloop As String = ""
- Try
- Split_to_Variablen(file)
- Dim tr(counter_v) As Vector3
- Vertice = tr
- For i = 1 To counter_v
- Dim ste() As String = v_felder(i).Split(" ")
- If position.Z > 0 Then
- Vertice(i) = New Vector3(Double.Parse(ste(1)), Double.Parse(ste(2)), Double.Parse(ste(3)) + position.Z)
- End If
- If position.Z < 0 Then
- Vertice(i) = New Vector3(Double.Parse(ste(1)), Double.Parse(ste(2)), Double.Parse(ste(3)) - position.Z)
- End If
- If position.X > 0 Then
- Vertice(i) = New Vector3(Double.Parse(ste(1)) + position.X, Double.Parse(ste(2)), Double.Parse(ste(3)))
- End If
- If position.X < 0 Then
- Vertice(i) = New Vector3(Double.Parse(ste(1)) - position.X, Double.Parse(ste(2)), Double.Parse(ste(3)))
- End If
- If position.Y > 0 Then
- Vertice(i) = New Vector3(Double.Parse(ste(1)), Double.Parse(ste(2)) + position.Y, Double.Parse(ste(3)))
- End If
- If position.Y < 0 Then
- Vertice(i) = New Vector3(Double.Parse(ste(1)), Double.Parse(ste(2)) - position.Y, Double.Parse(ste(3)))
- End If
- Next
- Dim vrt As Integer = 0
- For i = 0 To counter_f
- f_felder(i) = f_felder(i).Remove(0, 1)
- f_felder(i) = f_felder(i).Replace(" ", "_")
- Dim ste() As String = f_felder(i).Split("_")
- list_of(i) = New list_of_Vertice(Vertice(Integer.Parse(ste(0))), Vertice(Integer.Parse(ste(1))), Vertice(Integer.Parse(ste(2))), Vertice(Integer.Parse(ste(3))))
- Next
- test = New CustomVertex.PositionColored(0 To counter_f * counter_f) {}
- Dim loader As Integer = 0
- For z = 0 To counter_f
- For i = 0 To 3
- Try
- test(loader) = New CustomVertex.PositionColored
- test(loader).Position = list_of(z).vertice(i)
- test(loader).Color = Color.Silver.ToArgb
- loader += 1
- Catch ex As Exception
- MsgBox(loader & " " & counter_f * counter_f & vbNewLine & ex.ToString)
- End Try
- Next
- Next
- Catch ex As Exception
- MsgBox(ex.ToString)
- End Try
- Return backloop
- End Function 'achtung der name des objectes darf nicht "o" oder "v" in den namen haben
- Function Del_char_of_index(ByVal text As String, ByVal count As Integer, ByVal ch As Char) As String
- Dim backloop As String = ""
- Dim che() As Char = text
- If che(count) = ch Then
- backloop = Delect_char(text, count)
- Else
- backloop = text
- End If
- Return backloop
- End Function
- Function Split_to_Variablen(ByVal file As String) As String
- obj_file = file
- mtl_name = name_of_file(file)
- Dim backloop As String = ""
- Dim st As String = My.Computer.FileSystem.ReadAllText(file)
- st = st.Remove(0, 71)
- st = st.Replace(".", ",")
- object_name = To_next_char(st, "o", "v")
- st = st.Remove(0, To_next_char_count(st, "o", "v"))
- st &= ";"
- v_feld = st.Remove(Char_Position(st, "u"), To_next_char_count(st, "u", ";") + 1)
- st = st.Replace(";", "")
- f_feld = st.Remove(0, Char_Position(st, "f") + 3)
- v_felder = v_string_Split(v_feld)
- f_felder = f_string_Split(f_feld)
- Return backloop
- End Function
- Function v_string_Split(ByVal text As String) As String()
- Dim backloop(99999) As String
- Try
- Dim backloop1(99999) As String
- Dim counter As Integer = 0
- text = text.Replace("v", ":v")
- Dim ch() As Char = text
- For i = 0 To ch.Count - 1
- If ch(i) = ":" Then
- counter += 1
- End If
- Next
- text = Delect_char(text, 0)
- For i = 1 To counter
- 'MsgBox(i)
- If i = counter Then
- backloop1(i) = text
- backloop1(i) = backloop1(i).Replace(":v", "")
- Else
- backloop1(i) = To_next_char(text, "v", ":v")
- End If
- text = Delect_char(text, 0)
- text = text.Remove(0, Char_Position(text, ":"))
- Next
- counter_v = counter
- backloop = backloop1
- Catch ex As Exception
- MsgBox(ex.ToString)
- End Try
- Return backloop
- End Function
- Function f_string_Split(ByVal text As String) As String()
- Dim backloop(99999) As String
- Try
- Dim backloop1(99999) As String
- Dim counter As Integer = 0
- text = text.Replace("f", ":f")
- Dim ch() As Char = text
- For i = 0 To ch.Count - 1
- If ch(i) = ":" Then
- counter += 1
- End If
- Next
- text = Delect_char(text, 0)
- For i = 0 To counter - 1
- 'MsgBox(i)
- If i = counter - 1 Then
- backloop1(i) = text
- backloop1(i) = backloop1(i).Replace(":f", "")
- Else
- backloop1(i) = To_next_char(text, "f", ":f")
- End If
- text = Delect_char(text, 0)
- text = text.Remove(0, Char_Position(text, ":"))
- Next
- f_feld = f_feld.Replace("f", "")
- counter_f = counter - 1
- backloop = backloop1
- Catch ex As Exception
- MsgBox(ex.ToString)
- End Try
- Return backloop
- End Function
- Function Delect_char(ByVal text As String, ByVal count As Integer) As String
- Dim backloop As String = ""
- Dim l() As Char = text
- l(count) = ""
- backloop = l
- Return backloop
- End Function
- Function Char_Position(ByVal text As String, ByVal pos_char As Char) As Integer
- Dim backloop As Integer = 0
- Try
- Dim th() As Char = text
- For i = 0 To text.Length - 2
- If th(i) = pos_char Then
- backloop = i
- GoTo ent
- End If
- Next
- Catch ex As Exception
- MsgBox(ex.ToString & "2")
- End Try
- ent:
- Return backloop
- End Function
- Function To_next_char_count(ByVal text As String, ByVal start_char As Char, ByVal ende_char As Char) As Integer
- Dim backloop As Integer = 0
- Dim z() As Char = text
- For i = 0 To text.Length
- If z(i) = start_char Then
- For r = i To text.Length
- If z(r) = ende_char Then
- GoTo ent
- Else
- backloop += 1
- End If
- Next
- End If
- Next
- ent:
- Return backloop
- End Function
- Function To_next_char(ByVal text As String, ByVal start_char As Char, ByVal ende_char As Char) As String
- Dim backloop As String = ""
- Dim z() As Char = text
- Dim l As Byte = 0
- For i = 0 To text.Length
- If z(i) = start_char Then
- For r = i To text.Length
- If z(r) = ende_char Then
- GoTo ent
- Else
- If l = 0 Then
- l = 1
- Else
- backloop &= z(r)
- End If
- End If
- Next
- End If
- Next
- ent:
- Return backloop
- End Function
- Function name_of_file(ByVal file As String) As String
- Dim fr As Boolean = False
- Dim vt() As String = file.Split("\")
- Dim ch() As Char = vt(vt.Count - 1)
- Dim bg As String = ch
- Dim gr() As String = bg.Split(".")
- Dim lerz As String = ""
- Dim elee As Boolean = False
- Try
- lerz = gr(gr.Count - 2)
- Catch ex As Exception
- lerz = file
- End Try
- If elee = False Then
- If gr.Count > 2 Then
- lerz = ""
- For i = 0 To gr.Count - 2
- If i = gr.Count - 2 Then
- lerz &= gr(i)
- Else
- lerz &= gr(i) & "."
- End If
- Next
- End If
- End If
- Return lerz
- End Function
- Public Class list_of_Vertice
- Public vertice(3) As Vector3
- Public Sub New(ByVal v1 As Vector3, ByVal v2 As Vector3, ByVal v3 As Vector3, ByVal v4 As Vector3)
- vertice(0) = v1
- vertice(1) = v2
- vertice(2) = v3
- vertice(3) = v4
- End Sub
- End Class
- End Class
ich kann sie nicht mit :
anzeigen lassen was mache ich falsch ( ich habe alles richtig defieniert)#
mfg blacknetworkbit
Edit by ~blaze~:
*vb-Tag eingefügtt, Thema aus Hauptforum verschoben*
MFG 0x426c61636b4e6574776f726b426974
InOffical VB-Paradise IRC-Server
webchat.freenode.net/
Channel : ##vbparadise
InOffical VB-Paradise IRC-Server
webchat.freenode.net/
Channel : ##vbparadise
Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von „~blaze~“ ()