Who else has problems with GetCollsionPoint???
Just try the following code and explain me, why getcollsionpoint returns 0 ?! (its vb.net)
Code: Select all
Imports Irrlicht
Imports Irrlicht.Core
Imports Irrlicht.Video
Imports Irrlicht.Scene
Module modMain
Private irrDevice As IrrlichtDevice = New IrrlichtDevice(DriverType.OPENGL)
Private MainCam As ICameraSceneNode = irrDevice.SceneManager.AddCameraSceneNodeFPS(Nothing, 300, 300, 0)
Private triangleSelector As Irrlicht.Scene.ITriangleSelector
Sub Main()
irrDevice.FileSystem.AddZipFileArchive("..\..\media\map-20kdm2.pk3")
Dim tmpMesh As IAnimatedMesh = irrDevice.SceneManager.GetMesh("20kdm2.bsp")
Dim tmpNode As ISceneNode = irrDevice.SceneManager.AddOctTreeSceneNode(tmpMesh.GetMesh(0), Nothing, 0, 100)
triangleSelector = irrDevice.SceneManager.CreateOctTreeTriangleSelector(tmpMesh.GetMesh(0), tmpNode, 100)
MainCam.AddAnimator(irrDevice.SceneManager.CreateCollisionResponseAnimator(triangleSelector, MainCam, New Vector3D(10, 50, 10), New Vector3D(0, 0, 0), New Vector3D(0, 50, 0), 0.001))
Do While irrDevice.Run()
If irrDevice.WindowActive Then
irrDevice.VideoDriver.BeginScene(True, True, New Color(0, 100, 100, 100))
irrDevice.SceneManager.DrawAll()
Debug.Write("Y-Value of the CollisionPoint: '" & ReturnCollisionPointY() & "'" & vbCrLf)
irrDevice.VideoDriver.EndScene()
End If
Loop
End Sub
Private Function ReturnCollisionPointY() As Single
' Get the y.value of a CollsionPoint
' -> with getcollisionpoint
'
' [X] <-We are here (cam)
' |
' |
' |
' _ _|_________________________________ <- Ground (COLLISION!)
' |
' |
' |
' [X] <- Endpos is here
'
Dim CamPos As Vector3D
Dim EndPos As Vector3D
Dim ResPoint As Vector3D
Dim ray As Line3D
Dim ta As Triangle3D
CamPos = MainCam.Position
'Endpos ... look @ my "ascii-art" ;)
EndPos = New Vector3D(MainCam.Position.X, MainCam.Position.Y - 5000, MainCam.Position.Z)
ray.start = CamPos
ray.end = EndPos
If irrDevice.SceneManager.SceneCollisionManager.GetCollisionPoint(ray, triangleSelector, ResPoint, ta) Then
' COLLISION!
Return ResPoint.Y
Else
Return -1
End If
End Function
End Module
Greets
Mr.Y