|
'World-Koordinaten der Planes verändern
For i = 0 To UBound(PLANES())
'Winkel zur Spielerposition pro Plane berechnen
PLANES(i).RotateY = GetAngle(PLANES(i).WorldPos.x, _
PLANES(i).WorldPos.z, PLAYER.x, PLAYER.z)
Next
Public Sub Render3D()
Dim helpMatrix(1) As D3DMATRIX
Dim i As Integer, j As Integer
'Hilfsmatrix initialisieren
For i = 0 To 1
DX7.IdentityMatrix helpMatrix(i)
Next
Device.Clear 1, ClearRec(), D3DCLEAR_TARGET Or D3DCLEAR_ZBUFFER, _
DX7.CreateColorRGBA(0#, 0#, 0#, 1), 1, 0
Device.BeginScene
'Restliche Welt "normal" rendern
Device.SetTransform D3DTRANSFORMSTATE_WORLD, helpMatrix(0)
Call Device.SetTexture(0, texTextur(0))
'TexturKoordinaten ausserhalb der Textur werden nicht gespiegelt
Call Device.SetTextureStageState( _
0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)
'Bilinearen Texturfilter verwenden damit die Textur nicht so
'grob gerastert wird
Call Device.SetTextureStageState( _
0, D3DTSS_MAGFILTER, D3DTFG_LINEAR)
Call Device.DrawPrimitive(D3DPT_TRIANGLELIST, _
D3DFVF_LVERTEX, vxSkyBox(0), 36, D3DDP_WAIT)
Device.SetRenderState D3DRENDERSTATE_COLORKEYENABLE, True
'Textur für Planes setzen
Call Device.SetTexture(0, texTextur(1))
For j = 0 To UBound(PLANES())
'Objekt-Koordinaten in der WorldMatrix setzen
For i = 0 To 1
DX7.IdentityMatrix helpMatrix(i)
Next
'Die World-Matrix der Planes transformieren
Device.SetTransform D3DTRANSFORMSTATE_WORLD, _
PLANES(j).WorldMatrix
'HilfsMatrix in den Mittelpunkt der Plane schieben
TranslateMatrix helpMatrix(1), PlaneMittelpunkt
'Planes entsprechend drehen
RotateYMatrix helpMatrix(0), PLANES(j).RotateY * PI / 180
'Hilfsmatrizen miteinander multiplizieren
helpMatrix(1) = RetMatrixMult(helpMatrix(1), helpMatrix(0))
'Änderungen der World-Matrix der Planes durchführen
Device.MultiplyTransform D3DTRANSFORMSTATE_WORLD, helpMatrix(1)
'Plane rendern
Call Device.DrawPrimitive(D3DPT_TRIANGLELIST, _
D3DFVF_LVERTEX, vxPlane(0), 6, D3DDP_WAIT)
Next j
Device.SetRenderState D3DRENDERSTATE_COLORKEYENABLE, False
Device.EndScene
End Sub
|
|