1 (edited by HondaDarrell 2007-04-15 00:53:16)

Topic: Problem with collision result position

I am using the irrlicht collision manager to move the user.
I am confused with the command GetCollisionResultPosition.
I get an error about an "Unhandled Exception:Attempt to access field or method of Null object" about vector3df().
I'm also not sure how to use the resulting triangle position and find if the ellipsoid is falling. But I'll just post that on the irrlicht forums.

User.Node.setPosition( Col.getCollisionResultPosition( Selector, EllipsoidPos, EllipsoidRad, Velocity, TriOut, BFalling, SlideVal, Gravitation ))"

Re: Problem with collision result position

greetings smile  you need to make sure all your parameters are valid Irrlicht objects.  ie you need to perform at least a create() function or _ function on them.

the bOutFalling:Int Ptr parameter is a return parameter and stores True/False.  True if the ellipsoid is falling.

the triout:Triangle3df parameter is also a return parameter and needs to be a valid triangle object when you pass it in.  so:  triout=Triangle3df.create()  before you call the function.

since your reporting it on a vector3df, make sure that the pos, rad, velocity, and gravity vectors are also valid objects.  they are not return parameters so i would check where they are coming from for a possible bug.

if that doesnt work a little more code and i can probably spot whats up.

HTH

Re: Problem with collision result position

I am still receiving the same error. Here is what I'm working with.

Global Grv:Vector3df = Vector3df.createFromVals( 0, 0.5, 0 )

'///////////////////// Map //////////////////////
Local BSP:IAnimatedMesh = Scn.getMesh( "rok.bsp" )
Local Map:ISceneNode

If( BSP.isValid()) Then Map = Scn.addOctTreeSceneNode( Bsp.getMesh( 0 ))

Global Slc:ITriangleSelector

If( Map.isValid())
    Map.setPosition( Vector3df.createFromVals( 0, 0, 0 ))
    
     Slc = Scn.createOctTreeTriangleSelector( BSP.getMesh( 0 ), Map, 128 )
    Map.setTriangleSelector( Slc )
EndIf

'////////////////// Game Types //////////////////
Type User
    Global Mesh:IAnimatedMeshMS3D    'User Mesh
    Global Node:IAnimatedMeshSceneNode    'User Scenenode
    Global Ellipsoid:Vector3df = Vector3df.createFromVals( 15, 15, 15 )    'User Collision Ellipsoid
    Global Velocity:Vector3df = Vector3df.create()    'User Velocity
    Global State:String    'User State
    Global Stealth:Int    'Level of Stealth
    Global Health:Float    'User Health
    Global Armor:Float    'User Armor
    Global Item:String[][]    'User Item Name, Selected Item Slot
    Global Weapon:String[][]    'User Weapon Name, Selected Weapon Slot
    Global Animation:Int[][] = [[1, 41], [1, 1], [1, 1], [120, 153], [89, 119]] 'Stand, Walk, Run, Jump, Crawl
    Global Triangle:Triangle3df = Triangle3df.create()
    Global Fall:Int Ptr    'User is Falling
    
    Function Create:User( Pos:Vector3df, Msh:IAnimatedMeshMS3D )
        Local U:User = New User    'New User Instance
        
        User.MESH = Msh
        User.State = "Stand"
        User.Node = Scn.addAnimatedMeshSceneNode( U.MESH )
        User.Node.setPosition( Pos )
        User.Node.setMaterialFlag( EMF_LIGHTING, False )
        User.Node.setDebugDataVisible( True )
        User.Node.setAnimationSpeed( 0 )
        Return U
    End Function
    
    Function Update()
        Select User.State
            Case "Stand"
                If User.Node.getFrameNr() > User.Animation[0][1] Then User.Node.setCurrentFrame( User.Animation[0][0] )
            Case "Walk"
                If User.Node.getFrameNr() > User.Animation[1][1] Then User.Node.setCurrentFrame( User.Animation[1][0] )
            Case "Run"
                If User.Node.getFrameNr() > User.Animation[2][1] Then User.Node.setCurrentFrame( User.Animation[2][0] )
            Case "Jump"
                If User.Node.getFrameNr() > User.Animation[3][1] Then User.Node.setCurrentFrame( User.Animation[3][0] )
            Case "Flip"
                If User.Node.getFrameNr() > User.Animation[3][1] Then User.Node.setCurrentFrame( User.Animation[3][0] )
            Case "Leap"
            Case "Crouch"
            Case "Crawl"
                If User.Node.getFrameNr() > User.Animation[4][1] Then User.Node.setCurrentFrame( User.Animation[4][0] )
            Case "Climb"
            Case "Fall"
            Case "Use"
            Case "Action"
            Case "Hurt"
            Case "Dead"
        End Select
        
        User.Node.setPosition( Col.getCollisionResultPosition( Slc, User.Node.getPosition(), User.Ellipsoid, User.Velocity, User.Triangle, User.Fall, 0.0005, Grv ))
    End Function
End Type

Re: Problem with collision result position

to narrow it down, lets put this in front of your user.node.setposition(col.getcollisionresultposition()) call:

        If Not user Or Not user.node Or Not user.node.isvalid() Or Not user.node.getposition() Then RuntimeError "user"
        If Not user.Ellipsoid Or Not user.Ellipsoid.isvalid() Then RuntimeError "ellipsoid"
        If Not user.velocity Or Not user.velocity.isvalid() Then RuntimeError "velocity"
        If Not user.triangle Or Not user.triangle.isvalid() Then RuntimeError "triangle"
        If Not grv Or Not grv.isvalid() Then RuntimeError "gravity"
        If Not Col.getCollisionResultPosition( Slc, User.Node.getPosition(), User.Ellipsoid, User.Velocity, User.Triangle, User.Fall, 0.0005, Grv ) Then RuntimeError "getcollisionresultposition"

Re: Problem with collision result position

It showed no other runtime errors. Besides "Unhandled Exception:Unhandled Memory Exception Error"

Re: Problem with collision result position

is it still giving you that on the setposition(getcollisionresultposition())?  this may seem like a silly question but i have to ask...  have you checked for any copies of the v1.2 DLL that it may be using instead of the v1.3?

Re: Problem with collision result position

I was using 1.2 but now that I switched I receive an "Unhandled Exception:Unhandled Memory Exception Error" error for getMesh:IAnimatedMesh(). The DLLs and Mod Caches are updated for 1.3.

Here's where the mesh is loaded

Global Usr:User = User.Create( Vector3df.createFromVals( 300, 800, 30 ), IAnimatedMeshMS3D( Scn.getMesh( "Media/NinjaTest.ms3d" )))

Re: Problem with collision result position

could you please run in debug and then post the debug output?

thx.

9 (edited by HondaDarrell 2007-04-16 18:57:24)

Re: Problem with collision result position

Re: Problem with collision result position

is Media/Maps.pk3 in the proper path and is rok.bsp still in there?  erroring where it is usually means it cant find it.  is it still the attempt to access field or method of null object?  if at all possible, we may need to zip it up and send it to me to track it down.  if your willing of course.

Re: Problem with collision result position

I eMailed you the code.

Re: Problem with collision result position

found it.  while the collision function takes an int ptr to tell if its falling, what you pass in must be a ptr to an actual int variable so it has a place to store the value.  two changes are needed.  change your Type user global from:

Global Fall:Int Ptr    'User is Falling

to

Global Fall:Int    'User is Falling

and in User.Update() change:

User.Node.setPosition( Col.getCollisionResultPosition( Slc, User.Node.getPosition(), User.Ellipsoid, User.Velocity, User.Triangle, User.Fall, 0.0005, Grv ))

to

User.Node.setPosition( Col.getCollisionResultPosition( Slc, User.Node.getPosition(), User.Ellipsoid, User.Velocity, User.Triangle, Varptr(User.Fall), 0.0005, Grv ))

and you should be on your way smile

Re: Problem with collision result position

I'm still having a problem loading my bsp map. I can load other models as maps.
Could there be a problem with how I load the map from a pk3. Did you have any problem loading the map?

Re: Problem with collision result position

are you getting a crash or is it not showing?  i did not have a problem (at least i think).  nothing crashed and there was a cool looking level with grassy hilltops.  i removed your project already...  could you email me the link again?  i will redownload, zip, and send back to you.

15 (edited by HondaDarrell 2007-04-17 09:20:55)

Re: Problem with collision result position

Ah ok, I think my pk3 was corrupt.
Now my game is working. Thank You, gman.

Re: Problem with collision result position

one big difference between v1.2 and v1.3 of the mod is that now when the C++ Irrlicht method return null pointer, the mod now returns a Null BMAX object.  before it would return a valid BMAX object, but the handle would be 0 and you would have to check IsValid().  got your email will take a look over lunch.

Re: Problem with collision result position