internal TrajectoryModel(ref ArrayMemory memory, ref Binary binary)
        {
            //
            // Initialize attributes
            //

            this.binary = MemoryRef <Binary> .Create(ref binary);

            float sampleRate  = binary.SampleRate;
            float timeHorizon = binary.TimeHorizon;

            int trajectoryLength =
                DurationToFrames(timeHorizon * 2.0f, sampleRate);

            trajectory = memory.CreateSlice <AffineTransform>(trajectoryLength);
            for (int i = 0; i < trajectoryLength; ++i)
            {
                trajectory[i] = AffineTransform.identity;
            }

            var accumulatedIdentity =
                AccumulatedTransform.Create(
                    AffineTransform.identity, math.rcp(binary.SampleRate));

            deltaSpaceTrajectory = memory.CreateSlice <AccumulatedTransform>(trajectoryLength * 2);
            for (int i = 0; i < trajectoryLength * 2; ++i)
            {
                deltaSpaceTrajectory[i] = accumulatedIdentity;
            }

            Assert.IsTrue(trajectoryLength == TrajectoryLength);
        }
        /// <summary>
        /// Setup binding between character joints and animator stream, that will be written by Kinematica job
        /// </summary>
        /// <param name="animator">Unity animator associated with the animation job</param>
        /// <param name="transforms">Character joint transforms</param>
        /// <param name="synthesizer">Reference to motion synthesizer</param>
        /// <param name="deltaTimePropertyHandle">Property handle for the deltaTime</param>
        /// <returns></returns>
        public bool Setup(Animator animator, Transform[] transforms, ref MotionSynthesizer synthesizer, PropertySceneHandle deltaTimePropertyHandle)
        {
            this.synthesizer = MemoryRef <MotionSynthesizer> .Create(ref synthesizer);

            int numJoints = synthesizer.Binary.numJoints;

            this.transforms = new NativeArray <TransformStreamHandle>(numJoints, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);

            boundJoints = new NativeArray <bool>(numJoints, Allocator.Persistent, NativeArrayOptions.ClearMemory);

            // Root joint is always first transform, and names don't need to match contrary to other joints
            this.transforms[0] = animator.BindStreamTransform(transforms[0]);
            boundJoints[0]     = true;

            for (int i = 1; i < transforms.Length; i++)
            {
                int jointNameIndex = synthesizer.Binary.GetStringIndex(transforms[i].name);
                int jointIndex     = (jointNameIndex >= 0) ? synthesizer.Binary.animationRig.GetJointIndexForNameIndex(jointNameIndex) : -1;
                if (jointIndex >= 0)
                {
                    this.transforms[jointIndex] = animator.BindStreamTransform(transforms[i]);
                    boundJoints[jointIndex]     = true;
                }
            }

            deltaTime = deltaTimePropertyHandle;

            return(true);
        }
예제 #3
0
 internal static Query Create(ref Binary binary)
 {
     return(new Query()
     {
         binary = MemoryRef <Binary> .Create(ref binary)
     });
 }
예제 #4
0
        public PoseGenerator(ref ArrayMemory memory, ref Binary binary, float blendDuration)
        {
            triggerTransition = false;

            previousDeltaTime = 0.0f;

            this.blendDuration = blendDuration;

            m_binary = MemoryRef <Binary> .Create(ref binary);

            var numJoints = binary.numJoints;

            currentPushIndex = -1;
            approximateTransitionProgression = 0;

            previousPose = TransformBuffer.Create(ref memory, numJoints);
            currentPose  = TransformBuffer.Create(ref memory, numJoints);

            transitions = memory.CreateSlice <TransformTransition>(numJoints);

            for (int i = 0; i < numJoints; ++i)
            {
                currentPose.transforms[i] = binary.animationRig.bindPose[i].localTransform;

                transitions[i] = TransformTransition.Identity;
            }
        }
예제 #5
0
        internal static QueryTraitExpression Create(ref Binary binary, NativeString64 debugName = default(NativeString64))
        {
            var constraints = new NativeList <Constraint>(Allocator.Temp);

            return(new QueryTraitExpression()
            {
                binary = MemoryRef <Binary> .Create(ref binary),
                constraints = constraints,
                debugName = debugName
            });
        }
예제 #6
0
        public SegmentTooShortException(ref MotionSynthesizer synthesizer, int segmentIndex)
        {
            m_Synthesizer = MemoryRef <MotionSynthesizer> .Create(ref synthesizer);

            m_SegmentIndex = segmentIndex;
        }