Пример #1
0
    /// <summary>
    /// 构建八叉树
    /// </summary>
    public static Octree Build(TreeModel treeModel)
    {
        GameObject root = treeModel.TreeModelInstance;     //获取根节点表示的模型

        if (root == null)
        {
            return(null);
        }

        /*
         * 添加包含整个植物的包围盒
         * 八叉树则以该包围盒为根节点进行构建
         */
        Mesh.AddBoxColliderInParent(root);
        Bounds rootBounds = root.GetComponent <Collider>().bounds;

        if (IsEmpty(rootBounds))
        {
            return(null);
        }

        List <Triangle> triangles = GameObjectOperation.GetTreeTriangles(treeModel);

        if (triangles == null || triangles.Count == 0)
        {
            return(null);
        }

        return(new Octree(rootBounds.center, rootBounds.size, GameObjectOperation.GetTreeTriangles(treeModel), 5));
    }
Пример #2
0
    /// <summary>
    /// 占地面积(㎡)
    /// </summary>
    public double FloorArea()
    {
        if (TreeModelInstance.GetComponent <Collider>() == null)
        {
            Mesh.AddBoxColliderInParent(TreeModelInstance);
        }

        Bounds bounds = TreeModelInstance.GetComponent <Collider>().bounds;

        return(bounds.size.x * bounds.size.z * MaizeParams.SCALE * MaizeParams.SCALE);
    }
Пример #3
0
    public static double SunShineSim(TreeModel treeModel, PhotosyntheticModels type)
    {
        double biomass = 0.0;

        switch (type)
        {
        case PhotosyntheticModels.LightResponse:
            Octree octree = Octree.Build(treeModel);
            biomass =
                octree == null?         //无模型,说明未出苗
                MaizeParams.SEED_BIOMASS : DailySunShineSimluation(treeModel, DateTime.Now, 119, 26, octree, 0.1f, 100, 100);
            if (octree != null)
            {
                octree.Clear();
            }
            break;

        default:
            GameObject go = treeModel.TreeModelInstance;

            if (go != null)
            {
                Mesh.AddBoxColliderInParent(go);
            }

            biomass =
                treeModel.GetLeafIndexes().Count != 0 ?         //无叶片,说明未出苗
                BeerRule.BiomassCal(treeModel) / FunctionSim.ComputeDaysInGC(treeModel) : MaizeParams.SEED_BIOMASS;
            break;
        }

        if (biomass != MaizeParams.SEED_BIOMASS)
        {
            biomass *= EnvironmentEffect.TemperatureStressFactor(treeModel) * EnvironmentEffect.WaterStressFactor(treeModel) * EnvironmentEffect.SunshineStress(treeModel);
        }

        return(biomass);
    }