ModifyTerrain MAV
Blitz3D Forums/Blitz3D Beginners Area/ModifyTerrain MAV
| ||
I think I'm missing something really obvious here, but I can't see any wood for the trees. The Terrain definitely exists, so the issue isn't to do with that: Function RandomiseTerrain(Terr) Local Temp#=Rnd(-5.0,5.0) Local Temp2#=Rnd(1.0,9.0) Local ModifyY#=0.0 For ModifyX=1 To TerrainSize(Terr) For ModifyZ=1 To TerrainSize(Terr) ModifyY#=(Abs(Temp#*Temp2#)*0.1) ModifyTerrain Terr,ModifyX,ModifyZ,ModifyY#,True Temp#=Rnd(-5.0,5.0) Temp2#=(Temp2#-(Sgn(Temp2#))) If ((Abs(Temp2))<0.01) Temp2#=Rnd(1.0,9.0) End If Next Next RenderWorld End Function If I edit the Modify line to read: ModifyTerrain Terr,ModifyX,ModifyZ,0.1 I get no error, although the debug window shows that the ModifyY# values should be valid (at least, they fall between 0.0 and 1.0 and the for/next loops never get past the first value (1) ) |
| ||
Should the TerrainSize() loop be zero-indexed?For ModifyX=0 To TerrainSize(Terr)-1 ? |
| ||
the only way i have a MAV with your code is if this line include the True (realtime). with out the flag i have no problems. I supose that it is unnecesary because you are calling RenderWorld to accept all the modifications. Juan |
| ||
the only way i have a MAV with your code is if this line include the True (realtime). with out the flag i have no problems. I supose that it is unnecesary because you are calling RenderWorld to accept all the modifications. The Renderworld was only in there as I experimented with a Realtime=False flag. However, I still got a MAV there. Weird. :S Should the TerrainSize() loop be zero-indexed? I tried both starting from 0 and 1, same thing :( |
| ||
do at leas one RenderWorld before any modification, i donīt know why but it work. I put a renderworld inside your function and MAV dissapear. from the CreateTerrain example (added your function): juan |
| ||
Hm... maybe the 3D 'stuff' needs to be initialised or something. Weird that. but thanks a lot, Charrua. Works here too :) If anyone knows WHY the Renderworld() needs to be called BEFOREHAND, please let me know, I'm quite curious :D |
| ||
I guess that the actual terrain isn't created until RenderWorld is called. |
| ||
i try LoadTerrain and with any previous RenderWorld and works ok!. Aparently LoadTerrain create the terrain previous to RenderWorld and CreateTerrain no (?). I don't know but is strange that 2 similar (should be the same) commands has diferent behavior. Its a mav not so obvious. In the midle of more code probably this were the las i ask or think for. Juan |
| ||
try LoadTerrain and with any previous RenderWorld and works ok!. Aparently LoadTerrain create the terrain previous to RenderWorld and CreateTerrain no (?). This would seem to agree with I guess that the actual terrain isn't created until RenderWorld is called. Makes sense. |
| ||
I scrapped the idea for a separate function that generated and modified the terrain all in one. It works okay most of the time, but on occasion I still get a MAV when the Program next calls Renderworld. Looking back through the DebugLog, I don't see anything that stands out, but then, perhaps I'm not sure what I should be checking for. As an example, I will try to obtain copy of the debug output for an instance where it fails. (Typically of course, it's not MAV when I test it now... |