[Closed] Make objects face the viewport.. could use some help
Okay, I know this has been done before, but I need to get it set up in a way that I can understand so that I am able to use it in my current project.
What I need to get working is a script that will force an object to face directly toward the viewport. I have gotten most of the way there; right now the object does in fact face the viewport, but sometimes will spin sideways or upside-down.
In order to try and make sense of why this might be happening, I have set up a text object that displays the transform information of the viewport. I am still a bit sketchy on reading matrix values, so maybe someone else here can help me.
The relevant code in its current state is as follows:
text size:100 isSelected: on
marker = $
if ((isValidNode $viewportTarget) == false)
then
(
point isSelected:on
viewportTarget = $
$.name = "viewportTarget"
)
marker.rotation.controller = LookAt_Constraint ()
marker.rotation.controller.appendTarget $viewportTarget 50
marker.rotation.controller.target_axis = 2
marker.rotation.controller.upnode_axis = 2
fn viewportSet =
(
viewTM = inverse( getViewTM() )
if gw.IsPerspView()
then $viewportTarget.transform = viewTM
viewTM_1 = viewTM.row1 as string
viewTM_2 = viewTM.row2 as string
viewTM_3 = viewTM.row3 as string
viewTM_4 = viewTM.row4 as string
viewTM_T = viewTM.translation as string
marker.text = "row1: " + viewTM_1 + "\r" \
+ "row2: " + viewTM_2 + "\r" \
+ "row3: " + viewTM_3 + "\r" \
+ "row4: " + viewTM_4 + "\r" \
+ "\r" \
+ "translation: " + viewTM_T
)
registerRedrawViewsCallback viewportSet
select marker
u can make a orthographic camera for object to switch to the viewport or render it by get the face selection of the object and the size of the obj .
any question , mail me . http://forums.cgsociety.org/haibo.lan@gmail.co m” data-bbcode=”true”>haibo.lan@gmail.com .
i have try to reply here , always down . dont know why.
This probably isn’t much help, but in the “old” days this kind of spinning around at times was due to a problem with gimbal lock (it was mostly a camera issue, but can occur with any object). Something about the rotational angle being interpreted either the way you want or 360 degrees in the opposite direction.
I had thought this issue was resolved along the way but perhaps it still is occuring here. You might try and do some research on this topic if you don’t get help otherwise.