コード例 #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 void init( HoudiniPartControl part_control )
	{
		init( (HoudiniGeoControl) part_control );

		prAsset			= part_control.prAsset;
		prPartId		= part_control.prPartId;
		prPartName		= part_control.prPartName;
	}
コード例 #3
0
	private GameObject createPart( int part_id )
	{
		GameObject child = new GameObject( "uninitialized_part" );
		child.transform.parent = gameObject.transform;
		child.isStatic = gameObject.isStatic;

		// Need to reset position here because the assignment above will massage the child's
		// position in order to be in the same place it was in the global namespace.
		child.transform.localPosition	= new Vector3();
		child.transform.localRotation	= new Quaternion();
		child.transform.localScale		= new Vector3( 1.0f, 1.0f, 1.0f );

		HoudiniPartControl control = child.AddComponent< HoudiniPartControl >();
		control.init( this );
		control.prPartId = part_id;
		control.prGeoControl = this;
		control.prObjectControl = prObjectControl;

		return child;
	}
コード例 #4
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();
    }
コード例 #5
0
    public void refresh(bool reload_asset)
    {
        if (prObjectControl == null)
        {
            Debug.LogError("Why is my object control null on a refresh?");
            return;
        }

        GameObject geo_node = gameObject;

        // Get Geo info.
        HAPI_GeoInfo geo_info = new HAPI_GeoInfo();

        HoudiniHost.getGeoInfo(prAssetId, prObjectId, prGeoId, out geo_info);

        if (geo_info.type == HAPI_GeoType.HAPI_GEOTYPE_INPUT)
        {
            return;
        }

        if (!reload_asset && !geo_info.hasGeoChanged && !geo_info.hasMaterialChanged)
        {
            return;
        }

        if (reload_asset || geo_info.type == HAPI_GeoType.HAPI_GEOTYPE_CURVE)
        {
            for (int i = 0; i < myParts.Count; ++i)
            {
                HoudiniAssetUtility.destroyGameObject(myParts[i]);
            }
            myParts.Clear();
        }

        if (reload_asset || geo_info.hasGeoChanged)
        {
            // Initialize our geo control.
            init(
                geo_info.nodeId, prGeoId, geo_info.name, (HAPI_GeoType)geo_info.type,
                geo_info.isEditable, geo_info.isDisplayGeo);

            // Set node name.
            geo_node.name = prGeoName;
        }

        if (!geo_info.isDisplayGeo &&
            (geo_info.type != HAPI_GeoType.HAPI_GEOTYPE_CURVE &&
             !myObjectControl.prAsset.prImportTemplatedGeos &&
             geo_info.isTemplated))
        {
            return;
        }

        if (geo_info.type == HAPI_GeoType.HAPI_GEOTYPE_CURVE)
        {
            createAndInitCurve(prNodeId, prObjectId, prGeoId, prIsEditable);
        }
        else
        {
            if (reload_asset || geo_info.hasGeoChanged)
            {
                // Add new geos as needed.
                while (myParts.Count < geo_info.partCount)
                {
                    myParts.Add(createPart(myParts.Count));
                }

                // Remove stale geos.
                while (myParts.Count > geo_info.partCount)
                {
                    HoudiniAssetUtility.destroyGameObject(myParts[geo_info.partCount]);
                    myParts.RemoveAt(geo_info.partCount);
                }
            }

            // Refresh all geos.
            for (int i = 0; i < myParts.Count; ++i)
            {
                myParts[i].GetComponent <HoudiniPartControl>().refresh(
                    reload_asset, geo_info.hasGeoChanged, geo_info.hasMaterialChanged);
            }

            // Handle Edit/Paint Nodes
#if !HAPI_PAINT_SUPPORT
            if (geo_info.type == HAPI_GeoType.HAPI_GEOTYPE_INTERMEDIATE)
            {
                // We are limited to using the first part, always.
                if (myGeoAttributeManager == null && myParts.Count > 0)
                {
                    const int part_id = 0;

                    GameObject         part_gameobject = myParts[part_id];
                    HoudiniPartControl part_control    = part_gameobject.GetComponent <HoudiniPartControl>();
                    MeshFilter         mesh_filter     = part_control.getOrCreateComponent <MeshFilter>();
                    MeshRenderer       mesh_renderer   = part_control.getOrCreateComponent <MeshRenderer>();
                    MeshCollider       mesh_collider   = part_control.getOrCreateComponent <MeshCollider>();
                    Mesh mesh = mesh_filter.sharedMesh;

                    myGeoAttributeManager = ScriptableObject.CreateInstance <HoudiniGeoAttributeManager>();
                    myGeoAttributeManager.init(mesh, mesh_renderer, mesh_collider, part_gameobject.transform);

                    // Fetch all point attributes.
                    string[] point_attribute_names = HoudiniHost.getAttributeNames(
                        prAssetId, prObjectId, prGeoId, part_id, HAPI_AttributeOwner.HAPI_ATTROWNER_POINT);

                    foreach (string point_attribute_name in point_attribute_names)
                    {
                        if (point_attribute_name == "P")
                        {
                            continue;
                        }

                        HAPI_AttributeInfo point_attribute_info = HoudiniHost.getAttributeInfo(
                            prAssetId, prObjectId, prGeoId, part_id, point_attribute_name,
                            HAPI_AttributeOwner.HAPI_ATTROWNER_POINT);

                        if (point_attribute_info.storage == HAPI_StorageType.HAPI_STORAGETYPE_INT)
                        {
                            int[] data = new int[0];
                            HoudiniAssetUtility.getAttribute(
                                prAssetId, prObjectId, prGeoId, part_id,
                                point_attribute_name,
                                ref point_attribute_info,
                                ref data,
                                HoudiniHost.getAttributeIntData);
                            HoudiniGeoAttribute attribute =
                                myGeoAttributeManager.createAttribute(point_attribute_name);
                            attribute.init(
                                mesh, point_attribute_name, HoudiniGeoAttribute.Type.INT,
                                point_attribute_info.tupleSize);
                            attribute.prOriginalAttributeOwner = HAPI_AttributeOwner.HAPI_ATTROWNER_POINT;

                            if (data.Length != attribute.prIntData.Length)
                            {
                                Debug.LogError("Size mis-match in paint tools.");
                            }
                            else
                            {
                                for (int i = 0; i < data.Length; ++i)
                                {
                                    attribute.prIntData[i] = data[i];
                                }
                            }
                        }
                        else if (point_attribute_info.storage == HAPI_StorageType.HAPI_STORAGETYPE_FLOAT)
                        {
                            int     tuple_size = point_attribute_info.tupleSize;
                            float[] data       = new float[0];
                            HoudiniAssetUtility.getAttribute(
                                prAssetId, prObjectId, prGeoId, part_id,
                                point_attribute_name,
                                ref point_attribute_info,
                                ref data,
                                HoudiniHost.getAttributeFloatData);
                            HoudiniGeoAttribute attribute =
                                myGeoAttributeManager.createAttribute(point_attribute_name);
                            attribute.init(
                                mesh, point_attribute_name, HoudiniGeoAttribute.Type.FLOAT,
                                tuple_size);
                            attribute.prOriginalAttributeOwner = HAPI_AttributeOwner.HAPI_ATTROWNER_POINT;

                            // Get Vertex list.
                            HAPI_PartInfo part_info = new HAPI_PartInfo();
                            HoudiniHost.getPartInfo(
                                prAssetId, prObjectId, prGeoId, part_id, out part_info);
                            int[] vertex_list = new int[part_info.vertexCount];
                            HoudiniAssetUtility.getArray4Id(
                                prAssetId, prObjectId, prGeoId, part_id, HoudiniHost.getVertexList,
                                vertex_list, part_info.vertexCount);

                            if (part_info.vertexCount * tuple_size != attribute.prFloatData.Length)
                            {
                                Debug.LogError("Size mis-match in paint tools.");
                            }
                            else
                            {
                                for (int i = 0; i < part_info.vertexCount; ++i)
                                {
                                    for (int tuple = 0; tuple < tuple_size; ++tuple)
                                    {
                                        attribute.prFloatData[i * tuple_size + tuple] =
                                            data[vertex_list[i] * tuple_size + tuple];
                                    }
                                }
                            }
                        }
                        else if (point_attribute_info.storage == HAPI_StorageType.HAPI_STORAGETYPE_STRING)
                        {
                        }
                    }
                }
            }
#endif // !HAPI_PAINT_SUPPORT

            // Handle script attaching.
            if (reload_asset && geo_info.partCount > 0)
            {
                HAPI_AttributeInfo script_attr_info = new HAPI_AttributeInfo("Unity_Script");
                int[] script_attr = new int[0];

                HoudiniAssetUtility.getAttribute(
                    prAssetId, prObjectId, prGeoId, 0, "Unity_Script",
                    ref script_attr_info, ref script_attr, HoudiniHost.getAttributeStringData);

                if (script_attr_info.exists && script_attr_info.owner != HAPI_AttributeOwner.HAPI_ATTROWNER_DETAIL)
                {
                    throw new HoudiniErrorIgnorable("I only understand Unity_Script as detail attributes!");
                }

                if (script_attr_info.exists && script_attr.Length > 0)
                {
                    string script_to_attach = HoudiniHost.getString(script_attr[0]);
                    HoudiniAssetUtility.attachScript(geo_node, script_to_attach);
                }
            }
        }
    }
コード例 #6
0
	public bool refresh( bool reload_asset )
	{
		bool needs_recook = false;

		if ( prObjectControl == null )
		{
			Debug.LogError( "Why is my object control null on a refresh?" );
			return needs_recook;
		}

		GameObject geo_node = gameObject;

		// Get Geo info.
		HAPI_GeoInfo geo_info = new HAPI_GeoInfo();
		try
		{
			// If templated geos are off this will error out for templated
			// geos because they woudn't have cooked. But we still need to
			// get the geo info to see that this is a templated geo and skip it.
			HoudiniHost.getGeoInfo( prAssetId, prObjectId, prGeoId, out geo_info );
		}
		catch ( HoudiniErrorInvalidArgument ) {}

		if ( geo_info.type == HAPI_GeoType.HAPI_GEOTYPE_INPUT )
			return needs_recook;

		if ( geo_info.isTemplated && !prAsset.prImportTemplatedGeos && !geo_info.isEditable )
			return needs_recook;

		if ( !reload_asset && !geo_info.hasGeoChanged && !geo_info.hasMaterialChanged )
			return needs_recook;

		if ( reload_asset || geo_info.type == HAPI_GeoType.HAPI_GEOTYPE_CURVE )
		{
			for ( int i = 0; i < myParts.Count; ++i )
				HoudiniAssetUtility.destroyGameObject( myParts[ i ] );
			myParts.Clear();
		}

		if ( reload_asset || geo_info.hasGeoChanged )
		{
			// Initialize our geo control.
			init( 
				geo_info.nodeId, prGeoId, geo_info.name, (HAPI_GeoType) geo_info.type, 
				geo_info.isEditable, geo_info.isDisplayGeo );

			// Set node name.
			geo_node.name = prGeoName;
		}

		if ( !geo_info.isDisplayGeo && 
				(	geo_info.type != HAPI_GeoType.HAPI_GEOTYPE_CURVE && 
					!myObjectControl.prAsset.prImportTemplatedGeos && 
					geo_info.isTemplated ) )
		{
			return needs_recook;
		}

		if ( geo_info.type == HAPI_GeoType.HAPI_GEOTYPE_CURVE )
		{
			createAndInitCurve( prNodeId, prObjectId, prGeoId, prIsEditable );
			needs_recook = true;
		}
		else
		{
			if ( reload_asset || geo_info.hasGeoChanged )
			{
				// Add new geos as needed.
				while ( myParts.Count < geo_info.partCount )
					myParts.Add( createPart( myParts.Count ) );

				// Remove stale geos.
				while ( myParts.Count > geo_info.partCount )
				{
					HoudiniAssetUtility.destroyGameObject( myParts[ geo_info.partCount ] );
					myParts.RemoveAt( geo_info.partCount );
				}
			}
		
			// Refresh all geos.
			for ( int i = 0; i < myParts.Count; ++i )
				myParts[ i ].GetComponent< HoudiniPartControl >().refresh( 
					reload_asset, geo_info.hasGeoChanged, geo_info.hasMaterialChanged );

			// Handle Edit/Paint Nodes
			if ( geo_info.type == HAPI_GeoType.HAPI_GEOTYPE_INTERMEDIATE )
			{
				// Currently, we only support painting on the first part.
				const int part_id = 0;

				GameObject part_gameobject = myParts[ part_id ];
				HoudiniPartControl part_control = part_gameobject.GetComponent< HoudiniPartControl >();
				MeshFilter mesh_filter = part_control.getOrCreateComponent< MeshFilter >();
				MeshRenderer mesh_renderer = part_control.getOrCreateComponent< MeshRenderer >();
				MeshCollider mesh_collider = part_control.getOrCreateComponent< MeshCollider >();
				Mesh mesh = mesh_filter.sharedMesh;

				// We are limited to using the first part, always.
				if ( myGeoAttributeManager == null && myParts.Count > 0 )
				{
					if ( prAsset.prGeoAttributeManagerMap.contains( getRelativePath() ) )
					{
						myGeoAttributeManager = prAsset.prGeoAttributeManagerMap.get( getRelativePath() );
						myGeoAttributeManager.name = getAbsolutePath() + "/GeoAttributeManager";
						myGeoAttributeManager.reInit( mesh, mesh_renderer, mesh_collider, part_gameobject.transform );
					}
					else
					{
						myGeoAttributeManager = ScriptableObject.CreateInstance< HoudiniGeoAttributeManager >();
						myGeoAttributeManager.name = getAbsolutePath() + "/GeoAttributeManager";
						myGeoAttributeManager.init( mesh, mesh_renderer, mesh_collider, part_gameobject.transform );
						prAsset.prGeoAttributeManagerMap.add( getRelativePath(), myGeoAttributeManager );
					}

					// Sync the attributes and see if we need a recook.
					if ( myGeoAttributeManager.syncAttributes( prAssetId, prObjectId, prGeoId, part_id, mesh ) )
					{
						HoudiniAssetUtility.setMesh(
							prAssetId, prObjectId, prGeoId,
							ref mesh, part_control, myGeoAttributeManager );
						needs_recook = true;
					}
				}
				else
				{
					// Just sync the attributes but don't recook. Setting needs_recook to true here would
					// cause infinite cooking.
					myGeoAttributeManager.syncAttributes( prAssetId, prObjectId, prGeoId, part_id, mesh );
				}
			}

			// Handle script attaching.
			if ( reload_asset && geo_info.partCount > 0 )
			{
				HAPI_AttributeInfo script_attr_info = new HAPI_AttributeInfo( "Unity_Script" );
				int[] script_attr = new int[ 0 ];
			
				HoudiniAssetUtility.getAttribute( 
					prAssetId, prObjectId, prGeoId, 0, "Unity_Script",
					ref script_attr_info, ref script_attr, HoudiniHost.getAttributeStringData );
			
				if ( script_attr_info.exists && script_attr_info.owner != HAPI_AttributeOwner.HAPI_ATTROWNER_DETAIL )
					throw new HoudiniErrorIgnorable( "I only understand Unity_Script as detail attributes!" );
			
				if ( script_attr_info.exists && script_attr.Length > 0 )
				{
					string script_to_attach = HoudiniHost.getString( script_attr[ 0 ] );
					HoudiniAssetUtility.attachScript( geo_node, script_to_attach );
				}
			}
		}

		return needs_recook;
	}
コード例 #7
0
    public void init( HoudiniPartControl part_control )
    {
        init( (HoudiniGeoControl) part_control );

        prAsset			= part_control.prAsset;
        prPartId		= part_control.prPartId;
        prPartName		= part_control.prPartName;
    }
コード例 #8
0
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Public

    public void OnSceneGUI()
    {
        HoudiniPartControl control = target as HoudiniPartControl;

        if (control.prShowPointNumbers)
        {
            // Get position attributes.
            HAPI_AttributeInfo pos_attr_info = new HAPI_AttributeInfo(HoudiniConstants.HAPI_ATTRIB_POSITION);
            float[]            pos_attr      = new float[0];
            HoudiniAssetUtility.getAttribute(
                myPartControl.prAssetId, myPartControl.prObjectId, myPartControl.prGeoId,
                myPartControl.prPartId, HoudiniConstants.HAPI_ATTRIB_POSITION,
                ref pos_attr_info, ref pos_attr, HoudiniHost.getAttributeFloatData);
            if (!pos_attr_info.exists)
            {
                throw new HoudiniError("No position attribute found.");
            }

            int point_count = pos_attr.Length / 3;
            // Determine which control point was pressed for modification.
            for (int i = 0; i < point_count; ++i)
            {
                Vector3 position = new Vector3(
                    -pos_attr[i * 3 + 0], pos_attr[i * 3 + 1], pos_attr[i * 3 + 2]);
                position = myPartControl.transform.TransformPoint(position);

                Color    original_color = GUI.color;
                GUIStyle style          = new GUIStyle(GUI.skin.label);

                GUI.color       = Color.yellow;
                style.fontStyle = FontStyle.Normal;
                style.fontSize  = 12;
                Handles.Label(position, new GUIContent("" + i), style);

                GUI.color = original_color;
            }
        }

        /*
         * {
         *      try
         *      {
         *              HAPI_AttributeInfo pos_attr_info = new HAPI_AttributeInfo( HoudiniConstants.HAPI_ATTRIB_POSITION );
         *              float[] pos_attr = new float[ 0 ];
         *              HoudiniAssetUtility.getAttribute(
         *                      myPartControl.prAssetId, myPartControl.prObjectId, myPartControl.prGeoId,
         *                      myPartControl.prPartId, HoudiniConstants.HAPI_ATTRIB_POSITION,
         *                      ref pos_attr_info, ref pos_attr, HoudiniHost.getAttributeFloatData );
         *              if ( !pos_attr_info.exists )
         *                      throw new HoudiniError( "No position attribute found." );
         *
         *              bool[] membership = HoudiniHost.getGroupMembership(
         *                      myPartControl.prAssetId, myPartControl.prObjectId, myPartControl.prGeoId,
         *                      myPartControl.prPartId, HAPI_GroupType.HAPI_GROUPTYPE_POINT, "exteriorPoints" );
         *
         *              int point_count = pos_attr.Length / 3;
         *
         *              if ( membership.Length != point_count )
         *                      Debug.LogError( "WTF" );
         *
         *              // Determine which control point was pressed for modification.
         *              for ( int i = 0; i < point_count; ++i )
         *              {
         *                      if ( membership[ i ] )
         *                      {
         *                              Vector3 position = new Vector3( -pos_attr[ i * 3 + 0 ], pos_attr[ i * 3 + 1 ], pos_attr[ i * 3 + 2 ] );
         *                              Handles.Label( position, new GUIContent("" + i ) );
         *                      }
         *              }
         *      }
         *      catch
         *      {}
         *
         *      try
         *      {
         *              bool[] membership = HoudiniHost.getGroupMembership(
         *                      myPartControl.prAssetId, myPartControl.prObjectId, myPartControl.prGeoId,
         *                      myPartControl.prPartId, HAPI_GroupType.HAPI_GROUPTYPE_PRIM, "LG_4" );
         *
         *              Mesh mesh = myPartControl.GetComponent< MeshFilter >().sharedMesh;
         *              if ( membership.Length != mesh.triangles.Length / 3 )
         *                      Debug.LogError( "WTF" );
         *
         *              for ( int i = 0; i < mesh.triangles.Length / 3; ++i )
         *              {
         *                      if ( membership[ i ] )
         *                      {
         *                              Vector3[] vects = new Vector3[ 4 ];
         *                              vects[ 0 ] = mesh.vertices[ mesh.triangles[ i * 3 + 0 ] ];
         *                              vects[ 1 ] = mesh.vertices[ mesh.triangles[ i * 3 + 0 ] ];
         *                              vects[ 2 ] = mesh.vertices[ mesh.triangles[ i * 3 + 1 ] ];
         *                              vects[ 3 ] = mesh.vertices[ mesh.triangles[ i * 3 + 2 ] ];
         *                              Handles.DrawSolidRectangleWithOutline( vects, Color.red, Color.yellow );
         *                      }
         *              }
         *      }
         *      catch
         *      {}
         * }*/

        HoudiniInstance instance = findInstanceControlInParent();

        if (instance == null)
        {
            return;
        }

        bool is_overridden = instance.prInstancer.isPointOverridden(instance.prInstancePointNumber);

        if (is_overridden)
        {
            instance.prInstancer.drawPin(instance.prInstancePointNumber);
        }

        Event curr_event = Event.current;

        if (
            curr_event.isMouse && curr_event.type == EventType.MouseDown &&
            HoudiniHost.prAutoPinInstances)
        {
            control.prTransformChanged = false;
        }
        else if (
            curr_event.isMouse && curr_event.type == EventType.MouseUp &&
            HoudiniHost.prAutoPinInstances && control.prTransformChanged)
        {
            instance.prInstancer.pinObject(control.gameObject, true);
            control.prTransformChanged = false;
            Repaint();
        }
    }
コード例 #9
0
    public override void OnInspectorGUI()
    {
        myPartControl.prShowDisplayOptions =
            HoudiniGUI.foldout("Display Options", myPartControl.prShowDisplayOptions, true);
        if (myPartControl.prShowDisplayOptions)
        {
            {
                if (HoudiniGUI.button("print_attribute_names", "Print Attribute Names"))
                {
                    HoudiniAssetUtility.printAllAttributeNames(
                        myPartControl.prAssetId, myPartControl.prObjectId,
                        myPartControl.prGeoId, myPartControl.prPartId);
                }

                if (HoudiniGUI.button("print_group_info", "Print Group Info"))
                {
                    HoudiniAssetUtility.printAllGroups(
                        myPartControl.prAssetId, myPartControl.prObjectId,
                        myPartControl.prGeoId, myPartControl.prPartId);
                }
            }

            {             // Show Houdini Point Numbers
                bool value      = myPartControl.prShowPointNumbers;
                bool undo_value = false;
                bool changed    = HoudiniGUI.toggle(
                    "show_point_numbers", "Show Houdini Point Numbers", ref value,
                    null, ref undo_value);
                myPartControl.prShowPointNumbers = value;
                if (changed)
                {
                    EditorUtility.SetDirty(myPartControl);
                }
            }
        }

        myPartControl.prShowIntermediateResultControls =
            HoudiniGUI.foldout("Intermediate Results", myPartControl.prShowIntermediateResultControls, true);
        if (myPartControl.prShowIntermediateResultControls)
        {
            bool gui_enabled = GUI.enabled;
            if (myPartControl.prGeoType != HAPI_GeoType.HAPI_GEOTYPE_INTERMEDIATE)
            {
                HoudiniGUI.help(
                    "Only specially marked intermediate results geometries can be edited.",
                    MessageType.Info);
                GUI.enabled = false;
            }

            if (GUILayout.Button("Update Intermediate Result"))
            {
                MeshFilter         mesh_filter  = myPartControl.gameObject.GetComponent <MeshFilter>();
                Mesh               shared_mesh  = mesh_filter.sharedMesh;
                HoudiniPartControl part_control = myPartControl.gameObject.GetComponent <HoudiniPartControl>();

                HoudiniAssetUtility.setMesh(
                    myPartControl.prAsset.prAssetId,
                    myPartControl.prObjectId,
                    myPartControl.prGeoId,
                    ref shared_mesh,
                    part_control,
                    null);

                myPartControl.prAsset.buildClientSide();
            }

            if (GUILayout.Button("Clear Edits"))
            {
                HoudiniHost.revertGeo(
                    myPartControl.prAsset.prAssetId,
                    myPartControl.prObjectId,
                    myPartControl.prGeoId);

                myPartControl.prAsset.buildClientSide();
            }

            GUI.enabled = gui_enabled;
        }

        myPartControl.prShowInfo =
            HoudiniGUI.foldout("Info", myPartControl.prShowInfo, true);
        if (myPartControl.prShowInfo)
        {
            HoudiniGUI.help("Values here are for debugging only and should not be modified directly.", MessageType.Info);
            bool gui_enabled = GUI.enabled;
            GUI.enabled = false;
            DrawDefaultInspector();
            GUI.enabled = gui_enabled;
        }
    }