Пример #1
0
		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);
		}
Пример #2
0
		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();
		}
Пример #3
0
		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;
		}
Пример #4
0
		public float TranslateDistToContour(float dist, Contour contour) {
			float x = GetPointAtDist(dist).x;
			return contour.GetDistAtX(x);
		}
Пример #5
0
		private ContourSegment GenerateSection(Contour terrain, ContourSegmentConfig config) {
			ContourSegment section = new GameObject("Section", typeof(ContourSegment)).GetComponent<ContourSegment>();
			section.Initialize(terrain, config, attributes);
			return section;
		}
Пример #6
0
		public ContourSegment GenerateSection(Contour terrain, ContourSegment previousSection, float length, float slope, bool bumpify) {
			return GenerateSection(terrain, previousSection.endPoint, previousSection.distEnd, length, slope, bumpify);
		}
Пример #7
0
		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);
		}
Пример #8
0
		private void Awake() {
			terrain = GetComponent<Contour>();
		}