public static double TemperatureStressFactor(TreeModel treeModel)
    {
        EnvironmentParams envirParams = treeModel.EnvironmentParams;

        return(TemperatureStressFactor(FunctionSim.GrowthPeriodJudgment(treeModel),
                                       envirParams.DailyMaxTemperature, envirParams.DailyMinTemperature));
    }
    public static double WaterStressFactor(TreeModel treeModel)
    {
        EnvironmentParams envirParams = treeModel.EnvironmentParams;

        return(WaterStressFactor(envirParams.DailyMaxTemperature, envirParams.DailyMinTemperature,
                                 envirParams.DailyMaxRelativeHumidity, envirParams.DailyMinRelativeHumidity,
                                 envirParams.WindSpeed, SolarSim.DailyDirectIrradiance(DateTime.Now, 119, 26),
                                 treeModel.ComputeGrowthCycle(), FunctionSim.GrowthPeriodJudgment(treeModel),
                                 envirParams.WaterContent));
    }
    public void MorphologicalSim(List <BranchIndex> branchIndexes, List <OrganIndex> organIndexes)
    {
        GrowthPeriod period = FunctionSim.GrowthPeriodJudgment(branchIndexes, organIndexes);    //判断生长时期

        if (period <= GrowthPeriod.TASSELING_STAGE)
        {
            MorphologicalSim(FemaleType.Hair);
        }
        else
        {
            MorphologicalSim(FemaleType.Corn);
        }
    }
Example #4
0
    public void MorphologicalSim(double biomass, bool isClear = true, bool isSameGC = false)
    {
        DataCheck();    //数据检查

        /*
         * 包含枝干和器官的索引
         * 其每一个索引包含了后续生成GameObject所需的形态信息(旋转角度)以及
         * 生成形态信息所需的数据(生物量、年龄)
         */
        List <OrganIndex> indexes = GetIndexes(isClear, isSameGC);

        /*
         * 分配生物量给各个器官
         * 累积的生物量为后续形态模拟提供参考依据
         */
        FunctionSim.PhotosynthateAllocation(this, biomass, FunctionSim.GrowthPeriodJudgment(BranchIndexes, OrganIndexes));

        /*
         * 遍历每个Index
         * 计算形态数据
         * 根据形态数据绘制GameObject
         */
        int             curLevel      = 0;
        Vector3         curPosition   = Vector3.zero;
        Stack <Vector3> positionStack = new Stack <Vector3>();

        foreach (OrganIndex index in indexes)
        {
            switch (index.Type)
            {
            case OrganType.Branch:
                BranchIndex branchIndex = index as BranchIndex;

                if (branchIndex.Level > curLevel)
                {
                    positionStack.Push(curPosition);
                }
                else if (branchIndex.Level < curLevel)
                {
                    curPosition = positionStack.Pop();
                }

                curLevel    = branchIndex.Level;
                curPosition = RecordBranchModel(branchIndex, curPosition);

                break;

            case OrganType.Leaf:

                LeafIndex leafIndex = index as LeafIndex;
                CreateLeafModel(leafIndex, curPosition);

                break;

            case OrganType.Flower:

                MaleIndex maleIndex = index as MaleIndex;
                CreateFlowerModel(maleIndex, curPosition);

                break;

            case OrganType.Fruit:

                FemaleIndex femaleIndex = index as FemaleIndex;
                CreateFruitModel(femaleIndex, curPosition);

                break;
            }
        }

        CreateBranchModel();

        /*
         * 病虫害模拟
         * 测试
         */
        InsectSimulation();

        PostProcessing();
    }