Procedural tree generation
Blitz3D Forums/Blitz3D Programming/Procedural tree generation
| ||
Need some help finding a tutorial on how to do this or guidance. |
| ||
http://lmgtfy.com/?q=Procedural+tree+generation+tutorial |
| ||
Search L-System: http://bostandjiev.com/Graphics%20class%20final/index.html http://spanky.triumf.ca/www/fractint/lsys/plants.html |
| ||
Is there a way to get the vertex coordinates of a mesh after PositionEntity(), RotateEntity commands so that the entity's position is included to the vertex coordinates? hope that makes sense. |
| ||
To get the position of each vertex in world coords, taking into consideration scaling, position and rotation use ... s = getsurface( mymesh, 1 ) for v = 0 to countvertices(s)-1 tformpoint vertexx(s,v), vertexy(s,v), vertexz(s,v), mymesh, 0 wx# = tformedx() wy# = tformedy() wz# = tformedz() next |
| ||
Oh nice! But I figured out another way. I just used the example from the code archives and made some changes so that it returns one tree mesh (no leaves, erm dead leafs). spacebar to generate a new random tree |
| ||
Another question. I'm trying to align the trees to stand up (or out) on the surface of a sphere. Im placing them directly on randomly picked vertices. now I can get them on the surface with the help of Stevie G's Tformed. But now I need to figure out the pitch and yaw to stand them up. As it is now they lay on the surface except to the north of the sphere. |
| ||
Use AlignToVector with the picked vertex normal below the tree, something like this: AlignToVector tree,NX,NY,NZ,2 |
| ||
christain, I cant seem to get it working. I'm makeing tree tiles, for the tiled geosphere I've made. is there a simple formula for like: Pitch_from x,y,z to 0,0,0 is a Yaw_from x,y,z to 0,0,0 is b so that if you do , rotatemesh mesh,-a,-b,0 the top of the mesh would be facing x,y,z and the bottom of the mesh would be facing 0,0,0 |
| ||
Oh awesome, trees on a geosphere. Use some gravity and it would be awesome, jumpin around like a retard all over the planet. |
| ||
Here is an example, using my geosphere code from the codearchives. 1000 single surface trees aligned correct to land only vertices using AlignToVector command:![]() The way to go: - choose a random vertex from the planet - place tree at this vertex position - get normal vectors of this vertex - use AlignToVector to align the tree according to the vertex normal To determine if a vertex is land or water I checked the distance between the vertex position and the center planet pivot: if the distance is 1.0 or greater it is land - so I repeated choosing random vertices until it is far away. |
| ||
oh nice, thanks, but... I'm making a tree tile, grouping tree's to a single mesh. so i have to rotate the mesh and position the mesh directly. Then add mesh to the tree tile. Havent tried it yet but i'm guessing i can use entitypitch yaw roll and store those after a aligntovector for use later to rotatemesh. Christian, should change this line: vert=Rand(0,CountVertices(surf)) to vert=Rand(0,CountVertices(surf)-1) I think. |
| ||
well got it to work kind of.... the trees are lining up to the right direction. just not on the surface of the geosphere, sometimes far above it, sometimes below it.. don't know why. |
| ||
well here is what i'm doing, each mesh tile is stored in planettiles(n,0) (n,1) (n,2)(n,3) is the middle vertex xyz axis, and (n,4) tree mesh tile. Now, the tree's are not lining up to the planet mesh |
| ||
ahh got it to work just a few more things to add till i release the source |
| ||
ok, I need help figuring out how to put leaves on the trees, but here is the source for tiled planet with tree's(tree trunks I mean). It comes in 3 parts. example: 3D perlin noise engine/geosphere: Tree maker: |