예제 #1
0
        public static int Between <T>(this StampGenerator <T, int> generator, int min, int max) where T : class
        {
            if (max < int.MaxValue)
            {
                max++;
            }

            return(generator.GetRandomizer().Next(min, max));
        }
예제 #2
0
    public override void updateDistortedMap(PlanarMesh planarMesh = null)
    {
        if (lowerLayer != null)
        {
            lowerLayer.updateDistortedMap(planarMesh);
            if (colorMap != null)
            {
                if (lowerLayer.getColorMap() != null)
                {
                    if (distortedColorMap == null)
                    {
                        distortedColorMap = new Texture2D(lowerLayer.getColorMap().width, lowerLayer.getColorMap().height);
                    }
                    if (planarMesh == null)
                    {
                        planarMesh = new PlanarMesh();
                    }

                    drawingOver = true;
                    planarMesh.renderMapOver(colorMap, distortedColorMap, lowerLayer.getColorMap(), 0, getUsedPassesCount() - 1);
                }
                if (lowerLayer.getHeightMap() != null)
                {
                    if (distortedHeightMap == null)
                    {
                        distortedHeightMap = new Texture2D(lowerLayer.getHeightMap().width, lowerLayer.getHeightMap().height);
                    }
                    if (distortedNormalMap == null)
                    {
                        distortedNormalMap = new Texture2D(lowerLayer.getNormalMap().width, lowerLayer.getNormalMap().height);
                    }

                    Color[] combinedHeight = getColorMapPixels();
                    Color[] lowerHeight    = lowerLayer.getHeightMap().GetPixels();
                    for (int i = 0; i < combinedHeight.Length; i++)
                    {
                        float color = Mathf.Min(1, lowerHeight[i].r + combinedHeight[i].a);
                        combinedHeight[i] = new Color(color, color, color, 1);
                    }
                    distortedHeightMap.SetPixels(combinedHeight);
                    distortedHeightMap.Apply();

                    StampGenerator.printNormalMap(distortedNormalMap, distortedHeightMap);
                }
                setTextures();
            }
        }
        else if (colorMap != null)
        {
            setTextures();
        }
    }
    public override void init()
    {
        mesh3d = GetComponent <MeshFilter>().mesh;

        if (item == null)
        {
            return;
        }

        // generates raytraced maps from 3D object
        generator = new StampGenerator(item, itemResolution, stampRotation);

        // raytracing stamp textures from 3D object
        heightMap           = generator.getHeightMap();
        normalMap           = generator.getNormalMap();
        normalMapFromHeight = generator.getNormalMapFromHeight();
        edgeMap             = generator.getEdgeMap(new Color(.7f, .7f, .72f, 1), 15, 3);

        // creation of resusable textures that will be used on model
        distortedHeightMap = new Texture2D(textureResolution, textureResolution);
        distortedNormalMap = new Texture2D(textureResolution, textureResolution);
        distortedColorMap  = new Texture2D(textureResolution, textureResolution);

        planarMesh = new PlanarMesh(
            GetComponent <Transform>(),
            mesh3d,
            getArranger(),
            normalizationSteps,
            normalizationStrength,
            showingNormalization,
            neighbourRadius,
            detectOverlappingOnAllTriangles,
            detectOverlappingOnAllEdges,
            useStrength,
            alwaysBuildBestMesh);
    }
예제 #4
0
 public static bool Vary <T>(this StampGenerator <T, bool> generator) where T : class
 {
     return(generator.GetRandomizer().Next(2) == 1);
 }
예제 #5
0
        public Stamp <T> Bind <TProperty>(Expression <Func <T, TProperty> > property, Func <StampGenerator <T, TProperty>, TProperty> callback)
        {
            var generator = new StampGenerator <T, TProperty>(this, property);

            return(Bind(property, callback(generator)));
        }