Camera and @orient attribute

   2373   6   0
User Avatar
Member
76 posts
Joined: Aug. 2018
Offline
Hi,

How i can put my camera in point the way it uses @orient attribute for camera rotations? I can move the camera in point using point() but camera rotations are in Euler angles.

Thank you
Mika
User Avatar
Member
7737 posts
Joined: Sept. 2011
Offline
You can create a custom constraint using a transform wrangle.

Heres an example vexpression using a quaternion representing a 45 degree rotation about the Y axis:

#include <voplib.h>
// Fetch transform inputs
chopTRS c0 = c->fetchInput(0);
float yrot = radians(45);
vector4 orient = set(0, sin(yrot/2), 0, cos(yrot/2));
vector4 rot = eulertoquaternion(radians(c0.r), XFORM_XYZ);
rot = qmultiply(orient, rot);
// Compute transform
@t = c0.t;
@r = degrees(quaterniontoeuler(rot, XFORM_XYZ));
@s = c0.s;
User Avatar
Member
76 posts
Joined: Aug. 2018
Offline
jsmack
You can create a custom constraint using a transform wrangle.

Heres an example vexpression using a quaternion representing a 45 degree rotation about the Y axis:

#include <voplib.h>
// Fetch transform inputs
chopTRS c0 = c->fetchInput(0);
float yrot = radians(45);
vector4 orient = set(0, sin(yrot/2), 0, cos(yrot/2));
vector4 rot = eulertoquaternion(radians(c0.r), XFORM_XYZ);
rot = qmultiply(orient, rot);
// Compute transform
@t = c0.t;
@r = degrees(quaterniontoeuler(rot, XFORM_XYZ));
@s = c0.s;


Ok this seems to be what I need but how I can import attributes from geometry node? I tried point() trick but it doesn't seems to work as in normal point wrangle?
User Avatar
Member
7737 posts
Joined: Sept. 2011
Offline
point() vex function should work. First argument is the file containing you point to sample, or if sampling a sop node, use an op: reference path.

int pt = 0;
vector4 orient = point("op:/obj/geo1/point_to_sample", "orient", pt);
User Avatar
Member
8514 posts
Joined: July 2007
Online
or just extract X and Y axis vectors from orient and use in Rivet Object
v@xaxis = qrotate(p@orient, {1,0,0});
v@zaxis = qrotate(p@orient, {0,0,1});

Attachments:
align_object_with_point.hip (136.8 KB)

Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
7737 posts
Joined: Sept. 2011
Offline
I don't like those old object level constraint tools. IMO they should have been ophidden with the introduction of chop constraints.
User Avatar
Member
76 posts
Joined: Aug. 2018
Offline
jsmack
vector4 orient = point(“opobj/geo1/point_to_sample”, “orient”, pt);

Thx! I got it work! “op” was missing element
  • Quick Links