示例#1
0
    public void Generate(BoundsInt bound, World world)
    {
        Vector3 dirc = (bound.max - bound.min);

        //TestTree.FillCyclinder(world, (uint)Blocks.wood, bound.min, bound.max, 4, 2, dirc.normalized, dirc.normalized);

        System.Random random = new System.Random((bound.x << 16) ^ (bound.y << 8) ^ (bound.z));

        startNode          = new TreeVer4_Ultra(random, this.trunkLen, crownWidth, rootScale, endRadiusScale);
        startNode.growRate = startGrowRate;

        startNode.init();

        Descript(startNode, 0);

        FractalRenderState state = new FractalRenderState();

        state.position = new Vector3(bound.center.x, bound.min.y, bound.center.z);
        state.rotation = Quaternion.identity;
        state.scale    = this.scale;

        Render(world, state, startNode);
    }
    public void ReDraw()
    {
        UnityEngine.Random.seed = randomSeed;

        switch (fractalType) //Simple factory
        {
        case FractalType.boxTest:
            startNode          = new BoxTest();
            startNode.growRate = startGrowRate;
            break;

        case FractalType.treeVer1:
            startNode          = new TreeVer1Beta();
            startNode.growRate = startGrowRate;
            break;

        case FractalType.treeVer1_ReducedVertices:
            startNode          = new TreeVer1_ReducedVertices();
            startNode.growRate = startGrowRate;
            break;

        case FractalType.treeVer2Cyc_ConcretedNormals:
            startNode          = new TreeVer2Cyc();
            startNode.growRate = startGrowRate;
            break;

        case FractalType.treeVer3Cyc_Spline:
            startNode          = new TreeVer3_CycWithSpline();
            startNode.growRate = startGrowRate;
            break;

        case FractalType.treeVer3_G:
            startNode          = new TreeVer3_withGravity();
            startNode.growRate = startGrowRate;
            break;

        case FractalType.treeVer4:
            startNode          = new TreeVer4_Ultra();
            startNode.growRate = startGrowRate;
            break;

        case FractalType.treeVer4_Frond:
            startNode          = new TreeVer4_Frond();
            startNode.growRate = startGrowRate;
            break;
        }
        startNode.startGrowRate = startGrowRate;

        indices.Clear();
        indicesCount.Clear();
        verticesCount = 0;
        for (int i = 0; i < startNode.submeshCount; i++)
        {
            indices.Add(new int[indicesMax]);
            indicesCount.Add(0);
        }

        startNode.randomSeed *= randomSeed;
        startNode.fractalMode = fractalMode;

        startNode.init();

        Descript(startNode, 0);

        //Debug.Log(stoppedCount);

        RenderMesh();
    }