Jump to content

Problem with BABYLON.Ray


Shakes
 Share

Recommended Posts

Hey guys,

I am currently working on a litte project but I need to have a way to check if between two different Meshes theres another one. The current Situation is, that the Ray ignores Walls and just goes through them and so I get meshes which are behind obstacles.

For an example: I want to make some kind of this: http://babylonjs-playground.com/#1QF77H#2 --- Important here is, that the waypoints in my Code are imported by Blender and are saved in an Array (TP), if this maks any difference...

The problem is, I cannot transfer this into my code, and I since now I invested about 2 hours of testing an rewriting things but I always get far too many points.Maybe the problem is the if-statement in line 12 (screen).

 

I really hope you guys can help me :)

Shakes

Auswahl_001.png

EDIT: Sorry for all grammar and/or other mistakes :/

Link to comment
Share on other sites

Hello

can you please create a repro on the Playground? It is tough to help you just with a screen capture :)

However some things are suspicious:

- intersectsBox requires a bounding box (http://doc.babylonjs.com/classes/2.5/Ray#intersectsbox-box-rarr-boolean) and not a bounding info so it should be ray.intersectsBox(otherMesh.getBoundingInfo().boundingBox

- intersectsBox works in mesh world so I suggest using a simpler version with:

ray = BABYLON.Ray.Transform(ray, BABYLON.Matrix.Invert(mesh.getWorldMatrix())
if (mesh.intersects(ray)) {
...
}

 

Link to comment
Share on other sites

Hey,

@Deltakosh I tried your ways but it also didn't work, after testing a little bit I moved the box around and you can see here (http://babylonjs-playground.com/#CJXIU#1)

 the scenario I want to have. But if you remove the // in line 19 you move the wall away and now it has to draw a line between every single Waypoint. But it doesn't, the position is not updated even if the boundingbox is at the "right" coordinates.

Another thing is this playground here: http://www.babylonjs-playground.com/#1NE4XO#18

Theres the same problem. If you move the normal box (where you want to check the ray with) away (Line 18) it writes in the console "hit" if the ray hits the position of the box when you don't move it. How I can update the position so that these mistakes will not appear ?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...