GetCollsionPoint BUG

Irrlicht.Net is no longer developed or supported, Irrlicht.Net Cross Platform is a much more complete wrapper. Please ask your C# related questions on their forums first.
Locked
Mr. Y

GetCollsionPoint BUG

Post by Mr. Y »

Hi!

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


Has anyone a fix for this problem? Or does anyone know if its fixed in the next version of irrlicht?

Greets
Mr.Y
Raedwulf
Posts: 62
Joined: Sat Aug 20, 2005 7:08 am

Post by Raedwulf »

Yes I think its a bug. You'll have to wait for next version.
Read this http://www.irrlicht3d.org/pivot/entry.php?id=115
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Yep, I'll try to repair it. Won't take long.
Mr. Y

Post by Mr. Y »

It isn't corrected in the new irrlicht 0.12, rigth? :cry:
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Mr. Y wrote:It isn't corrected in the new irrlicht 0.12, rigth? :cry:
What? It should be. Doesn't it work?
Mr. Y

Post by Mr. Y »

May be iam doing something very wrong but my code returns always "0" for the Y-Value of the "outcollisionPoint"... The function itself returns true if the cam is above the map...

Just try it yourself. The code i posted can be copied/pasted and will run without any other code. (takes about 2min)

But all the other improvements are very nice! Great Job, Niko! :D

Mr. Y
Mr. Y

Post by Mr. Y »

Okay, i fixed the code in the .net wrapper.dll ... it works now... but my solution is not the best

Code: Select all


	Core::Vector3D ISceneCollisionManager::GetCollisionPoint(Core::Line3D ray,
		Scene::ITriangleSelector* selector, 
		[PARAMFLAG::Out] Core::Vector3D outCollisionPoint,
		[PARAMFLAG::Out] Core::Triangle3D outTriangle)
	{
		irr::core::vector3df outCP;
		irr::core::triangle3df outTr;

		bool ret = SCM->getCollisionPoint(
			irr::NativeConverter::getNativeLine(ray),
			selector ? selector->get_NativeTriangleSelector() : 0,
			outCP,
			outTr);

		outCollisionPoint = irr::NativeConverter::getNETVector(outCP);
		outTriangle = irr::NativeConverter::getNETTriangle(outTr);

		return irr::NativeConverter::getNETVector(outCP);
	}

Mr. Y[/url]
Locked