Terrain?

BlitzMax Forums/MiniB3D Module/Terrain?

ckob(Posted 2007) [#1]
Did anyone ever add Terrain to miniB3d? i know this was discussed awhile ago but I didn't see anything new and when I try searching for it..well for anything I get a 404.


C64(Posted 2007) [#2]
In the newest minib3d (0.41 Xtnd (klepto2)) is a Xmpl for a Terrain.
Get the newest version of minib3d (Xtnd) and show for the Terrain Xmpl.


H&K(Posted 2007) [#3]
But its not realy a Terrain example is it?
By that I mean that its just an "Ordenary" model that is used as a Terrain, isnt it?


klepto2(Posted 2007) [#4]
It is a real Terrain loaded of a pregenerated Heightmap.

Terrain commands:
LoadTerrain:TTerrain(URL:String,Chunksize:Int = 64)
PositionTerrain(Terrain:TTerrain , X:Float , Y:Float , Z:Float)
ScaleTerrain(Terrain:TTerrain , X:Float , Y:Float , Z:Float)
TextureTerrain(Terrain:TTerrain , File:String , Layer:Int = 0)
TerrainY(Terrain:TTerrain,X:Float,Y:Float,Z:Float,Mode:Int = 1)

The mode parameter in TerrainY stays for the method used to get the y height value.

0 = Very fast (interpolated Heightmap Values) but not very accurate
1 = Medium speed but very accurate (uses LinePick)
2 = Slow but most accurate (calculates the exact height on tri)


ckob(Posted 2007) [#5]
seems like the terrain example takes forever to load but when it does load it runs very smooth.


H&K(Posted 2007) [#6]
Wow, well I missed that getting added.

To save me doewloading and experementing, couple of questions.

I assume that Terrain is a complete type? so
ATerrain.Position(x:float,y:float,z:float)
ATerrain.Scale(X:float,y:float,z:float) etc

Also is it a singleton? That is can I have more than one?

And Finaly, Does it have a Level of Detail parameter? Or is it a Full Mesh all the time? (I assume that it several split meshs of "ChunkSize", and not a true LOD mesh)

Thanks


Brucey(Posted 2007) [#7]
seems like the terrain example takes forever to load

Indeed. Completely unusable on my system because of how long it takes to create the "chunks". UpdateNormals() is the main problem. It's speed is dire... Surely there must be a faster way to do that ?


Brucey(Posted 2007) [#8]
Here's one small optimization :

Instead of calling TriangleVertex() which creates a array of ints and copies values into it before returning one of those, perhaps this is faster (and more GC friendly)...
' before
Local v=surf.TriangleVertex(t,c)

' after
Local v=surf.tris[(t + 1)*3 - (c + 1)]

Saves one method call too...

Not sure how much faster it is to pull "(t + 1)*3" out of the inner loop and put it in a var, even. But there are lots of those around I see, do I guess it's not important.