PDA

View Full Version : On linking node properties


MarcoBrunetta
05-28-2009, 03:21 AM
Here's a little experiment I've been playing with. For some time I've wanted to have in MAX the ability to "link" individual object properties so that whenever one changes the other does too. Think of it as "selective instancing", changing one object modifies another, but on a predefined way.

The following bit of code will create a rollout, where you can choose a Source Box and a Target Box and link them. Then, changing the height of the first will modify the width of the second. If this was extended so you could choose any two properties in any object (easy), or maybe something more elaborate like the distance between vertices (not so easy?), it could become useful perhaps.


IF LinkItArray == undefined DO LinkItArray = #()

struct linkItLink
(
sourceObj,
targetObj,
sourceProp,
sourcePropValue,
targetProp
)

rollout linkRoll "Link It!"
(
local sourceObj
local targetObj

pickButton linkSource "Source"
pickButton linkTarget "Target"
button linkBtn "Link It!"

ON linkSource PICKED arg DO
(
IF classOf arg == Box DO
(
sourceObj = arg
linkSource.text = arg.name
)
)

ON linkTarget PICKED arg DO
(
IF classOf arg == Box DO
(
targetObj = arg
linkTarget.text = arg.name
)
)

ON linkBtn PRESSED DO
(
IF targetObj != undefined AND sourceObj != undefined THEN
(
local newLink = linkItLink sourceObj:sourceObj targetObj:targetObj sourceProp:"height" sourcePropValue:sourceObj.height targetProp:"width"
append LinkItArray newLink
destroyDialog linkRoll

fn callbackFn theEvent theNode =
(
--print "Object Geometry Changed"
local objToCheck = GetAnimByHandle theNode[1]
FOR theLink in linkItArray DO
(
IF theLink.sourceObj == objToCheck DO
(
--print "Match Found!"
local theDifference = (theLink.sourcePropValue-(getProperty theLink.sourceObj theLink.sourceProp))
theLink.sourcePropValue = (getProperty theLink.sourceObj theLink.sourceProp)
setProperty theLink.targetObj theLink.targetProp ((getProperty theLink.targetObj theLink.targetProp)+theDifference)
)
)
)

local callbackItem = NodeEventCallback mouseUp:false geometryChanged:callbackFn
)
ELSE
(
messageBox "Select some boxes shmuck!" title:"DOH!"
)
)
)

createDialog linkRoll

ZeBoxx2
05-29-2009, 05:55 PM
isn't that called parameter wiring? :curious:

Edit: let me clarify, as I know you're familiar with parameter wiring.. so my (implied) question was: how does this differ, where might you use it instead of parameter wiring, etc.

MarcoBrunetta
05-29-2009, 06:03 PM
........................:blush:
.
.
.
.


NOTE TO SELF: check animation tutorials


REPLY TO THE EDIT: I actually was not familiar with this. I've never done much animating as 99% my work has been on the arch VIZ business (where you hardly ever need more than a door opening or a cemera moving). In fact I was thinking of use this as a way to link architectural elements, so that when changing one I did not have to remodel the other parts........

Me thinks I've just made an arse of myself.... I'll go hide in a hole for the rest of the day

ZeBoxx2
05-29-2009, 06:04 PM
d'oh! I could've sworn you did (see my edit)

hey, on the up side, though... here's a good response to self: Marco's implementation doesn't crash, or lose settings (once stored in globals/a CA), etc. ;)

MarcoBrunetta
05-29-2009, 06:08 PM
This thread is getting harder and harder to read....lol

PEN
05-29-2009, 07:22 PM
You might want to have a look at Parameter Wires, Reaction Manager, Script Controllers, Expression Controllers, Instancing Controllers, all of these could do what you are looking for. Instanced controllers would be the best solution I would think as it would be fast, stable and two way.

ZeBoxx2
05-29-2009, 08:43 PM
yeah, but instanced controllers don't let you do all the fun and exciting stuff that you usually want to do.

It's great if you want two boxes to be the same height, but now get one box to always be half the height of the other.
( yes, that can be done with an instanced controller - cookies for who can say how :D But I'm thinking that's only one-way. )

That's where parameter wiring, expression controllers, and script controllers come in :)

PiXeL_MoNKeY
05-29-2009, 09:26 PM
( yes, that can be done with an instanced controller - cookies for who can say how :D But I'm thinking that's only one-way. )Straight instanced controllers, no but nested inside a List controller, it could be done.

-Eric

ZeBoxx2
05-29-2009, 09:38 PM
pfff... much easier - multiplier curve!
no cookies for anyone, then! ;)

*cedes and makes sure to get PiX cookies next encounter*

JHN
05-31-2009, 06:09 PM
I'd go with paramWire, it can wire to a controllers parent and so you can swap the x controller with another type of controller. Heck you can wire to a list controller and change all controller is the list controller and still be able to get feedback, instanced controllers don't allow that!
Wire controller for president (single way that is!) oh and when a wire breaks the animation is still preserved!

-Johan Wired Boekhoven

CGTalk Moderation
05-31-2009, 06:09 PM
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.