Advertisement
Guest User

Untitled

a guest
Dec 15th, 2012
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. MAX_ANGLE_OFFSET = 5
  2.  
  3. generate_tree = function (pos,initial_axiom,rules_a,rules_b,iterations,angle)
  4.  
  5. prop_a=1.0
  6. prop_b=0.8
  7.  
  8. stackPosition = NewStack()
  9. stackOrientation = NewStack()
  10. axiom = initial_axiom
  11. for i = 1, iterations, 1 do
  12. local temp=""
  13. for j = 1, #axiom, 1 do
  14. local c=string.sub(axiom,j,j)
  15. rValue = (math.random()+ 1.0) / 2.0
  16. if c=="A" then
  17. if prop_a > (1.0 - rValue) then
  18. temp=temp..rules_a
  19. end
  20. else
  21. if c=="B" and rules_b~="" then
  22. if prop_b > (1.0 - rValue) then
  23. temp=temp..rules_b
  24. end
  25. else
  26. temp=temp..c
  27. end
  28. end
  29. end
  30. axiom=temp
  31. end
  32.  
  33. position=matrix:new({0,0,0})
  34. rotation=matrix:new(4,"I")
  35.  
  36. end
  37.  
  38.  
  39. generate_tree({0,0,0},"FFFFFFA","[&FFBFA]////[&BFFFA]////[&FBFFA]","[&FFFA]////[&FFFA]////[&FFFA]",4,30)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement