【发布时间】:2015-07-13 21:25:19
【问题描述】:
我正在为一个学校项目开发 Unity,我正在使用 Kinect 来识别面部表情。它显示的“默认”表情是中性的,当我将面部表情更改为快乐或惊讶等时,它会发生变化。
我创建了一个名为 Face 的游戏对象,我在其中设置了不同的纹理(PC 根据我的表情显示的面孔),并且我希望当我改变我的面部表情时他也会改变。但由于某种原因,它不起作用。
我正在使用 C#,首先我设置了这个:
public static Texture[] textures = new Texture[7];
public Texture neutral, smiling, happy, angry, sad, kissing, surprised;
public GameObject Face;
public Renderer rend;
一开始我有这个:
Face = GameObject.Find ("Face");
textures[0] = neutral;
textures[1] = smiling;
textures[2] = happy;
textures[3] = angry;
textures[4] = sad;
textures[5] = sad;
textures[6] = surprised;
顺便说一句,它没有找到 Face 所以我把它放在检查员那里,我对纹理/面做了同样的事情。 然后在更新中我把它定义如下:
ClassifyAndApply(numbers);
private void SaveAnimUnits()
{
numbers[0] = _animUnits.LipRaiser;
numbers[1] = _animUnits.JawLowerer;
numbers[2] = _animUnits.LipStretcher;
numbers[3] = _animUnits.BrowLowerer;
numbers[4] = _animUnits.LipCornerDepressor;
numbers[5] = _animUnits.OuterBrowRaiser;
}
private void ClassifyAndApply(float[] units){
// Renderer rend = GetComponent<Renderer>();
// Face = GameObject.Find ("Face");
if (units[2] <= 0.264888){
if (units[3] <= 0.817408){
if (units[1] <= 0.181886){
if (units[0] <= -0.216908){
if (units[4] <= 0.395523){
if (units[1] <= 0.104226){
Face. GetComponent<Renderer>().material.mainTexture = textures[3];
}
else{
Face. GetComponent<Renderer>().material.mainTexture = textures[0];
}
这棵树还在继续,但我认为我的问题是这样,但我不确定。
Face. GetComponent<Renderer>().material.mainTexture = textures[0];
【问题讨论】: