plsm scaling heights

rschlend

06-09-2006 04:10:44

Hi all--

First off, I love plsm, however I'm having some kind of scaling problem in the heightmap (the y axis) while using plsm. I've spent 10+ hours or so trying to figure out the root cause of this so any hints or help will be greatly appreciated.

What I would like to do is use freeworld3d to create a terrain and generate a road. I've been able to export the heightmap (16 bit raw), and generate the road mesh and load them in my app using plsm.

Everything looks almost "ok" but I've noticed a few things...

1) I've had to scale the road mesh based on the page size. This is easily solved however (by simply scaling the mesh when I export it from freeworld3d)

2) If the heightmap from freeworld is a flat plane at 100 units in the y direction, it is imported at 0 after running mapsplitter.

3) when I export the heightmap from freeworld3d, I get close to the right answer if I take the maximum value in the heightmap and use this as the scaleY in the *.cfg file.

4) In order to reduce the complexity I am just using one page, making a location on the heightmap 0 (in order to avoid the offset thing I see in step 2), and trying to scale it based on the maximium value. After doing all of this the road mesh still doesn't quite sit perfectly on the road. (If I make the entire terrain flat the road sits perfectly on the terrain)

From reading the source code and the experiments I've done above it seems like the problem is related to the maximum value in the heightmap.

If anyone can provide input as to why I am seeing these things, or how to accomplish what I'm trying to do I'd greatly appreciated.

Thanks in advance,

Rob

PatrickB3

06-09-2006 06:31:31

I would guess it is the LOD system. PLSM2 uses different LOD the further away from the camera the tile is. I get the same thing with shrubs on the terrain. At a distance they float above or are in the terain and close up they line up perfectly.
In my case I don't really care about the ones in the distance but using a mesh for a road wouldn't really be feasible. Walk around the world and you will see the terrain morph between the LODs.

tuan kuranes

06-09-2006 09:28:46

I get close to the right answer if I take the maximum value in the heightmap and use this as the scaleY in the *.cfg file
ScaleY IS the maximum value.

heightmap has to be resolution independant, meaning a heightmap is scaled into [0,1] before being scaled by ScaleY.

If 8bits heightmap is divided by 256 then multiplied by ScaleY.
If 16bits heightmap is divided by 65535 then multiplied by ScaleY.

scalex and scalez represent the distance between 2 neigbour point in the heightmap respectively in x, z direction.

you need to offset the whole terrain to have (heightmap value=0 => y=100)
There a setOption that does that, but that need some patching (rayscenequeries seems false afterwards.)

About Road mesh, as pointed by PatrickB3, try to make sure you're using maximum LOD on the tile were you put it.
Either make LODED Road mesh that changes When terrain changes, or best make a road mesh with huge "foundations", so that it doesn't float.