Von |
Crack man |
Datum |
19. November 2009 um 20:56:48 |
Antwort |
Hi Problem gelöst...oder auch nicht!? Ich habe festgestellt, dass es darauf ankommt in welcher Reihenfolge die Dreiecke in dem Rendervogang angegeben werden und dass das erste Dreieck in jeder Position und in jedem Winkel gezeichnet wird. Danach habe ich versucht jeweils für jedes Dreieck ein Rendervorgang zu beginnen und wieder zu beenden. Um die Übersicht zu bewahren, habe ich diese noch in Functions und Subs untergebracht. Der Source Code sieht dann so aus: Code in Main(Hauptformular):Option Explicit Public DX As New DirectX7 Dim DD As DirectDraw7, D3D As Direct3D7 Dim ddsd As DDSURFACEDESC2 Public Prim As DirectDrawSurface7, Mirror As DirectDrawSurface7, BackBuffer As DirectDrawSurface7, ZBuffer As DirectDrawSurface7, TextureBoden As DirectDrawSurface7, TextureWand As DirectDrawSurface7, TextureFire As DirectDrawSurface7, Fire As DirectDrawSurface7 Public Device As Direct3DDevice7, mirrDevice As Direct3DDevice7 Dim vPort As D3DVIEWPORT7, rcViewport(0) As D3DRECT Dim matProj As D3DMATRIX, matView As D3DMATRIX, ObjectMatrix(2) As D3DMATRIX Dim Vertex(29) As D3DVERTEX Dim Light0 As D3DLIGHT7, Light1 As D3DLIGHT7, Material As D3DMATERIAL7 Dim LightPos As D3DVECTOR, LightDir As D3DVECTOR Public Winkel As Double, V As Long, oldX As Double, oldZ As Double, deltaX As Double, deltaZ As Double, PI As Double, FireCount As Single, Geo As Double Private Sub InitDD() Set DX = New DirectX7 Set DD = DX.DirectDrawCreate("") Set D3D = DD.GetDirect3D DD.SetCooperativeLevel Main.hWnd, DDSCL_FULLSCREEN Or DDSCL_EXCLUSIVE Or DDSCL_ALLOWREBOOT DD.SetDisplayMode 1920, 1200, 32, 0, DDSDM_DEFAULT ddsd.lFlags = DDSD_BACKBUFFERCOUNT Or DDSD_CAPS ddsd.ddsCaps.lCaps2 = DDSCAPS2_HINTANTIALIASING ddsd.ddsCaps.lCaps = DDSCAPS_COMPLEX Or DDSCAPS_FLIP Or DDSCAPS_PRIMARYSURFACE Or DDSCAPS_VIDEOMEMORY Or DDSCAPS_3DDEVICE ddsd.lBackBufferCount = 1 Set Prim = DD.CreateSurface(ddsd) Dim Caps As DDSCAPS2 Caps.lCaps = DDSCAPS_BACKBUFFER Set BackBuffer = Prim.GetAttachedSurface(Caps) Dim ddsd2 As DDSURFACEDESC2 ddsd2.lFlags = DDSD_CAPS Or DDSD_WIDTH Or DDSD_HEIGHT Or DDSD_PIXELFORMAT ddsd2.ddsCaps.lCaps = DDSCAPS_ZBUFFER ddsd2.lHeight = 1200 ddsd2.lWidth = 1920 Dim ddpf As DDPIXELFORMAT, d3dEnumPFs As Direct3DEnumPixelFormats, i As Long Set d3dEnumPFs = D3D.GetEnumZBufferFormats("IID_IDirect3DHALDevice") For i = 1 To d3dEnumPFs.GetCount Call d3dEnumPFs.GetItem(i, ddpf) If ddpf.lFlags = DDPF_ZBUFFER Then Exit For Next i ddsd2.ddpfPixelFormat = ddpf ddsd2.ddsCaps.lCaps = ddsd2.ddsCaps.lCaps Or DDSCAPS_VIDEOMEMORY Set ZBuffer = DD.CreateSurface(ddsd2) BackBuffer.AddAttachedSurface ZBuffer Dim ddsd3 As DDSURFACEDESC2 ddsd3.ddsCaps.lCaps = DDSCAPS_TEXTURE Set TextureBoden = DD.CreateSurfaceFromFile("C:\Program Files\VB\Racing\picture\Boden.bmp", ddsd3) Set TextureWand = DD.CreateSurfaceFromFile("C:\Program Files\VB\Racing\picture\Wand.bmp", ddsd3) ddsd3.lHeight = 512 ddsd3.lWidth = 256 With Create.Auflösung .x = ddsd3.lWidth .y = ddsd3.lHeight End With Set TextureFire = DD.CreateSurface(ddsd3) Dim ck As DDCOLORKEY ck.high = DX.CreateColorRGB(0, 0, 0) ck.low = ck.high Call TextureFire.SetColorKey(DDCKEY_SRCBLT, ck) ddsd3.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH ddsd3.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN ddsd3.lHeight = 256 ddsd3.lWidth = 256 Set Fire = DD.CreateSurfaceFromFile("C:\Program Files\VB\Racing\picture\Feuer.bmp", ddsd3) ddsd3.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH ddsd3.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN ddsd3.lHeight = 1200 ddsd3.lWidth = 1920 Set Mirror = DD.CreateSurface(ddsd3) InitD3D End Sub Private Sub InitD3D() Set Device = D3D.CreateDevice("IID_IDirect3DHALDevice", BackBuffer) 'Set mirrDevice = D3D.CreateDevice("IID_IDirect3DHALDevice", Mirror) vPort.lX = 0 vPort.lY = 0 vPort.lHeight = 1200 vPort.lWidth = 1920 Device.SetViewport vPort With rcViewport(0) .X1 = 0: .Y1 = 0 .x2 = 1920 .y2 = 1200 End With DX.IdentityMatrix matView Call DX.ViewMatrix(matView, MakeVector(0, 0, -70), MakeVector(0, 0, 0), MakeVector(0, 1, 0), 0) Device.SetTransform D3DTRANSFORMSTATE_VIEW, matView DX.IdentityMatrix matProj Call DX.ProjectionMatrix(matProj, 1, 10000, 3.14159 / 2) Device.SetTransform D3DTRANSFORMSTATE_PROJECTION, matProj Device.SetRenderTarget BackBuffer DX.IdentityMatrix ObjectMatrix(0) DX.IdentityMatrix ObjectMatrix(1) Create.FireI.MidPos.z = 50 Dim LC As D3DCOLORVALUE, LC2 As D3DCOLORVALUE LC.r = 5 LC.g = 2.5 LC.b = 0 LC2.r = 1 LC2.g = 1 LC2.b = 1 LightDir = MakeVector(0, -1, 0) LightPos = MakeVector(0, 0, -200) 'Dim Light As D3DLIGHT7 Light0.diffuse = LC Light0.specular = LC Light0.Ambient = LC Light0.attenuation1 = 0.1 'Light.attenuation0 = 0 Light0.dltType = D3DLIGHT_POINT Light0.position = LightPos Light0.direction = LightDir Light0.range = 600 Light0.phi = 100 Light0.theta = 40 Light0.falloff = 10 Device.SetLight 0, Light0 Device.LightEnable 0, True Material.diffuse = LC2 Material.specular = LC Material.Ambient = LC2 Material.power = 0.1 Device.SetMaterial Material Device.SetRenderState D3DRENDERSTATE_AMBIENT, DX.CreateColorRGBA(0.1, 0.1, 0.1, 0) Dim TextureMagFilter As CONST_D3DTEXTUREMAGFILTER Dim TextureMinFilter As CONST_D3DTEXTUREMINFILTER TextureMagFilter = D3DTFG_POINT TextureMinFilter = D3DTFG_POINT Device.SetTextureStageState 0, D3DTSS_MAGFILTER, TextureMagFilter Device.SetTextureStageState 0, D3DTSS_MINFILTER, TextureMinFilter Device.SetRenderState D3DRENDERSTATE_ZENABLE, D3DZB_TRUE Device.SetRenderState D3DRENDERSTATE_COLORKEYENABLE, True End Sub Public Function MakeVector(a As Double, b As Double, c As Double) As D3DVECTOR Dim vecOut As D3DVECTOR With vecOut .x = a .y = b .z = c End With MakeVector = vecOut End Function Private Function MakeVertex(x As Single, y As Single, z As Single, nx As Single, ny As Single, nz As Single, tu As Single, tv As Single) As D3DVERTEX Dim vertOut As D3DVERTEX Call DX.CreateD3DVertex(x, y, z, nx, ny, nz, tu, tv, vertOut) MakeVertex = vertOut End Function Private Sub Form_Load() InitDD V = 0 PI = 3.14159 Winkel = PI / 2 oldZ = 1 oldX = 0 'Device.SetRenderState D3DRENDERSTATE_FILLMODE, D3DFILL_WIREFRAME Randomize Timer FireCount = -1 Geo = 0 Game_Loop.Enabled = True End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) DD.SetCooperativeLevel Form1.hWnd, DDSCL_NORMAL DD.RestoreDisplayMode Set DD = Nothing Set Device = Nothing Set DX = Nothing End Sub Private Sub Game_Loop_Timer() FireCount = FireCount + 0.5 If FireCount > 32 Then FireCount = 0 If GetAsyncKeyState(vbKeyUp) <> 0 Then V = 1 If GetAsyncKeyState(vbKeyDown) <> 0 Then V = -1 If GetAsyncKeyState(vbKeyUp) = 0 And GetAsyncKeyState(vbKeyDown) = 0 Then V = 0 If GetAsyncKeyState(vbKeyLeft) <> 0 Then Winkel = Winkel + 0.01 If GetAsyncKeyState(vbKeyRight) <> 0 Then Winkel = Winkel - 0.01 If Winkel > 2 * PI Then Winkel = 0 If Winkel < 0 Then Winkel = 2 * PI If GetAsyncKeyState(vbKeyEscape) <> 0 Then End DX.IdentityMatrix matView If V = 1 Then If Not ZColision(Cos(Winkel) * 20 + oldX, 0, Sin(Winkel) * 20 + oldZ) = True Then oldZ = (oldZ + Sin(Winkel) * 2 + oldZ) / 2 If Not XColision(Cos(Winkel) * 20 + oldX, 0, Sin(Winkel) * 20 + oldZ) = True Then oldX = (oldX + Cos(Winkel) * 2 + oldX) / 2 End If If V = -1 Then Winkel = Winkel + PI If Winkel > 2 * PI Then Winkel = Winkel + (2 * PI) If Not ZColision(Cos(Winkel) * 20 + oldX, 0, Sin(Winkel) * 20 + oldZ) = True Then oldZ = (oldZ + Sin(Winkel) * 2 + oldZ) / 2 If Not XColision(Cos(Winkel) * 20 + oldX, 0, Sin(Winkel) * 20 + oldZ) = True Then oldX = (oldX + Cos(Winkel) * 2 + oldX) / 2 Winkel = Winkel - PI If Winkel < 0 Then Winkel = (2 * PI) + Winkel End If deltaZ = Sin(Winkel) * 1 + oldZ deltaX = Cos(Winkel) * 1 + oldX Call DX.ViewMatrix(matView, MakeVector(oldX, 0, oldZ), MakeVector(deltaX, 0, deltaZ), MakeVector(0, 1, 0), 0) Device.SetTransform D3DTRANSFORMSTATE_VIEW, matView Device.Clear 1, rcViewport(), D3DCLEAR_TARGET, &H0, 0, 0 Device.Clear 1, rcViewport(), D3DCLEAR_ZBUFFER, 0, 1, 0 Device.SetTransform D3DTRANSFORMSTATE_WORLD, ObjectMatrix(0) Call Light Call Create.Fire(Winkel, FireCount, Create.FireI) Call Create.Walls(Device, False) Call BackBuffer.DrawText(0, 0, oldX, False) Prim.Flip Nothing, DDFLIP_WAIT End Sub Function XColision(x As Double, y As Double, z As Double) As Boolean XColision = False If x > 69 And z < 1000 Then XColision = True If x < -69 Then XColision = True End Function Function ZColision(x As Double, y As Double, z As Double) As Boolean If z > 1139 Or z < -1 Then ZColision = True End Function Sub Light() Dim LC As D3DCOLORVALUE, gFac As Long 'Light.attenuation0 = 0 Light0.position.x = Create.FireI.MidPos.x Light0.position.y = Create.FireI.MidPos.y Light0.position.z = Create.FireI.MidPos.z gFac = 12 LC.r = (Light0.diffuse.r * gFac + (5 + (Rnd() * 8 - 4))) / (gFac + 1) LC.g = (Light0.diffuse.g * gFac + (2.5 + (Rnd() * 8 - 4))) / (gFac + 1) LC.b = 0 Light0.diffuse = LC Device.SetLight 0, Light0 End Sub In dem Modul Create:Option Explicit Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer Type POS x As Double y As Double z As Double tu As Double tv As Double End Type Type FIREINFORMATION LeftPos As POS MidPos As POS RightPos As POS Index As Long End Type Public Type PicAuflösung x As Long y As Long bit As Byte End Type Public Auflösung As Create.PicAuflösung Public FireI As FIREINFORMATION Public Sub Triangle(ByVal x As Single, ByVal y As Single, ByVal z As Single, ByVal tu As Single, ByVal tv As Single, ByVal x2 As Single, ByVal y2 As Single, ByVal z2 As Single, ByVal tu2 As Single, ByVal tv2 As Single, ByVal x3 As Single, ByVal y3 As Single, ByVal z3 As Single, ByVal tu3 As Single, ByVal tv3 As Single, ByVal CullMode As Long, ByVal Device As Direct3DDevice7) On Error GoTo fehler Dim vertOut(0 To 2) As D3DVERTEX, CullSave As Long CullSave = Device.GetRenderState(D3DRENDERSTATE_CULLMODE) Device.SetRenderState D3DRENDERSTATE_CULLMODE, CullMode Main.DX.CreateD3DVertex x, y, z, 0, 0, -1, tu, tv, vertOut(0) Main.DX.CreateD3DVertex x2, y2, z2, 0, 0, -1, tu2, tv2, vertOut(1) Main.DX.CreateD3DVertex x3, y3, z3, 0, 0, -1, tu3, tv3, vertOut(2) Device.BeginScene Device.DrawPrimitive D3DPT_TRIANGLELIST, D3DFVF_VERTEX, vertOut(0), 3, D3DDP_WAIT Device.EndScene Device.SetRenderState D3DRENDERSTATE_CULLMODE, CullSave Exit Sub fehler: If Err.Describtion = "Automatisierungsfehler" Then Resume Next End Sub Public Sub Square(ByVal x As Single, ByVal y As Single, ByVal z As Single, ByVal tv As Single, ByVal tu As Single, ByVal x2 As Single, ByVal y2 As Single, ByVal z2 As Single, ByVal tv2 As Single, ByVal tu2 As Single, ByVal x3 As Single, ByVal y3 As Single, ByVal z3 As Single, ByVal tv3 As Single, ByVal tu3 As Single, ByVal x4 As Single, ByVal y4 As Single, ByVal z4 As Single, ByVal tv4 As Single, ByVal tu4 As Single, ByVal CullMode As Long, ByVal Device As Direct3DDevice7, ByVal dir As Boolean, ByVal Geometry As Long) Dim P1 As POS, P2 As POS, P3 As POS, P4 As POS, P5 As POS, i As Long P1 = DurchschnittXYZ(x, y, z, tu, tv, x2, y2, z2, tu2, tv2) P3 = DurchschnittXYZ(x3, y3, z3, tu3, tv3, x4, y4, z4, tu4, tv4) P4 = DurchschnittXYZ(x, y, z, tu, tv, x3, y3, z3, tu3, tv3) P5 = DurchschnittXYZ(x2, y2, z2, tu2, tv2, x4, y4, z4, tu4, tv4) P2 = PDurchschnittXYZ(P1, P3) If dir = True Then If Geometry > 0 Then Do Geometry = Geometry - 1 Call Create.Square(x, y, z, tv, tu, P1.x, P1.y, P1.z, P1.tv, P1.tu, P4.x, P4.y, P4.z, P4.tv, P4.tu, P2.x, P2.y, P2.z, P4.tv, P1.tu, CullMode, Device, dir, Geometry) Call Create.Square(P1.x, P1.y, P1.z, P1.tv, P1.tu, x2, y2, z2, tv2, tu2, P2.x, P2.y, P2.z, P5.tv, P1.tu, P5.x, P5.y, P5.z, P5.tv, P5.tu, CullMode, Device, dir, Geometry) Call Create.Square(P4.x, P4.y, P4.z, P4.tv, P4.tu, P2.x, P2.y, P2.z, P5.tv, P1.tu, x3, y3, z3, tv3, tu3, P3.x, P3.y, P3.z, P3.tv, P3.tu, CullMode, Device, dir, Geometry) Call Create.Square(P2.x, P2.y, P2.z, P5.tv, P1.tu, P5.x, P5.y, P5.z, P5.tv, P5.tu, P3.x, P3.y, P3.z, P3.tv, P3.tu, x4, y4, z4, tv4, tu4, CullMode, Device, dir, Geometry) If Geometry = 0 Then Exit Sub Loop End If If Geometry = 0 Then Call Create.Triangle(x, y, z, tu, tv, x2, y2, z2, tu2, tv2, x3, y3, z3, tu3, tv3, CullMode, Device) Call Create.Triangle(x2, y2, z2, tu2, tv2, x4, y4, z4, tu4, tv4, x3, y3, z3, tu3, tv3, CullMode, Device) End If Else Call Create.Triangle(x, y, z, tu3, tv3, x2, y2, z2, tu, tv, x3, y3, z3, tu4, tv4, CullMode, Device) Call Create.Triangle(x2, y2, z2, tu, tv, x4, y4, z4, tu2, tv2, x3, y3, z3, tu4, tv4, CullMode, Device) End If End Sub Public Sub Rectangle(x As Single, y As Single, z As Single, tv As Single, tu As Single, x4 As Single, y4 As Single, z4 As Single, tv4 As Single, tu4 As Single, CullMode As Long, Device As Direct3DDevice7) Dim x2 As Single, y2 As Single, z2 As Single, tv2 As Single, x3 As Single, y3 As Single, z3 As Single If x = x4 Then Call Triangle(x, y, z, tu, tv, x, y, z4, tu4, tv, x, y4, z, tu, tv4, CullMode, Device) Call Triangle(x, y, z4, tu4, tv, x4, y4, z4, tu4, tv4, x, y4, z, tu, tv4, CullMode, Device) End If If y = y4 Then Call Triangle(x, y, z, tu, tv, x, y, z4, tu4, tv, x4, y, z, tu, tv4, CullMode, Device) Call Triangle(x, y, z4, tu4, tv, x4, y4, z4, tu4, tv4, x4, y, z, tu, tv4, CullMode, Device) End If If z = z4 Then Call Triangle(x, y, z, tu, tv, x, y4, z, tu4, tv, x4, y, z, tu, tv4, CullMode, Device) Call Triangle(x, y4, z, tu4, tv, x4, y4, z4, tu4, tv4, x4, y, z, tu, tv4, CullMode, Device) End If End Sub Public Sub Walls(Device As Direct3DDevice7, mirr As Boolean) Dim P1 As POS, P2 As POS, P3 As POS, P4 As POS, vTo As POS, vFrom As POS, W As Double Create.FireI.MidPos.z = 500 Device.SetTexture 0, Main.TextureBoden Call Create.Square(-70, -70, 0, 0, 13, -70, -70, 1140, 0, 0, 70, -70, 0, 7.7, 13, 70, -70, 1140, 7.7, 0, D3DCULL_CCW, Device, True, 1) 'unten Call Create.Square(70, -70, 1000, 0, 1.6, 70, -70, 1140, 0, 0, 430, -70, 1000, 19.8, 1.6, 430, -70, 1140, 19.8, 0, D3DCULL_CCW, Device, True, 1) 'unten2 Device.SetTexture 0, Main.TextureWand Call Create.Square(430, -70, 1000, 0, 11.4, 70, -70, 1000, 0, 0, 430, 70, 1000, 4, 11.4, 70, 70, 1000, 4, 0, D3DCULL_CW, Device, True, 1) 'hinten2 Call Create.Square(70, 70, 1000, 0, 1.6, 70, 70, 1140, 0, 0, 430, 70, 1000, 19.8, 1.6, 430, 70, 1140, 19.8, 0, D3DCULL_CW, Device, True, 1) 'oben2 Call Create.Square(-70, -70, 0, 0, 2.8, -70, 70, 0, 0, 0, 70, -70, 0, 4, 2.8, 70, 70, 0, 4, 0, D3DCULL_CW, Device, False, 1) 'vorne Call Create.Square(430, -70, 1140, 0, 11.4, -70, -70, 1140, 0, 0, 430, 70, 1140, 4, 11.4, -70, 70, 1140, 4, 0, D3DCULL_CCW, Device, True, 1) 'hinten Call Create.Square(-70, 70, 0, 0, 22.8, -70, 70, 1140, 0, 0, -70, -70, 0, 4, 22.8, -70, -70, 1140, 4, 0, D3DCULL_CCW, Device, True, 1) 'links Call Create.Square(70, 70, 0, 0, 26.8, 70, 70, 1140, 0, 0, -70, 70, 0, 5, 26.8, -70, 70, 1140, 5, 0, D3DCULL_CCW, Device, True, 1) 'oben Call Create.Square(70, -70, 0, 0, 20, 70, -70, 1000, 0, 0, 70, 70, 0, 4, 20, 70, 70, 1000, 4, 0, D3DCULL_CCW, Device, True, 1) 'rechts Device.SetTexture 0, Main.TextureFire Device.SetRenderState D3DRENDERSTATE_DESTBLEND, 2 Device.SetRenderState D3DRENDERSTATE_ALPHABLENDENABLE, True Call Create.Square(0 + FireI.RightPos.x, -16, 0 + FireI.RightPos.z, 0, 1, 0 + FireI.RightPos.x, 16, 0 + FireI.RightPos.z, 0, 0, 0 + FireI.LeftPos.x, -16, 0 + FireI.LeftPos.z, 1, 1, 0 + FireI.LeftPos.x, 16, 0 + FireI.LeftPos.z, 1, 0, D3DCULL_NONE, Device, False, 0) Device.SetRenderState D3DRENDERSTATE_ALPHABLENDENABLE, False If mirr = True Then P1.x = -10 P1.y = -10 P1.z = 0 P2.x = -10 P2.y = 10 P2.z = 0 P3.x = 10 P3.y = -10 P3.z = 0 P4.x = 10 P4.y = 10 P4.z = 0 vFrom = PDurchschnittXYZ(PDurchschnittXYZ(P1, P2), PDurchschnittXYZ(P3, P4)) W = Atn((vFrom.x - Main.oldX) / (vFrom.z - Main.oldZ)) W = 2 * Main.PI - ((Main.PI / 2 - W) + (2 * Atn((P3.x - P4.x) / (P3.z - P4.z)) + (W - Main.PI / 2))) vTo.x = Cos(W) vTo.y = 0 vTo.z = Sin(W) Call Create.Walls(Main.mirrDevice, False) End If End Sub Public Sub Fire(Winkel As Double, fIndex As Single, FireI As FIREINFORMATION) Dim srcRect As RECT, destRect As RECT, Index As Long FireI.RightPos.x = Cos(Winkel + 1 / 2 * Main.PI) * 8 + FireI.MidPos.x FireI.RightPos.z = Sin(Winkel + 1 / 2 * Main.PI) * 8 + FireI.MidPos.z FireI.LeftPos.x = Cos(Winkel + 3 / 2 * Main.PI) * 8 + FireI.MidPos.x FireI.LeftPos.z = Sin(Winkel + 3 / 2 * Main.PI) * 8 + FireI.MidPos.z Index = Int(fIndex) destRect.Bottom = Auflösung.y destRect.Right = Auflösung.x Select Case Index Case Is < 8 srcRect.Top = 0 srcRect.Bottom = 64 srcRect.Left = Index * 32 srcRect.Right = (Index + 1) * 32 Call Main.TextureFire.Blt(destRect, Main.Fire, srcRect, DDBLT_WAIT) Case Is < 16 srcRect.Top = 64 srcRect.Bottom = 128 srcRect.Left = (Index - 8) * 32 srcRect.Right = (Index - 7) * 32 Call Main.TextureFire.Blt(destRect, Main.Fire, srcRect, DDBLT_WAIT) Case Is < 24 srcRect.Top = 128 srcRect.Bottom = 192 srcRect.Left = (Index - 16) * 32 srcRect.Right = (Index - 15) * 32 Call Main.TextureFire.Blt(destRect, Main.Fire, srcRect, DDBLT_WAIT) Case Is < 32 srcRect.Top = 192 srcRect.Bottom = 256 srcRect.Left = (Index - 24) * 32 srcRect.Right = (Index - 23) * 32 Call Main.TextureFire.Blt(destRect, Main.Fire, srcRect, DDBLT_WAIT) End Select End Sub Function DurchschnittXYZ(ByVal x As Double, ByVal y As Double, ByVal z As Double, ByVal tu As Double, ByVal tv As Double, ByVal x2 As Double, ByVal y2 As Double, ByVal z2 As Double, ByVal tu2 As Double, ByVal tv2 As Double) As POS DurchschnittXYZ.x = (x + x2) / 2 DurchschnittXYZ.y = (y + y2) / 2 DurchschnittXYZ.z = (z + z2) / 2 DurchschnittXYZ.tu = (tu + tu2) / 2 DurchschnittXYZ.tv = (tv + tv2) / 2 End Function Function PDurchschnittXYZ(P1 As POS, P2 As POS) As POS PDurchschnittXYZ.x = (P1.x + P2.x) / 2 PDurchschnittXYZ.y = (P1.y + P2.y) / 2 PDurchschnittXYZ.z = (P1.z + P2.z) / 2 PDurchschnittXYZ.tv = (P1.tu + P2.tu) / 2 PDurchschnittXYZ.tu = (P1.tv + P2.tv) / 2 End Function Es werden nun allerdings hunderte von Rendervorgänge gestartet: Das Programm wird sehr langsam Gibt es da Abhilfe oder gar eine Lösung für mein altes Problem(, das ja wieder besteht, wenn man aus dem ganzen wieder ein Rendervorgang macht) LG Crack man P.S. Ich habe den ganzen Code mitgelifert, da ich keine Ahnung habe, wo der Fehler liegen könnte. Wer noch Fragen an meinen Code hat, der kann diese ja posten. |
|