예제 #1
0
 public virtual void applyBap(AnimationParametersFrame bf)
 {
     if (needsUpdate(bf))
     {
         bone.localRotation = postRotation * getRotation(bf) * preRotation;
     }
 }
예제 #2
0
            public override void concatenate(AnimationParametersFrame original, AnimationParametersFrame result)
            {
                int[]     addition = new int[3];
                JointType joint    = to;

                while (joint != from)
                {
                    add(addition, original, joint);
                    joint = joint.parent;
                }
                add(addition, original, from);

                if (to.rotationX != BAPType.null_bap)
                {
                    result.applyValue(to.rotationX, addition[0]);
                }
                if (to.rotationY != BAPType.null_bap)
                {
                    result.applyValue(to.rotationY, addition[1]);
                }
                if (to.rotationZ != BAPType.null_bap)
                {
                    result.applyValue(to.rotationZ, addition[2]);
                }
            }
예제 #3
0
 public APExternalClient(int numberOfAP_, string host, int port) : base(host, port)
 {
     numberOfAP   = numberOfAP_;
     timer        = new TimeController();
     lastFrame    = new AnimationParametersFrame(numberOfAP, 0);
     apFramesList = new APFramesList(lastFrame);
 }
예제 #4
0
        public override bool needsUpdate(AnimationParametersFrame bf)
        {
            bool update = base.needsUpdate(bf);

            twist.twistUpdate = update;
            return(update);
        }
예제 #5
0
 public override void applyFap(AnimationParametersFrame ff)
 {
     faceBone.localPosition = new Vector3(
         position.x + dir.x * ff.getValue(type1) + dir2.x * ff.getValue(type2),
         position.y + dir.y * ff.getValue(type1) + dir2.y * ff.getValue(type2),
         position.z + dir.z * ff.getValue(type1) + dir2.z * ff.getValue(type2));
 }
예제 #6
0
        public override Quaternion getRotation(AnimationParametersFrame bf)
        {
            Quaternion original = base.getRotation(bf);

            twist.twistRotation = getTwistRotation(original);
            return(propagateTwist(twist.twistRotation, original));
        }
예제 #7
0
 public void applyFapFrame(AnimationParametersFrame fapframe)
 {
     foreach (autodeskcharacter.fapmapper.FapMapper mapper in fapMappers)
     {
         mapper.applyFap(fapframe);
     }
 }
예제 #8
0
    // Use this for initialization
    void Awake()
    {
        InitCharacterMesh();

        changeTPoseToNPose();
        setUpSkeleton();

        // from old code
        Time.fixedDeltaTime = (float)0.04;
        characterTimer      = new TimeController();
        characterTimer.setTimeMillis(0);

        bapReceiver   = new BAPReceiver(NUMBER_OF_BAPS, BAP_RECEIVER_PORT);
        fapReceiver   = new FAPReceiver(NUMBER_OF_FAPS + 1, FAP_RECEIVER_PORT);
        audioReceiver = new AudioReceiver(AUDIO_RECEIVER_PORT);

        lastFAPFrame  = new AnimationParametersFrame(NUMBER_OF_FAPS + 1, 0);
        lastBAPFrame  = new AnimationParametersFrame(NUMBER_OF_BAPS, 0);
        cptFrames     = 0;
        commandSender = new CommandSender(GretaServersHost, CMD_SENDER_PORT);
        agentPlaying  = false;

        _currentAudioSource = getBone("Head").gameObject.AddComponent <AudioSource>();
        audioFilePlayer     = new AudioFilePlayer();
    }
예제 #9
0
 public override void applyFap(AnimationParametersFrame ff)
 {
     if (ff.getMask(axis1Type) || ff.getMask(axis2Type) || ff.getMask(stretchType))
     {
         faceBone.localPosition =
             new Vector3(
                 position.x +
                 direction1.x * ff.getValue(axis1Type) +
                 direction2.x * ff.getValue(axis2Type) +
                 stretchDirection.x * ff.getValue(stretchType),
                 position.y +
                 direction1.y * ff.getValue(axis1Type) +
                 direction2.y * ff.getValue(axis2Type) +
                 stretchDirection.y * ff.getValue(stretchType),
                 position.z +
                 direction1.z * ff.getValue(axis1Type) +
                 direction2.z * ff.getValue(axis2Type) +
                 stretchDirection.z * ff.getValue(stretchType));
     }
     if (ff.getMask(innerType))
     {
         float      dist = ff.getValue(innerType);
         Quaternion q    = Quaternion.AngleAxis(dist * magicNumber, rotationAxis);
         faceBone.localRotation = q * orientinitial;
     }
 }
예제 #10
0
 public override void applyFap(AnimationParametersFrame ff)
 {
     if (ff.getMask(type) || ff.getMask(type2))
     {
         float fapvaltouse = 0;
         if (ff.getMask(type))
         {
             if (ff.getMask(type2))
             {
                 fapvaltouse = Mathf.Max(ff.getValue(type), ff.getValue(type2));
             }
             else
             {
                 fapvaltouse = ff.getValue(type);
             }
         }
         else
         {
             ff.getValue(type2);
         }
         faceBone.localScale = new Vector3(
             1 + dir.x * fapvaltouse,
             1 + dir.y * fapvaltouse,
             1 + dir.z * fapvaltouse);
     }
 }
예제 #11
0
        public override Quaternion getRotation(AnimationParametersFrame bf)
        {
            Quaternion q1 = newQuaternion(axis1, lastVal1);
            Quaternion q2 = newQuaternion(axis2, lastVal2);

            return(q2 * q1);
        }
예제 #12
0
 public void applyBapFrame(AnimationParametersFrame bapframe)
 {
     bapframe = concatenator.concatenateJoints(bapframe);
     foreach (autodeskcharacter.bapmapper.BapMapper mapper in bapMappers)
     {
         mapper.applyBap(bapframe);
     }
 }
예제 #13
0
        public override Quaternion getRotation(AnimationParametersFrame bf)
        {
            Quaternion q1 = newQuaternion(axis1, (lastVal1 * scale));
            Quaternion q2 = newQuaternion(axis2, (lastVal2 * scale));
            Quaternion q3 = newQuaternion(axis3, (lastVal3 * scale));

            return(q3 * q2 * q1);
        }
예제 #14
0
        protected static Quaternion getJointRotation(AnimationParametersFrame frame, JointType joint)
        {
            Quaternion q = fromXYZ(
                joint.rotationX == BAPType.null_bap ? 0 : (float)frame.getRadianValue(joint.rotationX),
                joint.rotationY == BAPType.null_bap ? 0 : (float)frame.getRadianValue(joint.rotationY),
                joint.rotationZ == BAPType.null_bap ? 0 : (float)frame.getRadianValue(joint.rotationZ));

            return(q);
        }
예제 #15
0
        public AnimationParametersFrame concatenateJoints(AnimationParametersFrame frame)
        {
            AnimationParametersFrame result = new AnimationParametersFrame(frame.APVector.Count, frame.getFrameNumber());

            foreach (Concatenator c in concatenators)
            {
                c.concatenate(frame, result);
            }
            return(result);
        }
예제 #16
0
 private void copy(AnimationParametersFrame original, AnimationParametersFrame result, BAPType bapType)
 {
     if (bapType != BAPType.null_bap)
     {
         if (original.getMask(bapType))
         {
             result.applyValue(bapType, original.getValue(bapType));
         }
     }
 }
예제 #17
0
        protected static Quaternion computeChain(AnimationParametersFrame frame, JointType jointFrom, JointType jointTo)
        {
            Quaternion qTo = getJointRotation(frame, jointTo);

            if (jointFrom == jointTo)
            {
                return(qTo);
            }
            return(computeChain(frame, jointFrom, jointTo.parent) * qTo);
        }
예제 #18
0
        public override bool needsUpdate(AnimationParametersFrame bf)
        {
            bool toReturn = base.needsUpdate(bf);

            if (bf.getMask(type3))
            {
                lastVal3 = bf.getRadianValue(type3);
                toReturn = true;
            }
            return(toReturn);
        }
예제 #19
0
    // Update is called once per frame
    void Update()
    {
        if (apReceiver.timer.isSynchronized())
        {
            AnimationParametersFrame currentAPFrame = apReceiver.getCurrentFrame(apReceiver.timer.getTimeMillis() / 40);

            if (currentAPFrame != null)
            {
                Debug.Log(apReceiver.timer.getTimeMillis() / 40 + " " + currentAPFrame.AnimationParametersFrame2String());
            }
        }
    }
예제 #20
0
        public AnimationParametersFrame getCurrentFrame(long currentTime)
        {
            //Debug.Log ("current frame: "+ apFramesList.getCurrentFrame(currentTime));
            AnimationParametersFrame currentAPFrame = apFramesList.getCurrentFrame(currentTime);

            /*if(lastFrame.isEqualTo(currentAPFrame)){
             * return null;
             * } else {
             * lastFrame = currentAPFrame;*/
            return(currentAPFrame);
            //}
        }
예제 #21
0
        public override void applyFap(AnimationParametersFrame ff)
        {
            if (ff.getMask(pitch) || ff.getMask(yaw))
            {
                Quaternion qx = Quaternion.AngleAxis(
                    ff.getValue(pitch) * amplitude1,
                    pitchAxis);

                Quaternion qy = Quaternion.AngleAxis(
                    ff.getValue(yaw) * amplitude2,
                    yawAxis);
                faceBone.localRotation = qy * qx * orientInitial;
            }
        }
예제 #22
0
 private void add(int[] addition, AnimationParametersFrame frame, JointType joint)
 {
     if (joint.rotationX != BAPType.null_bap && frame.getMask(joint.rotationX))
     {
         addition[0] = addition[0] + frame.getValue(joint.rotationX);
     }
     if (joint.rotationY != BAPType.null_bap && frame.getMask(joint.rotationY))
     {
         addition[1] = addition[1] + frame.getValue(joint.rotationY);
     }
     if (joint.rotationZ != BAPType.null_bap && frame.getMask(joint.rotationZ))
     {
         addition[2] = addition[2] + frame.getValue(joint.rotationZ);
     }
 }
예제 #23
0
        public override bool needsUpdate(AnimationParametersFrame bf)
        {
            bool toReturn = false;

            if (bf.getMask(type1))
            {
                lastVal1 = bf.getRadianValue(type1);
                toReturn = true;
            }
            if (bf.getMask(type2))
            {
                lastVal2 = bf.getRadianValue(type2);
                toReturn = true;
            }
            return(toReturn);
        }
예제 #24
0
            public override void concatenate(AnimationParametersFrame original, AnimationParametersFrame result)
            {
                Vector3 xyz = toEulerXYZ(computeChain(original, from, to));

                if (from.rotationX != BAPType.null_bap)
                {
                    result.setRadianValue(from.rotationX, xyz.x);
                }
                if (from.rotationY != BAPType.null_bap)
                {
                    result.setRadianValue(from.rotationY, xyz.y);
                }
                if (from.rotationZ != BAPType.null_bap)
                {
                    result.setRadianValue(from.rotationZ, xyz.z);
                }
            }
예제 #25
0
        public List <AnimationParametersFrame> thriftAPFrameList2gretaAPFrameList(List <ThriftAnimParamFrame> thriftAPframes)
        {
            List <AnimationParametersFrame> gretaAPFrameList = new List <AnimationParametersFrame>(thriftAPframes.Count);

            foreach (ThriftAnimParamFrame thriftFrame in thriftAPframes)
            {
                AnimationParametersFrame gretaFrame   = new AnimationParametersFrame(numberOfAP, (long)thriftFrame.FrameNumber);
                List <ThriftAnimParam>   thriftAPList = thriftFrame.AnimParamList;
                int i = 0;
                foreach (ThriftAnimParam thriftAP in thriftAPList)
                {
                    gretaFrame.setAnimationParameter(i, thriftAP.Value, thriftAP.Mask);
                    ++i;
                }
                gretaAPFrameList.Add(gretaFrame);
            }
            return(gretaAPFrameList);
        }
예제 #26
0
 public APFilePlayer(int numOfAP)
 {
     numberOfAP   = numOfAP;
     lastFrame    = new AnimationParametersFrame(numberOfAP, 0);
     apFramesList = new APFramesList(lastFrame);
 }
예제 #27
0
 public override Quaternion getRotation(AnimationParametersFrame bf)
 {
     return(newQuaternion(axis1, bf.getRadianValue(type1)));
 }
예제 #28
0
 public override bool needsUpdate(AnimationParametersFrame bf)
 {
     return(bf.getMask(type1));
 }
예제 #29
0
 public virtual Quaternion getRotation(AnimationParametersFrame bf)
 {
     return(Quaternion.identity);
 }
예제 #30
0
 public virtual bool needsUpdate(AnimationParametersFrame bf)
 {
     return(false);
 }