sketchucation logo sketchucation
    • Login
    1. Home
    2. TomPendergrass
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 7
    • Groups 1

    TomPendergrass

    @TomPendergrass

    10
    Reputation
    1
    Profile views
    7
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    TomPendergrass Unfollow Follow
    registered-users

    Latest posts made by TomPendergrass

    • RE: [Info] Ambient Occlusion -> Simple Rays

      Hey qpik,

      I know it's been a whole year, I didn't notice that you had posted back on the forum. You're right, you'd need to do a check of what is in your range, and hide everything else. I actually made a script for this way back when, but it remains to be purely experimental. What I did was accept a point in space and created a square bounding box, since bounding spheres aren't really a thing. From that I can iterate through the scene and hide any group that isn't touching my bounding box by using the .contains? method (.contains in versions before 2015 returned invalid results sometimes).

      Assuming a dense scene is constructed of small groups, you could do this .contains check for every x amount of rays you cast and hide the irrelevant geometry. It's a patchy fix to a clunky raycast system, but it may fit all of your needs. If you're still interested in this topic, let me know and I'll dust off the old code and post it here.

      posted in Plugins
      TomPendergrassT
      TomPendergrass
    • RE: [Info] Ambient Occlusion -> Simple Rays

      Hello SketchUcators!

      I have a lot of interest in this topic. While modeling in Sketchup can be bliss, creating impressive visual displays without a full blown renderer is very difficult. Being a game developer hobbyist, this limitation keeps me in Blender for most of my game related art.

      Anyways, I was curious about raytest and what it's quirks were. As was stated earlier in this thread, limiting the raytest's scanning distance could be the solution to faster raycasting. Unfortunately, the ruby API doesn't offer this option; I suppose all rays are infinite (or my theory is the raytests are to the bounds of the scene.)

      I decided to do a test: I made a ruby method > raytest_repeating(ray, repeatCount) and cast a ray along the y axis 10,000 times. With no obstructions, it completed it's process on average around 0.15 seconds. Introducing two cubes in separate groups to intersect with, the same method took about 0.68 seconds on average. Here's the interesting part. I placed 2000 groups along the y axis and ran the same method again. This process took ~938 seconds to complete! Keeping the same cubes in the scene and moving all but two of them out of the ray path dropped the calculation back down to the 0.68 average!

      In conclusion, raytest must be spending time on all objects the ray interesects, even though it only returns the closest object. It's no wonder your occlusion process drops to a crawl in dense scenes, since I assume you're casting hemispherical rays into 'infinite space', colliding with EVERYTHING along the way! I believe a possible solution to your problem is to find the faces that are in the range of a raytest (IE, nearby faces that actually effect the shading) and to dynamically hide the rest of your scene as needed. Since the raytest can ignore hidden objects, it should speed up the overall process considerably. I ran one final test with the 2000 cubes, hiding all but 2 of them. While the process was slower, 10,000 rays came back in 5.2 seconds, which is far better than 938!

      I hope my findings can assist you on this wonderful creation of yours!

      -Thomas Pendergrass

      posted in Plugins
      TomPendergrassT
      TomPendergrass
    • RE: Issues with Scrambler

      This is an old thread, But I'd just like to go on the record that Sketchup 2014 has fixed one of the issues. I have a .rbs that includes the previously mentioned FILE. It runs just fine in 2014, yet it breaks down in 2013, giving me the following error:

      no .<digit> floating literal anymore; put 0 before dot

      good luck fellow coders.

      posted in Developers' Forum
      TomPendergrassT
      TomPendergrass
    • RE: Close a WebDialog, THEN execute ruby code?

      I attempted the set_on_close method, and it kept the dialog box open until the method within the set_on_close call had finished. it seems to run it's code block and then close the dialog box, instead of vice versa.

      After a long drive I've decided to replace the type=file input with a button that calls UI.openpanel from ruby, and then returns the path that sketchup provides back into a text field in the webDialog. I just tested it and it solves the problem! Thank you all for your timely responses.

      Thomas

      posted in Developers' Forum
      TomPendergrassT
      TomPendergrass
    • Close a WebDialog, THEN execute ruby code?

      Greetings users! I have quite a specific conundrum that I could use help solving.

      I'm writing a ruby script that deals with importing ESRI shapefiles and related imagery. long story short, I need file paths to several different folders (Input_Dir, Output_Dir, Texture.jpg, etc) Instead of bombarding the user with four+ UI.openpanel calls, I've created a WebDialog which uses several <input type='file'>.

      after the user presses Ok I gather all the file paths from the inputs through dialog.get_element_value('element_id') and call the rest of my code. This is where my issue occurs:

      I am unable to load the texture file. no error is passed but the texture is blank. Through experimentation I realized that if the texture is 'opened' in the WebDialog and I try to that texture to a material through sketchup normally (not through ruby) Sketchup states that it is unable to load the file. After I close the dialog I am able to import the texture image. Is there a way I can close the webdialog, and afterwards execute the rest of my code? I didn't notice any Observers related to webdialogs.

      Thank you ahead of time for considering my predicament!

      posted in Developers' Forum
      TomPendergrassT
      TomPendergrass
    • RE: Get latLong of origin?

      Thank you for your help! Turns out the camera that the photos were taken off of had some weird GPS offset, which is why my photos were imported yet placed kilometers away. I solved my problem by using a 'reference point'. I have the user import one photo and place that photo where they believe it was taken. I use that photo's lat and long to modify the rest of the photos that were imported. Success ๐Ÿ˜„

      posted in Developers' Forum
      TomPendergrassT
      TomPendergrass
    • Get latLong of origin?

      Greetings, users!

      I'm trying to find the point where a photo was taken in relation to a sketchup scene. The scene has been geolocated and has buildings constructed in their proper locations. I have the EXIF data of the photo: lat long, altitude, etc. Is there a way to plug this information into a ruby script and find the point?

      My approach was to get the lat long of the scene's origin and finding the point by calculating distance and direction between the two locations.

      Thank you ahead of time for any insight into my predicament!

      posted in Developers' Forum
      TomPendergrassT
      TomPendergrass