Saving a terrain made in blitz...Again

Blitz3D Forums/Blitz3D Beginners Area/Saving a terrain made in blitz...Again

RiverRatt(Posted 2004) [#1]
I know I posted this problem a while back and tried some of your suggestions the best I could, so now I have this
terrain maker working and it saves a terrain but it saves
it with out any terrain detail. Neos wrote a function for me(thank you Neos) to save terains but it is just saving a flat plane. I don't have a clue why its not saving correctly. One thing I can say is that the saved terain does carry some of the detail just none of the hight changes. In other words it saves as a plain, but when viewed in wireframe mode I can see that it is adding vertices where the hills should be. I will try to put some screen shots in my next post but for now here is the code. Please help?



RiverRatt(Posted 2004) [#2]
This code will run now I have disabled the texures and model
so you all can run it and check it out. It looks a lot better when its textured. If you want to run it here are the
official docs...
Do this first!
Press 1 on keypad to fix camera to the marker position.
arrow keys to move marker and camera
a and z to raise or lower terrain
f1 - f5 to change modes
f1 free roming mode (lets you move around without changing
the terrain.)
f2 wireframe veiw
f3 - f5 changes different drawing styles
1 on keypad again changes camera views
L = light position at marker position
- on numberpad to change lightrange and coneangles
1 on numberpad to change light color (randomly)
space bar for general help instructions (not finished yet but works 8 times)
esc to quit


Ross C(Posted 2004) [#3]
The code still doesn't work, as your still loading them.

So basically, you saving your terrain, then loading it back in, but the mesh loads in as a flat plain?

I assume that's what your wanting, is to convert a terrain, into a mesh?


RiverRatt(Posted 2004) [#4]
The Terrain starts as a flat plane When I begin the program.
Then I raise various points in the terrain to make it look like trenches or hills or whatever, what I want is to save the end result of the terrain as untextured landscape, not nessesarily a mesh. A hightmap would be better. Right now
Neos's function saves a.......somthin witch I can veiw in another program I made last night. The problem is its truncating the land scape when I save, (just in the saved version) so when I load it into another program all I get is a flat plain again. I want the landscape.
One interesting fact, is that the saved terrain does have a lot of extra vertices, wher the hills should be You Know what I meen?
In flat plane you only have 4 vertises right?

"So basically, you saving your terrain, then loading it back in, but the mesh loads in as a flat plain?"
Yes but I am not loading it back into the above program
just another one I made for viewing it. Heres that one.
Graphics3D 640,480
SetBuffer BackBuffer()
Global camera=CreateCamera()
lite=CreateLight(3)
RotateEntity lite,90,0,0
Global terra
glassgrid_tex=LoadTexture("_tex/crossgrid.bmp")
terra = LoadTerrain("myterrain2.b3d")
;EntityTexture terra,glassgrid_tex
PositionEntity terra,0,-20,0
PositionEntity camera, EntityX(terra)+20,EntityY(terra)+10,EntityZ(terra)-10
While Not KeyDown(1)
If KeyHit(57) = True Then enable=1-enable 
WireFrame enable 
 


RenderWorld

Flip

Wend

End



RiverRatt(Posted 2004) [#5]
So, is this just to tough or impossible to do?
Is that why I can't seam to get many responces?

Am I excomunicated?
Is anyone out there?
Is it a laim question and I should already have it figured out?

Has anyone tried it out? If not Please do so now cuz it's cool.
I know probably bin done before, but not by me.

So can I get a Whomp-Whomp???


Jeppe Nielsen(Posted 2004) [#6]
I think that the TerrainHeight() command returns values between 0 and 1, so in your save terrain function you need to multiple it with 255 to get a useable color out of it, Only a guess though:
Anyway try changing the line:
hgt# = Floor(TerrainHeight#(terra, x, y))

To:
hgt# = Floor(TerrainHeight#(terra, x, y))*255

Hope this helps.


RiverRatt(Posted 2004) [#7]
I added that line and it works better but still not propper.
Now instead of saving it as a flat plain it is at least saving it with some of the terrain detail but only 1 unit
high. I found a save terrain funcion in the code archives
and it does the exact same thing.


RiverRatt(Posted 2004) [#8]
.


Bremer(Posted 2004) [#9]
A heightmap is grayscale with a range from 0-255, but when loaded with the "loadterrain" command is converted to values between 0-1. That is why if you are saving a terrain out as a heightmap you need to multiply by 255 as Jeppe expained.

When you have loaded the terrain then use the "scaleentity" command to set the scale of the terrain. The Y value determines how high the hills and how low the valleys.

I hope that helps somewhat.


RiverRatt(Posted 2004) [#10]
Yep that helped lots. So it finaly works!
Also you just awnswered another queston I just posted.

Thanks all.


Bremer(Posted 2004) [#11]
You're welcome. I'm glad that it helped, I wasn't sure it was what you were looking for.