Jump to content

Recommended Posts

Posted

Any advice on this GetLayers() command?  All I get back is an Read Pixel Out of Bounds error.

Also the docs show sending coords  x and y on a 3d terrain ? Should I be sending x and z?

 

                            local tbl = terrain:GetLayers(self.entity:GetPosition().x, self.entity:GetPosition().z)
Posted

The coordinates are the X and Y coordinate of the terrain, not the world position. The lower-left corner of the terrain is coordinate 0, 0.

World position to terrain coordinate is usually something like this:

int x = Round( (pos.x - terrain->resolution.x / 2) / terrain->scale.x );
int y = Round( (pos.z - terrain->resolution.y / 2) / terrain->scale.z );
x = Clamp(x, 0, terrain->resolution.x - 1);
y = Clamp(y, 0, terrain->resolution.y - 1);

  • Like 1

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

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.

×
×
  • Create New...