public void SetPreviewFactoryForTargetSocket(string targetSocketName, NPVoxIMeshFactory meshFactory)
    {
        Undo.RecordObjects(new Object[] { this, animation }, "set preview socket factory enabled");
        NPVoxSocketAttachment p = SelectedFrame.GetPreviewAttachmentForTargetSocket(targetSocketName, true);

        p.meshFactory = meshFactory as NPVoxMeshOutput;
        wipePreviewMeshFactories(targetSocketName);
    }
    protected NPVoxIModelFactory GetPreviewModelFactoryForTargetSocket(string targetSocketName)
    {
        NPVoxIMeshFactory meshFactory = GetPreviewFactoryForTargetSocket(targetSocketName);
        NPipeIComposite   composite   = meshFactory as NPipeIComposite;

        if (composite != null && composite.Input is NPVoxIModelFactory)
        {
            return(composite.Input as NPVoxIModelFactory);
        }
        return(null);
    }
    public NPVoxIMeshFactory GetSocketPreviewMeshFactoryForCurrentFrame(string targetSocketName)
    {
        NPVoxSocketAttachment p = SelectedFrame.GetPreviewAttachmentForTargetSocket(targetSocketName);

        if (this.selectedFrameIndex < 0 || p == null)
        {
            return(null);
        }

        NPVoxIModelFactory modelFactory = GetPreviewModelFactoryForTargetSocket(targetSocketName);

        string inputSocketName = p.sourceSocketName;

        if (p.outputMeshFactory == null)
        {
            NPVoxIMeshFactory meshFactory = GetPreviewFactoryForTargetSocket(targetSocketName);

            if (meshFactory == null)
            {
                return(null);
            }

            NPVoxModelSocketCombiner combiner = NPVoxModelCombiner.CreateInstance <NPVoxModelSocketCombiner>();
            combiner.Input                 = modelFactory;
            combiner.InputSocketName       = inputSocketName;
            combiner.TargetSocketName      = targetSocketName;
            combiner.ResolveConflictMethod = NPVoxModelTransformationUtil.ResolveConflictMethodType.FILL_GAPS;
            combiner.Target                = (UnityEngine.Object)SelectedFrame.PreOutput.Input;
            combiner.StorageMode           = NPipeStorageMode.MEMORY;

            NPVoxMeshOutput previewFactory = (NPVoxMeshOutput)meshFactory.Clone();
            previewFactory.StorageMode = NPipeStorageMode.MEMORY;
            previewFactory.Input       = combiner;

            p.outputMeshFactory = previewFactory;
        }
        else
        {
            NPVoxModelSocketCombiner combiner = ((NPVoxModelSocketCombiner)((NPVoxMeshOutput)p.outputMeshFactory).Input);
            // check if something changed in the meanwhipe
            if (combiner.Target != TotalModelFactory as UnityEngine.Object || combiner.InputSocketName != inputSocketName)
            {
                p.outputMeshFactory.Invalidate();
                combiner.Target          = (UnityEngine.Object)TotalModelFactory;
                combiner.InputSocketName = inputSocketName;
                combiner.Invalidate();
            }
        }

        return(p.outputMeshFactory);
    }
Exemplo n.º 4
0
    //======================================================================================================================================
    // Socket Tools
    //======================================================================================================================================

    private void DrawSocketTools()
    {
        EditorGUILayout.BeginVertical();
        if (viewModel.DrawSockets != EditorGUILayout.Toggle("Show Socket Axes In View", viewModel.DrawSockets))
        {
            viewModel.SetDrawSockets(!viewModel.DrawSockets);
        }

        foreach (string targetSocketName in viewModel.GetPreviewTargetSocketNames())
        {
            EditorGUILayout.BeginHorizontal();
            if (viewModel.GetPreviewSocketEnabled(targetSocketName) != EditorGUILayout.Toggle(viewModel.GetPreviewSocketEnabled(targetSocketName)))
            {
                viewModel.SetPreviewSocketEnabled(targetSocketName, !viewModel.GetPreviewSocketEnabled(targetSocketName));
            }
            NPVoxIMeshFactory selectedFactory    = viewModel.GetPreviewFactoryForTargetSocket(targetSocketName);
            NPVoxIMeshFactory newSelectedFactory = NPipelineUtils.DrawSourceSelector(targetSocketName, selectedFactory);
            if (selectedFactory != newSelectedFactory)
            {
                viewModel.SetPreviewFactoryForTargetSocket(targetSocketName, newSelectedFactory);
            }

            string[] sourceSockets = viewModel.GetSourceSocketsForTargetSocket(targetSocketName);
            if (sourceSockets == null || sourceSockets.Length == 0)
            {
                GUILayout.Label("No Socket");
            }
            else
            {
                string selectedSourceSocket    = viewModel.GetSourceSocketForTargetSocket(targetSocketName);
                string newSelectedSourceSocket = NPipeGUILayout.Popup(sourceSockets, sourceSockets, selectedSourceSocket, true);
                if (selectedSourceSocket != newSelectedSourceSocket)
                {
                    viewModel.SetSourceSocketForTargetSocket(targetSocketName, newSelectedSourceSocket);
                }
            }
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.EndVertical();
    }