Brandon Riza

BrandonRiza

About Me

専門知識
Developer
INDUSTRY
VR

Connect

LOCATION
Not Specified
ウェブサイト

Houdini Skills

Availability

Not Specified

Recent Forum Posts

Orient a bounding box to look-at a target? 2023年4月14日18:52

Hi Tomas.

I was missing the "m = invert (m);"
Your edited code works. Thank you! And thank you too, animatrix.

Attached is a simple hip of part of the larger setup i'm working on.
If you open the file and scrub to frame 100, you'll see it gathers up 100 bounding boxes, all looking at the target defined (a point) and still properly bounding the underlying geo (in this sample, randomly-rotated pig heads).
From here i'm proceeding onto the rest of the system, but this was what i was getting hung up on.

Orient a bounding box to look-at a target? 2023年4月14日16:00

This definitely fixes the up direction issue, but the described (below) iterations of this code seem to break the look-at:

vector up = set(0,1,0);


vector source = point ( 1, "P", 0 );
vector target = point ( 1, "P", 1 );
vector dir = normalize ( source - target );


vector cdir = normalize ( cross ( up, dir ) );
dir = normalize ( cross ( cdir, up ) );

matrix3 m = maketransform ( dir, up );
//matrix3 m = maketransform ( normalize(dir), normalize(up) );

setdetailattrib ( 0, "M", m );
@P *= m;

Commenting out the "vector cdir" and "dir = normalize" lines yields the same results as leaving them in.
Swapping the commenting status on the matrix lines also yields the same results.

GIF for visual reference.
What am i missing?

Orient a bounding box to look-at a target? 2023年4月13日15:58

Here's a comparison of the end result. No up vector defined (first option) vs defining the up vector (second option).

I'll keep digging; thanks for the tips.