lesbentley opened this issue on Mar 31, 2008 ยท 137 posts
lesbentley posted Fri, 04 April 2008 at 2:12 PM
**Injecting ERC slaving (part 2).
Squint eyes.**In my last post I showed how we can slave one channel to another. You will notice that is was not necessary to include the master channel in the pose file, it was sufficient to "point" to the master channel in the slaving code. Sometimes we may need to change things in the master channel as well. The next example is such a case.
The next example is a pz2 that can make V3 (or any figure that uses PBMCC_## channels) squint. The pz2 slaves the 'yrot' channels in both eyes to the 'PBMCC_16' channel in the head:
{
//V3_Squint.pz2
//For V3 and similar figures.
//Adds dials to the head to rotate both eyes at once.
version
{
number 3
}
//The section below sets up the initial state of the master targetGeom channel in the head,
//note in particular the use of 'indexes 0' to clear any deltas from the channel.
actor head
{
channels
{
targetGeom PBMCC_16
{
name Eyes_Squint
initValue 0
hidden 0
forceLimits 1
min -5.5
max 5.5
trackingScale 0.02
keys
{
static 0
k 0 0
}
interpStyleLocked 0
indexes 0
}
}
}
//The section below is used to inject slaving code into the 'yrot' channel of the eyes.
actor leftEye
{
channels
{
rotateY yrot
{
valueOpDeltaAdd
Figure
head
Eyes_Squint
deltaAddDelta -10.000000
}
}
}
actor rightEye
{
channels
{
rotateY yrot
{
valueOpDeltaAdd
Figure
head
Eyes_Squint
deltaAddDelta 10.000000
}
}
}
figure
{
}
}
NOTES: If the head (rather than some other part) is selected when you apply the file, then the new dial may not show in the parameters pallet. Select some other body part, then reselect the head, this should cause the parameter pallet to refresh, and you will be able to see the new dial.
Let's take a closer look at this file. We are using 'targetGeom PBMCC_16' in the head as the master channel. First we give the dial a descriptive name "Eyes_Squint". We need to ensure that the value it will be Restored to is zero, and that it is not hidden from the parameters pallet, the next two lines take care of that. 'forceLimits 4' constrains the value of the channel to between the values in the 'min' and 'max' lines ('forceLimits 4' also works). The value of the 'trackingScale' at 0.02 is the default for a targetGeom channel that contains no deltas, and unlike in most other channel types it can not be changed. The last line in this channel is 'indexes 0' this deletes any morph deltas that may be in the channel, we don't want V3 turning into an alien as we squint her eyes (or perhaps sometimes we do).
The next section injects the slaving code into the 'yrot' channels of the eyes. We can slave the channels to either the internal name of the master 'PBMCC_16' or to its dial name 'Eyes_Squint', above I have used the dial name. This is normal practice when slaving to a targetGeom or valueParm channel. When we slave to the dial name the slaving can be broken because a pose file can inject a new dial name, being able to break the slaving can be useful in some situations. If we had slaved to the internal name, the slaving could not be broken by the application of a pose file.
Because we want the eyes to rotate in opposite directions, the deltaAddDelta value in the left eye is negative. When slaving a rotate channel to a targetGeom or valueParm channel you will usually need to use a deltaAddDelta value of around 10.0 or greater. With a deltaAddDelta value of 1.0 the eyes would rotate in such fine increments that the dial may appear not to be working.
There are a couple of potential problems with the above file that you should be aware of. First, because it uses a targetGeom (morph) channel, if you save a pose using the option to include morphs, the value of the master channel will be remembered in the pose, so applying a pose you saved, to the figure, has the potential to reset the value of this dial.This could be a good thing or a bad thing, depending on the circumstances and what you want. Also third party poses to inject morphs, may reset this channel, or even want to change its dial name and inject deltas into it. These problems are common to all pose files that use the DAZ PBMCC_## channels, not just our Squint pose.
From the above file it should be obvious that we are not limited to squinting the eyes, we can have master dials that make both eyes go side-side, and up-down, and translate two eyes from one dial. I will try to post more on that later, but for the time being why not see you can work out how to do it your self? One tip if you do, try a deltaAddDelta of around 0.001 as a starting point for the translate channels.
To be continued...