I am a big fan of voxel engines as seen in some amiga demos and where you can fly arround. I dont know how to code such a great voxel engine and so i thought about it and tried something myself with following result, which doesnt looks bad. But now i have reached the point, where i dont know how to continue nor if my solution is the right way or not.
; ************************************************************
; *
; * Trying to find out, how to code a voxel engine. v0.1
; * Thorsten Will (aka 'Mr.Vain / Secretly!')
; * PureBasic - 19-Aug-2011
; *
; ************************************************************
InitSprite()
OpenWindow(0, 0, 0, 800, 600, "Trying to find out, how to code a voxel engine - Mr.Vain/Secretly!", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 800, 600, 0, 0, 0)
Dim MapData.l(512,512)
;// -------- Load Map and save it into array
LoadSprite(0,"d:\map.bmp")
StartDrawing(SpriteOutput(0))
For x = 0 To 500-1
For y = 0 To 500-1
MapData(x,y) = Point(x,y)
Next
Next
StopDrawing()
;// -------- Mainloop (drawing is very slow)
Repeat
Event = WindowEvent()
ClearScreen(RGB(0, 0, 0))
StartDrawing(ScreenOutput())
For y = 0 To 500-1
For x = 0 To 500-1
value = MapData(x,y)
Line(x,300-Red(value)+y,1, Red(value)+y,value)
;LineXY(x,300-Red(value)+y,x, Red(value)+y,value)
Next
Next
StopDrawing()
FlipBuffers()
Until Event = #PB_Event_CloseWindow
Attachement: Map.png (the used map) ... VoxelTest.png (my first generated result)