public void Start3() { var length = 50; float[,] heightArray = new float[length, length]; for (int x = 0; x < length; x++) { for (int y = 0; y < length; y++) { var ax = x / (float)length * 2 * Mathf.PI; var ay = y / (float)length * 2 * Mathf.PI; heightArray[x, y] = Mathf.Sin(ax) / 10; } } var mesh = PlaneGenerator.CreatePlaneMesh(1, 1, heightArray); MyAssetDatabase.CreateAndSaveAsset(mesh, "Assets/NPRResources/SimpleMesh1.asset"); }
protected override async Task <UInt32> CreateTerrainAsync() { var ring1Position = Ring1Node.Ring1Position; var xOffset = _globalHeightmap.Width * ring1Position.X; var yOffset = _globalHeightmap.Height * ring1Position.Y; var width = _globalHeightmap.Width * ring1Position.Width; var height = _globalHeightmap.Height * ring1Position.Height; var subArray = slicer.GetSubarrayWithEmptyMarginsSafe(_globalHeightmap.HeightmapAsArray, (int)xOffset, (int)yOffset, (int)width, (int)height); Point2D newGameObjectSize = new Point2D(33, 33); var simplifiedMap = simplyfyer.SimplyfyHeightmap(new HeightmapArray(subArray), newGameObjectSize.X - 1, newGameObjectSize.Y - 1); var mesh = await _meshGenerator.AddOrder( () => PlaneGenerator.CreatePlaneMesh(1, 1, simplifiedMap.HeightmapAsArray)); UniformsPack pack = await CreateUniformsPack(Ring1Node); var inGamePosition = _coordsCalculator.CalculateGlobalObjectPosition(Ring1Node.Ring1Position); var triplet = new MyTransformTriplet(new Vector3(inGamePosition.X, 0, inGamePosition.Y), Vector3.zero, new Vector3(inGamePosition.Width, 1, inGamePosition.Height)); var creationTemplate = new Ring1GroundPieceCreationTemplate() { Name = "Ring1 terrain object " + inGamePosition.ToString(), ParentGameObject = ParentObject, PieceMesh = mesh, ShaderName = "Custom/Terrain/Ring1DirectHeight", TransformTriplet = triplet, Uniforms = pack }; var objectId = OrderGrabber.AddCreationOrder(creationTemplate); return(objectId); }