Raytest
-
Does any kind person have any sample coding for raytest? I want to use it to detect and avoid clashes of two or more moving objects on distribution paths. Thanks.
Chris
-
I have lots of code with raytests, but most of it is pretty lengthy.
Cobble something together, best you can, post it here, and I'll help you through it.
Todd
-
-
[flash=425,344:24w1bqhm]http://www.youtube.com/v/cBDihpeXkFQ[/flash:24w1bqhm]
Here is an experiment resulting from what I have cobbled together so far in respect of animation. As you see I can determine the direction, rotation (including offsetting) and speed for three components along three different paths. Of course I could have staggered the starts but left that until later as I was first curious whether the basics could be achieved. What I cannot determine is clashes, hence my cry for help.
Here is what I have done in case it is relevant to raytesting (or whether raytesting is worth considering if the process is doomed to fail or run too slowly).
The paths and so forth are made with this interface.
[flash=425,344:24w1bqhm]http://www.youtube.com/v/TJ_jZAJn1bg[/flash:24w1bqhm]
As I don't know how many components are to be animated at any one time, I have a function that writes a new function for each component's animation. There is a single setInterval function that calls each of the new functions at every pass (presumably a sillysecond apart).
I guess the raytest should be added to this:
@dlg.add_action_callback("mover") {|d, p| a = p.split(",") entityNo = Integer(a[0]) theX = Integer(a[1]).mm theY = Integer(a[2]).mm theZ = Integer(a[3]).mm model = Sketchup.active_model entities = model.active_entities entity = entities[entityNo] point = Geom;;Point3d.new theX, theY, theZ t = Geom;;Transformation.new point entity.transform! t }
the variables being supplied from the webdialog's javascript. The raytest would need to determine a possible clash and stop its component. It seems to me a lot of things arise from that, but first I think it best to find out whether you think I'm bonkers.
Of course I am not only thinking about moving sanitaryware around but any process that can be elaborated by Namesets, visualised with Sketchup and analysed by both.
Thanks for your offer of help (I hope it still stands!)
Chris
Added second video clip 11.00 GMT
-
Silly me... I thought you wanted to learn how to use raytest! You want to know how to do collision detection in 3D. If I knew, I'd tell. I presume raytest would be a piece of that somewhere.
Todd
-
Let me just throw this out there for consideration..
I'm not sure a raytest is the best (first) strategy here. It may be easier to use a simple distance calculated from the center of each object's BoundingBox.
I say this because it may simplify the math down to calculating and comparing distances. It's really just based on my intuition that you could end up with a complicated array of raytests when a simple distance would work.
-
@jim said:
I'm not sure a raytest is the best (first) strategy here. It may be easier to use a simple distance calculated from the center of each object's BoundingBox.
Thanks Jim. I agree - generally I use maths (Brit) when I know the positions of objects, for example, when transferring from trucks to stack or stack to hoist. But what happens if two such operations are worked at the same time - one team is stacking the objects whilst the other is picking the most recently stacked for the hoist (the remainder forming the buffer)? The hoisting cycle will be variable depending on floors served (particularly on high rise) and also the truck cycle is unlikely to match. In this case I think a raytest would be most appropriate.
I don't know yet how to code for raytesting, but it seems to me there is likely to be many peripheral things to consider. For example, if two or three objects are charged with raytests that tell them to stop when another is detected, and they all detect each other how do they know when to restart?
If you are interested in this kind of thing I would much appreciate your continuing advice.
Cheers
Chris
-
@unknownuser said:
Silly me... I thought you wanted to learn how to use raytest! You want to know how to do collision detection in 3D. If I knew, I'd tell. I presume raytest would be a piece of that somewhere.
Todd
I am sorry Todd if you think I misled you. Yes, I do want to learn how to use raytest and I believe what I am thinking about is simple clash detection in the XY plane. If you have time any snippets you feel may be appropriate would be well received.
Thanks
Chris
Advertisement