/// <summary> /// Generates the structure of a tree, but no vertex data. /// </summary> /// <param name="rnd">Object providing random numbers.</param> /// <param name="userConstraint">Object imposing user-defined constraints on the generated tree. See <see cref="TreeConstraints"/>.</param> /// <returns>A new tree skeleton.</returns> /// <seealso cref="TreeSkeleton"/> /// <seealso cref="TreeMesh"/> /// <seealso cref="TreeLeafCloud"/> /// <seealso cref="SimpleTree"/> public TreeSkeleton GenerateTree(Random rnd, TreeContraints userConstraint) { if (root == null || maxLevel == 0) { throw new InvalidOperationException( "TreeGenerator has not been initialized. Must set Root and MaxLevel before generating a tree."); } var crayon = new TreeCrayon(); crayon.Level = maxLevel; crayon.BoneLevels = BoneLevels; crayon.Constraints = constraints; constraints.UserConstraint = userConstraint; crayon.Skeleton.LeafAxis = LeafAxis; crayon.Skeleton.Bones.Add(new TreeBone(Quaternion.Identity, -1, Matrix.Identity, Matrix.Identity, 1, 1, -1)); root.Execute(crayon, rnd); crayon.Skeleton.CloseEdgeBranches(); crayon.Skeleton.TextureHeight = textureHeight + textureHeightVariation * (2.0f * (float)rnd.NextDouble() - 1.0f); return(crayon.Skeleton); }
/// <summary> /// Generates the structure of a tree, but no vertex data. /// </summary> /// <param name="rnd">Object providing random numbers.</param> /// <param name="userConstraint">Object imposing user-defined constraints on the generated tree. See <see cref="TreeConstraints"/>.</param> /// <returns>A new tree skeleton.</returns> /// <seealso cref="TreeSkeleton"/> /// <seealso cref="TreeMesh"/> /// <seealso cref="TreeLeafCloud"/> /// <seealso cref="SimpleTree"/> public TreeSkeleton GenerateTree(Random rnd, TreeContraints userConstraint) { if (root == null || maxLevel == 0) throw new InvalidOperationException( "TreeGenerator has not been initialized. Must set Root and MaxLevel before generating a tree."); var crayon = new TreeCrayon(); crayon.Level = maxLevel; crayon.BoneLevels = BoneLevels; crayon.Constraints = constraints; constraints.UserConstraint = userConstraint; crayon.Skeleton.LeafAxis = LeafAxis; crayon.Skeleton.Bones.Add(new TreeBone(Quaternion.Identity, -1, Matrix.Identity, Matrix.Identity, 1, 1, -1)); root.Execute(crayon, rnd); crayon.Skeleton.CloseEdgeBranches(); crayon.Skeleton.TextureHeight = textureHeight + textureHeightVariation*(2.0f*(float) rnd.NextDouble() - 1.0f); return crayon.Skeleton; }