示例#1
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 };
        }
    }
示例#2
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 };
        }
    }
示例#3
0
    public NPVoxFrame DeepCopy(NPVoxAnimation targetAnimation)
    {
        NPVoxFrame other = new NPVoxFrame(targetAnimation);

        other.source             = this.source;
        other.preOutput.Input    = other.Source;
        other.previewAttachments = new NPVoxSocketAttachment[this.previewAttachments.Length];

        for (int i = 0; i < other.previewAttachments.Length; i++)
        {
            other.previewAttachments[i]                  = new NPVoxSocketAttachment();
            other.previewAttachments[i].meshFactory      = this.previewAttachments[i].meshFactory;
            other.previewAttachments[i].sourceSocketName = this.previewAttachments[i].sourceSocketName;
            other.previewAttachments[i].targetSocketName = this.previewAttachments[i].targetSocketName;
            other.previewAttachments[i].visible          = this.previewAttachments[i].visible;
        }

        foreach (NPVoxCompositeProcessorBase <NPVoxIModelFactory, NPVoxModel> modelFactory in this.transformers)
        {
            NPVoxCompositeProcessorBase <NPVoxIModelFactory, NPVoxModel> clonedFactory = (NPVoxCompositeProcessorBase <NPVoxIModelFactory, NPVoxModel>)modelFactory.Clone();
            other.AppendTransformer(clonedFactory);
        }
        return(other);
    }