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.

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.