diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
| commit | b691c43c44ff180d10e7d4a9afc83b98551ff586 (patch) | |
| tree | 3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.World/BasicTree.h | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.World/BasicTree.h')
| -rw-r--r-- | Minecraft.World/BasicTree.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/Minecraft.World/BasicTree.h b/Minecraft.World/BasicTree.h new file mode 100644 index 00000000..feb14581 --- /dev/null +++ b/Minecraft.World/BasicTree.h @@ -0,0 +1,70 @@ +#pragma once +#include "Feature.h" + +class Level; + +class BasicTree : public Feature +{ +private: + // The axisConversionArray, when given a primary index, allows easy + // access to the indices of the other two axies. Access the data at the + // primary index location to get the horizontal secondary axis. + // Access the data at the primary location plus three to get the + // remaining, tertiary, axis. + // All directions are specified by an index, 0, 1, or 2 which + // correspond to x, y, and z. + // The axisConversionArray is used in several places + // notably the crossection and taperedLimb methods. + // Example: + // If the primary axis is z, then the primary index is 2. + // The secondary index is axisConversionArray[2] which is 0, + // the index for the x axis. + // The remaining axis is axisConversionArray[2 + 3] which is 1, + // the index for the y axis. + // Using this method, the secondary axis will always be horizontal (x or z), + // and the tertiary always vertical (y), if possible. + static byte axisConversionArray[]; + + // Set up the pseudorandom number generator + Random *rnd; + + // Make fields to hold the level data and the random seed + Level *thisLevel; + + // Field to hold the tree origin, x y and z. + int origin[3]; + // Field to hold the tree height. + int height; + // Other important tree information. + int trunkHeight; + double trunkHeightScale; + double branchDensity; + double branchSlope; + double widthScale; + double foliageDensity; + int trunkWidth; + int heightVariance; + int foliageHeight; + // The foliage coordinates are a list of [x,y,z,y of branch base] values for each cluster + int **foliageCoords; + int foliageCoordsLength; + void prepare(); + void crossection(int x, int y, int z, float radius, byte direction, int material); + float treeShape(int y); + float foliageShape(int y); + void foliageCluster(int x, int y, int z); + void limb(int *start, int *end, int material); + void makeFoliage(); + bool trimBranches(int localY); + void makeTrunk(); + void makeBranches(); + int checkLine(int *start, int *end); + bool checkLocation(); + +public: + BasicTree(bool doUpdate); + virtual ~BasicTree(); + + virtual void init(double heightInit, double widthInit, double foliageDensityInit); + virtual bool place(Level *level, Random *random, int x, int y, int z); +}; |
