Create an Ray casting based on a cylinder

Hello,



i would like to implement an selection method based on a cylinder. Means instead of a ray, i would like to cast/draw an cylinder and as a result get all the object that collide with this cylinder. The problem is to draw/cast a cylinder in the right direction like the ray does.



Thanks and regards

make cylinder geometry (its Collidible)

use camera’s direction and position

use cylinder.collideWith()



or you can shoot rays in a circle. which would be quite computing intensive i think.

1 Like

ok, that was the right hint. I compute the local coordinates of direction and position with direction = …worldToLocal(direction,null) and position …worldToLocal(position,null) and apply the lookAt(direction,cam.getDirection()) method. The cylinder is now in the same position and direction as the ray. The next step will be the usage of cylinder.collideWith().



Thanks!

One more question. The objects that are inside of the cylinder and not intersect them will not be in the results of the cylinder.collideWith().

Is there a possibility to include the objects inside of the cylinder to the collision results?



Thanks!

Some more background information on what/why you are trying to do might allow people to suggest a simple alternative…

i wont to select more that one object at a time. Therefore i create a cylinder and use it as a ray. Every object that is inside of the cylinder or intersect them should be selected. The problem is that objects inside of the cylinder are not in the results of the cylinder.collideWith(object,result).

The figure below illustrate this situation. The highlighted sphere with the blue bounding box is intersected by the cylinder wall. The other one is directly inside of the cylinder and isn’t highlighted but i would like to have them highlighted/selected too. How to get them in the collision result?



http://i.imgur.com/HCHlV.png

How big are the objects u need to select ?



You could make more cylinders inside cylinders depending on the scale of things. :smiley:

You might get better results with another approach. Put invisible bounding boxes around all the objects, then cast a single ray and read all the intersections with the bounding boxes.



That way you can select per object what area you want them to cover for selection purposes and doing the detection is just a simple ray test.



Of course that does have the downside of the extra objects in the scene graph but unless we are talking a lot of objects that should be ok.

also consider using a sweep test, or just put a collisionshape where you need it (note you don’t need to use actual physics to use this), just as a collision detection mechanism.