[Closed] Realtime orientation to viewport
Hi all,
I’m currently trying to orient a node to the viewport (User or perspective) using scriptcontroller, but it doesn’t update in realtime.
Here is the rotation_script controller of the node
(inverse (viewport.GetTM()).rotationpart)
I read in other topics that I need to create a variable in the script controller to the reference object, but my reference object is the viewport itself, i.e not a node (as far as I know).
Is there a way to get this working?
I think you need to add a viewport changed callback to reevaluate the script controller.
if you use #viewportChange callback anyway why do you need the scripted controller?
Actually I create billboards on mouseclicks on objects and add them scripted controllers.
You’re right, I could loop through all created billboards and set their rotation on #viewportChange. Let’s try this.
Erm… The result is quite different… and bad.
the original method :
function createBillboardText _text:"Billboard Text" _pos:[0,0,0] _size:100=
(
currText = text text:_text wirecolor:white pos:_pos size:_size
scriptController = rotation_script()
currText.rotation.controller = scriptController
scriptController.script = "(inverse (viewport.GetTM()).rotationpart)"
currText
)
which is updated with the viewport change :
for annotation in rateItAnnotations where (isValidNode annotation.textNode) do
annotation.textNode.rotation.controller.Update()
the new method
for annotation in rateItAnnotations where (isValidNode annotation.textNode) do
(annotation.textNode.rotation=(inverse (viewport.GetTM()).rotationpart))
Produces crappy results (object rotating in the wrong direction, and its position moving !)
the only problem is your wrong math…
http://forums.cgsociety.org/showpost.php?p=6577193&postcount=8