Advertisement
cwkitkat

Untitled

Feb 19th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. delete objects
  2.  
  3. function tree currentHeight maxHeight parentbox:undefined branchingChance:0.13 =
  4. (
  5. firstbox = undefined
  6.  
  7. for i = currentHeight to maxHeight do
  8. (
  9. newbox = Box length: 5 width: 5 height: 5
  10.  
  11. if firstbox == undefined then
  12. (
  13. firstbox = newbox
  14. )
  15.  
  16. if parentbox != undefined then
  17. (
  18. newbox.parent = parentbox
  19.  
  20. /*
  21. [in] coordsys parent
  22. Use the object's parent's coordinate system
  23. https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2015/ENU/MAXScript-Help/files/GUID-6C7219CF-B9B7-4B18-A846-5522A9D970F3-htm.html
  24. */
  25.  
  26. in coordsys parent newbox.scale = [0.95, 0.95, 0.95]
  27.  
  28. in coordsys parent newbox.pos = [0, 0, 6]
  29.  
  30. rotX = random -10.0 10.0
  31. rotY = random -10.0 10.0
  32. rotZ = random -10.0 10.0
  33. in coordsys parent rotate newbox (eulerAngles rotX rotY rotZ)
  34.  
  35. branchRoll = random 0.0 1.0
  36. if branchRoll <= branchingChance then
  37. (
  38. branchbox = tree i maxHeight parentbox:newbox
  39. leafprism = prism side1length: 2 side2length: 2 side3length: 3 height: 0.1
  40. (
  41. in coordsys branchbox leafprism.pos = [0,0,1]
  42. )
  43. rotbranchX = random -45.0 45.0
  44. rotbranchY = random -45.0 45.0
  45. rotbranchZ = random -180.0 180.0
  46. about newbox rotate branchbox (eulerAngles rotbranchX rotbranchY rotbranchZ)
  47.  
  48.  
  49.  
  50.  
  51. )
  52. )
  53.  
  54. parentbox = newbox
  55. )
  56.  
  57. firstbox
  58. )
  59.  
  60.  
  61. tree 0 20 branchingChance:0.3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement