//[ MenuItem( HoudiniConstants.HAPI_PRODUCT_NAME + "/Create Simple Input Geo", false, 1000 ) ] static private void createSimpleInputGeo() { int asset_id = HoudiniHost.createInputNode("simple_input_geo_test"); HoudiniHost.cookNode( asset_id, HoudiniHost.prSplitGeosByGroup, HoudiniHost.prSplitPointsByVertexAttributes, HoudiniHost.prImportTemplatedGeos); HAPI_PartInfo new_part = new HAPI_PartInfo(); new_part.vertexCount = 3; new_part.pointCount = 3; new_part.faceCount = 1; new_part.type = HAPI_PartType.HAPI_PARTTYPE_MESH; HoudiniHost.setPartInfo(0, 0, ref new_part); HAPI_AttributeInfo attrib_info = new HAPI_AttributeInfo("P"); attrib_info.exists = true; attrib_info.count = 3; // 3 points attrib_info.tupleSize = 3; // 3 floats per point (x, y, z) attrib_info.owner = HAPI_AttributeOwner.HAPI_ATTROWNER_POINT; attrib_info.storage = HAPI_StorageType.HAPI_STORAGETYPE_FLOAT; HoudiniHost.addAttribute(0, 0, "P", ref attrib_info); float[] positions = new float[9] { 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f }; HoudiniHost.setAttributeFloatData(0, 0, "P", ref attrib_info, positions, 0, 3); int[] vertices = new int[3] { 0, 1, 2 }; HoudiniHost.setVertexList(0, 0, vertices, 0, 3); int[] face_counts = new int[1] { 3 }; // 3 edges for the first face (the only face) HoudiniHost.setFaceCounts(0, 0, face_counts, 0, 1); bool[] point_group_mem = new bool[3] { true, true, false }; HoudiniHost.addGroup(0, 0, HAPI_GroupType.HAPI_GROUPTYPE_POINT, "test_pt_group"); HoudiniHost.setGroupMembership( 0, 0, HAPI_GroupType.HAPI_GROUPTYPE_POINT, "test_pt_group", point_group_mem, 3); bool[] prim_group_mem = new bool[1] { true }; HoudiniHost.addGroup(0, 0, HAPI_GroupType.HAPI_GROUPTYPE_PRIM, "test_prim_group"); HoudiniHost.setGroupMembership( 0, 0, HAPI_GroupType.HAPI_GROUPTYPE_PRIM, "test_prim_group", prim_group_mem, 1); HoudiniHost.commitGeo(0); }
//[ MenuItem( HoudiniConstants.HAPI_PRODUCT_NAME + "/Create Two Curves and a Merge", false, 1000 ) ] static private void blah() { HoudiniHost.createInputAsset("curve1"); { HAPI_PartInfo new_part = new HAPI_PartInfo(); new_part.vertexCount = 3; new_part.pointCount = 3; new_part.faceCount = 2; new_part.type = HAPI_PartType.HAPI_PARTTYPE_CURVE; HoudiniHost.setPartInfo(0, 0, ref new_part); HAPI_AttributeInfo attrib_info = new HAPI_AttributeInfo("P"); attrib_info.exists = true; attrib_info.count = 3; // 3 points attrib_info.tupleSize = 3; // 3 floats per point (x, y, z) attrib_info.owner = HAPI_AttributeOwner.HAPI_ATTROWNER_POINT; attrib_info.storage = HAPI_StorageType.HAPI_STORAGETYPE_FLOAT; HoudiniHost.addAttribute(0, 0, "P", ref attrib_info); float[] positions = new float[9] { 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f }; HoudiniHost.setAttributeFloatData(0, 0, "P", ref attrib_info, positions, 0, 3); int[] vertices = new int[3] { 0, 1, 2 }; HoudiniHost.setVertexList(0, 0, vertices, 0, 3); int[] face_counts = new int[2] { 2, 2 }; // 3 edges for the first face (the only face) HoudiniHost.setFaceCounts(0, 0, face_counts, 0, 2); HoudiniHost.commitGeo(0); } HoudiniHost.createInputNode("curve2"); int merge = HoudiniHost.createNode(-1, "SOP/merge", true); int convert = HoudiniHost.createNode(-1, "SOP/convert", true); //HoudiniHost.connectAssetGeometry( curve1, 0, merge, 0 ); //HoudiniHost.connectAssetGeometry( curve2, 0, merge, 1 ); //HoudiniHost.connectAssetGeometry( merge, 0, convert, 0 ); HAPI_AssetInfo convert_info = HoudiniHost.getAssetInfo(convert); Debug.Log(HoudiniHost.getNodeInfo(HoudiniHost.getAssetInfo(merge).nodeId).parmCount); int convert_to_parm_id = HoudiniHost.getParmIdFromName(convert_info.nodeId, "totype"); //HAPI_ParmInfo[] convert_to_parm_info = new HAPI_ParmInfo[ 1 ]; int[] value_arr = new int[1]; value_arr[0] = 2; HoudiniHost.setParmIntValues(convert_info.nodeId, value_arr, convert_to_parm_id, 1); HoudiniHost.cookNode(convert, true, true, false); }
public void initDefaultParameters() { // Set curve defaults. try { if (myIsFirstCook) { HoudiniHost.setParmIntValue(prControl.prNodeId, "type", 0, HoudiniHost.prCurvePrimitiveTypeDefault); HoudiniHost.setParmIntValue(prControl.prNodeId, "method", 0, HoudiniHost.prCurveMethodDefault); myIsFirstCook = false; } HoudiniHost.cookNode( prControl.prAsset.prAssetId, prControl.prAsset.prSplitGeosByGroup, prControl.prAsset.prSplitPointsByVertexAttribute, prControl.prAsset.prImportTemplatedGeos); } catch {} }
public bool refresh(bool reload_asset, HAPI_ObjectInfo object_info) { bool needs_recook = false; if (reload_asset) { for (int i = 0; i < myGeos.Count; ++i) { if (myGeos[i]) { HoudiniAssetUtility.destroyGameObject(myGeos[i]); } } myGeos.Clear(); } if (reload_asset || object_info.haveGeosChanged) { // Get the GeoInfos of the display geo node HAPI_GeoInfo display_geo_info = HoudiniHost.getDisplayGeoInfo(prObjectId); int GeoCount = object_info.geoCount = 1; // Add new geos as needed. while (myGeos.Count < GeoCount) { myGeos.Add(createGeo(display_geo_info.nodeId)); } int node_id = object_info.nodeId; if (prAsset.prNodeInfo.type == HAPI_NodeType.HAPI_NODETYPE_SOP) { node_id = display_geo_info.nodeId; } // Look for editable nodes inside the network/the object const bool recursive = true; int[] editable_networks = HoudiniHost.getChildNodeList( node_id, (int)HAPI_NodeType.HAPI_NODETYPE_SOP, (int)HAPI_NodeFlags.HAPI_NODEFLAGS_EDITABLE, recursive); // Add the editable nodes to it for (int n = 0; n < editable_networks.Length; n++) { // The editable node has to be cooked first HoudiniHost.cookNode(editable_networks[n]); HAPI_GeoInfo editGeoInfo = HoudiniHost.getGeoInfo(editable_networks[n]); myGeos.Add(createGeo(editGeoInfo.nodeId)); GeoCount++; } // Remove stale geos. while (myGeos.Count > GeoCount) { HoudiniAssetUtility.destroyGameObject(myGeos[GeoCount]); myGeos.RemoveAt(GeoCount); } // Refresh all geos. for (int i = 0; i < myGeos.Count; ++i) { needs_recook |= myGeos[i].GetComponent <HoudiniGeoControl>().refresh(reload_asset); } } return(needs_recook); }