コード例 #1
0
ファイル: GRingNodeTerrain.cs プロジェクト: defacto2k15/PwMgr
        private async Task <GRingTerrainId> CreateTerrainAsync()
        {
            //Debug.Log("G34 Start");
            var triplet     = _tripletProvider.ProvideTriplet();
            var meshDetails = await _terrainMeshProvider.ProvideMeshDetailsAsync();

            //Debug.Log("G35 Mesh detail");
            var groundShapeDetails = await _groundShapeProvider.ProvideGroundTextureDetail();

            //Debug.Log("G36 Ground shape detail");
            var surfaceProviderDetails = await _surfaceProvider.ProvideSurfaceDetail();

            var weldingDetails =
                _weldingUpdater.ProvideWeldingDetails(groundShapeDetails.HeightDetailOutput, meshDetails.HeightmapLod);

            _groundShapeToken = groundShapeDetails.GroundShapeToken;

            var creationTemplatesList = new List <Ring1GroundPieceCreationTemplate>();
            int layerIndex            = surfaceProviderDetails.Count;

            foreach (var surfaceDetail in surfaceProviderDetails)
            {
                UniformsPack pack = new UniformsPack();
                pack.MergeWith(meshDetails.Uniforms);
                pack.MergeWith(groundShapeDetails.Uniforms);
                pack.MergeWith(surfaceDetail.UniformsWithKeywords.Uniforms);
                pack.MergeWith(weldingDetails.UniformsPack);

                var keywordsSet = ShaderKeywordSet.Merge(groundShapeDetails.ShaderKeywordSet,
                                                         surfaceDetail.UniformsWithKeywords.Keywords);

                var layerTriplet = triplet.Clone();
                var oldPosition  = layerTriplet.Position;
                layerTriplet.Position = new Vector3(oldPosition.x, oldPosition.y + layerIndex / 2000f, oldPosition.z);

                creationTemplatesList.Add(
                    new Ring1GroundPieceCreationTemplate()
                {
                    Name =
                        $"TerrainElementLayer l:{layerIndex} ql:{_flatLod.SourceQuadLod} fl:{_flatLod.ScalarValue} wd {weldingDetails.WeldingIndex}",
                    ParentGameObject = _parentObject,
                    PieceMesh        = meshDetails.Mesh,
                    TransformTriplet = layerTriplet,
                    ShaderName       = surfaceDetail.ShaderName,
                    ShaderKeywordSet = keywordsSet,
                    Uniforms         = pack,
                    Modifier         = weldingDetails.Modifier
                });

                layerIndex--;
            }

            return(new GRingTerrainId()
            {
                ElementsIds = creationTemplatesList.Select(c => _orderGrabber.AddCreationOrder(c)).ToList()
            });
        }
コード例 #2
0
        private async Task <GRingTerrainId> CreateTerrainAsync()
        {
            var triplet = _tripletProvider.ProvideTriplet();

            var mesh = await _meshGeneratorUtProxy.AddOrder(() => PlaneGenerator.CreateFlatPlaneMesh(65, 65));

            var creationTemplatesList = new List <Ring1GroundPieceCreationTemplate>();
            int layerIndex            = 0;

            UniformsPack pack = new UniformsPack();

            pack.SetUniform("_LodLevel", _flatLod.ScalarValue);
            pack.SetUniform("_NodeId", LastId);

            var groundShapeDetails = await _groundShapeProvider.ProvideGroundTextureDetail();

            _groundShapeToken = groundShapeDetails.GroundShapeToken;
            pack.MergeWith(groundShapeDetails.Uniforms);

            creationTemplatesList.Add(
                new Ring1GroundPieceCreationTemplate()
            {
                Name             = $"TerrainElementLayer l:{layerIndex} fl:{_flatLod.ScalarValue}, X:{LastId++}",
                ParentGameObject = _parentObject,
                PieceMesh        = mesh,
                TransformTriplet = triplet,
                ShaderName       = "Custom/Terrain/DebugTerrainedLod",
                //ShaderName = "Custom/Terrain/Ring0",
                ShaderKeywordSet = groundShapeDetails.ShaderKeywordSet,
                Uniforms         = pack,
                Modifier         = new Ring1GroundPieceModifier()
            });


            var toReturn = new GRingTerrainId()
            {
                ElementsIds = creationTemplatesList.Select(c => _orderGrabber.AddCreationOrder(c)).ToList()
            };

            return(toReturn);
        }