Lunarovich Posted May 30, 2015 Share Posted May 30, 2015 I have two questions regarding terrain: 1) How can I access a terrain made in the editor from Lua script? Secondly, is there any way to create it programmatically / procedurally, ie. via scripting and not in the editor? 2) I see that a terrain is shaded, which is fine. However, I notice that it does not cast shadows, which is very unrealistic. Is there a way to make it cast shadows. Thank you! Quote Link to comment Share on other sites More sharing options...
shadmar Posted May 30, 2015 Share Posted May 30, 2015 1. Probably not supported, since CountEntities and GetEntity are not dicumented, but here is a way --get world and terrain 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 2. Not that I know. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
macklebee Posted May 30, 2015 Share Posted May 30, 2015 Also, the terrain commands (not supported/documented) are exposed to lua. example Main.lua: window = Window:Create("terrain example",0,0,800,600) context = Context:Create(window) world = World:Create() camera = Camera:Create() camera:SetPosition(0,6,0) camera:SetRotation(0,45,0) camera:SetMultisampleMode(8) skybox = Texture:Load("Materials/Sky/skybox_texture.tex") camera:SetSkybox(skybox) light = DirectionalLight:Create() light:SetRotation(45,45,0) terrain = Terrain:Create(128,true) terrain:SetLayerTexture(0, Texture:Load("Materials/Nature/terrain_savannah_dirt.tex"), 0) terrain:SetLayerTexture(0, Texture:Load("Materials/Nature/terrain_savannah_dirtdot3.tex"), 1) terrain:SetScale(1,5,1) for x = 0, 64 do for y = 64, 128 do height = Math:Random(0,1)+0.5 height = Math:Min(height,1.0) terrain:SetHeight(x,y,height) end end terrain:UpdateNormals() camrot = camera:GetRotation() gx=Math:Round(context:GetWidth()/2) gy=Math:Round(context:GetHeight()/2) move = 0 strafe = 0 while window:KeyDown(Key.Escape)==false do if window:Closed() then break end local mouseposition = window:GetMousePosition() local dx = mouseposition.x - gx local dy = mouseposition.y - gy camrot.x = camrot.x + dy / 10.0 camrot.y = camrot.y + dx / 10.0 camera:SetRotation(camrot) window:SetMousePosition(gx,gy) move = Math:Curve(((window:KeyDown(Key.W)and 1 or 0) - (window:KeyDown(Key.S) and 1 or 0)),move,10) strafe = Math:Curve(((window:KeyDown(Key.D)and 1 or 0) - (window:KeyDown(Key.A) and 1 or 0)),strafe,10) camera:Move(strafe,0,move) Time:Update() world:Update() world:Render() context:Sync() end As for terrain shadows, I haven't seen those since LE2. I suspect it will be re-introduced once LE3 gets vegetation. 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Lunarovich Posted May 31, 2015 Author Share Posted May 31, 2015 Thank you for these excellent answers! I'm wandering, though, why those stay undocumented... Btw, how do you know these things? From Visual Studio auto-complete, trial & error, and similar? P.S. If they are there, why do you say that they are unsupported? Because they might change in the future, might disappear, or similar? 1 Quote Link to comment Share on other sites More sharing options...
shadmar Posted May 31, 2015 Share Posted May 31, 2015 I look in the cpp header files yes If they are not documented, they might change/be taken out/or not. Only Josh knows for sure. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
macklebee Posted May 31, 2015 Share Posted May 31, 2015 I perform a global variable dump in lua since i do not have the c++ version of LE. I can see each command/member available for each class. This is the latest version: globals.txt Edit- and like shadmar suggests, if it is not documented, then Josh has repeatedly warned that it may be removed or stop working at any time. 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Lunarovich Posted May 31, 2015 Author Share Posted May 31, 2015 I perform a global variable dump in lua since i do not have the c++ version of LE. Maybe now it's the right time to get it if you need it: P.S. How do you do a global variable dump? Quote Link to comment Share on other sites More sharing options...
macklebee Posted May 31, 2015 Share Posted May 31, 2015 nope im good - no need to use the c++ version Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
BadJeanBon Posted August 13, 2016 Share Posted August 13, 2016 I perform a global variable dump in lua. How do you do that ?? Quote Link to comment Share on other sites More sharing options...
macklebee Posted April 26, 2017 Share Posted April 26, 2017 updated for latest beta: GlobalList_042517.txt 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel 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.