Ejemplo n.º 1
0
    private void createSlaveAnimationFromPreview(NPVoxAnimation animation, NPVoxIModelFactory inputModelFactory)
    {
        var path = NPipelineUtils.GetCreateScriptableObjectAssetPath <NPVoxAnimation>(AssetDatabase.LoadMainAssetAtPath(AssetDatabase.GetAssetPath(inputModelFactory as Object)).name + "_" + animation.name);

        if (path.Length != 0)
        {
            NPVoxAnimation slaveAnimation = NPipelineUtils.CreatePipeContainer <NPVoxAnimation>(path);
            foreach (NPVoxFrame sourceFrame in animation.Frames)
            {
                NPVoxFrame targetFrame = slaveAnimation.AppendFrame();

                NPVoxSocketAttachment attachment = sourceFrame.GetPreviewAttachmentForFactory(inputModelFactory);
                if (attachment == null)
                {
                    Debug.LogWarning("no attachment found for the given model factory");
                    continue;
                }

                targetFrame.Source = inputModelFactory;
                NPVoxModelSocketCombiner combiner = NPVoxModelSocketCombiner.CreateInstance <NPVoxModelSocketCombiner>();

                if (!sourceFrame.PreOutput)
                {
                    sourceFrame.FixStuff();
                }
                combiner.Target           = sourceFrame.PreOutput;
                combiner.InputSocketName  = attachment.sourceSocketName;
                combiner.TargetSocketName = attachment.targetSocketName;
                targetFrame.AppendTransformer(combiner);
            }

            Selection.objects = new Object[] { slaveAnimation };
        }
    }
Ejemplo n.º 2
0
    private void createSlaveAnimation(NPVoxAnimation animation, string targetSocket, NPVoxIModelFactory inputModelFactory, string inputSocket)
    {
        var path = NPipelineUtils.GetCreateScriptableObjectAssetPath <NPVoxAnimation>(AssetDatabase.LoadMainAssetAtPath(AssetDatabase.GetAssetPath(inputModelFactory as Object)).name + "_" + targetSocket + "_" + animation.name);

        if (path.Length != 0)
        {
            NPVoxAnimation slaveAnimation = NPipelineUtils.CreatePipeContainer <NPVoxAnimation>(path);
            foreach (NPVoxFrame sourceFrame in animation.Frames)
            {
                NPVoxFrame targetFrame = slaveAnimation.AppendFrame();
                targetFrame.Source = inputModelFactory;
                NPVoxModelSocketCombiner combiner = NPVoxModelSocketCombiner.CreateInstance <NPVoxModelSocketCombiner>();

                if (!sourceFrame.PreOutput)
                {
                    sourceFrame.FixStuff();
                }
                combiner.Target           = sourceFrame.PreOutput;
                combiner.InputSocketName  = inputSocket;
                combiner.TargetSocketName = targetSocket;
                targetFrame.AppendTransformer(combiner);
            }

            Selection.objects = new Object[] { slaveAnimation };
        }
    }