property. it is only this change. we can color every step in a different color by preceding it with something like
i have used the corrected procedure by netmaestro.
make a tour around the curve using the mouse and keyboard.
Code: Select all
#CameraSpeed = 10
#Camera = 0
Global.l x0, y0, tot
x0 = 0: y0 = 0
Define.f KeyX, KeyY, MouseX, MouseY
Procedure Hilbert(depth.i, dx.f, dy.f)
If depth > 1
Hilbert(depth - 1, dy, dx)
MeshVertexColor(RGB(0,255,0))
MeshVertexPosition(x0, y0, 0)
MeshVertexPosition(x0+dx, y0+dy, 0)
;LineXY(x0,y0 , x0+dx, y0+dy)
x0 + dx: y0 + dy
Hilbert(depth - 1, dx, dy)
MeshVertexPosition(x0, y0, 0)
MeshVertexPosition(x0+dy, y0+dx, 0)
;LineXY(x0,y0 , x0+dy, y0+dx)
x0 + dy: y0 + dx
Hilbert(depth - 1, dx, dy)
MeshVertexPosition(x0, y0, 0)
MeshVertexPosition(x0-dx, y0-dy, 0)
;LineXY(x0,y0 , x0-dx, y0-dy)
x0 - dx: y0 - dy
Hilbert(depth - 1, -dy, -dx)
EndIf
EndProcedure
IncludeFile #PB_Compiler_Home + "Examples/3D/Screen3DRequester.pb"
Define.f KeyX, KeyY, MouseX, MouseY
If InitEngine3D()
Add3DArchive(".", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Models", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Scripts",#PB_3DArchive_FileSystem)
Parse3DScripts()
InitSprite()
InitKeyboard()
InitMouse()
ExamineDesktops()
DesktopW = DesktopWidth(0)
DesktopH = DesktopHeight(0)
If OpenWindow(0, 0, 0, DesktopW, DesktopH, "Hilbert Curve, use the mouse / keyboard to travel over the curve ")
If OpenWindowedScreen(WindowID(0), 0, 0, DesktopW, DesktopH, 0, 0, 0)
CreateMesh(0, #PB_Mesh_LineStrip , #PB_Mesh_Static)
CreateMaterial(0, LoadTexture(0, "White.jpg"))
DisableMaterialLighting(0, #True)
SetMeshMaterial(0, MaterialID(0))
; Camera
;
CreateCamera(#Camera, 0, 0, 100, 100)
MoveCamera(#Camera, 0, 500, 600, #PB_Absolute)
CameraLookAt(#Camera, 0, 0, 0)
RotateCamera(#Camera, -10,0,0,#PB_Relative)
depth.i = 8
Hilbert(depth, 10, 0)
FinishMesh(#True)
CreateEntity(0,MeshID(0),MaterialID(0) )
MoveEntity(0, -250,0,-200)
EndIf
EndIf
RotateEntity(0, 90,0,0)
Repeat
event = WindowEvent()
If ExamineMouse()
MouseX = -MouseDeltaX()/20
MouseY = -MouseDeltaY()/20
EndIf
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = #CameraSpeed
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = #CameraSpeed
Else
KeyY = 0
EndIf
EndIf
RotateCamera(#Camera, MouseY, MouseX, 0, #PB_Relative)
MoveCamera(#Camera, KeyX, 0, KeyY)
;RotateEntity(0, 0,1,0,#PB_Relative) ; to rotate the curve
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
;EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
End