Code: Select all
Imports System
Imports Irrlicht
Imports Irrlicht.Video
Imports Irrlicht.Core
Imports Irrlicht.Scene
Module Module1
Private device As IrrlichtDevice
Private cam As ICameraSceneNode
Private Camcol As ISceneNodeAnimator
Public Class MyEventReceiver
Implements IEventReceiver
Public Function OnEvent(ByVal e As [Event]) As Boolean Implements IEventReceiver.OnEvent
If e.Type = EventType.KeyInput Then
'37=leftkey,38=upkey,39=rightkey,40=downkey,
If e.Key = KeyCode.KEY_ESCAPE Then
End
End If
End If
Return False
End Function
End Class
Sub Main()
' The Engine
device = New IrrlichtDevice(DriverType.OPENGL, New Dimension2D(1024, 768), 32, False, True, False)
device.ResizeAble = True
' The Scene
Dim smgr As ISceneManager = device.SceneManager
Dim driver As IVideoDriver = device.VideoDriver
Dim mesh As IAnimatedMesh = smgr.GetMesh("devmap.3ds")
Dim mapnode As ISceneNode = smgr.AddAnimatedMeshSceneNode(mesh, Nothing, 0)
Dim xnode As IAnimatedMeshSceneNode = CType(mapnode, IAnimatedMeshSceneNode)
xnode.AddShadowVolumeSceneNode()
Dim selector As ITriangleSelector = Nothing
If Not (mapnode Is Nothing) Then
mapnode.Position = New Vector3D(0, 0, 0)
selector = smgr.CreateOctTreeTriangleSelector(mesh.GetMesh(0), mapnode, 128)
End If
mapnode.SetMaterialFlag(MaterialFlag.LIGHTING, True)
mapnode.SetMaterialFlag(MaterialFlag.NORMALIZE_NORMALS, True)
smgr.AddLightSceneNode(Nothing, New Vector3D(0, 10, 0), New Colorf(1.0F, 1.0F, 1.0F, 1.0F), 100, 0)
smgr.ShadowColor = New Color(100, 0, 0, 0)
' The Camera
cam = smgr.AddCameraSceneNodeFPS(smgr.RootSceneNode, 100, 50, -1)
cam.Position = New Vector3D(0, 5, 0)
Dim anim As ISceneNodeAnimator = smgr.CreateCollisionResponseAnimator(selector, cam, New Vector3D(2, 4, 2), New Vector3D(0, -2, 0), New Vector3D(0, 0, 0), 0)
'cam.AddAnimator(anim)
device.CursorControl.Visible = False
' Drawing Loop
Dim fps As Integer = 0
While device.Run() = True
If device.WindowActive Then
device.VideoDriver.BeginScene(True, True, New Color(0, 100, 100, 100))
device.SceneManager.DrawAll()
device.VideoDriver.EndScene()
device.EventReceiver = New MyEventReceiver()
If (fps <> device.VideoDriver.FPS) Then
fps = device.VideoDriver.FPS
device.WindowCaption = "Test1 [" + device.VideoDriver.Name + "] fps:" + fps.ToString
End If
End If
End While
End Sub
End Module