Game Development Reference
In-Depth Information
How to do it...
All the required functionalities can be implemented in a single class by performing the fol-
lowing steps:
1. To start off, we create a new class called ExpressionsControl that extends
AbstractControl .
2. Inside this, we add AnimControl named animControl , one AnimChannel
called mouthChannel , and another AnimChannel called eyeBrowChan-
nel .
3. We define an enum to keep track of the phonemes that the controller supports.
These are some of the most common ones, plus a RESET option for a neutral
mouth expression, as shown in the following code:
public enum PhonemeMouth{
AAAH, EEE, I, OH, OOOH, FUH, MMM, LUH, ESS, RESET;
};
4. We create another enum to set the expressions of the eyes, which is a simple way
of adding emotions to what the character says, as shown in the following code:
public enum ExpressionEyes{
NEUTRAL, HAPPY, ANGRY;
};
5. In the setSpatial method, we create AnimChannel for mouth animations
and one for the eyes, then we add suitable bones to each of these, as shown in the
following code. The list of bones available can be seen in SkeletonControl in
SceneComposer .
mouthChannel = animControl.createChannel();
mouthChannel.addBone("LipSide.L");
...
6. Since the animations we'll use might just be one or a few frames each, we can set
LoopMode to Loop or Cycle . The speed has to be higher than 0 or blending
won't work. Set these for both AnimChannels .
7. Then, we have two setter methods to directly set an expression or phoneme in the
control. The naming convention might differ depending on the assets, and it's good
to have a small blending value:
Search WWH ::




Custom Search