示例#1
0
        private List <Grass2PositionedEntity> PositionEntitiesFromAspect(Grass2Aspect aspect, DesignBodySpotModification modification)
        {
            var flatPos = aspect.FlatPos;

            //var rotation = Quaternion.LookRotation(modification.Normal.normalized).eulerAngles * Mathf.Deg2Rad; //TODO recreate
            if (!WarningWasSaid)
            {
                Debug.Log("W4 WARNING. GRASS ROTATION IS NOT SET. DO STH!!!");
                WarningWasSaid = true;
            }
            var centerTriplet = new MyTransformTriplet(
                new Vector3(flatPos.x, 0, flatPos.y),
                Vector3.zero, //rotation,
                Vector3.one
                );

            if (modification.SpotData != null)
            {
                centerTriplet.Position = new Vector3(centerTriplet.Position.x, modification.SpotData.Height, centerTriplet.Position.z);
            }
            var centerMatrix = centerTriplet.ToLocalToWorldMatrix();

            var additionalUniforms = new UniformsPack();

            if (modification.Uniforms != null)
            {
                additionalUniforms = modification.Uniforms;
            }

            return(aspect.Entities.Select(c => new Grass2PositionedEntity()
            {
                LocalToWorldMatrix = centerMatrix * c.DeltaTransformTriplet.ToLocalToWorldMatrix(),
                Uniforms = UniformsPack.MergeTwo(c.Uniforms, additionalUniforms)
            }).ToList());
        }
        private void AlignUniforms()
        {
            var debugRendererPack = ShaderCustomizationUtils.RetriveUniforms(StrokeSeedGridMapDebugRendererMaterial);
            var stage1Pack        = ShaderCustomizationUtils.RetriveUniforms(Stage1RenderingMaterial);
            var geometryPack      = ShaderCustomizationUtils.RetriveUniforms(SelectedGeometryMaterial);

            _masterUniformsPack = UniformsPack.MergeTwo(UniformsPack.MergeTwo(debugRendererPack, stage1Pack), geometryPack).WithoutDebugUniforms();

            new List <Material>()
            {
                StrokeSeedGridMapDebugRendererMaterial, Stage1RenderingMaterial, SelectedGeometryMaterial
            }.ForEach(m =>
            {
                ShaderCustomizationUtils.FilterNonPresentUniforms(m, _masterUniformsPack).SetUniformsToMaterial(m);
            });
        }