Exemple #1
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;
            }
        }
        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);
        }
Exemple #3
0
        public static void Reserve(ref ArrayMemory memory, ref Binary binary)
        {
            var numJoints = binary.numJoints;

            memory.Reserve <AffineTransform>(2 * numJoints);
            memory.Reserve <TransformTransition>(numJoints);
        }
 public static TransformBuffer Create(ref ArrayMemory memory, int numTransforms)
 {
     return(new TransformBuffer()
     {
         transforms = memory.CreateSlice <AffineTransform>(numTransforms)
     });
 }
        internal static void Reserve(ref ArrayMemory memory, ref Binary binary)
        {
            float sampleRate  = binary.SampleRate;
            float timeHorizon = binary.TimeHorizon;

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

            memory.Reserve <AffineTransform>(trajectoryLength);
            memory.Reserve <AccumulatedTransform>(trajectoryLength * 2);
        }
            Memory(int numTransforms, Allocator allocator)
            {
                int transformSize = 0;

                unsafe
                {
                    transformSize = UnsafeUtility.SizeOf <AffineTransform>();
                }

                memory = ArrayMemory.Create();
                memory.Reserve <AffineTransform>(numTransforms);
                memory.Allocate(allocator);

                buffer = Create(ref memory, numTransforms);
            }
        MotionSynthesizer(BlobAssetReference <Binary> binary, AffineTransform worldRootTransform, float blendDuration, Allocator allocator)
        {
            m_binary = binary;

            arrayMemory = ArrayMemory.Create();

            ReserveTraitTypes(ref arrayMemory);
            PoseGenerator.Reserve(ref arrayMemory, ref binary.Value);
            TrajectoryModel.Reserve(ref arrayMemory, ref binary.Value);

            arrayMemory.Allocate(allocator);

            // We basically copy statically available data into this instance
            // so that the burst compiler does not complain about accessing static data.
            traitTypes = ConstructTraitTypes(ref arrayMemory, ref binary.Value);

            poseGenerator = new PoseGenerator(ref arrayMemory, ref binary.Value, blendDuration);

            trajectory = new TrajectoryModel(ref arrayMemory, ref binary.Value);

            rootTransform      = worldRootTransform;
            rootDeltaTransform = AffineTransform.identity;

            updateInProgress = false;

            _deltaTime = 0.0f;

            lastSamplingTime = TimeIndex.Invalid;

            samplingTime = SamplingTime.Invalid;

            delayedPushTime = TimeIndex.Invalid;

            frameCount = -1;

            lastProcessedFrameCount = -1;

            isValid = true;

            isDebugging      = false;
            readDebugMemory  = DebugMemory.Create(1024, allocator);
            writeDebugMemory = DebugMemory.Create(1024, allocator);
        }