|
'World-Koordinaten der Billboards verändern
For i = 0 To UBound(BILLBOARDS())
'Winkel zur Spielerposition pro Billboard berechnen
BILLBOARDS(i).RotateY = GetAngle(BILLBOARDS(i).WorldPos.X, _
BILLBOARDS(i).WorldPos.Z, PLAYER.X, PLAYER.Z)
Next
Private Sub Render3D()
Dim helpMatrix(1) As D3DMATRIX
Dim i As Integer, j As Integer
On Error GoTo ErrOut
'Hilfsmatrix initialisieren
For i = 0 To 1
D3DXMatrixIdentity helpMatrix(i)
Next
If gD3DDevice8 Is Nothing Then Exit Sub
'Bereinigen des BackBuffers und des ZBuffers
gD3DDevice8.Clear 0, ByVal 0, D3DCLEAR_TARGET Or _
D3DCLEAR_ZBUFFER, 0#, 1#, 0
'Szene beginnen
gD3DDevice8.BeginScene
'VertexFormat setzen
gD3DDevice8.SetVertexShader D3DFVF_CUSTOMVERTEX
'Restliche Welt "normal" rendern
gD3DDevice8.SetTransform D3DTS_WORLD, helpMatrix(0)
'Textur setzen
gD3DDevice8.SetTexture 0, texBox
'TexturKoordinaten ausserhalb der Textur werden nicht gespiegelt
gD3DDevice8.SetTextureStageState 0, D3DTSS_ADDRESSW, _
D3DTADDRESS_WRAP
'Bilinearen Texturfilter verwenden damit die Skybox nicht
'so grob gerastert wird
gD3DDevice8.SetTextureStageState 0, D3DTSS_MAGFILTER, _
D3DTEXF_LINEAR
'Die Box rendern
gD3DDevice8.DrawPrimitiveUP D3DPT_TRIANGLELIST, 12, _
vxBox(0), Len(vxBox(0))
gD3DDevice8.SetTextureStageState 0, D3DTSS_ADDRESSW, 0
'Textur setzen
gD3DDevice8.SetTexture 0, texBillboard
For j = 0 To UBound(BILLBOARDS())
'Objekt-Koordinaten in der WorldMatrix setzen
For i = 0 To 1
D3DXMatrixIdentity helpMatrix(i)
Next
'Die World-Matrix der Billboards transformieren
gD3DDevice8.SetTransform D3DTS_WORLD, BILLBOARDS(j).WorldMatrix
'HilfsMatrix in den Mittelpunkt der Billboards schieben
TranslateMatrix helpMatrix(1), BillboardMittelpunkt
'Billboards entsprechend drehen
RotateYMatrix helpMatrix(0), BILLBOARDS(j).RotateY * PI / 180
'Hilfsmatrizen miteinander multiplizieren
helpMatrix(1) = RetMatrixMult(helpMatrix(1), helpMatrix(0))
'Änderungen der World-Matrix der Billboards durchführen
gD3DDevice8.MultiplyTransform D3DTS_WORLD, helpMatrix(1)
'Billboard rendern
gD3DDevice8.DrawPrimitiveUP D3DPT_TRIANGLELIST, 2, _
vxBillboard(0), Len(vxBillboard(0))
Next j
'Mit der Draw-Methode des D3DX8Sprite-Objektes werden
'die Bilder gezeichnet
Call gD3DX8Sprite.Draw(texFadenkreuz, recFadenkreuz, _
vecScalingDummy, vecRotationCenterDummy, 0, _
vecFadenkreuz, lngColorDummy)
'Text zeichnen
myDXFont.DrawTextW strText, Len(strText), recText, _
DT_WORDBREAK, D3DColorMake(1, 1, 1, 1)
'Szene beenden
gD3DDevice8.EndScene
'Kompletten BackBuffer zum FrontBuffer kopieren
gD3DDevice8.Present ByVal 0, ByVal 0, 0, ByVal 0
Exit Sub
ErrOut:
Debug.Print Err.Number & " - " & Err.Description
End Sub
|
|