Verfasst: 07.03.2008 16:15
Zap3D ist halt uralt (Würde auch nichtmehr mit PB laufen - Vorgänger von Senseflare3D :-P ), da kann man nichts machen.Xaby hat geschrieben:Und Zap3D
Das deutsche PureBasic-Forum
https://www.purebasic.fr/german/
Zap3D ist halt uralt (Würde auch nichtmehr mit PB laufen - Vorgänger von Senseflare3D :-P ), da kann man nichts machen.Xaby hat geschrieben:Und Zap3D
Code: Alles auswählen
Procedure InitRayK()
Global RayK_MaxZPos = 2048
Global RayK_ScaleFaktor = 128
Global RayK_ScreenMiddleX = 512
Global RayK_ScreenMiddleY = 384
EndProcedure
Procedure RayK_GetXCoord(x,z)
Out = X * RayK_MaxZPos / ( Z + X ) + RayK_ScreenMiddleX
ProcedureReturn Out
EndProcedure
Procedure RayK_GetYCoord(y,z)
Out = Y * RayK_MaxZPos / ( Z + Y ) + RayK_ScreenMiddleY
ProcedureReturn Out
EndProcedure
Procedure RayK_GetWidth(Width,Z)
Width = Width + ( -Z / RayK_ScaleFaktor )
ProcedureReturn Width
EndProcedure
Procedure RayK_GetHeight(Height,z)
Height = Height + ( -Z / RayK_ScaleFaktor )
ProcedureReturn Height
EndProcedure
Procedure RayK_GetDepth(Depth,z)
Depth = Depth + ( -Z / RayK_ScaleFaktor )
ProcedureReturn Depth
EndProcedure
Procedure RayK_CalculateDistance(x,y,x2,y2)
Out = CalculateDistance(x,y,x2,y2)
ProcedureReturn Out
EndProcedure
Procedure RayK_DrawBox(x,y,z,Width,Height,Color)
X = RayK_GetXCoord(x,z)
Y = RayK_GetYCoord(y,z)
Height = RayK_GetHeight(Height,z)
Width = RayK_GetWidth(Width,z)
If Height <= 1
Height = 1
ElseIf Width <=1
Width = 1
ElseIf Width <= 1 And Height <= 1
Plot(x,y,color)
Else
Box(X,Y,Width,Height,Color)
EndIf
EndProcedure
Procedure RayK_DrawLineXYZ(x,y,z,x2,y2,z2,Color)
X = RayK_GetXCoord(x,z)
Y = RayK_GetYCoord(y,z)
X2 = RayK_GetXCoord(x2,z2)
Y2 = RayK_GetYCoord(y2,z2)
LineXY(x,y,x2,y2,color)
EndProcedure
Procedure RayK_DrawBoxWire(x,y,z,width,height,depth,color)
width = RayK_GetWidth(width,z)
height = RayK_GetHeight(height,z)
depth = RayK_GetDepth(depth,z)
x = x
y = y
z = z
x2 = x + width
y2 = y
z2 = z
x3 = x + width
y3 = y + height
z3 = z
x4 = x
y4 = y + height
z4 = z
x5 = x + depth
y5 = y + depth
z5 = z + depth
x6 = x + width + depth
y6 = y + depth
z6 = z + depth
x7 = x + width + depth
y7 = y + height + depth
z7 = z + depth
x8 = x + depth
y8 = y + height + depth
z8 = z + depth
X = RayK_GetXCoord(x,z)
Y = RayK_GetYCoord(y,z)
X2 = RayK_GetXCoord(x2,z2)
Y2 = RayK_GetYCoord(y2,z2)
X3 = RayK_GetXCoord(x3,z3)
Y3 = RayK_GetYCoord(y3,z3)
X4 = RayK_GetXCoord(x4,z4)
Y4 = RayK_GetYCoord(y4,z4)
X5 = RayK_GetXCoord(x5,z5)
Y5 = RayK_GetYCoord(y5,z5)
X6 = RayK_GetXCoord(x6,z6)
Y6 = RayK_GetYCoord(y6,z6)
X7 = RayK_GetXCoord(x7,z7)
Y7 = RayK_GetYCoord(y7,z7)
X8 = RayK_GetXCoord(x8,z8)
Y8 = RayK_GetYCoord(y8,z8)
If Width <= 1 And height <= 1 And Depth <= 1
Plot(x,y,color)
Else
LineXY(x,y,x2,y2,color)
LineXY(x2,y2,x3,y3,color)
LineXY(x3,y3,x4,y4,color)
LineXY(x4,y4,x,y,color)
LineXY(x5,y5,x6,y6,color)
LineXY(x6,y6,x7,y7,color)
LineXY(x7,y7,x8,y8,color)
LineXY(x8,y8,x5,y5,color)
LineXY(x,y,x5,y5,color)
LineXY(x2,y2,x6,y6,color)
LineXY(x3,y3,x7,y7,color)
LineXY(x4,y4,x8,y8,color)
EndIf
EndProcedure
Procedure RayK_DrawTriangle(x,y,z,x2,y2,z2,x3,y3,z3,color)
x = RayK_GetXCoord(x,z)
y = RayK_GetYCoord(y,z)
x2 = RayK_GetXCoord(x2,z2)
y2 = RayK_GetYCoord(y2,z2)
x3 = RayK_GetXCoord(x3,z3)
y3 = RayK_GetYCoord(y3,z3)
LineXY(x,y,x2,y2,color)
LineXY(x2,y2,x3,y3,color)
LineXY(x3,y3,x,y,color)
EndProcedure
InitSprite()
InitKeyboard()
InitRayK()
OpenScreen(1024,768,32,"Raycasting...")
Repeat
ClearScreen(#Black)
ExamineKeyboard()
Z + 64
StartDrawing(ScreenOutput())
RayK_DrawTriangle(10,10,z,30,10,z+10,10,30,z-10,#Red)
StopDrawing()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
End
; IDE Options = PureBasic 4.10 (Windows - x86)
; CursorPosition = 176
; FirstLine = 8
; Folding = Dw
; EnableXP
; EnableOnError
; EnableCompileCount = 86
; EnableBuildCount = 0
; EnableExeConstant