Hehe, I thought terrastruct was totally bugged, whenever I loaded a map it looked all distorted. Then after some ages I figured out that you move the scene with the middle mouse button
Well, I got my mesh loaded and I made a simple testscene:
http://bayimg.com/jaeikaAcF
But when running debug nothing happens to the height variable. As there is no info at all in the wiki on this stuff, I?m kind of confused with all the available expressions. I thought Z usually represent depth, right? So when moving about it should give some kind of value, no?
edit: Hm, I realised nwo that maybe I need something like "get closest vertex"
edit2: aha, I realised now that I misinterpreted some things, with colums and rows. I?ll do some more digging
edit3: got it now! I just divided the players x/y with the number of rows/colums in the mesh.. Seems to be working, I?ll do some more messing around..
edit4: hehe, it seems like it is only giving me the X/Y position of a specific place on the mesh, not actual depth values of the vertecie. I?m not sure, will to some more tinkering.
edit5: okay, after puting some food in my stomach I finally figured out a formula (math ain?t exacly my greatest skill) to detarmain the height..
When player-object is overlapping heightmap, give private variable 'height' the following value:
Heightmap.VertexZ(Player.Y/(Heightmap.Height/Heightmap.MeshCols), Player.X/(Heightmap.Width/Heightmap.MeshRows))
Now, there is one problem: it only works when the heightmap is put in the top-left corner of the layout. I need to make it relative somehow.. I?ll see if I can figure it out on my own..
Hm, I can tell that this is going to be a real drain on the system. CPU waiting for GPU went from 90% to 30% when using six objects at once. Imagine having like 20-30 + a lot of other complex calculations.. Guess I have to find a way to optimize this..
edit6: Ah, it was no problem optimizing it, I just set it to happen every 500ms and the cpu usage was barely noticable. I guess if I have a lot of units I could optimize it even further by making some kind of que system so objects never check their height on the same tick..
Many edits