Example #1
0
 public virtual Serializable2DByteArray BlendDetails(DetailPrototypeWrapper detail,
                                                     int x, int z, int width, int height, int dRes, Serializable2DByteArray result)
 {
     // throw new NotImplementedException();
     //Debug.LogErrorFormat("BlendDetails is not implemented for {0} ({1})", name, GetType());
     return(result);
 }
Example #2
0
        public void SetDetailMap(DetailPrototypeWrapper prototype, int x, int z, Serializable2DByteArray details, int dRes, Serializable2DFloatArray stencil = null)
        {
            if (DetailData == null)
            {
                DetailData = new CompressedDetailDataLookup();
            }

            Serializable2DByteArray existingDetails;

            if (!DetailData.TryGetValue(prototype, out existingDetails) || existingDetails.Width != dRes ||
                existingDetails.Height != dRes)
            {
                existingDetails       = new Serializable2DByteArray(dRes, dRes);
                DetailData[prototype] = existingDetails;
            }

            var width  = details.Width;
            var height = details.Height;

            for (var u = x; u < x + width; ++u)
            {
                for (var v = z; v < z + height; ++v)
                {
                    var hx = u - x;
                    var hz = v - z;

                    try
                    {
                        var splatSample = details[hx, hz];
                        if (stencil != null)
                        {
                            existingDetails[u, v] = (byte)Mathf.Clamp(Mathf.Lerp(existingDetails[u, v], splatSample, stencil[hx, hz]), 0, 255);
                        }
                        else
                        {
                            existingDetails[u, v] = (byte)splatSample;
                        }
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
            }


#if UNITY_EDITOR
            UnityEditor.EditorUtility.SetDirty(this);
#endif
        }
Example #3
0
        public override Serializable2DByteArray BlendDetails(DetailPrototypeWrapper detailWrapper, int x, int z, int width, int height, int dRes,
                                                             Serializable2DByteArray result)
        {
            var layerDetails = GetDetailMap(detailWrapper, x, z, width, height, dRes);

            if (layerDetails == null)
            {
                return(result);
            }

            var stencil = IsValidStencil(Stencil)
                ? Stencil
                : null;

            BlendMMTerrainLayerUtility.BlendArray(ref result, layerDetails, stencil, BlendMode,
                                                  Common.Coord.Zero, new Common.Coord(dRes, dRes));
            return(result);
        }
Example #4
0
        public override Serializable2DByteArray GetDetailMap(DetailPrototypeWrapper detailWrapper, int x, int z, int width, int height, int detailResolution)
        {
            if (DetailData == null)
            {
                return(null);
            }

            Serializable2DByteArray data;

            if (!DetailData.TryGetValue(detailWrapper, out data))
            {
                return(null);
            }

            if (data.Width != detailResolution || data.Height != detailResolution)
            {
                DetailData.Remove(detailWrapper);
                return(null);
            }

            var detailMap = new Serializable2DByteArray(width, height);

            for (var u = x; u < x + width; ++u)
            {
                for (var v = z; v < z + height; ++v)
                {
                    var hx = u - x;
                    var hz = v - z;
                    try
                    {
                        var detail = data[u, v];
                        detailMap[hx, hz] = detail;
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
            }
            return(detailMap);
        }
Example #5
0
 public virtual Serializable2DByteArray GetDetailMap(DetailPrototypeWrapper detailWrapper, int x, int z,
                                                     int width, int height, int detailResolution)
 {
     return(null);
 }