Hey escape_artist,
Yes in case on a terrain, you need to pass the x and z values,
Indeed because of the rotation you've set to the extrude, you need to pass a negative z instead.

the offset is straight forward.
Lets say for the ease, that your terrain is flat and that all values are the lowest. you must set your extrude at y 0; So when a terrain has more height, If you pass the recenter = true, then the generated volume is evenly spreaded along the z axis at generation time, then once rotated along the x axis, you need to align the bottom to y 0, you need to say: y += obj.minZ; or if you know its height, (with the new objectHeight), you just add *.5 of this value.

if you want to move your sphere on it, with its radius at 50, then the offset would be 25. but for practical reasons, depending on the resolution of your terrain and cam angle, you might need to increase that offset to avoid sorting issues.

By default the offset is 0, it's there to allow you to be able to place anything on the terrain even if your terrain do not have zero values (lowest level) or to allow an object to glide above the ground yet still following it. Note also here that if you pass for instance an int 2 to the constructor, an average value would be returned, this is done to allow a smoother gliding even if the terrain is pretty rough.

hope it helps.

Fabrice

On Sep 22, 2008, at 2:22 AM, Escape-Artist wrote:


Hi everyone,

I'm trying to use the ElevationReader method getLevel to position a
sphere on a generated terrain.

My terrain is defined like that:

_extrude = new SkinExtrude(points, {material:mat, recenter:true,
closepath:false, coverall:true, subdivision:1, bothsides:true,
flip:false});
_extrude.rotationX = 90;
_extrude.x = 0
_extrude.z = 500;
_extrude.y = 0;
(_extrude as Mesh).pushback = true;

Then my sphere:

var matsphere:ColorMaterial = new ColorMaterial( 0x2222AA );
_sphere = new Sphere ( {material:matsphere, segmentsH:15, segmentsW:
15, radius:50} );
_sphere.pushfront = true;
_sphere.x = 0;
_sphere.y = elevationreader.getLevel( 0, -500 );
_sphere.z = 500;
_view.scene.addChild(_sphere);

but the sphere is not position on the ground. it's flying up in the
air.
So in getLevel you're supposed to put the x and y value, but I used
the x and z values because the y value is the one I'm after. I used -z
( -500 ) because i've seen it like that in a tutorial but i'm not sure
if i should use 500 instead.
Also I suppose i should use an offset value but I have no idea how to
calculate it. I've seen something about it in a post but I didn't
understand it.
Can anyone see what's wrong? Can you explain how to find the offset
value? I think it's based on the height of the terrain but still not
confident about how to get the exact value.

Thanks!

Reply via email to