Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2015
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. using UnityEngine;
  2. using Forge;
  3. using Forge.Primitives;
  4. using Forge.Filters;
  5.  
  6. public class DNADoubleHelix : ProceduralAsset {
  7.  
  8. private float Radius = 0.04f;
  9. private float Offset = 0.4f;
  10.  
  11. [Range(0, 70)] public int Copies = 1;
  12. [Range(-20f, 20f)] public float Twist = 5f;
  13. [Range(0.0f, 0.5f)] public float SegmentLength = 0.05f;
  14.  
  15. private int Detail = 8;
  16.  
  17. public override Geometry Build() {
  18.  
  19. // A
  20. var circle1 = new Circle();
  21. circle1.Radius = Radius;
  22. circle1.Center = new Vector3(Offset, 0f, 0f);
  23. circle1.Segments = Detail;
  24.  
  25. var copy1 = new Copy(circle1.Output());
  26. copy1.Rotation = new Vector3(0f, Twist, 0f);
  27. copy1.Position = new Vector3(0f, SegmentLength, 0f);
  28. copy1.Copies = Copies;
  29.  
  30. var bridge1 = new Bridge(copy1.Output());
  31.  
  32. // B
  33. var circle2 = new Circle();
  34. circle2.Radius = Radius;
  35. circle2.Center = new Vector3(-Offset, 0f, 0f);
  36. circle2.Segments = Detail;
  37.  
  38. var copy2 = new Copy(circle2.Output());
  39. copy2.Rotation = new Vector3(0f, Twist, 0f);
  40. copy2.Position = new Vector3(0f, SegmentLength, 0f);
  41. copy2.Copies = Copies;
  42.  
  43. var bridge2 = new Bridge(copy2.Output());
  44.  
  45. // C
  46. var circle3 = new Circle();
  47. circle3.Radius = Radius / 3;
  48. circle3.Orientation = OrientationPreset.ZY;
  49. circle3.Center = new Vector3(Offset, 0f, 0f);
  50. circle3.Segments = Detail;
  51.  
  52. var mirror = new Mirror(circle3.Output());
  53. var mid = new Merge(Reverse.Process(circle3.Output()), mirror.Output());
  54. var midBridge = new Bridge(mid.Output());
  55. midBridge.RecalculateNormals = true;
  56.  
  57. var midCopy = new Copy(midBridge.Output());
  58. midCopy.Copies = Copies / 2 - 1;
  59. midCopy.Rotation = new Vector3(0f, Twist * 2, 0f);
  60. midCopy.Position = new Vector3(0f, SegmentLength * 2, 0f);
  61.  
  62. // Glue all the pieces now!
  63. var merge = new Merge(
  64. bridge1.Output(),
  65. midCopy.Output(),
  66. bridge2.Output()
  67. );
  68.  
  69. return merge.Output();
  70. }
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement