Skip to content

2011 10 31 Solid objects and pattern improvements

Robin Deits edited this page Mar 24, 2013 · 4 revisions

2011-10-31 Solid objects and pattern improvements

I'd like to be able to represent solid objects and do more with things like opacity. This seems to be possible through the Ruby API, though it means that it probably makes more sense to rewrite the whole project in Ruby. I can access the observer position with

view = Sketchup.active_model.active_view

print view.camera.eye

I can test for opacity with the model.raytest function: http://code.google.com/apis/sketchup/docs/ourdoc/model.html#raytest

Here's a possible strategy:

Divide the z-axis into n rows. Divide the angles between -pi/2 and +pi/2 into m angles.

  • For each row:

    • For each angle:

      • Starting location is the current camera position rotated by the angle in the x-y plane about the center of the model

      • Ending location is the center of the model

      • raytest from start to end location

      • get coordinates of point where ray intersects model (if any)

      • print a line segment corresponding to those coordinates at that viewing angle

Actually, I can easily improve this by printing an arc segment with the correct radius of curvature instead of a line.

#Remaining questions:

  • How do I identify the correct z-slices? That is to say, what are the max and min z values of the model?

Clone this wiki locally