Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using Forge;
- using Forge.Primitives;
- using Forge.Filters;
- public class DNADoubleHelix : ProceduralAsset {
- private float Radius = 0.04f;
- private float Offset = 0.4f;
- [Range(0, 70)] public int Copies = 1;
- [Range(-20f, 20f)] public float Twist = 5f;
- [Range(0.0f, 0.5f)] public float SegmentLength = 0.05f;
- private int Detail = 8;
- public override Geometry Build() {
- // A
- var circle1 = new Circle();
- circle1.Radius = Radius;
- circle1.Center = new Vector3(Offset, 0f, 0f);
- circle1.Segments = Detail;
- var copy1 = new Copy(circle1.Output());
- copy1.Rotation = new Vector3(0f, Twist, 0f);
- copy1.Position = new Vector3(0f, SegmentLength, 0f);
- copy1.Copies = Copies;
- var bridge1 = new Bridge(copy1.Output());
- // B
- var circle2 = new Circle();
- circle2.Radius = Radius;
- circle2.Center = new Vector3(-Offset, 0f, 0f);
- circle2.Segments = Detail;
- var copy2 = new Copy(circle2.Output());
- copy2.Rotation = new Vector3(0f, Twist, 0f);
- copy2.Position = new Vector3(0f, SegmentLength, 0f);
- copy2.Copies = Copies;
- var bridge2 = new Bridge(copy2.Output());
- // C
- var circle3 = new Circle();
- circle3.Radius = Radius / 3;
- circle3.Orientation = OrientationPreset.ZY;
- circle3.Center = new Vector3(Offset, 0f, 0f);
- circle3.Segments = Detail;
- var mirror = new Mirror(circle3.Output());
- var mid = new Merge(Reverse.Process(circle3.Output()), mirror.Output());
- var midBridge = new Bridge(mid.Output());
- midBridge.RecalculateNormals = true;
- var midCopy = new Copy(midBridge.Output());
- midCopy.Copies = Copies / 2 - 1;
- midCopy.Rotation = new Vector3(0f, Twist * 2, 0f);
- midCopy.Position = new Vector3(0f, SegmentLength * 2, 0f);
- // Glue all the pieces now!
- var merge = new Merge(
- bridge1.Output(),
- midCopy.Output(),
- bridge2.Output()
- );
- return merge.Output();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement