public void SimpleSwitchGraphBuild() { PWMainGraph graph = TestUtils.GenerateTestMainGraphBiomeSwitch(); BiomeData bd = new BiomeData(); var wlevel = graph.FindNodeByName("wlevel"); var bswitch = graph.FindNodeByName <PWNodeBiomeSwitch>("bswitch"); var b1 = graph.FindNodeByName <PWNodeBiome>("b1"); var b2 = graph.FindNodeByName <PWNodeBiome>("b2"); bd.biomeSwitchGraphStartPoint = wlevel; PartialBiome p1 = new PartialBiome(); PartialBiome p2 = new PartialBiome(); b1.outputBiome = p1; b2.outputBiome = p2; //setup the switch values var sd = bswitch.switchList.switchDatas; sd[0].min = 0; sd[0].max = 5; sd[0].name = "1"; sd[0].samplerName = BiomeSamplerName.terrainHeight; sd[1].min = 5; sd[1].max = 10; sd[1].name = "2"; sd[1].samplerName = BiomeSamplerName.terrainHeight; Sampler2D terrainHeight = new Sampler2D(32, 1); terrainHeight.min = 0; terrainHeight.max = 10; bd.UpdateSamplerValue(BiomeSamplerName.terrainHeight, terrainHeight); BiomeSwitchGraph switchGraph = new BiomeSwitchGraph(); switchGraph.BuildGraph(bd); Assert.That(switchGraph.isBuilt == true); var values = new BiomeSwitchValues(); values[0] = 4.0f; Assert.That(switchGraph.FindBiome(values).id == p1.id); values[0] = 0f; Assert.That(switchGraph.FindBiome(values).id == p1.id); values[0] = 5f; Assert.That(switchGraph.FindBiome(values).id == p1.id); values[0] = 6.0f; Assert.That(switchGraph.FindBiome(values).id == p2.id); values[0] = 10f; Assert.That(switchGraph.FindBiome(values).id == p2.id); }
public override void OnNodeProcess() { calls++; if (calls > 10) { return; } if (inputDataMode == BiomeDataInputMode.WorldGraph || graphRef.IsRealMode()) { if (outputPartialBiome != null) { return; } if (previewGraph == null) { throw new InvalidOperationException("[BiomeGraph] can't proces a graph in worldGraph data input mode with a null main graph"); } //check if the preview graph have a reference of this graph. if (!previewGraph.FindNodesByType <NodeBiome>().Any(b => b.biomeGraph == graphRef)) { throw new InvalidOperationException("[BiomeGraph] the specified preview graph (" + previewGraph + ") does not contains a reference of this biome graph"); } //we process the graph to provide the outputPartialBiome //it require that biomeGraph to be contained in the previewGraph. previewGraph.ProcessFrom(biomeGraphRef); //if the graph we process does not contains an instance of our biome graph if (outputPartialBiome == null) { throw new InvalidOperationException("[BiomeGraph] " + graphRef + " there is a problem with the biome switch graph in (" + previewGraph + ") "); } } else { outputPartialBiome = inputDataGenerator.GeneratePartialBiome2D(biomeGraphRef); } }
public override void OnNodeProcess() { if (inputPartialBiome == null) { Debug.LogError("[NodeBiomeDataDecomposer]: Null input partial biome data"); return; } var biomeData = inputPartialBiome.biomeDataReference; if (biomeData == null) { return; } outputBiomeData = inputPartialBiome; outputTerrain = biomeData.GetSampler(BiomeSamplerName.terrainHeight); outputTemperatureMap = biomeData.GetSampler(BiomeSamplerName.temperature); outputWetnessMap = biomeData.GetSampler(BiomeSamplerName.wetness); }
public override void OnNodeEnable() { outputBiome = new PartialBiome(); }
public void SetInput(PartialBiome biomeData) { var input = inputNode as PWNodeBiomeGraphInput; input.outputPartialBiome = biomeData; }