[Closed] Flip viewport camera position abotu the view plane
I simply can’t get my brain to handle view matrix calculations currently, maybe i’m already too old for that 😈 …
Could someone help me out here please ?
Given a Max perspective or user othogonal viewport, i can grab the view matrix using viewport.getTM()
Now i want to flip the Matrix about the viewplane ( that would be flipping the virtual camera’s z position’s sign and rotate it 180° on it’s local Y axis ). In praxis that would mean that i get a view on an object’s opposite side, when the objects sits on the viewplane
I think this is just some simple matrix calculation,. But i simple can’t bring my tired brain to do this
anyone could help – please ?
is it this ?
tm = viewport.getTM();
RotateY tm 180;
tm[4] *= -1;
viewport.setTM tm;
assuming you are rotating around the origin
Ha ! Seems to do exactly the thing i wanted to achieve
Thanks a lot for that snippet !
Just to finally report back:
The method listed above does not mirror along the viewplane in any arbitrary user view, but always mirrors on the world center ( thats the tm[4] *= -1 part )
That’s not what i was after , so i finally achieved what i wanted using the following steps
- translate the viewmatrix position’s local z to the viewplane (using viewport.getFocalDistance() )
- do the 180° rotation
- translate the viewmatrix local z back again by -viewport.getFocalDistance()
This creates a view matrix perfectly reflected on it’s current viewplane and works with orthographics and perspective views. Applying the same mechanism on the inverse of a camera’s transform matrix, flips the camera position perfectly about it’s focus point