sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Raytest

    Scheduled Pinned Locked Moved Developers' Forum
    8 Posts 4 Posters 781 Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • chrisglasierC Offline
      chrisglasier
      last edited by

      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

      With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

      1 Reply Last reply Reply Quote 0
      • T Offline
        todd burch
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • T Offline
          tomasz
          last edited by

          Hi Chris,

          My small script FrontFace uses raytest.

          Front Face SCF thread

          Tomasz

          Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

          1 Reply Last reply Reply Quote 0
          • chrisglasierC Offline
            chrisglasier
            last edited by

            [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.

            NS animation UI.jpg

            [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

            With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

            1 Reply Last reply Reply Quote 0
            • T Offline
              todd burch
              last edited by

              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

              1 Reply Last reply Reply Quote 0
              • J Offline
                Jim
                last edited by

                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.

                Hi

                1 Reply Last reply Reply Quote 0
                • chrisglasierC Offline
                  chrisglasier
                  last edited by

                  @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

                  With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

                  1 Reply Last reply Reply Quote 0
                  • chrisglasierC Offline
                    chrisglasier
                    last edited by

                    @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

                    With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      Last post
                    Buy SketchPlus
                    Buy SUbD
                    Buy WrapR
                    Buy eBook
                    Buy Modelur
                    Buy Vertex Tools
                    Buy SketchCuisine
                    Buy FormFonts

                    Advertisement