コード例 #1
0
    public override void OnSceneGUI()
    {
        base.OnSceneGUI();

#if !HAPI_PAINT_SUPPORT
        if (myGeoAttributeManagerGUI != null)
        {
            myGeoAttributeManagerGUI.OnSceneGUI();
            if (myGeoAttributeManager != null && myGeoAttributeManager.prHasChanged && myGeoAttributeManager.prLiveUpdates)
            {
                myGeoAttributeManager.prHasChanged = false;

                HoudiniPartControl part_control =
                    myAssetOTL.prActiveEditPaintGeo.prParts[0].GetComponent <HoudiniPartControl>();
                Mesh mesh = part_control.GetComponent <MeshFilter>().sharedMesh;
                HoudiniAssetUtility.setMesh(
                    part_control.prAssetId, part_control.prObjectId, part_control.prGeoId,
                    ref mesh, part_control, myGeoAttributeManager);
                myAssetOTL.buildClientSide();
            }
        }
#endif // !HAPI_PAINT_SUPPORT

        handlesOnSceneGUI();
    }
コード例 #2
0
    public override void OnSceneGUI()
    {
        base.OnSceneGUI();

        // If no active attribute manager is set yet, set it.
        if (myAssetOTL.prEditPaintGeos.Count > 0 && myGeoAttributeManagerGUI == null)
        {
            myGeoAttributeManager    = myAssetOTL.prActiveAttributeManager;
            myGeoAttributeManagerGUI = new HoudiniGeoAttributeManagerGUI(myGeoAttributeManager);
        }

        // If we have an active attribute manager then go ahead and draw its Scene GUI.
        if (myGeoAttributeManagerGUI != null)
        {
            // First, get the current active paint geo index, then call the manager's
            // OnSceneGUI function to draw the GUI and get back the new active paint
            // geo index.
            int current_active_edit_paint_geo_index =
                myAssetOTL.prEditPaintGeos.FindIndex(
                    delegate(HoudiniGeoControl g) {
                return(System.Object.ReferenceEquals(
                           g.prGeoAttributeManager, myAssetOTL.prActiveAttributeManager));
            });
            int new_active_edit_paint_geo_index =
                myGeoAttributeManagerGUI.OnSceneGUI(
                    "Intermediate Result",
                    current_active_edit_paint_geo_index,
                    myAssetOTL.prEditPaintGeos.ConvertAll <string>(x => x.prGeoName).ToArray());

            // If the new active paint geo index is different than the old one we need to
            // switch attribute managers.
            if (new_active_edit_paint_geo_index != current_active_edit_paint_geo_index)
            {
                // Save the current mode on the current attribute manager and restore
                // its mode to NONE so that it properly hides its geometry.
                HoudiniGeoAttributeManager.Mode current_mode =
                    myAssetOTL.prActiveAttributeManager.prCurrentMode;
                myAssetOTL.prActiveAttributeManager.changeMode(
                    HoudiniGeoAttributeManager.Mode.NONE);

                // Switch to the new attribute manager.
                myAssetOTL.prActiveAttributeManager =
                    myAssetOTL.prEditPaintGeos[new_active_edit_paint_geo_index].prGeoAttributeManager;

                // Change the new attribute manager's mode to the previous attribute manager's mode.
                // This is important so that we have a smooth transition between attribute managers
                // and so that the new attribute manager's geo is unhidden.
                myAssetOTL.prActiveAttributeManager.changeMode(current_mode);

                // Update our local attribute manager pointer with the new attribute manager
                // and create a new attribute manager GUI for it.
                myGeoAttributeManager    = myAssetOTL.prActiveAttributeManager;
                myGeoAttributeManagerGUI = new HoudiniGeoAttributeManagerGUI(myGeoAttributeManager);
            }

            // If the value has changed (something was painted) and we have live updates enabled,
            // apply the modification on the mesh itself and cook the asset.
            if (myGeoAttributeManager != null &&
                myGeoAttributeManager.prHasChanged &&
                myGeoAttributeManager.prLiveUpdates)
            {
                myGeoAttributeManager.prHasChanged = false;

                HoudiniPartControl part_control =
                    myAssetOTL
                    .prEditPaintGeos[new_active_edit_paint_geo_index]
                    .prParts[0]
                    .GetComponent <HoudiniPartControl>();
                Mesh mesh = part_control.GetComponent <MeshFilter>().sharedMesh;
                HoudiniAssetUtility.setMesh(
                    part_control.prAssetId, part_control.prObjectId, part_control.prGeoId,
                    ref mesh, part_control, myGeoAttributeManager);
                myAssetOTL.buildClientSide();
            }
        }

        handlesOnSceneGUI();
    }