In this example we see how to use parameters. Parameters show up as slide bars under the right click menu for each object in the 3D window. Using parameters lets you test that your code works with different input data. Note the use of the BowlerDatabase to store variables.
A more advanced example is the Animatronic Head
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/.settings | |
/.project | |
/.classpath | |
/.cproject | |
/cache/ | |
/*.class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"under breast to waist": { | |
"name": "under breast to waist", | |
"options": [ | |
"120.0", | |
"1.0" | |
], | |
"value": 101600 | |
}, | |
"waist high hip": { | |
"name": "waist high hip", | |
"options": [ | |
"120.0", | |
"1.0" | |
], | |
"value": 101600 | |
}, | |
"high hip": { | |
"name": "high hip", | |
"options": [ | |
"120.0", | |
"1.0" | |
], | |
"value": 990599 | |
}, | |
"low hip": { | |
"name": "low hip", | |
"options": [ | |
"120.0", | |
"1.0" | |
], | |
"value": 1041399 | |
}, | |
"waist to top back": { | |
"name": "waist to top back", | |
"options": [ | |
"120.0", | |
"1.0" | |
], | |
"value": 177799 | |
}, | |
"underbust": { | |
"name": "underbust", | |
"options": [ | |
"120.0", | |
"1.0" | |
], | |
"value": 863599 | |
}, | |
"waist": { | |
"name": "waist", | |
"options": [ | |
"120.0", | |
"1.0" | |
], | |
"value": 762000 | |
}, | |
"waist to pubic bone": { | |
"name": "waist to pubic bone", | |
"options": [ | |
"120.0", | |
"1.0" | |
], | |
"value": 152399 | |
}, | |
"waist to bottom back": { | |
"name": "waist to bottom back", | |
"options": [ | |
"120.0", | |
"1.0" | |
], | |
"value": 171450 | |
}, | |
"number rows or rivets": { | |
"name": "number rows or rivets", | |
"options": [ | |
"1", | |
"2" | |
], | |
"value": 2000 | |
}, | |
"number of panels": { | |
"name": "number of panels", | |
"options": [ | |
"12", | |
"4" | |
], | |
"value": 8000 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CSG makeCube(){ | |
//Set up som parameters to use | |
xkey = new LengthParameter("X dimention",30,[120.0,1.0]) | |
ykey = new LengthParameter("Y dimention",30,[130.0,2.0]) | |
zkey = new LengthParameter("Z dimention",30,[140.0,3.0]) | |
sphereSize = new LengthParameter("Sphere Size",30,[150.0,4.0]) | |
//you can also create parametrics that are not used in creating primitives | |
offset = new LengthParameter("Sphere Offset Distance",15,[20,-5]) | |
//build geometry with them | |
def cube = new Cube(xkey,ykey,zkey).toCSG() | |
sphere = new Sphere(sphereSize).toCSG() | |
//apply moves based on the valeus in the parameters | |
distance = xkey.getMM()/2-offset.getMM()+sphereSize.getMM() | |
cube=cube.union(sphere.movex(distance)) | |
return cube | |
.setParameter(offset)// add any parameters that are not used to create a primitive | |
.setRegenerate({ makeCube()})// add a regeneration function to the CSG being returrned to lonk a change event to a re-render | |
} | |
//CSGDatabase.clear()//set up the database to force only the default values in | |
return makeCube(); |