mdgrigg Posted August 4, 2014 Share Posted August 4, 2014 Hi guys, wondering if anyone could explain the easiest ways to place a large amount of trees on the terrain, preferably randomised with different heights and variation. Can't wait for the vegetation took in terrain tab! "Fingers crossed" I'm assuming a script would be the only way. Appreciate your time guys, Griggzy Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted August 4, 2014 Share Posted August 4, 2014 A vegetation placement tool is planned for this year. In the mean time you can place your trees by hand, which is really cumbersome or by code. Code wise, I would go accross all terrain vertices, have a random number choose whether to plant a tree, and as extra check also check the slope angle and/or height of the vertex. 1 Quote Link to comment Share on other sites More sharing options...
mdgrigg Posted August 4, 2014 Author Share Posted August 4, 2014 A vegetation placement tool is planned for this year. In the mean time you can place your trees by hand, which is really cumbersome or by code. Code wise, I would go accross all terrain vertices, have a random number choose whether to plant a tree, and as extra check also check the slope angle and/or height of the vertex. Thanks Aggror, my WIP is 4096 x 4096 do I am trying to avoid placing by hand, i was talking to ChrisV and he suggested creating a group prefab of trees (thanks dude) and im probably going to resort to that for now, only problem is ill more than likely have to manually adjust for terrain vertices\slope angles. 1 Quote Link to comment Share on other sites More sharing options...
Rick Posted August 4, 2014 Share Posted August 4, 2014 You could combine the 2. Prefab and code for placement. Make a prefab with a bunch of trees. Then in code loop over all these prefabs and their children (each tree) and cast a ray downward until you hit the terrain. Then adjust the tree to that point (probably a little more downward even). That way you can still manually make sure your big prefab of trees isn't on big slopes and have code adjust it. However, it'll look ugly in the editor as the trees will be hovering over the ground and only adjust at startup. You could place the code in a post processing script which would get ran in the editor, but not sure if it's that big of a deal or not. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted August 4, 2014 Share Posted August 4, 2014 Are these going to be restricted to Lua games? I hope not. I think you are posting in the wrong topic. Quote Link to comment Share on other sites More sharing options...
shadmar Posted August 4, 2014 Share Posted August 4, 2014 What is a large amount? Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
mdgrigg Posted August 5, 2014 Author Share Posted August 5, 2014 What is a large amount? I'd say 10,000~ Quote Link to comment Share on other sites More sharing options...
mdgrigg Posted August 5, 2014 Author Share Posted August 5, 2014 You could combine the 2. Prefab and code for placement. Make a prefab with a bunch of trees. Then in code loop over all these prefabs and their children (each tree) and cast a ray downward until you hit the terrain. Then adjust the tree to that point (probably a little more downward even). That way you can still manually make sure your big prefab of trees isn't on big slopes and have code adjust it. However, it'll look ugly in the editor as the trees will be hovering over the ground and only adjust at startup. You could place the code in a post processing script which would get ran in the editor, but not sure if it's that big of a deal or not. Good idea, thanks Rick I'll look into it. Quote Link to comment Share on other sites More sharing options...
Jakuryusei Posted August 9, 2014 Share Posted August 9, 2014 I know that blender has a fast way to make individual trees, but I haven't found time to mess with it myself yet! Quote Link to comment Share on other sites More sharing options...
mdgrigg Posted August 9, 2014 Author Share Posted August 9, 2014 I know that blender has a fast way to make individual trees, but I haven't found time to mess with it myself yet! Yeah im using Blender to create tree models etc.. I just dont want to have to place those models 1x1. Quote Link to comment Share on other sites More sharing options...
shadmar Posted August 17, 2014 Share Posted August 17, 2014 This should now work in the latest beta function Script:Start() --Adjustables, size and treemodel local terrainsize=4096 local number=2000 local model=Model:Box() model:SetScale(1,50,1) --Find the terrain ( I know, but currently the only way ) local world=World:GetCurrent() for i=0,world:CountEntities()-1 do if world:GetEntity(i):GetClass()==Object.TerrainClass then self.terrain=world:GetEntity(i) tolua.cast(self.terrain,"Terrain") break end end --Put "trees" at random positions if self.terrain then for i=0,number-1,1 do local m=model:Instance() local pos=Vec3(Math:Random(-terrainsize/2,terrainsize/2),0,Math:Random(-terrainsize/2,terrainsize/2)) pos.y = self.terrain:GetElevation(pos.x,pos.z) m:SetPosition(pos) end end end 1 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.