コード例 #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
    public void ProcessInvalidations(bool force = false)
    {
        if (force || (invalidationRequestedAt > 0 && EditorApplication.timeSinceStartup - invalidationRequestedAt > 0.1f))
        {
            frame = null;
            invalidationRequestedAt = 0;
            if (invalidatedTransformation != null)
            {
                if (editorModelFactorySource == invalidatedTransformation as NPVoxIModelFactory)
                {
                    EditorModelFactory.Invalidate();
                }

                SelectedFrame.InvalidateTransformation(invalidatedTransformation);
                invalidatedTransformation = null;
            }
            if (ModelMarker != null)
            {
                ModelMarker.Invalidate();
            }
            PreviewMeshOutput.Invalidate();
            invalidatePreviewMeshFactories();
            FireOnMeshChange();
        }
        else
        {
            if (invalidationRequestedAt > 0)
            {
                if (OnCheckForInvalidation != null)
                {
                    OnCheckForInvalidation();
                }
            }
        }
    }
コード例 #3
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 };
        }
    }
コード例 #4
0
    public void SetFrameModel(int frameIndex, NPVoxIModelFactory source)
    {
        Undo.RecordObject(animation, "change model");
        NPVoxFrame frame = GetFrameAt(frameIndex);

        frame.Source = source;
        EditorUtility.SetDirty(Animation);
        InvalidateOutputMeshes();
    }
コード例 #5
0
    public void RemoveFrameAt(int frameIndex)
    {
        NPVoxFrame[] frames = Frames;
        NPVoxFrame   frame  = frames[frameIndex];

        ArrayUtility.RemoveAt(ref frames, frameIndex);
        Frames = frames;
        EditorUtility.SetDirty(this);
        frame.Destroy();
    }
コード例 #6
0
    public NPVoxFrame AddFrameAt(int frameIndex, NPVoxFrame template = null)
    {
        NPVoxFrame[] frames   = Frames;
        NPVoxFrame   newFrame = template != null?template.DeepCopy(this) : new NPVoxFrame(this);

        // Debug.Log("adding frame at " + i);
        ArrayUtility.Insert(ref frames, frameIndex, newFrame);
        Frames = frames;
        EditorUtility.SetDirty(this);
        return(newFrame);
    }
コード例 #7
0
    public void InvalidateOutputMeshes(NPVoxCompositeProcessorBase <NPVoxIModelFactory, NPVoxModel> transform = null, bool immediateRefresh = false)
    {
        if (frame != null && frame != SelectedFrame)
        {
            ProcessInvalidations(true);
        }
        if (invalidatedTransformation != null && invalidatedTransformation != transform)
        {
            ProcessInvalidations(true);
        }

        invalidatedTransformation = transform;
        frame = SelectedFrame;
        invalidationRequestedAt = invalidationRequestedAt < 1 ? EditorApplication.timeSinceStartup : invalidationRequestedAt;
        ProcessInvalidations(!DelayedRefreshEnabled || immediateRefresh);
    }
コード例 #8
0
    public void Paste()
    {
        if (HasTransformationToPaste())
        {
            NPVoxCompositeProcessorBase <NPVoxIModelFactory, NPVoxModel> transformer = ClipboardContent as NPVoxCompositeProcessorBase <NPVoxIModelFactory, NPVoxModel>;
            this.AddTransformation(transformer);
        }

        if (HasFrameToPaste())
        {
            NPVoxFrame frame = ClipboardContent as NPVoxFrame;
            Undo.RecordObjects(new Object[] { this, animation }, "Add frame from clipboard at " + selectedFrameIndex);
            animation.AddFrameAt(selectedFrameIndex, frame);
            SelectFrame(selectedFrameIndex, true);
        }
    }
コード例 #9
0
    public int MoveFrame(int frameIndex, int deltaIndex)
    {
        NPVoxFrame[] frames   = Frames;
        NPVoxFrame   swapWith = GetFrameAt(frameIndex + deltaIndex);

        if (swapWith == null)
        {
            return(-1);
        }
        if (Mathf.Abs(deltaIndex) > 1)
        {
            Debug.LogError("deltaIndex > 1 not supported yet");
            return(-1);
        }

        ArrayUtility.RemoveAt(ref frames, frameIndex + deltaIndex);
        ArrayUtility.Insert(ref frames, frameIndex, swapWith);
        Frames = frames;
        EditorUtility.SetDirty(this);
        return(frameIndex + deltaIndex);
    }
コード例 #10
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);
    }
コード例 #11
0
 public NPVoxFrame AppendFrame(NPVoxFrame template = null)
 {
     return(AddFrameAt(Frames.Length, template));
 }