Heightmap question

Hi!



I need to build realistic terrain, a 3d model of a certain area. Well, my problem is: the input data contains float values, but the a heightmap in jme is an array of ints…



Is there any way to use floating point numbers instead of ints? Or is there some other method that allows me to generate terrain without sacrificing precision?  If it's not possible, are there any plans to implement such functionality anytime soon?



P.S.: If the question is dumb, sorry. I'm new to 3d programming! -:slight_smile:



Thanks in advance!



Tom

It really depends on many factors:  For instance, if you floating point values are always between 0 and 1, then rescaling them to be integers would not yield significant loss of precision (since floats and ints are 32 bit).



On the other hand, if you just need a 3D mesh with the map, and no collision detection, (or even texture), you could code it yourself with not too much trouble (this way it will all be floats, and the scale you decide).



Finally, there is always the indirect way to do it. You can model it in 3DS or Blender, and then, when it looks like you want, you just export it to jME.

duenez said:

Finally, there is always the indirect way to do it. You can model it in 3DS or Blender, and then, when it looks like you want, you just export it to jME.


thats the way i would go ha :D 3ds ftw

Thanks for the answers guys!



Well, the range of the input values is 0-10000, and they have a 6 digit precision… -:frowning: Of course I don't need to use such precise values, something like 1.23 or 2456.54 would be enough for me.



As for 3ds max, thanks for the tip, but it's not an option in this case. There are many models to create (more than a hundred maybe), so it must be automated somehow. Texturing is not important, but the terrain needs to be as realistic as possible.



Condig it by hand is probably a good idea. One of the options would be Java 3D API, which allows me to use float values in heightmaps. But as far as I know Jmonkey is not compatible with Java 3D. Is there a way to make them work together? Or should I use LWJGL instead?



Well, to make it short, this thing will be a whole 3D world. Very, very large and complex terrain. What Java API would you recommend for this purpose?



Thanks in advance!



Tom

Well, the range of the input values is 0-10000, and they have a 6 digit precision... -:( Of course I don't need to use such precise values, something like 1.23 or 2456.54 would be enough for me.


have you tried shifting 6 to the left

Some comments back:


  1. When I said 3DS, I was thinking about an automated process too… There is a tool (language) called Max Script in 3DS. It allows to create meshes from files with little work. So it can still be done.


  2. If precision is not an absolute requirement, then an int should be able to handle your values pretty well. a 32-bit int has a range from -2000000000 to 2000000000  (that's two billions) roughly speaking. You could just multiply all your values by 100000 or so. This is what theprism is presumably suggesting by the shifting (which would be a decimal shifting and not a binary one)  :wink:


  3. When I said, do it by hand, I meant read the file and create a TriMesh in jME, which allows for floating point values in every vertex (I assume this is actually what is going on behind the screnes in the terrain generator). If texture is not an issue (as you said), then you can pretty much read the data straight and just create the triangles on-the-fly.


  4. Well I would recomend jME of course! I used to be a java3D user, but I found out it does not have a community as active as this one (Hurray for jME XD), and it also suffered from years of stagnation due to the separation from Sun. This has improved in recent years, but I still prefer jME.

ahh, shifting - yes that would give you a strange sideeffect- something matrix like must have come all over me. Mutliplication is correct



you may also like to look at http://www.jmonkeyengine.com/jmeforum/index.php?topic=5170.0



hopefully this terrain class will become the standard soon

There's also my RasterHeightMap class. It would be an easy change to whatever data set for your DEMs you might be using.



http://www.jmonkeyengine.com/jmeforum/index.php?topic=5253.0

Wow! Thanks for the responses!



Well, I don't know much about studio max, but that MaxScript sounds great. If I do it using max, it will create a lot of 3DS files. I know JME can handle those. Isn't this a much better solution than coding it in Java? I mean, if I have 3D models, then the engine doesn't have to calculate the terrain in real-time, so it must be much faster. Is this correct?



If it isn't any faster, I can still do it using JME, shifting will solve my problem.



Thanks in advance!



Tom

Yes, it should be faster. but it really depends on the efficiency of the importer, and I have no clue about that  :stuck_out_tongue:

not trying to hijack but are there disadvantages to modelled terrain that make them less attractive then heightmaps, the thing is for a long time I got the impression that loading a terrain model was…bad, then I read that id's mega texture thing used or neeeded uv mapped models to work properly.





personally I would be glad to do every thing I can in a modeller…even lights and cameras, would save me a great deal of hassle and believe it oir not physical pain :smiley: