public void BuildOctree(CartesianBounds cartesianBounds) { float centerX = (float)(cartesianBounds.MinimumCoordinates.X + cartesianBounds.MaximumCoordinates.X) / 2f; float centerZ = (float)(cartesianBounds.MinimumCoordinates.Y + cartesianBounds.MaximumCoordinates.Y) / 2f; float sizeX = (float)(cartesianBounds.MaximumCoordinates.X - cartesianBounds.MinimumCoordinates.X); float sizeZ = (float)(cartesianBounds.MaximumCoordinates.Y - cartesianBounds.MinimumCoordinates.Y); // NOTE: This is offset in y in a naive way, just so that two nodes on top of one another // don't have their adjoining edge at y=0 which many model bounds would intersect. So it improves the insertion quality for our purposes var boundary = new Bounds(new Vector3(centerX, 100f, centerZ), new Vector3(sizeX, 1000f, sizeZ)); _octree = new Octree(boundary, 1); _octree.Build(Models); }
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); }