Beispiel #1
0
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        var srcRigComponent  = SourceRigPrefab.GetComponent <RigComponent>();
        var dstRigComponent  = GetComponent <RigComponent>();
        var srcRigPrefab     = conversionSystem.TryGetPrimaryEntity(SourceRigPrefab);
        var srcRigDefinition = dstManager.GetComponentData <Rig>(srcRigPrefab);

        StringHash binding   = RemapLocalToRoot.transform.name;
        var        overrides = new Unity.Animation.RigRemapUtils.OffsetOverrides(1, Allocator.Temp);

        overrides.AddTranslationOffsetOverride(binding, new RigTranslationOffset {
            Rotation = quaternion.identity, Scale = 1f, Space = RigRemapSpace.LocalToRoot
        });
        overrides.AddRotationOffsetOverride(binding, new RigRotationOffset {
            PreRotation = quaternion.identity, PostRotation = quaternion.identity, Space = RigRemapSpace.LocalToRoot
        });

        var customHasher = new BindingHashGenerator
        {
            TransformBindingHashFunction = BindingHashGlobals.TransformBindingHashName,
            GenericBindingHashFunction   = BindingHashGlobals.GenericBindingHashName
        };

        var setup = new RigRemapSetup
        {
            SrcClip = SourceClip.ToDenseClip(),
            SrcRig  = srcRigDefinition.Value,

            // Automatically create a remap table based on matching rig component properties. This example uses two hierarchies that are
            // different but have matching transform names. For this specific case, we'll use a custom BindingHashGenerator (lines 33-37) to hash only transform names instead
            // of the default hashing strategy to find matching entries. Given we are remapping the srcRig (TerraFormerLOD1) to
            // a sub rig part (HandRigLOD0) we override the remapping offsets of the RightHand transform to perform operations in
            // LocalToRoot space (lines 29-32) in order to displace the hand at the wanted position/rotation.
            RemapTable = Unity.Animation.Hybrid.RigRemapUtils.CreateRemapTable(
                srcRigComponent, dstRigComponent, Unity.Animation.RigRemapUtils.ChannelFilter.All, overrides, customHasher
                )
        };

        dstManager.AddComponentData(entity, setup);

        dstManager.AddComponent <DeltaTime>(entity);
    }
Beispiel #2
0
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        var dstRig = GetComponent <RigComponent>();
        var srcRig = SourceRigPrefab.GetComponent <RigComponent>();
        var query  = CreateRemapQuery(srcRig, dstRig, RetargetMap);

        var srcRigPrefab     = conversionSystem.TryGetPrimaryEntity(SourceRigPrefab);
        var srcRigDefinition = dstManager.GetComponentData <Rig>(srcRigPrefab);
        var dstRigDefinition = dstManager.GetComponentData <Rig>(entity);

        var setup = new RigRemapSetup
        {
            SrcClip    = SourceClip.ToDenseClip(),
            SrcRig     = srcRigDefinition.Value,
            RemapTable = query.ToRigRemapTable(srcRigDefinition.Value, dstRigDefinition.Value)
        };

        dstManager.AddComponentData(entity, setup);

        dstManager.AddComponent <DeltaTime>(entity);
    }
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        var srcRigPrefab     = conversionSystem.TryGetPrimaryEntity(SourceRigPrefab);
        var srcRigDefinition = dstManager.GetComponentData <Rig>(srcRigPrefab);
        var dstRigDefinition = dstManager.GetComponentData <Rig>(entity);

        var setup = new RigRemapSetup
        {
            SrcClip = SourceClip.ToDenseClip(),
            SrcRig  = srcRigDefinition.Value,

            // Automatically create a remap table based on matching rig definition bindings.
            // This is useful for LOD setups which define matching skeleton hierarchies.
            // This example uses the TerraFormerLOD1 (srcRigDefinition) which animates 31 bones and the animation data is remapped
            // to TerraFormerLOD0 (dstRigDefinition) containing 131 bones.
            RemapTable = Unity.Animation.RigRemapUtils.CreateRemapTable(srcRigDefinition.Value, dstRigDefinition.Value)
        };

        dstManager.AddComponentData(entity, setup);

        dstManager.AddComponent <DeltaTime>(entity);
    }