Code: Select all
Imports Irrlicht
Module Module1
Sub Main()
' path to irrlicht media files
Dim Irrlichtpath = "C:\copy\irrlicht-0.11.0\irrlicht-0.11.0\media\"
' driver variable
Dim DriverType As New Irrlicht.Video.DriverType
' opengl as default
DriverType = Video.DriverType.OPENGL
' show question for driver
Console.WriteLine("Please select a driver you want for this example (then press Return):")
Console.WriteLine(" (a) Direct3D 9.0")
Console.WriteLine(" (b) Direct3D 8.1")
Console.WriteLine(" (c) OpenGL 1.2")
Console.WriteLine(" (d) Software Renderer")
Console.WriteLine(" (e) NullDevice")
Console.WriteLine(" (else) exit")
' read user entry and set the driver type
Dim Eingabe As Integer = Console.Read()
Select Case (Strings.Chr(Eingabe))
Case "a"
drivertype = Video.DriverType.DIRECTX9
Case "b"
drivertype = Video.DriverType.DIRECTX8
Case "c"
drivertype = Video.DriverType.OPENGL
Case "d"
drivertype = Video.DriverType.SOFTWARE
Case "e"
drivertype = Video.DriverType.NULL_DRIVER
Case Else
Exit Sub
End Select
' create and set device
Dim dimension As New Irrlicht.Core.Dimension2D(800, 600)
Dim device As New IrrlichtDevice(DriverType, dimension, 16, False, False, False, False, Nothing)
' define driver
Dim driver As Irrlicht.Video.IVideoDriver
driver = device.VideoDriver()
' define scene manager
Dim smgr As Irrlicht.Scene.ISceneManager
smgr = device.SceneManager
' load and add quake pak file
device.FileSystem.AddZipFileArchive(Irrlichtpath + "map-20kdm2.pk3")
' load mesh
Dim mesh As Irrlicht.Scene.IAnimatedMesh = device.SceneManager.GetMesh("20kdm2.bsp")
' add mesh to node
Dim node As Irrlicht.Scene.ISceneNode
' add mesh to node and set position
If Not mesh Is Nothing Then
node = smgr.AddOctTreeSceneNode(mesh.GetMesh(0, 0, 0, 0), Nothing, 1)
node.Position = New Irrlicht.Core.Vector3D(-1300, -144, -1249)
Else
MsgBox("could not load mesh: 20kdm2.bsp")
End If
' set camera
smgr.AddCameraSceneNodeFPS()
' device control should be visible
device.CursorControl.Visible = False
' variables for show fps
Dim lastFPS As Integer = -1
Dim fps As Integer
Dim caption As String
' main loop
While device.Run
' Start scene
driver.BeginScene(True, True, New Irrlicht.Video.Color(0, 200, 200, 200))
' draw all items of manager
smgr.DrawAll()
' end scene
driver.EndScene()
' calculate and show fps in caption
fps = driver.FPS
If lastFPS <> fps Then
caption = "2. Quake 3 Map! - Irrlicht Engine Demo ["
caption += driver.Name
caption += "] FPS:"
caption += CStr(fps)
device.WindowCaption = caption
lastFPS = fps
End If
End While
End Sub
End Module