Collision problem (getWorldCoordinates method problem)

ok, ive had this problem for a while, but i never got a chance to actually look into it. and today i gave it a try, but i just cant get a clue… :frowning:



i set up a collision detection method by using ray.



the first click always result in a ray direction of (0,0,1) which is not correct. and after that, everything works fine.



whats the problem here.



heres a part of the code



      Vector3f mouseWorldCoords = this.display.getWorldCoordinates(mouseScreenCoords, 0);
      Vector3f mouseWorldCoords2 = this.display.getWorldCoordinates(mouseScreenCoords, 1);
      Vector3f direction = mouseWorldCoords2.subtractLocal(mouseWorldCoords).normalizeLocal();
      Ray ray = new Ray(mouseWorldCoords, direction);

i have another problem, my character cant move to a position when the camera is facing one direction, but it works fine if the camera rotates to another direction.



i think there might be some problems with the getWorldCoordinates() method.



can someone plz check~thx  :smiley:

Not sure this is related to the second problem, but getModelViewMatrix initializes the needed matrix when called the first time. Probably there's a bug in the initialization causing the first problem, but I have no time to debug that.

irrisor said:

Not sure this is related to the second problem, but getModelViewMatrix initializes the needed matrix when called the first time. Probably there's a bug in the initialization causing the first problem, but I have no time to debug that.


thx for the info, ill c if i can debug it.

and since im not an expert...still need help on this~  :lol:

HELP~~~

i believe the second problem is caused by incorrect world coordinates returned by the camera.getWorldCoordinates(Vector2f, float, Vector3f) method.



can one of u developers confirm this plz~

Confirmed and hot-fixed: instead of calling onFrameChange, doFrameChange is called (with lwjgl calls) now. In multi-threaded (or multi-context) apps this means getWorld/ScreenCoordinates must be called in the correct thread/context the first time it is called.