Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / GetObjectHeightMapHeight() returns 0 if heightmap non-power-of-2

Author
Message
Nieb
9
Years of Service
User Offline
Joined: 13th May 2014
Location: Lurking
Posted: 12th Jul 2018 10:52 Edited at: 22nd Jul 2018 14:25
If either the heightmap image is non-power-of-2 or if the heightmap-object's size is set to non-power-of-2, then GetObjectHeightMapHeight() returns 0.

I would like my terrain to have 256x256 faces, with each face being 1x1 units, which requires 257x257 verts. Or, 256x256 verts which requires the object's size be 255x255. Either way GetObjectHeightMapHeight() won't work.

Attachments

Login to view attachments
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 12th Jul 2018 11:47
You could try just using recasting to get the height at any given spot.
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 12th Jul 2018 12:00 Edited at: 12th Jul 2018 12:05
Ive just tried GetHeightmapHeight with a 256x256 image and it works fine and returns the height absolutely fine.

I then tried with a 255x255 and then a 127x127 and they also work fine too.

With all due respect - your doing something wrong if its not working for you. Maybe check you coordinates that your checking the height for are actually within your terrain ??




Raycasting also works but requires a bit more calculation in the code and from AppGameKit too and is slower generally so I wouldnt use it unless you need to.
Bored of the Rings
User Banned
Posted: 12th Jul 2018 12:18
@Nieb-do have a code snippet so we can help?
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Nieb
9
Years of Service
User Offline
Joined: 13th May 2014
Location: Lurking
Posted: 12th Jul 2018 13:42 Edited at: 12th Jul 2018 16:06
I've decided to use RayCasting as Santman suggested.
Because I wanted the height of the center of the face, not the vertex, anyhow.
Nieb
9
Years of Service
User Offline
Joined: 13th May 2014
Location: Lurking
Posted: 12th Jul 2018 13:58 Edited at: 22nd Jul 2018 14:26
I've attached a test project, with code, demonstrating the issue.
It is attached to the original post.

Change the "Which" var to see the different examples.

Attachments

Login to view attachments
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 12th Jul 2018 14:47 Edited at: 12th Jul 2018 14:56
Quote: "Because I wanted the height of the center of the face, not the vertex, anyhow."


GetHeightmapHeight() doesnt give you the vertex height....it calculates the position on the face. (interpolates)
Nieb
9
Years of Service
User Offline
Joined: 13th May 2014
Location: Lurking
Posted: 12th Jul 2018 16:06
Ah right, suppose it does..

Login to post a reply

Server time is: 2024-03-28 12:43:30
Your offset time is: 2024-03-28 12:43:30