2
$\begingroup$

I want to bring a vertex to the zero position for a certain axis (x or Y), the vertex is on a special plane (not an object, a stored viewplane) so I tried to use the stored view matrix, set it to 0 for an axis and then tried to rotate it back.

rot_mat = self._view_context._view_mat # This is stored from Region3d.view_matrix. 

v = rot_mat @ vec_center

if axis == "X":
 v = Vector((-v[0],0,0)) # Difference in X location
elif axis == "Y":
 v = Vector((0,-v[1],0)) # Difference in Y location

vec_center += rot_mat.inverted() @ v

It works, but not, if the view is panned. How can I take the translation of the viewport into acount as well?

$\endgroup$

1 Answer 1

2
$\begingroup$

Found it, the view_matrix contains the translation as well, have to get the 3x3 matrix only:

rot_mat = self._view_context._view_mat.to_3x3()
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .