Advertisement
Lucas_3D

Line Bomb

Aug 19th, 2020 (edited)
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. delete Shapes
  2. delete $lbBox*
  3. delete Helpers
  4. --try (delete $lbPointObj)catch()
  5. deleteAllChangeHandlers id:#lineBomb
  6. with undo off
  7. (
  8. amtBoxes = 100
  9. numSegs = 5
  10. minPos = -100.0
  11. maxPos = 100.0
  12. innerCircle = 0.0
  13. lenLine = 200.0
  14.  
  15. lbPoint = Point pos:[0,0,0] cross:on size:10 name:"lbPointObj"
  16.  
  17. for i = 1 to amtBoxes do
  18. (
  19.  
  20. box position:[random minPos maxPos,random minPos maxPos,random minPos maxPos] length:5 width:5 height:5 wireColor:blue name:"lbBox"
  21. )
  22.  
  23. Fn ShpFmArr shpInterp shpPosArr col =
  24. (
  25. newShape = splineshape wireColor:col
  26. newSpline = addnewSpline newShape
  27. for myKnot in shpPosArr do
  28. (
  29. addKnot newShape newSpline shpInterp #curve myKnot
  30. --#corner, #smooth, #curve
  31. )
  32. updateShape newShape
  33. )
  34.  
  35. Fn LineBombOperation =
  36. with undo off(
  37. delete Shapes
  38. gSphere = (createInstance GeoSphere position:lbPoint.position radius:1 segs:numSegs name:"test")
  39. vecArr =#()
  40. for i = 1 to (getNumVerts gSphere.mesh) do
  41. (
  42. append vecArr (getVert gSphere.mesh i)
  43. )
  44. for i in vecArr do
  45. (
  46. firstPnt = (i*innerCircle)+lbPoint.position
  47. shpPosArr = #(firstPnt)
  48. myRay = ray (gSphere.position) i
  49. hitPoint = intersectRayScene myRay
  50. if hitPoint.count > 0 then
  51. (
  52. append shpPosArr hitPoint[1][2].position
  53. ShpFmArr #corner shpPosArr red
  54. ) else
  55. (
  56. if (random 1 7) == 1 do
  57. (
  58. append shpPosArr (i*lenLine+lbPoint.position)
  59. ShpFmArr #corner shpPosArr yellow
  60. )
  61. )
  62. )
  63. )
  64. when transform lbPoint changes id:#lineBomb do LineBombOperation()
  65. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement