public float l; //Longeur des internodes (= v/n) public Bud(Vector3 position, bool isNewAxis_) { isNewAxis = isNewAxis_; this.pos = position; targetMarkers = new List <Vector3>(); dir = new Vector3(0, 1, 0); state = BudState.DORMANT; mainVertices = null; mainNormales = null; lateralVertices = null; lateralNormales = null; }
IEnumerator Bloom(float bTime) { for (float t = 0.0f; t < 1.0f; t += Time.deltaTime / bTime) { if (riseTransform != null) { riseTransform.Translate(0, riseHeight * transform.localScale.x / bTime * Time.deltaTime, 0); } BlendPetals(t); blendTime = t; yield return(budState = BudState.Blooming); } foreach (MeshCollider col in meshCollider) { col.enabled = true; } yield return(budState = BudState.Bloomed); }
// appendNewShoots public void appendNewShoots() { if (isBroken) return; // Chain metamer calls if (mainMetamer != null) mainMetamer.appendNewShoots(); if (lateralMetamer != null) lateralMetamer.appendNewShoots(); if (activeBud != BudType.NONE) { // Check bud quality if (budQuality > 0) { // Create shoots... Debug.Assert(activeBud != BudType.NONE); if (activeBud == BudType.TERMINAL) { if (terminalBudState != BudState.DEAD) { mainMetamer = assembleShoot(); terminalBudState = mainMetamer == null ? BudState.DEAD : BudState.NODE; } activeBud = BudType.LATERAL; } else if (activeBud == BudType.LATERAL) { if (lateralBudState != BudState.DEAD) { lateralMetamer = assembleShoot(); lateralBudState = lateralMetamer == null ? BudState.DEAD : BudState.NODE; } activeBud = BudType.NONE; } } } }
public Metamer(Tree tree, Metamer previousMetamer, BudType activeBud, BudState terminalBudState, BudState lateralBudState, float axis, bool placeBudOnLeft) { this.tree = tree; this.activeBud = activeBud; this.previousMetamer = previousMetamer; this.terminalBudState = terminalBudState; this.lateralBudState = lateralBudState; this.axis = axis; this.placeBudOnLeft = placeBudOnLeft; aabb = new AABB(); isRoot = previousMetamer == null; constraintPoints = new List<Metamer>(); previousConstraintPoints = new List<Metamer>(); associatedMarkers = new List<MetamerMarker>(); fixturesToTest = new Fixture[MAX_FIXTURES_TO_TEST]; localGridHalfWidth = (int)Math.Floor(tree.perceptionRadius / TreeSystem.PLANT_CELL_SIZE) + 2; localGridHalfHeight = (int)Math.Floor(tree.perceptionRadius / TreeSystem.PLANT_CELL_SIZE) + 2; currentAngle = axis; currentTextureAngle = axis; collisionVertices = new Vector2[FarseerPhysics.Settings.MaxPolygonVertices]; collisionNormals = new Vector2[FarseerPhysics.Settings.MaxPolygonVertices]; constraints = new List<MetamerConstraint>(); relatedConstraints = new List<MetamerConstraint>(); _vertices = new VertexPositionColorTexture[2]; // Mass mass = 1f; inverseMass = 1f / mass; // Calculate position position = (isRoot ? tree.position : previousMetamer.position + new Vector2((float)Math.Cos(axis), (float)Math.Sin(axis)) * tree.internodeLength); oldPosition = position; // Trunk constraints if (!isRoot) { if (isApex() && tree.iterations < 2) { // Create anchor constraints Vector2 relative = position - tree.rootPosition; Vector2 anchorA = tree.rootPosition + tree.anchorNormal * 3f; float distance = (anchorA - position).Length(); constraints.Add(new TrunkMetamerConstraint(this, anchorA, distance)); Vector2 anchorB = tree.rootPosition + tree.anchorNormal * -3f; distance = (anchorB - position).Length(); constraints.Add(new TrunkMetamerConstraint(this, anchorB, distance)); } // Create metamer-metamer links if (!previousMetamer.isBroken) internodeConstraint = new DistanceMetamerConstraint(this, previousMetamer, tree.internodeLength * 0.8f, 0.5f); } // Put this metamer in a cell in the metamer grid ci = tree.treeSystem.getPlantGridX(position.X); cj = tree.treeSystem.getPlantGridY(position.Y); if (!tree.treeSystem.metamerGrid.ContainsKey(tree.levelUid)) { tree.treeSystem.metamerGrid.Add(tree.levelUid, new Dictionary<int, Dictionary<int, List<Metamer>>>()); } if (!tree.treeSystem.metamerGrid[tree.levelUid].ContainsKey(ci)) { tree.treeSystem.metamerGrid[tree.levelUid][ci] = new Dictionary<int, List<Metamer>>(); } if (!tree.treeSystem.metamerGrid[tree.levelUid][ci].ContainsKey(cj)) { tree.treeSystem.metamerGrid[tree.levelUid][ci][cj] = new List<Metamer>(); } tree.treeSystem.metamerGrid[tree.levelUid][ci][cj].Add(this); // Destroy markers in the occupied zone destroyMarkersInOccupiedZone(); // Expand level boundary tree.treeSystem.levelSystem.expandFallbackBoundary(tree.levelUid, position); // Determine z-index _z = tree.layerDepth + StasisMathHelper.floatBetween(-0.02f, 0.01f, tree.random); }