Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
pumachen committed Aug 24, 2022
0 parents commit 72d47eb
Show file tree
Hide file tree
Showing 35 changed files with 1,742 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Changelog

## [0.1.0] Initial Release
7 changes: 7 additions & 0 deletions CHANGELOG.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Editor/API.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions Editor/API/HDALibrary.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Harpoon.Utils;
using Newtonsoft.Json;
using UnityEditor;
using UnityEngine;
using UnityEngine.Networking;

namespace Harpoon
{
public static class HDALibrary
{
public struct HDAMeta
{
public string hda;
public string name;
}
public static void GetHDALibraryAsync(Action<HDAMeta[]> completed, Action failed = null)
{
Uri uri = new Uri(HarpoonUriBuilder.Root, "api/hdalibrary");
UnityWebRequest request = UnityWebRequest.Get(uri);
request.SendWebRequest((request) =>
{
if (request.result == UnityWebRequest.Result.Success)
{
dynamic hdaLibrary = JsonConvert.DeserializeObject(request.downloadHandler.text);
Dictionary<string, string> tops = hdaLibrary.Top.ToObject<Dictionary<string, string>>();
HDAMeta[] hdaMeta = new HDAMeta[tops.Count];
int i = 0;
foreach (var top in tops)
{
hdaMeta[i++] = new HDAMeta()
{
hda = top.Key,
name = top.Value
};
}

completed?.Invoke(hdaMeta);
}
else
{
Debug.Log(request.error);
failed?.Invoke();
}
});
}
}
}
11 changes: 11 additions & 0 deletions Editor/API/HDALibrary.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

85 changes: 85 additions & 0 deletions Editor/API/HDAProcessor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.IO;
using System.IO.Compression;
using Newtonsoft.Json;
using Unity.EditorCoroutines.Editor;
using UnityEditor;
using UnityEditor.PackageManager.Requests;
using UnityEngine;
using UnityEngine.Networking;
using Harpoon.Utils;
using UnityEditor.PackageManager;

namespace Harpoon
{
public static class HDAProcessor
{
private static Uri GetUri(string hdaName)
{
return new Uri(HarpoonUriBuilder.Root, $"api/hdaprocessor/{hdaName}");
}

public static void GetHDAHeaderAsync(string hdaName, Action<dynamic> completed, Action failed = null)
{
Uri uri = GetUri(hdaName);
UnityWebRequest request = UnityWebRequest.Get(uri);
request.SendWebRequest((request) =>
{
if (request.result == UnityWebRequest.Result.Success)
{
completed?.Invoke(JsonConvert.DeserializeObject(request.downloadHandler.text));
}
else
{
Debug.LogError(request.error);
failed?.Invoke();
}
});
}

public static void ProcessHDAAsync(string hda, List<HouParm> parms, Action<ZipArchive> completed, Action failed = null, int timeout = 60)
{
Uri uri = GetUri(hda);
List<IMultipartFormSection> formData = new List<IMultipartFormSection>();
foreach (var parm in parms)
{
formData.Add(parm.formSection);
}

string downloadedFile = Path.Combine(Path.GetDirectoryName(Application.dataPath), "Temp", $"Harpoon_Response{DateTime.Now.Ticks}.zip");
UnityWebRequest post = UnityWebRequest.Post(uri, formData);
post.useHttpContinue = false;
post.timeout = timeout;
post.downloadHandler = new DownloadHandlerFile(downloadedFile);
post.SendWebRequest((request) =>
{
if (request.result == UnityWebRequest.Result.Success)
{
using (var zipArchive = ZipFile.OpenRead(downloadedFile))
{
completed?.Invoke(zipArchive);
}
File.Delete(downloadedFile);
}
else
{
Debug.LogError(request.error);
failed?.Invoke();
}
});
}

public static void ProcessHDAAsync(this HDAProcessorPreset preset, Action<ZipArchive> completed, Action failed)
{
Uri uri = GetUri(preset.hda);
List<IMultipartFormSection> formData = new List<IMultipartFormSection>();
foreach (var parm in preset.parms)
{
formData.Add(parm.formSection);
}
}
}
}
11 changes: 11 additions & 0 deletions Editor/API/HDAProcessor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

115 changes: 115 additions & 0 deletions Editor/Enums.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Harpoon
{
// https://www.sidefx.com/docs/houdini/hom/hou/parmData.html
public enum ParmData
{
Int,
Float,
String,
Ramp
}

// https://www.sidefx.com/docs/houdini/hom/hou/stringParmType.html
public enum StringParmType
{
Regular,
FileReference,
NodeReference,
NodeReferenceList
}

// https://www.sidefx.com/docs/houdini/hom/hou/parmLook.html
public enum ParmLook
{
Regular,
Logarithmic,
Angle,
Vector,
ColorSquare,
HueCircle,
CRGBAPlaneChooser
}

// https://www.sidefx.com/docs/houdini/hom/hou/fileType.html
public enum FileType
{
Any,
Image,
Geometry,
Ramp,
Capture,
Clip,
Lut,
Cmd,
Midi,
I3d,
Chan,
Sim,
SimData,
Hip,
Otl,
Dae,
Gallery,
Directory,
Icon,
Ds,
Alembic,
Psd,
LightRig,
Gltf,
Movie,
Fbx,
Usd,
Sqlite,
}

// https://www.sidefx.com/docs/houdini/hom/hou/folderType.html
public enum FolderType
{
Collapsible,
Simple,
Tabs,
RadioButtons,
MultiparmBlock,
ScrollingMultiparmBlock,
TabbedMultiparmBlock,
ImportBlock
}

// https://www.sidefx.com/docs/houdini/hom/hou/parmTemplateType.html
public enum ParmTemplateType
{
Int,
Float,
String,
Toggle,
Menu,
Button,
FolderSet,
Separator,
Label,
Remap,
Data
}

// https://www.sidefx.com/docs/houdini/hom/hou/dataParmType.html
public enum DataParmType
{
Geometry,
KeyValueDictionary
}

// https://www.sidefx.com/docs/houdini/hom/hou/menuType.html
public enum MenuType
{
Normal,
Mini,
ControlNextParameter,
StringReplace,
StringToggle
}
}
11 changes: 11 additions & 0 deletions Editor/Enums.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions Editor/Harpoon.Editor.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "Harpoon.Editor",
"rootNamespace": "",
"references": [
"GUID:343deaaf83e0cee4ca978e7df0b80d21",
"GUID:478a2357cc57436488a56e564b08d223",
"GUID:2bafac87e7f4b9b418d9448d219b01ab"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
7 changes: 7 additions & 0 deletions Editor/Harpoon.Editor.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 72d47eb

Please sign in to comment.