Code: Select all
#Const EngineType_IrrlichtLime = 1
#Const EngineType_DarkGDK = 2
Imports IrrlichtLime
Imports IrrlichtLime.Core
Imports IrrlichtLime.GUI
Imports IrrlichtLime.IO
Imports IrrlichtLime.Video
Imports IrrlichtLime.Scene
Imports System
Imports System.IO
Imports System.Data.OleDb
Imports System.Math
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports Microsoft.VisualBasic
Public Class Form1
'IRRLICHT 3D ENGINE. ABLE TO USE OPEN GL, SOFTWARE, DIRECTX, PLUS CUSTOM SOFTWARE
'IRRLICHTLINE - ALLOWS ENGINE TO INTERFACE WITH MICROSOFTs VISUAL STUDIO, VISUAL BASIC.NET (4.0), C#.
'DARKIRRLICHT - ALLOWS ENGINE TO INTERFACE WITH THE GAME CREATORs DARK BASIC PROFESSIONAL.
Public bbox As New AABBox()
Public vertices As Vertex3D()
Public materialx As Video.Material
Public materiall As Material
Public Shared terrain As TerrainSceneNode
Public Shared skybox As SceneNode
Public Shared skydome As SceneNode
Public Shared camera As CameraSceneNode
Public DriverCode As Integer
Public driverType As DriverType = driverType.Direct3D9
Public Driver As VideoDriver
Public Light0 As SceneNode
Public Shared envgui As GUIEnvironment
Public Shared smgr As SceneManager
Public Shared EndProgram As Boolean
Public Shared device As IrrlichtDevice
Public Shared listbox As GUIListBox
Public Shared animc As SceneNodeAnimator
Public Shared selector As TriangleSelector
Public Shared winPosCounter As Integer = 0
Public Shared showBox As Boolean
Public Shared showDebug As Boolean
Public Const GUI_ID_ButtonQuit As Integer = 101
Public Const GUI_ID_ButtonWindowNew As Integer = 102
Public Const GUI_ID_ButtonFileOpen As Integer = 103
Public Const GUI_ID_ScrollbarTransparency As Integer = 104
Public Shared WinCursor As Boolean
'Trigonmetric Constants
Public Const Pi As Double = System.Math.PI
Public Const Degree_Convert As Double = 180 / System.Math.PI
Public WallMesh(9) As Mesh
Public WallNode(9) As SceneNode
Private Sub Form1_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
If e.KeyCode = Keys.Escape Then EndProgram = True
End Sub
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
EndProgram = False
Me.Visible = True
WinCursor = False
End Sub
Public Sub InitSample()
device = IrrlichtDevice.CreateDevice(driverType, New Dimension2Di(1280, 1024), 32, True, False, False)
device.SetWindowCaption("Irrlicht Project!")
Dim driver As VideoDriver = device.VideoDriver
Dim smgr As SceneManager = device.SceneManager
Dim gui As GUIEnvironment = device.GUIEnvironment
Do While device.Run()
driver.BeginScene(True, True, New Color(100, 101, 140))
smgr.DrawAll()
gui.DrawAll()
driver.EndScene()
Loop
device.Drop()
End Sub
Public Sub CombinedSample()
Dim lastFPS As Integer = -1
device = IrrlichtDevice.CreateDevice(driverType, New Dimension2Di(1024, 768))
If (device Is Nothing) Then
Return
End If
device.SetWindowCaption("Irrlicht Engine - User Interface Demo")
device.SetWindowResizable(True)
envgui = device.GUIEnvironment
smgr = device.SceneManager
Driver = device.VideoDriver
device.FileSystem.AddFileArchive("media/map-20kdm2.pk3")
Dim skin As GUISkin = envgui.Skin
Dim font As GUIFont = envgui.GetFont("media/fonthaettenschweiler.bmp")
Dim mesh1 As AnimatedMesh = smgr.GetMesh("media/sydney.md2")
Dim node1 As AnimatedMeshSceneNode = smgr.AddAnimatedMeshSceneNode(mesh1)
Dim node2 As SceneNode = smgr.AddCubeSceneNode()
Dim node3 As SceneNode = smgr.AddSphereSceneNode()
Dim node4 As SceneNode = Nothing
Dim node5 As New CSampleSceneNode(smgr.RootNode, smgr, 667)
Dim anim1 As SceneNodeAnimator = smgr.CreateFlyCircleAnimator(New Vector3Df(15, -16, 45), 15.0F, 0.002F)
Dim anim2 As SceneNodeAnimator = smgr.CreateFlyStraightAnimator(New Vector3Df(200, -15, 10), New Vector3Df(-200, -15, 10), 6.5F, True)
Dim anim3 As SceneNodeAnimator = smgr.CreateFlyStraightAnimator(New Vector3Df(-979999, 38400, -299999), New Vector3Df(979999, 38400, 299999), 120.0F, True)
Dim anim4 As SceneNodeAnimator = smgr.CreateRotationAnimator(New Vector3Df(0.0025, 0.0031, 0.0049))
Dim anim5 As SceneNodeAnimator = smgr.CreateRotationAnimator(New Vector3Df(0.8F, 0, 0.8F))
Dim mesh6 As AnimatedMesh = smgr.GetMesh("20kdm2.bsp")
Dim anms As AnimatedMeshSceneNode = smgr.AddAnimatedMeshSceneNode(smgr.GetMesh("media/ninja.b3d"))
Dim scrollbar As GUIScrollBar = envgui.AddScrollBar(True, New Recti(150, 45, 350, 60), Nothing, GUI_ID_ScrollbarTransparency)
Dim trq As GUIStaticText = envgui.AddStaticText("Logging ListBox:", New Recti(50, 110, 250, 130), True)
Light0 = smgr.AddLightSceneNode(Nothing, New Vector3Df(0, 4096, 0), New Colorf(0.5, 1.0, 0.5, 1.0), 65535, 1)
Light0.Visible = True
'material.Wireframe = True
camera = smgr.AddCameraSceneNodeFPS(Nothing, 100.0, 1.2)
camera.Position = New Vector3Df(2700, 255 * 2, 2600)
camera.Target = New Vector3Df(2397 * 2, 343 * 2, 2700 * 2)
camera.FarValue = 999999.0F
Make_Tunnel()
Init_Meshes()
If node1 IsNot Nothing Then
node1.SetMaterialFlag(MaterialFlag.Lighting, False)
node1.SetMD2Animation(AnimationTypeMD2.Stand)
node1.SetMaterialTexture(0, Driver.GetTexture("media/sydney.bmp"))
End If
If node2 IsNot Nothing Then
node2.Position = New Vector3Df(256, 20480, 2048)
node2.SetMaterialTexture(0, Driver.GetTexture("media/borg.bmp"))
node2.SetMaterialFlag(MaterialFlag.Lighting, False)
node2.Scale = New Vector3Df(2048, 2048, 2048)
If anim4 IsNot Nothing Then
node2.AddAnimator(anim4)
node2.AddAnimator(anim3)
anim3.Drop()
anim4.Drop()
End If
End If
If node3 IsNot Nothing Then
node3.SetMaterialTexture(0, Driver.GetTexture("media/t351sml.jpg"))
node3.SetMaterialFlag(MaterialFlag.Lighting, False)
node3.Position = New Vector3Df(20, 5, 10)
If anim1 IsNot Nothing Then
node3.AddAnimator(anim1)
anim1.Drop()
End If
End If
If mesh6 IsNot Nothing Then
node4 = smgr.AddOctreeSceneNode(mesh6.GetMesh(0), Nothing, -1, 1024)
End If
If node4 IsNot Nothing Then
node4.Position = New Vector3Df(-1300, -88, -1249)
End If
If anim5 IsNot Nothing Then
node5.Position = New Vector3Df(-10, 12, 5)
node5.AddAnimator(anim5)
anim5.Drop()
anim5 = Nothing
End If
Init_Terrain()
If anms IsNot Nothing Then
If anim2 IsNot Nothing Then
anms.AddAnimator(anim2)
anim2.Drop()
End If
anms.SetMaterialFlag(MaterialFlag.Lighting, False)
anms.SetFrameLoop(0, 13)
anms.AnimationSpeed = 15
anms.Scale = New Vector3Df(5)
anms.Rotation = New Vector3Df(0, -90, 0)
End If
'smgr.AddCameraSceneNodeFPS()
If (Not (font) Is Nothing) Then
skin.SetFont(font)
End If
envgui.Skin.SetFont(envgui.GetFont("media/fontlucida.png"))
envgui.Skin.SetColor(New Color(255, 0, 192), GUIDefaultColor.ButtonText)
envgui.Skin.SetColor(New Color(0, 32, 64), GUIDefaultColor.AppWorkspace)
skin.SetFont(envgui.BuiltInFont, GUIDefaultFont.Tooltip)
envgui.AddButton(New Recti(10, 240, 110, (240 + 32)), Nothing, GUI_ID_ButtonQuit, "Quit", "Exits Program")
envgui.AddButton(New Recti(10, 280, 110, (280 + 32)), Nothing, GUI_ID_ButtonWindowNew, "New Window", "Launches a new Window")
envgui.AddButton(New Recti(10, 320, 110, (320 + 32)), Nothing, GUI_ID_ButtonFileOpen, "File Open", "Opens a file")
envgui.AddStaticText("Transparent Control:", New Recti(150, 20, 350, 40), True, True, Nothing, -1, True)
envgui.AddEditBox("Editable Text", New Recti(750, 0, 950, 20))
scrollbar.MaxValue = 255
scrollbar.Position = CType(envgui.Skin.GetColor(GUIDefaultColor.WindowBackground).Alpha, Integer)
listbox = envgui.AddListBox(New Recti(50, 140, 250, 210))
AddHandler device.OnEvent, AddressOf Form1.device_OnEvent
'envgui.AddImage(driver.GetTexture("../../media/irrlichtlogoalpha2.tga"), New Vector2Di(10, 10))
'smgr.AddCameraSceneNode(Nothing, New Vector3Df(0, 30, -40), New Vector3Df(0, 5, 0))
Dim fps As Integer = Driver.FPS
While device.Run() And EndProgram = False
If device.WindowActive Then
Driver.BeginScene(True, True, New Color(200, 200, 200))
smgr.DrawAll()
envgui.DrawAll()
Driver.EndScene()
If lastFPS <> fps Then
envgui.AddStaticText([String].Format("Irrlicht Engine - User Interface Demo - Irrlicht Engine [{0}] fps: {1}", Driver.Name, fps), New Recti(20, 2, 600, 22), True, True, Nothing, -1, True)
lastFPS = fps
End If
'device.SetWindowCaption([String].Format("Terrain rendering example - Irrlicht Engine [{0}] fps: {1} Height: {2}", driver.Name, fps, terrain.GetHeight(camera.AbsolutePosition.X, camera.AbsolutePosition.Z)))
End If
End While
device.Drop()
End
End Sub
Shared KeyIsDown As New Dictionary(Of KeyCode, Boolean)
Private Shared Function device_OnEvent(e As [Event]) As Boolean
If e.Type = EventType.Key Then
If KeyIsDown.ContainsKey(e.Key.Key) Then
KeyIsDown(e.Key.Key) = e.Key.PressedDown
Else
KeyIsDown.Add(e.Key.Key, e.Key.PressedDown)
End If
End If
If (e.Type = EventType.GUI) Then
Dim id As Integer = e.GUI.Caller.ID
Select Case (e.GUI.Type)
Case GUIEventType.ScrollBarChanged
If (id = GUI_ID_ScrollbarTransparency) Then
Dim pos As Integer = CType(e.GUI.Caller, GUIScrollBar).Position
For Each which As GUIDefaultColor In [Enum].GetValues(GetType(GUIDefaultColor))
Dim color As Color = envgui.Skin.GetColor(which)
color.Alpha = pos
envgui.Skin.SetColor(color, which)
Next
End If
Case GUIEventType.ButtonClicked
Select Case (id)
Case GUI_ID_ButtonQuit
device.Close()
Return True
Case GUI_ID_ButtonWindowNew
listbox.AddItem("Window created")
winPosCounter = (winPosCounter + 30)
If (winPosCounter > 200) Then
winPosCounter = 0
End If
Dim c As Integer = winPosCounter
Dim window As GUIWindow = envgui.AddWindow(New Recti((100 + c), (100 + c), (300 + c), (200 + c)), False, "Test window")
envgui.AddStaticText("Please close me", New Recti(35, 35, 140, 50), True, False, window)
Return True
Case GUI_ID_ButtonFileOpen
listbox.AddItem("File open")
' There are some options for the file open dialog
' We set the title, make it a modal window, and make sure
' that the working directory is restored after the dialog
' is finished.
envgui.AddFileOpenDialog("Please choose a file", True, Nothing, -1, True)
Return True
Case Else
Return False
End Select
Case GUIEventType.FileDialogFileSelected
' show the filename, selected in the file dialog
Dim d As GUIFileOpenDialog = CType(e.GUI.Caller, GUIFileOpenDialog)
listbox.AddItem(d.FileName)
Exit Select
End Select
End If
If e.Type = EventType.Key AndAlso e.Key.PressedDown Then
Select Case e.Key.Key
Case KeyCode.Esc
EndProgram = True
Case KeyCode.KeyW
' switch wire frame mode
terrain.SetMaterialFlag(MaterialFlag.Wireframe, Not terrain.GetMaterial(0).Wireframe)
terrain.SetMaterialFlag(MaterialFlag.PointCloud, False)
Return True
Case KeyCode.KeyP
' switch point cloud mode
terrain.SetMaterialFlag(MaterialFlag.PointCloud, Not terrain.GetMaterial(0).PointCloud)
terrain.SetMaterialFlag(MaterialFlag.Wireframe, False)
Return True
Case KeyCode.KeyC
' toggle WinCursor
WinCursor = True ' Not WinCursor
If WinCursor = False Then
'selector = smgr.CreateTerrainTriangleSelector(terrain, 0)
animc = smgr.CreateCollisionResponseAnimator(selector, camera, New Vector3Df(60, 100, 60), New Vector3Df(0, 0, 0), New Vector3Df(0, 50, 0))
camera.AddAnimator(animc)
device.CursorControl.Visible = False
ElseIf WinCursor = True Then
camera.RemoveAnimator(animc)
camera.RemoveAnimators()
animc.Drop()
'selector.Drop()
device.CursorControl.Visible = True
End If
Return True
Case KeyCode.KeyD
' toggle detail map
terrain.SetMaterialType(If(terrain.GetMaterial(0).Type = MaterialType.Solid, MaterialType.DetailMap, MaterialType.Solid))
Return True
Case KeyCode.KeyS
' toggle skies
showBox = Not showBox
skybox.Visible = showBox
skydome.Visible = Not showBox
Return True
Case KeyCode.KeyX
' toggle debug information
showDebug = Not showDebug
terrain.DebugDataVisible = If(showDebug, DebugSceneType.BBoxAll, DebugSceneType.Off)
Return True
End Select
End If
Return False
End Function
Private Shared Function IsKeyDown(keyCode As KeyCode) As Boolean
Return If(KeyIsDown.ContainsKey(keyCode), KeyIsDown(keyCode), False)
End Function
Private Sub RadioButton1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton1.CheckedChanged
DriverCode = 1
driverType = driverType.BurningsVideo
End Sub
Private Sub RadioButton2_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton2.CheckedChanged
DriverCode = 2
driverType = driverType.Direct3D8
End Sub
Private Sub RadioButton3_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton3.CheckedChanged
DriverCode = 3
driverType = driverType.Direct3D9
End Sub
Private Sub RadioButton4_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton4.CheckedChanged
DriverCode = 4
driverType = driverType.Null
End Sub
Private Sub RadioButton5_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton5.CheckedChanged
DriverCode = 5
driverType = driverType.OpenGL
End Sub
Private Sub RadioButton6_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton6.CheckedChanged
DriverCode = 6
driverType = driverType.Software
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Panel1.Visible = False
CombinedSample()
End Sub
Public Sub Init_Terrain()
skybox = smgr.AddSkyBoxSceneNode("media/irrlicht2_up.jpg", "media/irrlicht2_dn.jpg", "media/irrlicht2_lf.jpg", "media/irrlicht2_rt.jpg", "media/irrlicht2_ft.jpg", "media/irrlicht2_bk.jpg")
skydome = smgr.AddSkyDomeSceneNode(Driver.GetTexture("media/skydome.jpg"), 16, 8, 0.95F, 2)
terrain = smgr.AddTerrainSceneNode("media/heightmap2.bmp", Nothing, -1, New Vector3Df(), New Vector3Df(), New Vector3Df(40, 4.4F, 40), New Color(255, 255, 255), 5, TerrainPatchSize._17, 4)
selector = smgr.CreateTerrainTriangleSelector(terrain, 0)
Dim lastFPS As Integer = -1
Dim TerrainEvent As New TerrainEventReceiver(device, terrain, skybox, skydome)
terrain.Scale = New Vector3Df(64, 8, 64)
terrain.Position = New Vector3Df(-8192, -48, -8192)
Driver.SetTextureCreationFlag(TextureCreationFlag.Always32Bit, True)
' add irrlicht logo
'envgui.AddImage(driver.GetTexture("media/irrlichtlogoalpha2.tga"), New Vector2Di(10))
' set gui font
' add some help text
envgui.AddStaticText("Press 'W' to change wireframe mode" & vbLf & "Press 'C' to release Mouse" & vbLf & "Press 'D' to toggle detail map" & vbLf & "Press 'S' to toggle skybox/skydome" & vbLf & "Press 'P' to toggle Point Cloud" & vbLf & "Press 'X' to toggle Point Debug", New Recti(2, 512, 242, 640), True, True, Nothing, -1, True)
' add camera
' disable mouse cursor
' add terrain scene node
' heightmap
' parent node
' node id
' position
' rotation
' scale
' vertex color
' max LOD
' patch size
' smooth factor
terrain.SetMaterialFlag(MaterialFlag.Lighting, False)
terrain.SetMaterialTexture(0, Driver.GetTexture("media/terrain-texture.jpg"))
terrain.SetMaterialTexture(1, Driver.GetTexture("media/detailmap3.jpg"))
terrain.SetMaterialType(MaterialType.DetailMap)
terrain.ScaleTexture(1, 20)
' create triangle selector for the terrain
terrain.TriangleSelector = selector
terrain.OverrideLODDistance(4, 16384)
' create collision response animator and attach it to the camera
animc = smgr.CreateCollisionResponseAnimator(selector, camera, New Vector3Df(60, 100, 60), New Vector3Df(0, 0, 0), New Vector3Df(0, 50, 0))
device.CursorControl.Visible = False
' create skybox and skydome
Driver.SetTextureCreationFlag(TextureCreationFlag.CreateMipMaps, False)
Driver.SetTextureCreationFlag(TextureCreationFlag.CreateMipMaps, True)
' create event receiver
showBox = True
showDebug = False
End Sub
Sub Init_Meshes()
Dim buf0 As MeshBuffer = MeshBuffer.Create(VertexType.Standard, IndexType._16Bit)
Dim buf1 As MeshBuffer = MeshBuffer.Create(VertexType.Standard, IndexType._16Bit)
Dim buf2 As MeshBuffer = MeshBuffer.Create(VertexType.Standard, IndexType._16Bit)
Dim buf3 As MeshBuffer = MeshBuffer.Create(VertexType.Standard, IndexType._16Bit)
Dim buf4 As MeshBuffer = MeshBuffer.Create(VertexType.Standard, IndexType._16Bit)
Dim vertices(7 * 2 - 1) As Vertex3D
Dim indices(5 * 6 - 1) As UShort
Dim indices4 As UShort() = New UShort() {0, 1, 2, 1, 3, 2} ',
Dim i As Integer
Dim j As Single
Dim k As Integer
Dim v As Integer
Dim iColor As New Video.Color(40, 40, 255)
k = 0
i = 0
v = 0
For v = 0 To 6 Step 2
If j < 384 Then
indices(k + 0) = v + 0
indices(k + 1) = v + 1
indices(k + 2) = v + 2
indices(k + 3) = v + 1
indices(k + 4) = v + 3
indices(k + 5) = v + 2
k = k + 6
End If
Next
v = 0
i = 0
materialx = New Video.Material
materialx.SetTexture(0, Driver.GetTexture("media/wall02.jpg"))
materialx.BackfaceCulling = False
materialx.Type = MaterialType.Solid
materialx.Shininess = 128
materialx.Fog = False
materialx.SetFlag(MaterialFlag.Lighting, False)
materialx.SetFlag(MaterialFlag.NormalizeNormals, True)
materialx.Lighting = False
materialx.AmbientColor = New Color(0, 0, 0, 128)
materialx.DiffuseColor = New Color(0, 0, 0, 128)
materialx.EmissiveColor = New Color(0, 0, 0, 0)
materialx.SpecularColor = New Color(64, 32, 0, 128)
For j = 0 To 1536 Step 256
vertices(v + 0) = New Vertex3D(100, 200, j, 50, 0, j, New Color(255, 255, 255, 128), 0, i)
vertices(v + 1) = New Vertex3D(100, 0, j, 50, 0, j, New Color(255, 255, 255, 128), 1, i)
v = v + 2
i = i + 1
Next j
WallMesh(0) = IrrlichtLime.Scene.Mesh.Create
WallMesh(0).AddMeshBuffer(buf0)
buf0.Append(vertices, indices)
buf0.SetMaterial(materialx)
buf0.RecalculateBoundingBox()
buf0.Drop()
WallNode(0) = smgr.AddMeshSceneNode(WallMesh(0))
WallNode(0).SetMaterial(0, materialx)
WallNode(0).Position = New Vector3Df(-384, 768, 128)
WallNode(0).SetMaterialFlag(MaterialFlag.ColorMaterial, True)
'WallNode(0).SetMaterial(0, materialx)
WallMesh(0).SetMaterialFlag(MaterialFlag.Lighting, False)
WallMesh(0).SetMaterialFlag(MaterialFlag.ColorMaterial, True)
i = 0
v = 0
For j = 0 To 1536 Step 256
vertices(v + 1) = New Vertex3D(-100, 200, j, 0, 0, 0, New Color(255, 255, 255), 1, i)
vertices(v + 0) = New Vertex3D(-100, 0, j, 0, 0, 0, New Color(255, 255, 255), 0, i)
v = v + 2
i = i + 1
Next j
WallMesh(1) = IrrlichtLime.Scene.Mesh.Create
WallMesh(1).AddMeshBuffer(buf1)
buf1.Append(vertices, indices)
buf1.SetMaterial(materialx)
buf1.RecalculateBoundingBox()
buf1.Drop()
WallNode(1) = smgr.AddMeshSceneNode(WallMesh(1))
WallNode(1).SetMaterial(1, materialx)
WallMesh(1).SetMaterialFlag(MaterialFlag.Lighting, False)
WallNode(1).Position = New Vector3Df(-384, 768, 128)
'WallNode(1).SetMaterial(0, materialx)
i = 0
v = 0
For j = 0 To 1536 Step 256
vertices(v + 0) = New Vertex3D(-100, 200, j, 0, 0, 0, New Color(255, 255, 255), 0, i)
vertices(v + 1) = New Vertex3D(100, 200, j, 0, 0, 0, New Color(255, 255, 255), 1, i)
v = v + 2
i = i + 1
Next j
WallMesh(2) = IrrlichtLime.Scene.Mesh.Create
WallMesh(2).AddMeshBuffer(buf2)
buf2.Append(vertices, indices)
buf2.RecalculateBoundingBox()
buf2.Drop()
WallNode(2) = smgr.AddMeshSceneNode(WallMesh(2))
WallNode(2).Position = New Vector3Df(-384, 768, 128)
'WallNode(2).SetMaterial(0, materialx)
i = 0
v = 0
For j = 0 To 1536 Step 256
vertices(v + 0) = New Vertex3D(100, 0, j, 0, 0, j, New Color(255, 255, 255), 0, i)
vertices(v + 1) = New Vertex3D(-100, 0, j, 0, 0, j, New Color(255, 255, 255), 1, i)
v = v + 2
i = i + 1
Next j
WallMesh(3) = IrrlichtLime.Scene.Mesh.Create
WallMesh(3).AddMeshBuffer(buf3)
buf3.Append(vertices, indices)
buf3.RecalculateBoundingBox()
buf3.Drop()
WallNode(3) = smgr.AddMeshSceneNode(WallMesh(3))
WallNode(3).Position = New Vector3Df(-384, 768, 128)
'WallNode(3).SetMaterial(0, materialx)
vertices(0) = New Vertex3D(-100, 200, 0, 0, 0, 0, New Color(255, 255, 255), 0, 0)
vertices(1) = New Vertex3D(-100, 0, 0, 0, 0, 0, New Color(255, 255, 255), 0, 1)
vertices(2) = New Vertex3D(100, 200, 0, 0, 0, 0, New Color(255, 255, 255), 1, 0)
vertices(3) = New Vertex3D(100, 0, 0, 0, 0, 0, New Color(255, 255, 255), 1, 1)
WallMesh(4) = IrrlichtLime.Scene.Mesh.Create
WallMesh(4).AddMeshBuffer(buf4)
buf4.Append(vertices, indices4)
buf4.RecalculateBoundingBox()
buf4.Drop()
WallNode(4) = smgr.AddMeshSceneNode(WallMesh(4))
WallNode(4).Position = New Vector3Df(-384, 768, 128)
'materialx.MaterialTypeParam = 1
'materialx.MaterialTypeParam2 = 2
'materialx.ColorMask = ColorPlane.All
For i = 0 To 4
WallNode(i).SetMaterialFlag(MaterialFlag.BackFaceCulling, False)
WallNode(i).SetMaterialFlag(MaterialFlag.Lighting, False)
WallNode(i).SetMaterialFlag(MaterialFlag.NormalizeNormals, False)
WallNode(i).SetMaterialFlag(MaterialFlag.BlendOperation, True)
WallNode(i).SetMaterialTexture(0, Driver.GetTexture("media/wall02.jpg"))
WallNode(i).SetMaterialFlag(MaterialFlag.ColorMaterial, False)
WallNode(i).SetMaterialType(MaterialType.Solid)
smgr.MeshManipulator.SetVertexColors(WallMesh(i), New Color(255, 0, 0, 128))
WallNode(i).SetMaterial(0, materialx)
' WallNode(i).SetMaterial(1, materialx)
' WallNode(i).SetMaterial(2, materialx)
' WallNode(i).SetMaterial(3, materialx)
' WallNode(i).SetMaterial(4, materialx)
Next i
'WallNode(4).SetMaterial(0, materialx)
End Sub
End Class
Class CSampleSceneNode
Inherits SceneNode
Private bbox As New AABBox()
Private vertices As Vertex3D()
Private material As New Material()
Public Sub New(parent As SceneNode, smgr As SceneManager, id As Integer)
MyBase.New(parent, smgr, id)
vertices = New Vertex3D(5) {}
AddHandler Me.OnRegisterSceneNode, AddressOf CSampleSceneNode_OnRegisterSceneNode
AddHandler Me.OnRegisterSceneNode, AddressOf CSampleSceneNode_OnRegisterSceneNode
AddHandler Me.OnRender, AddressOf CSampleSceneNode_OnRender
AddHandler Me.OnGetBoundingBox, AddressOf CSampleSceneNode_OnGetBoundingBox
AddHandler Me.OnGetMaterialCount, AddressOf CSampleSceneNode_OnGetMaterialCount
AddHandler Me.OnGetMaterial, AddressOf CSampleSceneNode_OnGetMaterial
material.Wireframe = False
material.Lighting = False
' Very Similar to Truevisions 6.5 .AddVertex() statement, but color is before texture coordinates. Identical to TV 6.3< version of the command.
vertices(0) = New Vertex3D(3, 0, 3, 1, 1, 0, New Color(0, 0, 155), 1, 1)
vertices(1) = New Vertex3D(3, 0, -3, 1, 0, 0, New Color(0, 155, 0), 1, 0)
vertices(2) = New Vertex3D(-3, 0, -3, 0, 0, 1, New Color(0, 155, 155), 0, 0)
vertices(3) = New Vertex3D(-3, 0, 3, 0, 0, 1, New Color(155, 0, 0), 0, 1)
vertices(4) = New Vertex3D(0, 5, 0, 0, 1, 1, New Color(155, 0, 155), 0.5, 0.5)
vertices(5) = New Vertex3D(0, -5, 0, 0, 1, 1, New Color(155, 155, 0), 0.5, 0.5)
bbox.[Set](vertices(0).Position)
For i As Integer = 1 To 5
bbox.AddInternalPoint(vertices(i).Position)
Next i
End Sub
Private Sub CSampleSceneNode_OnRegisterSceneNode()
If Visible Then
SceneManager.RegisterNodeForRendering(Me)
End If
End Sub
Private Sub CSampleSceneNode_OnRender()
Dim indices As UShort() = New UShort() {5, 3, 2, 5, 1, 0, 5, 2, 1, 5, 0, 3, 4, 2, 3, 4, 0, 1, 4, 1, 2, 4, 3, 0}
Dim driver As VideoDriver = SceneManager.VideoDriver
driver.SetMaterial(material)
driver.SetTransform(TransformationState.World, AbsoluteTransformation)
driver.DrawVertexPrimitiveList(vertices, indices)
End Sub
Private Function CSampleSceneNode_OnGetBoundingBox() As AABBox
Return bbox
End Function
Private Function CSampleSceneNode_OnGetMaterialCount() As Integer
Return 1
End Function
Private Function CSampleSceneNode_OnGetMaterial(index As Integer) As Material
Return material
End Function
End Class
Class TerrainEventReceiver
Private terrain As SceneNode
Private skybox As SceneNode
Private skydome As SceneNode
Public Sub New(device As IrrlichtDevice, terrain As SceneNode, skybox As SceneNode, skydome As SceneNode)
Me.terrain = terrain
Me.skybox = skybox
Me.skydome = skydome
skybox.Visible = True
skydome.Visible = False
End Sub
End Class
I am looking to port a Role Playing Game Builder over to a different 3D engine. Right now it is using Truevision3D, but the people seem to had abandoned their 3D middleware. I am considering either IRRLICHT LIME or Dark GDK at this point to drive the 3D graphics part of