usage

:: using the BSO operator ::

The BSO3-plugin introduces a new node type "BSO" representing an boolean-set-operation in the growth-grammar. This short introduction into it's usage assumes that you are already familiar with GroIMP's XL-language. If not, you should definitely read this tutorial first!

The BSO operator comes in three "flavours":

  • Addition: Doing a logical union of sets
  • Subtraction: Doing a logical difference of sets
  • Common: Doing an intersection of sets
  • As a simple example we are going to subtract a sphere from a box. Firstoff, we are generating our graphical primitives and align them the way we want them. So we are adding the following code to our init method:

    
    		  protected void init()
    		  {
    		    Axiom ==>
    			 Box(.5f, .5f, .5f).(setColor(0.95f, 0.95f, 0.95f))
    			 Translate(0, 0, -.25f)
    			 Sphere(.32f).(setColor(0.95f, 0.95f, 0.95f));
    		  }       	
    		  
    The result is a sphere of radius (.32f) placed inside a box with edge length (.5f).

    To subtract the sphere from the box, we are now using an BSO Subtraction operator. But first, we are importing the BSO3 plugin:

    
    		  import net.cropsense.bso3.*;		  
    		  
    		  protected void init()
    		  {
    		    Axiom ==>
    			 BSO(CSGNodeType.Subtraction, new Color3f(0.95f, 0.95f, 0.95f))			 
    			 Box(.5f, .5f, .5f).(setColor(0.95f, 0.95f, 0.95f))
    			 Translate(0, 0, -.25f)
    			 Sphere(.32f).(setColor(0.95f, 0.95f, 0.95f));
    		  }       	
    		  

    If you are already familiar with XL, then you will know that next we need some "action" function, setting off our little XL-script. Let's call it "go" and add it to our script:

    
    		  import net.cropsense.bso3.*;		  
    		  
    		  protected void init()
    		  {
    		    Axiom ==>
    			 BSO(CSGNodeType.Subtraction, new Color3f(0.95f, 0.95f, 0.95f))			 
    			 Box(.5f, .5f, .5f).(setColor(0.95f, 0.95f, 0.95f))
    			 Translate(0, 0, -.25f)
    			 Sphere(.32f).(setColor(0.95f, 0.95f, 0.95f));
    		  }       			  
    		  
    		  public void go() 
    		  { 
    		    console().clear();
    			 [
    				b:first((* BSO *)) ::>
    				{
    					b.apply();
    				}
    			 ]
    		  }
    		  
    Saving this script should give you a button "go" in GroIMP, performing the CSG-operation. What it does is looking for the first BSO object in the parse-tree and call it's "apply"-function.

    Once the operation finishes, you might not immediately recognize the result. That is because of the original graphical primitives still existing in the scene. Go to "Graph"->"View"->"Redraw" and then select and delete everything under the "BSO" object! You should now see the resulting object.

    What else can be done? Instead of a Substraction, you could try a "BSO(CSGNodeType.Addition)" or "BSO(CSGNodeType.Common)" operation. Since the algorithm is working directly on the geometry, it relies on representing all primitives as volumes bounded by planes. And since a lot of plane intersections are performed, the performance of the algorithm depends heavily on the total number of planes representing the involved graphical primitives. To give you some control over the amount of planes used, there are additional methods of the BSO object "setPlanesSamplingSphere(n)" and "setPlanesSamplingCone(n)" defined. Increasing the integer "n" while give you a finer sampling with decreasing performance. The methods may be used like this:

    		  
    		   public void go() 
    		   { 
    		    console().clear();
    			 [
    				b:first((* BSO *)) ::>
    				{
    				   b.setPlanesSamplingSphere(25);					
    				   b.apply();
    				}
    			 ]
    		   }