View Aligned Node: Trick with Simple Manipulator

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 04 April 2011   #1
Wink View Aligned Node: Trick with Simple Manipulator

Many times in different threads people asked and showed some solutions how to make View Aligned (billboard) Node.

The basic idea is to use #viewportChange event or registered RedrawViewsCallback.
For example:
Code:
with redraw off ( callbacks.removeScripts id:#camFace delete objects global cameraFaced fn cameraFaced node: = if isvalidnode node do ( ntm = node.transform vtm = getViewTM() node.transform = translate (rotate (scalematrix ntm.scale) (inverse vtm.rotation)) ntm.pos ) global myText = text name:"myText" isselected:on cameraFaced node:myText callbacks.addScript #viewportChange "cameraFaced node:myText" id:#camFace )


It works but there are some problems with registering new nodes, adding scripts on startup, saving the setup with file using of persistent event scripts, etc.

Here is another way of doing the tick.
I'm using the fact that for every view change a Scripted Manipulator is called to update its gizmo. So we can use it to change the dependent node's transform. In the sample I'm changing the node's transform directly, but you can use scripted controllers with notifyDependents method (see mxs for details).

Code:
-- by denisT plugin simpleManipulator ViewWatcher name:"ViewWatcher" classID:#(0xb58aefb, 0x160048d9) --invisible:on --silentErrors:on category:"Manipulators" ( local c = colorMan.getColor #manipulatorsInactive local node, giz tool create ( on mousePoint click do ( nodeTM.translation = gridPoint #stop ) ) on canmanipulate target do return false on updateGizmos do ( if not isvalidnode node do node = refs.dependentnodes this firstOnly:on ntm = node.transform vtm = getViewTM() node.transform = translate (rotate (scalematrix ntm.scale) (inverse vtm.rotation)) ntm.pos if giz == undefined do ( giz = manip.makeCircle [0,0,0] 10 24 this.addGizmoShape giz (gizmoActiveViewportOnly + gizmoDontHitTest) c c ) ) ) with redraw off ( delete objects in (vw = ViewWatcher isselected:on) ( tx = text text:"View Watcher" size:10 tx.position.controller = Position_Constraint relative:off tx.position.controller.appendTarget vw 100. tx.rotation.controller = Orientation_Constraint relative:off tx.rotation.controller.appendTarget vw 100. ) )


The ViewWatcher no needs to manipulate anything, it can be used as parent and constraint controller target for any other nodes (text shape in my sample).

Here you are...
any questions are welcome
 
Old 05 May 2011   #2
Denis,

This is an interesting idea! Will it also work/update correctly on rendertime in a camera view?

Thanks,
-Johan
__________________
Online: LinkedIn
 
Old 05 May 2011   #3
Quote:
Originally Posted by JHN
Denis,

This is an interesting idea! Will it also work/update correctly on rendertime in a camera view?

Thanks,
-Johan

i don't think so. on render time the system probably shouldn't rebuild gizmos.
 
Old 05 May 2011   #4
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 08:55 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.