Paul Thomas Posted December 18, 2009 Share Posted December 18, 2009 Just experimenting and I'm trying to get the terrain grid points from a mouse click/position. Not sure how to go about it yet, just started messing around, and starting to try cameraproject but I don't think that's going to work out. Anyone have any ideas? Quote Link to comment Share on other sites More sharing options...
macklebee Posted December 18, 2009 Share Posted December 18, 2009 Just experimenting and I'm trying to get the terrain grid points from a mouse click/position. Not sure how to go about it yet, just started messing around, and starting to try cameraproject but I don't think that's going to work out. Anyone have any ideas? where are you trying to do this? in a program or the editor? for a lua program, this gives me the position of a pick for any entity class including terrain: pick=CameraPick(camera,Vec3(GraphicsWidth()/2,GraphicsHeight()/2,1000.0),0,0) if pick~=nil then pick_posX=pick.position.x pick_posY=pick.position.y pick_posZ=pick.position.z end it should also work for bmax as well 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...
Paul Thomas Posted December 18, 2009 Author Share Posted December 18, 2009 Sorry, I should have updated my post, I tried camerapick once I gave up on cameraproject. Thanks for replying though man. Quote Link to comment Share on other sites More sharing options...
Paul Thomas Posted December 18, 2009 Author Share Posted December 18, 2009 Still trying to figure out how to get the terrain grid points from a camera pick position. Still messing around with it, lol. No, in a program, not within the editor. Quote Link to comment Share on other sites More sharing options...
Paul Thomas Posted December 18, 2009 Author Share Posted December 18, 2009 Anyone know how to get terrain grid points from a camera pick? Quote Link to comment Share on other sites More sharing options...
Paul Thomas Posted December 18, 2009 Author Share Posted December 18, 2009 Never mind, just takes some math. Quote Link to comment Share on other sites More sharing options...
macklebee Posted December 18, 2009 Share Posted December 18, 2009 Never mind, just takes some math. so you got it? i think everyone would like to see it 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...
Paul Thomas Posted December 18, 2009 Author Share Posted December 18, 2009 Almost. I'll probably have it completed here in just a few, and I'll post up an example. Wanted to mess with terrain editing while "in-game" and it's going well, just have to finalize some of the math. Grid x=0, y=0 works fine, except that I have the y backwards, same with Grid x=128, y=128 (on a 128x128 terrain). Grid x=0, y=128 and Grid x=128, y=0, I have backwards, lol. So click 0, 128 raises the terrain over at 128, 0. Quote Link to comment Share on other sites More sharing options...
Paul Thomas Posted December 19, 2009 Author Share Posted December 19, 2009 Now that I'm done feeling stupid, here it is, after I realized no math was really required. Gather terrain resolution from your sandbox scene or use createterrain. local pick:tpick local grid:tvec3 local height:float local terrain:tterrain if mousehit(1) pick = camerapick(camera, vec3(mousex(), mousey(), 1000.0), 0, 0) if pick <> null and tterrain(pick.entity) terrain = tterrain(pick.entity) grid = pick.position grid.x = grid.x + ((-terrainResolution / 2) + terrainResolution) grid.z = grid.z + ((-terrainResolution / 2) + terrainResolution) height = terrainheight(terrain, grid.z, grid.x) setterrainheight(terrain, grid.z, grid.x, height + 0.001) endif endif That will edit the terrain while playing around with your program. Or terrain.resolution For BlitzMax Quote Link to comment Share on other sites More sharing options...
macklebee Posted December 19, 2009 Share Posted December 19, 2009 nice. 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...
Josh Posted December 20, 2009 Share Posted December 20, 2009 TerrainHeight will return the height at a specific grid point. Terrain elevation will return an interpolated height at a 3D position in global coordinates. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Paul Thomas Posted December 20, 2009 Author Share Posted December 20, 2009 Yeah, going to start experimenting with TerrainElevation instead, since using TerrainElevation was the only way to make my radius tool work correctly (drawn based on terrain height). I have a fairly smooth terrain editor so far, but I still have to work on providing radius (inner and outer). My calculations at the moment are way off. Quote Link to comment Share on other sites More sharing options...
Paul Thomas Posted December 20, 2009 Author Share Posted December 20, 2009 Quote Link to comment Share on other sites More sharing options...
Josh Posted December 20, 2009 Share Posted December 20, 2009 That looks familiar. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Paul Thomas Posted December 20, 2009 Author Share Posted December 20, 2009 lol. I'd like to mimic most of the 2.28 sandbox and then continue to build it to be more targeted for my project. Yes, I'm reinventing the wheel, but I can't build upon the LE sandbox. Project targeted features such as changing the time of day, visual cloud layer manipulation, eventually weather, and so forth. If the original LE sandbox was a module or available for purchase, that would be fantastic, but at the moment I'll have to work on this enough to fit my projects needs. Quote Link to comment Share on other sites More sharing options...
Josh Posted December 20, 2009 Share Posted December 20, 2009 You can do quite a bit to the 2.3 editor with scripts. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Paul Thomas Posted December 20, 2009 Author Share Posted December 20, 2009 Hmm Quote Link to comment Share on other sites More sharing options...
TylerH Posted December 20, 2009 Share Posted December 20, 2009 Lol E.C. It would be cool if we could add new toolbar, UI, etc. functionality to the 2.3 Editor via scripts. Similar to how the InitGrid works per-entity, but more so on a game/editor level. Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
L B Posted December 20, 2009 Share Posted December 20, 2009 I'd be quite interested in seeing the code for the radius drawing. Nice job, by the way. Quote Link to comment Share on other sites More sharing options...
Paul Thomas Posted December 20, 2009 Author Share Posted December 20, 2009 For the actual red radius that follows the terrain? BlitzMax In loop somewhere: pick = camerapick(camera, vec3(mousex(), mousey(), 1000.0), 0, 0) if pick <> null and tterrain(pick.entity) createradiusmesh(tterrain(pick.entity), pick.position.x, pick.position.y, pick.position.z) endif The above could be simplified, it was final code after testing purposes, but never polished up. function createradiusmesh(terrain:tterrain, x:float, y:float, z:float) if radiusmesh freeentity(radiusmesh) radiusmesh = createmesh() entitycolor(radiusmesh, vec4(1.0, 0.0, 0.0, 1.0)) radiussurface = createsurface(radiusmesh) for local i:int = 1 to 360 local px:float = x + cos(i) * radius local pz:float = z + sin(i) * radius local h:float = terrainelevation(terrain, pz, px) addvertex(radiussurface, vec3(px, h, pz)) next radiussurface.mode = GL_LINE_LOOP updatemesh(radiusmesh) entityshadowmode(radiusmesh, false) endfunction Again, can be polished up, and you need a tmesh/tsurface for the above. I'm not really sure how to do this with the current C# headers, have to still try the header out, just haven't had the time. Code above was also rewritten for this forum instead of copy and pasted, so there could be mistakes but it looks correct. And thanks 2 Quote 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.