Other [FIXED] JPCT and collisionlisteners

John.E

Member
Licensed User
Longtime User
Has anyone used the JPCT collision listeners? I have been playing but I keep generating initialisation errors. Code goes some thing like this...

Sub Process_Globals

Dim ball1 As JpctObject3D
Dim prim As JpctPrimitives
Dim ball1cl As JpctCollisionListener

End Sub

Sub Activity_Create(FirstTime As Boolean)

/* lots missing here */

ball1.Initialize3(prim.getSphere(10))
ball1cl.Initialize("ball1", False) /* have also tried ... ball1cl.initialise("ball1_collision_listener", false)
ball1.CollisionMode = ball1.COLLISION_CHECK_SELF
ball1.addCollisionListener(ball1cl)

/* more missing here */

end sub

Sub ball1_collision_listener(coleven As Int)
Log("ball1 collision")
End Sub

Errors tell me I need to initialise ball1cl when I try and bind it with ball1.addCollisionListener.

Anyone got any pointer as to what I have missed? fouled up?

Cheers in advance, John

P.S. I think this may be in the wrong place! If it is can a mod move to the correct location please. Sorry in advance.
 
Last edited:

John.E

Member
Licensed User
Longtime User
Fixed it :) Syntax is :-

Sub Process_Globals
Dim ball1cl As JpctCollisionListener
End Sub

Sub Activity_Create(FirstTime As Boolean)
/* lots chooped here */
ball1cl.Initialize("ball1", False)
/* more chopped here */
End sub

Sub ball_CollisionListener(getAlgorithm As Int, getPolygonIDs() As Int, getType As Int, toString As String, getFirstContact As JpctSimpleVector, getObject As JpctObject3D, getSource As JpctObject3D, getTargets() As JpctObject3D)
Log("ball1 collision")
End Sub

Just needed to engage brain and take a look at the wrapper sources :)
 
Last edited:
Upvote 0

John.E

Member
Licensed User
Longtime User
So the saga continues :)

Having got a collision system working (or so I thought) it now fails on compile with :-

Error description: Parameter name cannot hide global variable name.

Ah ha thinks I, change the offending getType to clGetType. Doh, nope :(

Then builds and executes until a collision an then the debugger reports:-

java.lang.Exception: Sub ball_collisionlistener signature does not match expected signature.
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

on this call:-

ball1.checkForCollisionSpherical(cVect, 10)

Ho hum :( anyone else had these problem or am I breaking ground here :)

Have enclosed the source, if anyone has time I would appreciate any feedback on what I am missing.
 

Attachments

  • jpctcollisiontest.zip
    2 KB · Views: 220
Upvote 0

ricardossy1

Member
Licensed User
Longtime User
Bonjour,

Fixed it :) Syntax is : (some fields may be returned Null !)


Sub ball_CollisionListener(getAlgorithm As Int,getPolygonID1() As Int,clgetType As Int, toString As String,Obj5 As Object,Obj6 As Object,Obj7 As Object ,Obj8 As Object)

Log("COLLISION: registered collision event :)")
If Obj5<>Null Then
Dim getFirstContact As JpctSimpleVector
getFirstContact=Obj5
End If

If Obj6<>Null Then
Dim getObject As JpctObject3D
getObject=Obj6
End If

If Obj7<>Null Then
Dim GetSource As JpctObject3D
GetSource=Obj7
End If
End Sub
 
Upvote 0

John.E

Member
Licensed User
Longtime User
Thank you so much for the fix (Makes mental note to self...). Now onwards with the grand plan (well, until the next hurdle) ;)
 
Upvote 0
Top