Code: Select all
#CameraSpeed = 10
IncludeFile "Screen3DRequester.pb"
Define.f KeyX, KeyY, MouseX, MouseY
If InitEngine3D()
Add3DArchive("Data\", #PB_3DArchive_FileSystem)
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
WorldShadows(#PB_Shadow_Additive) ; Set the shadow mode for the world
AmbientColor(RGB(128,128,128))
; Create a plan, manually
;
CreateMesh(1,100)
SetMeshData(1, #PB_Mesh_Vertex | #PB_Mesh_Normal | #PB_Mesh_UVCoordinate, ?PlanVertices, 4)
SetMeshData(1, #PB_Mesh_Face, ?PlanFaces, 2)
LoadMesh (0, "Robot.mesh")
LoadTexture(0, "r2skin.jpg")
CreateEntity (0, MeshID(0), CreateMaterial(0, TextureID(0)))
AnimateEntity(0, "Walk")
CreateMaterial(1, LoadTexture(1, "Background.png"))
CreateEntity (1, MeshID(1), MaterialID(1))
EntityRenderMode(1, 0) ; Disable shadow casting for this entity as it's our plan
ScaleEntity(1, 1000, 1, 1000)
MoveEntity(1, -500, 0, -500)
DisableMaterialLighting(1, #False)
CreateLight(0, RGB(255,255,255))
CreateCamera(0, 0, 0, 100, 100)
CameraLocate(0, 2000, 2000, 2000) ; 3D iso view
CameraLookAt(0, 0, 0, 0)
ResizeEntity(0, 4, 4, 4)
CameraProjection(0, #PB_Camera_Orthographic)
LightLocate(0, CameraX(0), CameraY(0), CameraZ(0))
Repeat
Screen3DEvents()
ClearScreen(RGB(0, 0, 0))
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Up)
EntityLocate(0, ex, 0, 0)
ex+3
EndIf
If KeyboardPushed(#PB_Key_Down)
EntityLocate(0, ex, 0, 0)
ex-3
EndIf
EndIf
If ExamineMouse()
;MouseX = -(MouseDeltaX()/10)*#CameraSpeed/2
;MouseY = -(MouseDeltaY()/10)*#CameraSpeed/2
EndIf
RenderWorld()
Screen3DStats()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
End
DataSection
PlanVertices:
; Note normals are important component to allow correct light support (and therefore shadow)
;
Data.f 0, 0, 0 ; Vertex 0
Data.f 1, 1, 1 ; Normals (perpendicular to the plan)
Data.f 0 , 0.33 ; UVCoordinate
Data.f 1, 0, 0 ; Vertex 1
Data.f 1,1,1 ; Normals
Data.f 0.33, 0.33 ; UVCoordinate
Data.f 1, 0, 1 ; Vertex 2
Data.f 1,1,1 ; Normals
Data.f 0.33, 0 ; UVCoordinate
Data.f 0, 0, 1 ; Vertex 3
Data.f 1,1,1 ; Normals
Data.f 0, 0 ; UVCoordinate
PlanFaces:
Data.w 2, 1, 0 ; bottom face (clockwise as it's reversed...)
Data.w 0, 3, 2
EndDataSection