Directx Vertice

  • VB.NET

Es gibt 2 Antworten in diesem Thema. Der letzte Beitrag () ist von BlackNetworkBit.

    Directx Vertice

    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:


    VB.NET-Quellcode

    1. Public Class loader_obj
    2. Public Normal As Vector3()
    3. Public vertrexe As CustomVertex()
    4. Public texturevertext As VertexTextureCoordinate()
    5. Public test() As CustomVertex.PositionColored
    6. Public f_feld, v_feld, object_name, obj_file, mtl_name As String
    7. Public f_felder(9999), v_felder(9999) As String
    8. Public counter_f, counter_v As Integer
    9. Public Vertice(99999) As Vector3
    10. Public list_of(99999) As list_of_Vertice
    11. Public position As Vector3
    12. Public Function OBJ_Loader(ByVal file As String, ByVal pos As Vector3) As String
    13. position = pos
    14. Dim backloop As String = ""
    15. Try
    16. Split_to_Variablen(file)
    17. Dim tr(counter_v) As Vector3
    18. Vertice = tr
    19. For i = 1 To counter_v
    20. Dim ste() As String = v_felder(i).Split(" ")
    21. If position.Z > 0 Then
    22. Vertice(i) = New Vector3(Double.Parse(ste(1)), Double.Parse(ste(2)), Double.Parse(ste(3)) + position.Z)
    23. End If
    24. If position.Z < 0 Then
    25. Vertice(i) = New Vector3(Double.Parse(ste(1)), Double.Parse(ste(2)), Double.Parse(ste(3)) - position.Z)
    26. End If
    27. If position.X > 0 Then
    28. Vertice(i) = New Vector3(Double.Parse(ste(1)) + position.X, Double.Parse(ste(2)), Double.Parse(ste(3)))
    29. End If
    30. If position.X < 0 Then
    31. Vertice(i) = New Vector3(Double.Parse(ste(1)) - position.X, Double.Parse(ste(2)), Double.Parse(ste(3)))
    32. End If
    33. If position.Y > 0 Then
    34. Vertice(i) = New Vector3(Double.Parse(ste(1)), Double.Parse(ste(2)) + position.Y, Double.Parse(ste(3)))
    35. End If
    36. If position.Y < 0 Then
    37. Vertice(i) = New Vector3(Double.Parse(ste(1)), Double.Parse(ste(2)) - position.Y, Double.Parse(ste(3)))
    38. End If
    39. Next
    40. Dim vrt As Integer = 0
    41. For i = 0 To counter_f
    42. f_felder(i) = f_felder(i).Remove(0, 1)
    43. f_felder(i) = f_felder(i).Replace(" ", "_")
    44. Dim ste() As String = f_felder(i).Split("_")
    45. 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))))
    46. Next
    47. test = New CustomVertex.PositionColored(0 To counter_f * counter_f) {}
    48. Dim loader As Integer = 0
    49. For z = 0 To counter_f
    50. For i = 0 To 3
    51. Try
    52. test(loader) = New CustomVertex.PositionColored
    53. test(loader).Position = list_of(z).vertice(i)
    54. test(loader).Color = Color.Silver.ToArgb
    55. loader += 1
    56. Catch ex As Exception
    57. MsgBox(loader & " " & counter_f * counter_f & vbNewLine & ex.ToString)
    58. End Try
    59. Next
    60. Next
    61. Catch ex As Exception
    62. MsgBox(ex.ToString)
    63. End Try
    64. Return backloop
    65. End Function 'achtung der name des objectes darf nicht "o" oder "v" in den namen haben
    66. Function Del_char_of_index(ByVal text As String, ByVal count As Integer, ByVal ch As Char) As String
    67. Dim backloop As String = ""
    68. Dim che() As Char = text
    69. If che(count) = ch Then
    70. backloop = Delect_char(text, count)
    71. Else
    72. backloop = text
    73. End If
    74. Return backloop
    75. End Function
    76. Function Split_to_Variablen(ByVal file As String) As String
    77. obj_file = file
    78. mtl_name = name_of_file(file)
    79. Dim backloop As String = ""
    80. Dim st As String = My.Computer.FileSystem.ReadAllText(file)
    81. st = st.Remove(0, 71)
    82. st = st.Replace(".", ",")
    83. object_name = To_next_char(st, "o", "v")
    84. st = st.Remove(0, To_next_char_count(st, "o", "v"))
    85. st &= ";"
    86. v_feld = st.Remove(Char_Position(st, "u"), To_next_char_count(st, "u", ";") + 1)
    87. st = st.Replace(";", "")
    88. f_feld = st.Remove(0, Char_Position(st, "f") + 3)
    89. v_felder = v_string_Split(v_feld)
    90. f_felder = f_string_Split(f_feld)
    91. Return backloop
    92. End Function
    93. Function v_string_Split(ByVal text As String) As String()
    94. Dim backloop(99999) As String
    95. Try
    96. Dim backloop1(99999) As String
    97. Dim counter As Integer = 0
    98. text = text.Replace("v", ":v")
    99. Dim ch() As Char = text
    100. For i = 0 To ch.Count - 1
    101. If ch(i) = ":" Then
    102. counter += 1
    103. End If
    104. Next
    105. text = Delect_char(text, 0)
    106. For i = 1 To counter
    107. 'MsgBox(i)
    108. If i = counter Then
    109. backloop1(i) = text
    110. backloop1(i) = backloop1(i).Replace(":v", "")
    111. Else
    112. backloop1(i) = To_next_char(text, "v", ":v")
    113. End If
    114. text = Delect_char(text, 0)
    115. text = text.Remove(0, Char_Position(text, ":"))
    116. Next
    117. counter_v = counter
    118. backloop = backloop1
    119. Catch ex As Exception
    120. MsgBox(ex.ToString)
    121. End Try
    122. Return backloop
    123. End Function
    124. Function f_string_Split(ByVal text As String) As String()
    125. Dim backloop(99999) As String
    126. Try
    127. Dim backloop1(99999) As String
    128. Dim counter As Integer = 0
    129. text = text.Replace("f", ":f")
    130. Dim ch() As Char = text
    131. For i = 0 To ch.Count - 1
    132. If ch(i) = ":" Then
    133. counter += 1
    134. End If
    135. Next
    136. text = Delect_char(text, 0)
    137. For i = 0 To counter - 1
    138. 'MsgBox(i)
    139. If i = counter - 1 Then
    140. backloop1(i) = text
    141. backloop1(i) = backloop1(i).Replace(":f", "")
    142. Else
    143. backloop1(i) = To_next_char(text, "f", ":f")
    144. End If
    145. text = Delect_char(text, 0)
    146. text = text.Remove(0, Char_Position(text, ":"))
    147. Next
    148. f_feld = f_feld.Replace("f", "")
    149. counter_f = counter - 1
    150. backloop = backloop1
    151. Catch ex As Exception
    152. MsgBox(ex.ToString)
    153. End Try
    154. Return backloop
    155. End Function
    156. Function Delect_char(ByVal text As String, ByVal count As Integer) As String
    157. Dim backloop As String = ""
    158. Dim l() As Char = text
    159. l(count) = ""
    160. backloop = l
    161. Return backloop
    162. End Function
    163. Function Char_Position(ByVal text As String, ByVal pos_char As Char) As Integer
    164. Dim backloop As Integer = 0
    165. Try
    166. Dim th() As Char = text
    167. For i = 0 To text.Length - 2
    168. If th(i) = pos_char Then
    169. backloop = i
    170. GoTo ent
    171. End If
    172. Next
    173. Catch ex As Exception
    174. MsgBox(ex.ToString & "2")
    175. End Try
    176. ent:
    177. Return backloop
    178. End Function
    179. Function To_next_char_count(ByVal text As String, ByVal start_char As Char, ByVal ende_char As Char) As Integer
    180. Dim backloop As Integer = 0
    181. Dim z() As Char = text
    182. For i = 0 To text.Length
    183. If z(i) = start_char Then
    184. For r = i To text.Length
    185. If z(r) = ende_char Then
    186. GoTo ent
    187. Else
    188. backloop += 1
    189. End If
    190. Next
    191. End If
    192. Next
    193. ent:
    194. Return backloop
    195. End Function
    196. Function To_next_char(ByVal text As String, ByVal start_char As Char, ByVal ende_char As Char) As String
    197. Dim backloop As String = ""
    198. Dim z() As Char = text
    199. Dim l As Byte = 0
    200. For i = 0 To text.Length
    201. If z(i) = start_char Then
    202. For r = i To text.Length
    203. If z(r) = ende_char Then
    204. GoTo ent
    205. Else
    206. If l = 0 Then
    207. l = 1
    208. Else
    209. backloop &= z(r)
    210. End If
    211. End If
    212. Next
    213. End If
    214. Next
    215. ent:
    216. Return backloop
    217. End Function
    218. Function name_of_file(ByVal file As String) As String
    219. Dim fr As Boolean = False
    220. Dim vt() As String = file.Split("\")
    221. Dim ch() As Char = vt(vt.Count - 1)
    222. Dim bg As String = ch
    223. Dim gr() As String = bg.Split(".")
    224. Dim lerz As String = ""
    225. Dim elee As Boolean = False
    226. Try
    227. lerz = gr(gr.Count - 2)
    228. Catch ex As Exception
    229. lerz = file
    230. End Try
    231. If elee = False Then
    232. If gr.Count > 2 Then
    233. lerz = ""
    234. For i = 0 To gr.Count - 2
    235. If i = gr.Count - 2 Then
    236. lerz &= gr(i)
    237. Else
    238. lerz &= gr(i) & "."
    239. End If
    240. Next
    241. End If
    242. End If
    243. Return lerz
    244. End Function
    245. Public Class list_of_Vertice
    246. Public vertice(3) As Vector3
    247. Public Sub New(ByVal v1 As Vector3, ByVal v2 As Vector3, ByVal v3 As Vector3, ByVal v4 As Vector3)
    248. vertice(0) = v1
    249. vertice(1) = v2
    250. vertice(2) = v3
    251. vertice(3) = v4
    252. End Sub
    253. End Class
    254. End Class


    ich kann sie nicht mit :

    VB.NET-Quellcode

    1. device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, Obj_loader.test)


    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

    Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von „~blaze~“ ()

    device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, Obj_loader.test)

    Interessant, du willst ein komplettes Objekt zeichnen, aber nur 1 Face...
    Wie wärs mit Vertice Count/3?! Vlt. guckst du das Objekt von hinten kann -> CullMode mal auf None...
    sicher, dass die Kamera außerdem richtig positioniert ist?!
    Ich wollte auch mal ne total überflüssige Signatur:
    ---Leer---
    kannst du mir ein code schnippsel zum nachdenken geben .
    ich glaube die kamera ist richtig gesetzt ...
    naja mal sehen danke für deine antwort
    mfg blacknetworkbit
    MFG 0x426c61636b4e6574776f726b426974
    InOffical VB-Paradise IRC-Server
    webchat.freenode.net/
    Channel : ##vbparadise