Jump to content

Using the terrain height map


morad
 Share

Recommended Posts

Hi

 

I'm just started scripting with lua with the demo version, using the great tutorials on youtube.

I'm have a problem with the terrain elevation\height: when i load the terrain height map its doesn't fit to the visible scene texture.

 

Any ideas?

 

Thanks

 

Morad

Link to comment
Share on other sites

--loading the terrain and scene

terrain=CreateTerrain(2048)

 

LoadTerrainHeightmap(terrain,"abstract::deserthighway_height.RAW")

 

world=LoadScene("abstract::deserthighway.sbx")

world:SetCollisionType(2)

 

(i have a body attached to the camera)

 

-- calculating the height of the camera above the ground

ALT=math.floor((body.position.y-TerrainElevation(terrain,body.position.x,body.position.z))/0.3048)

Link to comment
Share on other sites

why are you creating a terrain and also loading a terrain from the SBX file? just load the SBX and it will load the terrain for you...

 

also, you do not have to set the collisiontype for the loaded scene... it will be done automatically for the terrain

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

If your body is parented to the camera, you will need to transform its position from local space to world space to get the correct position for the call to TerrainElevation(). See TFormPoint().

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

When i don't create the terrain i don't know the terrain Entity name so i can't use it.

When i use "terrain" i get an "Exception access violation" message.

Do i need to create a world first or anything else is wrong?

I tried to transform to global coordinates. the different i got was twice the distance to each axis.

Still didn't get the right height.

 

???

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...