Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PineTree extends BasicTree {
- public PineTree() {
- super();
- branchSlope = 0.24;
- trunkHeightScale = 0.95;
- }
- float treeShape(int y) {
- // Take the y position relative to the base of the tree.
- // Return the distance the foliage should be from the trunk axis.
- // Return a negative number if foliage should not be created at this height.
- // This method is intended for overriding in child classes, allowing
- // different shaped trees.
- // This method should return a consistent value for each y (don't randomize).
- if (y < (((float) height) * 0.2)) return (float) -1.618;
- float invertedHeight = height - y;
- double distance = (0.36 * invertedHeight);
- // Alter this factor to change the overall width of the tree.
- return (float) distance;
- }
- float foliageShape(int y) {
- // Take the y position relative to the base of the foliage cluster.
- // Return the radius of the cluster at this y
- // Return a negative number if no foliage should be created at this level
- // this method is intended for overriding in child classes, allowing
- // foliage of different sizes and shapes.
- if ((y < 0) || (y >= foliageHeight)) return (float) -1;
- else if (y == 0) return (float) 3;
- else if (y == foliageHeight - 1) return (float) 1;
- else return (float) 2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement