public void GenerateValues( IVoxelProjection <TVoxel, TSurfaceData> projection, out TValue topLeftValue, out TValue topRightValue, out TValue bottomLeftValue, out TValue bottomRightValue) { foreach (var generator in this.generators) { if (generator.IsWithinThreshold(projection.SurfaceData.AdjustedSeed)) { generator.GenerateValues( projection, out topLeftValue, out topRightValue, out bottomLeftValue, out bottomRightValue); return; } } this.defaultGenerator.GenerateValues( projection, out topLeftValue, out topRightValue, out bottomLeftValue, out bottomRightValue); }
public static void Indexer <TVoxel, TSurfaceData>( IVoxelProjection <TVoxel, TSurfaceData> instance, Index3D relativeIndex) where TVoxel : struct where TSurfaceData : class { Contracts.Requires.That(instance != null); Contracts.Requires.That(instance.IsRelativeIndexValid(relativeIndex)); }
/// <summary> /// Determines whether the surface contour represented by the projection is horizontal (perpendicular to the y axis). /// </summary> /// <typeparam name="TVoxel">The type of the voxel.</typeparam> /// <typeparam name="TSurfaceData">The type of the surface data.</typeparam> /// <param name="projection">The projection.</param> /// <returns>True if the projection is horizontal.</returns> public static bool IsHorizontal <TVoxel, TSurfaceData>(this IVoxelProjection <TVoxel, TSurfaceData> projection) where TVoxel : struct where TSurfaceData : class { Contracts.Requires.That(projection != null); return(projection.AxisDirection.GetAxis() == Axis3D.Y); }
public static void GetVoxelAtStageIndex <TVoxel, TSurfaceData>( IVoxelProjection <TVoxel, TSurfaceData> instance, Index3D stageIndex) where TVoxel : struct where TSurfaceData : class { Contracts.Requires.That(instance != null); Contracts.Requires.That(instance.IsStageIndexValid(stageIndex)); }
/// <summary> /// Determines whether the surface contour represented by the projection is vertical (perpendicular to the x or z axis). /// </summary> /// <typeparam name="TVoxel">The type of the voxel.</typeparam> /// <typeparam name="TSurfaceData">The type of the surface data.</typeparam> /// <param name="projection">The projection.</param> /// <returns>True if the projection is vertical.</returns> public static bool IsVertical <TVoxel, TSurfaceData>(this IVoxelProjection <TVoxel, TSurfaceData> projection) where TVoxel : struct where TSurfaceData : class { Contracts.Requires.That(projection != null); return(!projection.IsHorizontal()); }
public void GenerateValues( IVoxelProjection <TVoxel, TSurfaceData> projection, out Vector3 topLeftValue, out Vector3 topRightValue, out Vector3 bottomLeftValue, out Vector3 bottomRightValue) { topLeftValue = projection.ConvertToAbsoluteVectorPosition(new Vector3(-.5f, .5f, -.5f)); topRightValue = projection.ConvertToAbsoluteVectorPosition(new Vector3(.5f, .5f, -.5f)); bottomLeftValue = projection.ConvertToAbsoluteVectorPosition(new Vector3(-.5f, -.5f, -.5f)); bottomRightValue = projection.ConvertToAbsoluteVectorPosition(new Vector3(.5f, -.5f, -.5f)); }
public void GenerateValues( IVoxelProjection <TVoxel, TSurfaceData> projection, out TValue topLeftValue, out TValue topRightValue, out TValue bottomLeftValue, out TValue bottomRightValue) { topLeftValue = this.topLeftValue; topRightValue = this.topRightValue; bottomLeftValue = this.bottomLeftValue; bottomRightValue = this.bottomRightValue; }
public void GenerateValues( IVoxelProjection <TVoxel, TSurfaceData> projection, out Vector2 topLeftValue, out Vector2 topRightValue, out Vector2 bottomLeftValue, out Vector2 bottomRightValue) { topLeftValue = this.textureSwatch.TopLeftCoordinate; topRightValue = this.textureSwatch.TopRightCoordinate; bottomLeftValue = this.textureSwatch.BottomLeftCoordinate; bottomRightValue = this.textureSwatch.BottomRightCoordinate; }
/// <inheritdoc /> public void GenerateValues( IVoxelProjection <TerrainVoxel, TSurfaceData> projection, out Vector3 topLeftValue, out Vector3 topRightValue, out Vector3 bottomLeftValue, out Vector3 bottomRightValue) { topLeftValue = CreateTopLeft(projection); topRightValue = CreateTopRight(projection); bottomLeftValue = CreateBottomLeft(projection); bottomRightValue = CreateBottomRight(projection); }
public void GenerateValues( IVoxelProjection <TVoxel, TSurfaceData> projection, out TValue topLeftValue, out TValue topRightValue, out TValue bottomLeftValue, out TValue bottomRightValue) { if (projection.SurfaceData.Diagonal == QuadDiagonal.Ascending) { projection.SurfaceData.SurfaceArea = PolyMath.GetArea( projection.SurfaceData.TopLeftVertex, projection.SurfaceData.BottomLeftVertex, projection.SurfaceData.TopRightVertex) + PolyMath.GetArea( projection.SurfaceData.BottomLeftVertex, projection.SurfaceData.BottomRightVertex, projection.SurfaceData.TopRightVertex); } else { projection.SurfaceData.SurfaceArea = PolyMath.GetArea( projection.SurfaceData.TopLeftVertex, projection.SurfaceData.BottomLeftVertex, projection.SurfaceData.BottomRightVertex) + PolyMath.GetArea( projection.SurfaceData.TopLeftVertex, projection.SurfaceData.BottomRightVertex, projection.SurfaceData.TopRightVertex); } if (projection.SurfaceData.SurfaceArea >= this.threshold) { this.aboveThresholdGenerator.GenerateValues( projection, out topLeftValue, out topRightValue, out bottomLeftValue, out bottomRightValue); } else { this.belowThresholdGenerator.GenerateValues( projection, out topLeftValue, out topRightValue, out bottomLeftValue, out bottomRightValue); } }
public void GenerateValues( IVoxelProjection<TVoxel, TSurfaceData> projection, out TValue topLeftValue, out TValue topRightValue, out TValue bottomLeftValue, out TValue bottomRightValue) { this.generator.GenerateValues( projection, out topLeftValue, out topRightValue, out bottomLeftValue, out bottomRightValue); }
/// <inheritdoc /> public void GenerateValues( IVoxelProjection <TerrainVoxel, TSurfaceData> projection, out Vector2 topLeftValue, out Vector2 topRightValue, out Vector2 bottomLeftValue, out Vector2 bottomRightValue) { this.propertiesTable[projection[Projection.Below].Material].Texturer.GenerateValues( projection, out topLeftValue, out topRightValue, out bottomLeftValue, out bottomRightValue); }
private static Vector3 CreateBottomRight( IVoxelProjection <TerrainVoxel, TSurfaceData> projection) { Vector3 vertex = CalculateVertex( projection[Projection.Above], projection[Projection.Below], projection[Projection.RightAbove], projection[Projection.RightBelow], projection[Projection.BotAbove], projection[Projection.BotBelow], projection[Projection.BotRightAbove], projection[Projection.BotRightBelow]); return(projection.ConvertToAbsoluteVectorPosition(vertex - new Vector3(0, 1, 1))); }
private static Vector3 CreateTopLeft( IVoxelProjection <TerrainVoxel, TSurfaceData> projection) { Vector3 vertex = CalculateVertex( projection[Projection.TopLeftAbove], projection[Projection.TopLeftBelow], projection[Projection.TopAbove], projection[Projection.TopBelow], projection[Projection.LeftAbove], projection[Projection.LeftBelow], projection[Projection.Above], projection[Projection.Below]); return(projection.ConvertToAbsoluteVectorPosition(vertex - new Vector3(1, 0, 1))); }
public void GenerateValues( IVoxelProjection <TVoxel, TSurfaceData> projection, out TValue topLeftValue, out TValue topRightValue, out TValue bottomLeftValue, out TValue bottomRightValue) { Index3D origin = projection.StageIndexOfOrigin; switch (projection.AxisDirection) { case AxisDirection3D.PositiveX: projection.SurfaceData.OriginalSeed = (float)this.positiveXNoise.Noise(origin.X, origin.Y, origin.Z); break; case AxisDirection3D.NegativeX: projection.SurfaceData.OriginalSeed = (float)this.negativeXNoise.Noise(origin.X, origin.Y, origin.Z); break; case AxisDirection3D.PositiveY: projection.SurfaceData.OriginalSeed = (float)this.positiveYNoise.Noise(origin.X, origin.Y, origin.Z); break; case AxisDirection3D.NegativeY: projection.SurfaceData.OriginalSeed = (float)this.negativeYNoise.Noise(origin.X, origin.Y, origin.Z); break; case AxisDirection3D.PositiveZ: projection.SurfaceData.OriginalSeed = (float)this.positiveZNoise.Noise(origin.X, origin.Y, origin.Z); break; case AxisDirection3D.NegativeZ: projection.SurfaceData.OriginalSeed = (float)this.negativeZNoise.Noise(origin.X, origin.Y, origin.Z); break; } projection.SurfaceData.AdjustedSeed = projection.SurfaceData.OriginalSeed; this.generator.GenerateValues( projection, out topLeftValue, out topRightValue, out bottomLeftValue, out bottomRightValue); }
public void GenerateValues( IVoxelProjection <TVoxel, TSurfaceData> projection, out Vector2 topLeftValue, out Vector2 topRightValue, out Vector2 bottomLeftValue, out Vector2 bottomRightValue) { this.generator.GenerateValues( projection, out topLeftValue, out topRightValue, out bottomLeftValue, out bottomRightValue); projection.SurfaceData.TopLeftTexture = topLeftValue; projection.SurfaceData.TopRightTexture = topRightValue; projection.SurfaceData.BottomLeftTexture = bottomLeftValue; projection.SurfaceData.BottomRightTexture = bottomRightValue; }
public void GenerateValues( IVoxelProjection <TVoxel, TSurfaceData> projection, out Color topLeftValue, out Color topRightValue, out Color bottomLeftValue, out Color bottomRightValue) { this.generator.GenerateValues( projection, out topLeftValue, out topRightValue, out bottomLeftValue, out bottomRightValue); projection.SurfaceData.TopLeftColor = topLeftValue; projection.SurfaceData.TopRightColor = topRightValue; projection.SurfaceData.BottomLeftColor = bottomLeftValue; projection.SurfaceData.BottomRightColor = bottomRightValue; }
public void GenerateValues( IVoxelProjection <TVoxel, TSurfaceData> projection, out TValue topLeftValue, out TValue topRightValue, out TValue bottomLeftValue, out TValue bottomRightValue) { switch (projection.AxisDirection) { case AxisDirection3D.PositiveX: this.positiveXAxisGenerator.GenerateValues( projection, out topLeftValue, out topRightValue, out bottomLeftValue, out bottomRightValue); break; case AxisDirection3D.NegativeX: this.negativeXAxisGenerator.GenerateValues( projection, out topLeftValue, out topRightValue, out bottomLeftValue, out bottomRightValue); break; case AxisDirection3D.PositiveY: this.positiveYAxisGenerator.GenerateValues( projection, out topLeftValue, out topRightValue, out bottomLeftValue, out bottomRightValue); break; case AxisDirection3D.NegativeY: this.negativeYAxisGenerator.GenerateValues( projection, out topLeftValue, out topRightValue, out bottomLeftValue, out bottomRightValue); break; case AxisDirection3D.PositiveZ: this.positiveZAxisGenerator.GenerateValues( projection, out topLeftValue, out topRightValue, out bottomLeftValue, out bottomRightValue); break; case AxisDirection3D.NegativeZ: this.negativeZAxisGenerator.GenerateValues( projection, out topLeftValue, out topRightValue, out bottomLeftValue, out bottomRightValue); break; default: throw InvalidEnumArgument.CreateException(nameof(projection.AxisDirection), projection.AxisDirection); } }