public ContourSegment GenerateSection(Contour terrain, Vector2 startPoint, float dist, float length, float slope, bool bumpify) { ContourSegmentConfig config = new ContourSegmentConfig(); config.startPoint = startPoint; config.length = length; config.slope = slope; config.distStart = dist; config.bumpify = bumpify; return GenerateSection(terrain, config); }
public void Initialize(Contour terrain, ContourSegmentConfig config, ContourSegmentAttributes attributes) { this.terrain = terrain; this.config = config; this.attributes = attributes; transform.parent = terrain.transform; transform.localPosition = Vector2.zero; CalculateSlopeVector(); CalculatePerpendicularSlopeVector(); GenerateEndPoint(); GenerateMidPoints(); // BumpifyMidPointsIfNeeded(); CollectAllPointsInList(); CalculateSurfaceMeasures(); CalculateDistAtEnd(); }
public List<ContourSegment> GenerateCurve(Contour terrain, Vector2 startPoint, float dist, float curveLength, float startSlope, float endSlope, bool bumpify) { float slopeRange = endSlope - startSlope; float deltaSlope = slopeRange / (resolution - 1); List<ContourSegment> sections = new List<ContourSegment>(); Vector2 nextStartPoint = startPoint; float nextDist = dist; for (int i = 0; i < resolution; i++) { float sectionLength = curveLength / resolution; float sectionSlope = startSlope + deltaSlope * i; ContourSegment section = GenerateSection(terrain, nextStartPoint, nextDist, sectionLength, sectionSlope, bumpify); nextStartPoint = section.endPoint; nextDist = section.distEnd; sections.Add(section); } return sections; }
public float TranslateDistToContour(float dist, Contour contour) { float x = GetPointAtDist(dist).x; return contour.GetDistAtX(x); }
private ContourSegment GenerateSection(Contour terrain, ContourSegmentConfig config) { ContourSegment section = new GameObject("Section", typeof(ContourSegment)).GetComponent<ContourSegment>(); section.Initialize(terrain, config, attributes); return section; }
public ContourSegment GenerateSection(Contour terrain, ContourSegment previousSection, float length, float slope, bool bumpify) { return GenerateSection(terrain, previousSection.endPoint, previousSection.distEnd, length, slope, bumpify); }
public List<ContourSegment> GenerateCurve(Contour terrain, ContourSegment previousSection, float sectionLength, float startSlope, float endSlope, bool bumpify) { return GenerateCurve(terrain, previousSection.endPoint, previousSection.distEnd, sectionLength, startSlope, endSlope, bumpify); }
private void Awake() { terrain = GetComponent<Contour>(); }