KimberlyC opened this issue on Oct 31, 2010 · 122 posts
lesbentley posted Wed, 03 August 2011 at 3:40 PM
How to write ERC code?
(Have one dial control many channels)
Here are the bare bones of it.
The output value of one channel can be used as input to influence the value of a some other channel. One way to do this is called 'ERC' (Enhanced Remote Control).
With ERC, the channel that is being influenced is called the 'slave' channel, and the channel that is doing the influencing is called the 'master' channel.
To slave one channel to another, you put slaving code in the slave channel. The slaving code tells the slave channel where to find its master. Look at this block of slaving code:
valueOpDeltaAdd
Figure 1
BODY:1
PBMCC_07
deltaAddDelta 1.000000
What does it all mean? First look at the three indented lines (in green). The first indented line says "Look for your master in 'Figure 1'". The second indented line says "Look for it in the BODY actor". The third line says "get your input from channel named 'PBMCC_07' in the actor you now looking in".
Let's take another example:
valueOpDeltaAdd
Figure 1
lCollar:1
xrot
deltaAddDelta 0.010000
The above says "Look in 'Figure 1' in the 'lCollar' actor, and get your input from the 'xrot' channel in that actor".
We have not looked at the very bottom line of the slaving code yet. The very bottom line is a control ratio, it says "Multiply the value you get from the master channel by the number in this line". So if the number is "1" as in the first example, an increment of 1 on the dial of the master channel would result in an increment of 1 in the slave channel. In the second example an increment of 1 on the dial of the master channel would result in an increment of 0.01 in the slave channel.
In the second example the master channel is a rotation channel. If we put the slaving code in another rotation channel, every degree of rotation in the master channel would result in 0.01 degrees of rotation in the slave channel. If we put the slaving code on a targetGeom (morph) channel, 100 degrees of rotation in the master channel would result in the morph being fully expressed at a value of 1.0 (0.01x100=1). If we used a value of 0.011111 in the deltaAddDelta, the morph would be fully expressed when the rotation reached 90 degrees. If we used a value of 0.022222, it would only take 45 degrees of rotation to fully express the morph.
So where abouts in a channel do we put the slaving code? We put it under the line that reads "interpStyleLocked 0", which in turn is under the 'keys' section of the channel. Below is an example of slaving code in a morph channel:
targetGeom Morph-01
{
name Morph-01
initValue 0
hidden 0
forceLimits 1
min -100000
max 100000
trackingScale 0.02
keys
{
static 0
k 0 0
}
interpStyleLocked 0
valueOpDeltaAdd
Figure 1
Cube-A:1
yrot
deltaAddDelta 0.022222
indexes 4
numbDeltas 8
deltas
{
d 2 0 0.09999999 0
d 3 0 0.09999999 0
d 6 0 0.09999999 0
d 7 0 0.09999999 0
}
blendType 0
}
One thing I have not mentioned yet is the very top line of the slaving code. This is the type of slaving, 98% of the time the only type you will come across, or need to use, is 'valueOpDeltaAdd', so I won't complicate things by describing the other types.
In the above example the code uses 'Figure 1' and 'Cube-A:1'. If there is already a 'Figure 1' in the scene, when you load your second figure Poser will automatically update the numbers in the slaving code so that they become 'Figure 2' and 'Cube-A:2'.
There is a lot more that could be said about ERC slaving, but that's the bare bones of it. It's not that difficult, just five lines of code telling the channel where to look for its input. There are some special circumstances to be considered when using ERC slaving in a conformer, or injecting it from a pose file, but I will leave that for another post.
You can find some more information at these links: