### how to get partical bounds info of a heightfield?

1146   2   1
Member
1 posts
Joined: 11月 2020
Offline
Currently, I have a 1024*1024 heightfield. Now, I want to retrieve the bounding box information for each 8*8 size grid in the heightfield. How can I achieve this?
Member
53 posts
Joined: 4月 2013
Offline
Cut "Boolean" in this example, the size required from a converted heightfield, then a bound node around the result.

Attachments:
Height_Bound.hipnc (165.5 KB)

Member
4602 posts
Joined: 2月 2012
Offline
Hi,

Here is one way using VEX (Detail Wrangle):

```int size = chi("size");
int index = chi("index");
string volumename = chs("volume_name");

float r = 0.5 * volumevoxeldiameter ( 1, volumename ) / sqrt ( 3 );
vector res = volumeres ( 1, volumename );
int nsections = int ( res.x / size );

int x = ( index % nsections ) * size;
int y = ( index / nsections ) * size;

int xend = x + size - 1;
int yend = y + size - 1;

float minheight = 1e16;
float maxheight = -1e16;
for ( int ix = x; ix <= xend; ++ix )
{
for ( int iy = y; iy <= yend; ++iy )
{
vector p = set ( ix, iy, 0 );
vector pnew = volumeindextopos ( 1, volumename, p );
float height = volumesample ( 1, volumename, pnew );
minheight = min ( height, minheight );
maxheight = max ( height, maxheight );
}
}

vector p0 = set ( x, y, 0 );
vector p1 = set ( xend, y, 0 );
vector p2 = set ( x, yend, 0 );
vector p3 = set ( xend, yend, 0 );

vector pnew0 = volumeindextopos ( 1, volumename, p0 );
vector pnew1 = volumeindextopos ( 1, volumename, p1 );
vector pnew2 = volumeindextopos ( 1, volumename, p2 );
vector pnew3 = volumeindextopos ( 1, volumename, p3 );

pnew0.x -= r;
pnew0.z -= r;
pnew1.x -= r;
pnew1.z += r;
pnew2.x += r;
pnew2.z -= r;
pnew3.x += r;
pnew3.z += r;

pnew0.y = minheight;
pnew3.y = maxheight;

addpoint ( 0, pnew0 );
addpoint ( 0, pnew1 );
addpoint ( 0, pnew2 );
addpoint ( 0, pnew3 );
```

Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
• Quick Links