Пример #1
0
        public virtual void update(double now, double[] viseme_weights)
        {
            unchecked {
                if (((((double[])(viseme_weights)) as global::System.Array).Length != global::haxe.root.EyeBlinker.VISEMES.length))
                {
                    throw global::haxe.lang.HaxeException.wrap(new global::haxe.root.BlinkException(((string)(global::haxe.lang.Runtime.concat(global::haxe.lang.Runtime.concat(global::haxe.lang.Runtime.concat(global::haxe.lang.Runtime.concat("Viseme weight vector has wrong size.", " Expected "), global::haxe.lang.Runtime.toString(global::haxe.root.EyeBlinker.VISEMES.length)), ", found "), global::haxe.lang.Runtime.toString((((double[])(viseme_weights)) as global::System.Array).Length))))));
                }

                if ((this.last_time == -1))
                {
                    this.last_time = now;
                    return;
                }

                double delta_time = (now - this.last_time);
                this.last_time = now;
                if ((this.blink_status == global::haxe.root.BlinkStatus.WAITING))
                {
                    if ((now >= this.next_blink_time))
                    {
                        this.blink_status = global::haxe.root.BlinkStatus.CLOSING;
                    }
                }
                else if ((this.blink_status == global::haxe.root.BlinkStatus.CLOSING))
                {
                    double delta_close = (global::haxe.root.EyeBlinker.EYE_CLOSE_SPEED * delta_time);
                    this.current_weight += delta_close;
                    if ((this.current_weight >= 1.0))
                    {
                        this.current_weight = 1.0;
                        this.blink_status   = global::haxe.root.BlinkStatus.OPENING;
                    }
                }
                else if ((this.blink_status == global::haxe.root.BlinkStatus.OPENING))
                {
                    double delta_open = (global::haxe.root.EyeBlinker.EYE_OPEN_SPEED * delta_time);
                    this.current_weight -= delta_open;
                    if ((this.current_weight <= 0.0))
                    {
                        this.current_weight = 0.0;
                        this.blink_status   = global::haxe.root.BlinkStatus.WAITING;
                        double delay = (global::haxe.root.EyeBlinker.MIN_DELAY + (((global::haxe.root.EyeBlinker.MAX_DELAY - global::haxe.root.EyeBlinker.MIN_DELAY)) * global::haxe.root.Math.rand.NextDouble()));
                        this.next_blink_time = (now + delay);
                    }
                }

                {
                    int _g1 = 0;
                    int _g  = global::haxe.root.EyeBlinker.VISEMES.length;
                    while ((_g1 < _g))
                    {
                        int i = _g1++;
                        ((double[])(viseme_weights))[i] = this.current_weight;
                    }
                }
            }
        }
Пример #2
0
        public override object __hx_setField(string field, int hash, object @value, bool handleProperties)
        {
            unchecked {
                switch (hash)
                {
                case 1743530741:
                {
                    this.blink_status = ((global::haxe.root.BlinkStatus)(@value));
                    return(@value);
                }


                case 1485070364:
                {
                    this.next_blink_time = ((double)(global::haxe.lang.Runtime.toDouble(@value)));
                    return(@value);
                }


                case 811651070:
                {
                    this.current_weight = ((double)(global::haxe.lang.Runtime.toDouble(@value)));
                    return(@value);
                }


                case 965584342:
                {
                    this.last_time = ((double)(global::haxe.lang.Runtime.toDouble(@value)));
                    return(@value);
                }


                default:
                {
                    return(base.__hx_setField(field, hash, @value, handleProperties));
                }
                }
            }
        }