Files
UltimateFishing/Assets/Scripts/Assembly-CSharp/Oculus/Avatar/CAPI.cs
2026-02-21 16:45:37 +08:00

578 lines
30 KiB
C#

using System;
using System.Runtime.InteropServices;
using UnityEngine;
namespace Oculus.Avatar
{
public class CAPI
{
public enum Result
{
Success = 0,
Failure = -1000,
Failure_InvalidParameter = -1001,
Failure_NotInitialized = -1002,
Failure_InvalidOperation = -1003,
Failure_Unsupported = -1004,
Failure_NotYetImplemented = -1005,
Failure_OperationFailed = -1006,
Failure_InsufficientSize = -1007
}
private static class OVRP_1_30_0
{
public static readonly Version version = new Version(1, 30, 0);
[DllImport("OVRPlugin", CallingConvention = CallingConvention.Cdecl)]
public static extern Result ovrp_SendEvent2(string name, string param, string source);
}
private const string LibFile = "libovravatar";
public static readonly Version AvatarSDKVersion = new Version(1, 32, 0);
private const string ovrPluginDLL = "OVRPlugin";
private static Version ovrPluginVersion;
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatar_Initialize(string appID);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatar_Shutdown();
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ovrAvatarMessage_Pop();
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern ovrAvatarMessageType ovrAvatarMessage_GetType(IntPtr msg);
public static ovrAvatarMessage_AvatarSpecification ovrAvatarMessage_GetAvatarSpecification(IntPtr msg)
{
IntPtr ptr = ovrAvatarMessage_GetAvatarSpecification_Native(msg);
return (ovrAvatarMessage_AvatarSpecification)Marshal.PtrToStructure(ptr, typeof(ovrAvatarMessage_AvatarSpecification));
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatarMessage_GetAvatarSpecification")]
private static extern IntPtr ovrAvatarMessage_GetAvatarSpecification_Native(IntPtr msg);
public static ovrAvatarMessage_AssetLoaded ovrAvatarMessage_GetAssetLoaded(IntPtr msg)
{
IntPtr ptr = ovrAvatarMessage_GetAssetLoaded_Native(msg);
return (ovrAvatarMessage_AssetLoaded)Marshal.PtrToStructure(ptr, typeof(ovrAvatarMessage_AssetLoaded));
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatarMessage_GetAssetLoaded")]
private static extern IntPtr ovrAvatarMessage_GetAssetLoaded_Native(IntPtr msg);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatarMessage_Free(IntPtr msg);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ovrAvatarSpecificationRequest_Create(ulong userID);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatarSpecificationRequest_Destroy(IntPtr specificationRequest);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatarSpecificationRequest_SetCombineMeshes(IntPtr specificationRequest, bool useCombinedMesh);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatarSpecificationRequest_SetLookAndFeelVersion(IntPtr specificationRequest, ovrAvatarLookAndFeelVersion version);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatarSpecificationRequest_SetLevelOfDetail(IntPtr specificationRequest, ovrAvatarAssetLevelOfDetail lod);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatar_RequestAvatarSpecification(ulong userID);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatar_RequestAvatarSpecificationFromSpecRequest(IntPtr specificationRequest);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatarSpecificationRequest_SetFallbackLookAndFeelVersion(IntPtr specificationRequest, ovrAvatarLookAndFeelVersion version);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatarSpecificationRequest_SetExpressiveFlag(IntPtr specificationRequest, bool enable);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ovrAvatar_Create(IntPtr avatarSpecification, ovrAvatarCapabilities capabilities);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatar_Destroy(IntPtr avatar);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatarPose_UpdateBody(IntPtr avatar, ovrAvatarTransform headPose);
public static void ovrAvatarPose_UpdateVoiceVisualization(IntPtr avatar, float[] pcmData)
{
ovrAvatarPose_UpdateVoiceVisualization_Native(avatar, (uint)pcmData.Length, pcmData);
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatarPose_UpdateVoiceVisualization")]
private static extern void ovrAvatarPose_UpdateVoiceVisualization_Native(IntPtr avatar, uint pcmDataSize, [In] float[] pcmData);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatarPose_UpdateHands(IntPtr avatar, ovrAvatarHandInputState inputStateLeft, ovrAvatarHandInputState inputStateRight);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatarPose_UpdateHandsWithType(IntPtr avatar, ovrAvatarHandInputState inputStateLeft, ovrAvatarHandInputState inputStateRight, ovrAvatarControllerType type);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatarPose_Update3DofHands(IntPtr avatar, IntPtr inputStateLeft, IntPtr inputStateRight, ovrAvatarControllerType type);
public static void ovrAvatarPose_UpdateSDK3DofHands(IntPtr avatar, ovrAvatarHandInputState inputStateLeft, ovrAvatarHandInputState inputStateRight, ovrAvatarControllerType type)
{
IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(inputStateLeft));
IntPtr intPtr2 = Marshal.AllocHGlobal(Marshal.SizeOf(inputStateRight));
Marshal.StructureToPtr(inputStateLeft, intPtr, false);
Marshal.StructureToPtr(inputStateRight, intPtr2, false);
ovrAvatar_SetLeftControllerVisibility(avatar, true);
ovrAvatar_SetRightControllerVisibility(avatar, true);
ovrAvatar_SetLeftHandVisibility(avatar, true);
ovrAvatar_SetRightHandVisibility(avatar, true);
ovrAvatarPose_Update3DofHands(avatar, intPtr, intPtr2, type);
Marshal.FreeHGlobal(intPtr);
Marshal.FreeHGlobal(intPtr2);
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatarPose_Finalize(IntPtr avatar, float elapsedSeconds);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatar_SetLeftControllerVisibility(IntPtr avatar, bool show);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatar_SetRightControllerVisibility(IntPtr avatar, bool show);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatar_SetLeftHandVisibility(IntPtr avatar, bool show);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatar_SetRightHandVisibility(IntPtr avatar, bool show);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern uint ovrAvatarComponent_Count(IntPtr avatar);
public static ovrAvatarComponent ovrAvatarComponent_Get(IntPtr avatar, uint index)
{
IntPtr ptr = ovrAvatarComponent_Get_Native(avatar, index);
return (ovrAvatarComponent)Marshal.PtrToStructure(ptr, typeof(ovrAvatarComponent));
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatarComponent_Get")]
public static extern IntPtr ovrAvatarComponent_Get_Native(IntPtr avatar, uint index);
public static ovrAvatarBaseComponent? ovrAvatarPose_GetBaseComponent(IntPtr avatar)
{
IntPtr intPtr = ovrAvatarPose_GetBaseComponent_Native(avatar);
return (!(intPtr == IntPtr.Zero)) ? new ovrAvatarBaseComponent?((ovrAvatarBaseComponent)Marshal.PtrToStructure(intPtr, typeof(ovrAvatarBaseComponent))) : ((ovrAvatarBaseComponent?)null);
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatarPose_GetBaseComponent")]
private static extern IntPtr ovrAvatarPose_GetBaseComponent_Native(IntPtr avatar);
public static ovrAvatarBodyComponent? ovrAvatarPose_GetBodyComponent(IntPtr avatar)
{
IntPtr intPtr = ovrAvatarPose_GetBodyComponent_Native(avatar);
return (!(intPtr == IntPtr.Zero)) ? new ovrAvatarBodyComponent?((ovrAvatarBodyComponent)Marshal.PtrToStructure(intPtr, typeof(ovrAvatarBodyComponent))) : ((ovrAvatarBodyComponent?)null);
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatarPose_GetBodyComponent")]
private static extern IntPtr ovrAvatarPose_GetBodyComponent_Native(IntPtr avatar);
public static ovrAvatarControllerComponent? ovrAvatarPose_GetLeftControllerComponent(IntPtr avatar)
{
IntPtr intPtr = ovrAvatarPose_GetLeftControllerComponent_Native(avatar);
return (!(intPtr == IntPtr.Zero)) ? new ovrAvatarControllerComponent?((ovrAvatarControllerComponent)Marshal.PtrToStructure(intPtr, typeof(ovrAvatarControllerComponent))) : ((ovrAvatarControllerComponent?)null);
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatarPose_GetLeftControllerComponent")]
private static extern IntPtr ovrAvatarPose_GetLeftControllerComponent_Native(IntPtr avatar);
public static ovrAvatarControllerComponent? ovrAvatarPose_GetRightControllerComponent(IntPtr avatar)
{
IntPtr intPtr = ovrAvatarPose_GetRightControllerComponent_Native(avatar);
return (!(intPtr == IntPtr.Zero)) ? new ovrAvatarControllerComponent?((ovrAvatarControllerComponent)Marshal.PtrToStructure(intPtr, typeof(ovrAvatarControllerComponent))) : ((ovrAvatarControllerComponent?)null);
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatarPose_GetRightControllerComponent")]
private static extern IntPtr ovrAvatarPose_GetRightControllerComponent_Native(IntPtr avatar);
public static ovrAvatarHandComponent? ovrAvatarPose_GetLeftHandComponent(IntPtr avatar)
{
IntPtr intPtr = ovrAvatarPose_GetLeftHandComponent_Native(avatar);
return (!(intPtr == IntPtr.Zero)) ? new ovrAvatarHandComponent?((ovrAvatarHandComponent)Marshal.PtrToStructure(intPtr, typeof(ovrAvatarHandComponent))) : ((ovrAvatarHandComponent?)null);
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatarPose_GetLeftHandComponent")]
private static extern IntPtr ovrAvatarPose_GetLeftHandComponent_Native(IntPtr avatar);
public static ovrAvatarHandComponent? ovrAvatarPose_GetRightHandComponent(IntPtr avatar)
{
IntPtr intPtr = ovrAvatarPose_GetRightHandComponent_Native(avatar);
return (!(intPtr == IntPtr.Zero)) ? new ovrAvatarHandComponent?((ovrAvatarHandComponent)Marshal.PtrToStructure(intPtr, typeof(ovrAvatarHandComponent))) : ((ovrAvatarHandComponent?)null);
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatarPose_GetRightHandComponent")]
private static extern IntPtr ovrAvatarPose_GetRightHandComponent_Native(IntPtr avatar);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatarAsset_BeginLoading(ulong assetID);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern bool ovrAvatarAsset_BeginLoadingLOD(ulong assetId, ovrAvatarAssetLevelOfDetail lod);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern ovrAvatarAssetType ovrAvatarAsset_GetType(IntPtr assetHandle);
public static ovrAvatarMeshAssetData ovrAvatarAsset_GetMeshData(IntPtr assetPtr)
{
IntPtr ptr = ovrAvatarAsset_GetMeshData_Native(assetPtr);
return (ovrAvatarMeshAssetData)Marshal.PtrToStructure(ptr, typeof(ovrAvatarMeshAssetData));
}
public static ovrAvatarMeshAssetDataV2 ovrAvatarAsset_GetCombinedMeshData(IntPtr assetPtr)
{
IntPtr ptr = ovrAvatarAsset_GetCombinedMeshData_Native(assetPtr);
return (ovrAvatarMeshAssetDataV2)Marshal.PtrToStructure(ptr, typeof(ovrAvatarMeshAssetDataV2));
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatarAsset_GetCombinedMeshData")]
private static extern IntPtr ovrAvatarAsset_GetCombinedMeshData_Native(IntPtr assetPtr);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatarAsset_GetMeshData")]
private static extern IntPtr ovrAvatarAsset_GetMeshData_Native(IntPtr assetPtr);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern uint ovrAvatarAsset_GetMeshBlendShapeCount(IntPtr assetPtr);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ovrAvatarAsset_GetMeshBlendShapeName(IntPtr assetPtr, uint index);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern uint ovrAvatarAsset_GetSubmeshCount(IntPtr assetPtr);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern uint ovrAvatarAsset_GetSubmeshLastIndex(IntPtr assetPtr, uint index);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ovrAvatarAsset_GetMeshBlendShapeVertices(IntPtr assetPtr);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ovrAvatarAsset_GetAvatar(IntPtr assetHandle);
public static ulong[] ovrAvatarAsset_GetCombinedMeshIDs(IntPtr assetHandle)
{
uint num = 0u;
IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(num));
IntPtr ptr = ovrAvatarAsset_GetCombinedMeshIDs_Native(assetHandle, intPtr);
num = (uint)Marshal.PtrToStructure(intPtr, typeof(uint));
ulong[] array = new ulong[num];
for (int i = 0; i < num; i++)
{
array[i] = (ulong)Marshal.ReadInt64(ptr, i * Marshal.SizeOf(typeof(ulong)));
}
Marshal.FreeHGlobal(intPtr);
return array;
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatarAsset_GetCombinedMeshIDs")]
public static extern IntPtr ovrAvatarAsset_GetCombinedMeshIDs_Native(IntPtr assetHandle, IntPtr count);
public static void ovrAvatar_GetCombinedMeshAlphaData(IntPtr avatar, ref ulong textureID, ref Vector4 offset)
{
IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ulong)));
IntPtr intPtr2 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Vector4)));
ovrAvatar_GetCombinedMeshAlphaData_Native(avatar, intPtr, intPtr2);
textureID = (ulong)Marshal.PtrToStructure(intPtr, typeof(ulong));
offset = (Vector4)Marshal.PtrToStructure(intPtr2, typeof(Vector4));
Marshal.FreeHGlobal(intPtr);
Marshal.FreeHGlobal(intPtr2);
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatar_GetCombinedMeshAlphaData")]
public static extern IntPtr ovrAvatar_GetCombinedMeshAlphaData_Native(IntPtr avatar, IntPtr textureIDPtr, IntPtr offsetPtr);
public static ovrAvatarTextureAssetData ovrAvatarAsset_GetTextureData(IntPtr assetPtr)
{
IntPtr ptr = ovrAvatarAsset_GetTextureData_Native(assetPtr);
return (ovrAvatarTextureAssetData)Marshal.PtrToStructure(ptr, typeof(ovrAvatarTextureAssetData));
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatarAsset_GetTextureData")]
private static extern IntPtr ovrAvatarAsset_GetTextureData_Native(IntPtr assetPtr);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatarAsset_GetMaterialData")]
private static extern IntPtr ovrAvatarAsset_GetMaterialData_Native(IntPtr assetPtr);
public static ovrAvatarMaterialState ovrAvatarAsset_GetMaterialState(IntPtr assetPtr)
{
IntPtr ptr = ovrAvatarAsset_GetMaterialData_Native(assetPtr);
return (ovrAvatarMaterialState)Marshal.PtrToStructure(ptr, typeof(ovrAvatarMaterialState));
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern ovrAvatarRenderPartType ovrAvatarRenderPart_GetType(IntPtr renderPart);
public static ovrAvatarRenderPart_SkinnedMeshRender ovrAvatarRenderPart_GetSkinnedMeshRender(IntPtr renderPart)
{
IntPtr ptr = ovrAvatarRenderPart_GetSkinnedMeshRender_Native(renderPart);
return (ovrAvatarRenderPart_SkinnedMeshRender)Marshal.PtrToStructure(ptr, typeof(ovrAvatarRenderPart_SkinnedMeshRender));
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatarRenderPart_GetSkinnedMeshRender")]
private static extern IntPtr ovrAvatarRenderPart_GetSkinnedMeshRender_Native(IntPtr renderPart);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern ovrAvatarTransform ovrAvatarSkinnedMeshRender_GetTransform(IntPtr renderPart);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern ovrAvatarTransform ovrAvatarSkinnedMeshRenderPBS_GetTransform(IntPtr renderPart);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern ovrAvatarTransform ovrAvatarSkinnedMeshRenderPBSV2_GetTransform(IntPtr renderPart);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern ovrAvatarVisibilityFlags ovrAvatarSkinnedMeshRender_GetVisibilityMask(IntPtr renderPart);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern bool ovrAvatarSkinnedMeshRender_MaterialStateChanged(IntPtr renderPart);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern bool ovrAvatarSkinnedMeshRenderPBSV2_MaterialStateChanged(IntPtr renderPart);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern ovrAvatarVisibilityFlags ovrAvatarSkinnedMeshRenderPBS_GetVisibilityMask(IntPtr renderPart);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern ovrAvatarVisibilityFlags ovrAvatarSkinnedMeshRenderPBSV2_GetVisibilityMask(IntPtr renderPart);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern ovrAvatarMaterialState ovrAvatarSkinnedMeshRender_GetMaterialState(IntPtr renderPart);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern ovrAvatarPBSMaterialState ovrAvatarSkinnedMeshRenderPBSV2_GetPBSMaterialState(IntPtr renderPart);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern ovrAvatarExpressiveParameters ovrAvatar_GetExpressiveParameters(IntPtr avatar);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ovrAvatarSkinnedMeshRender_GetDirtyJoints(IntPtr renderPart);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ovrAvatarSkinnedMeshRenderPBS_GetDirtyJoints(IntPtr renderPart);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ovrAvatarSkinnedMeshRenderPBSV2_GetDirtyJoints(IntPtr renderPart);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern ovrAvatarTransform ovrAvatarSkinnedMeshRender_GetJointTransform(IntPtr renderPart, uint jointIndex);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern ovrAvatarTransform ovrAvatarSkinnedMeshRenderPBS_GetJointTransform(IntPtr renderPart, uint jointIndex);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern ovrAvatarTransform ovrAvatarSkinnedMeshRenderPBSV2_GetJointTransform(IntPtr renderPart, uint jointIndex);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ovrAvatarSkinnedMeshRenderPBS_GetAlbedoTextureAssetID(IntPtr renderPart);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ovrAvatarSkinnedMeshRenderPBS_GetSurfaceTextureAssetID(IntPtr renderPart);
public static ovrAvatarRenderPart_SkinnedMeshRenderPBS ovrAvatarRenderPart_GetSkinnedMeshRenderPBS(IntPtr renderPart)
{
IntPtr ptr = ovrAvatarRenderPart_GetSkinnedMeshRenderPBS_Native(renderPart);
return (ovrAvatarRenderPart_SkinnedMeshRenderPBS)Marshal.PtrToStructure(ptr, typeof(ovrAvatarRenderPart_SkinnedMeshRenderPBS));
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatarRenderPart_GetSkinnedMeshRenderPBS")]
private static extern IntPtr ovrAvatarRenderPart_GetSkinnedMeshRenderPBS_Native(IntPtr renderPart);
public static ovrAvatarRenderPart_SkinnedMeshRenderPBS_V2 ovrAvatarRenderPart_GetSkinnedMeshRenderPBSV2(IntPtr renderPart)
{
IntPtr ptr = ovrAvatarRenderPart_GetSkinnedMeshRenderPBSV2_Native(renderPart);
return (ovrAvatarRenderPart_SkinnedMeshRenderPBS_V2)Marshal.PtrToStructure(ptr, typeof(ovrAvatarRenderPart_SkinnedMeshRenderPBS_V2));
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatarRenderPart_GetSkinnedMeshRenderPBSV2")]
private static extern IntPtr ovrAvatarRenderPart_GetSkinnedMeshRenderPBSV2_Native(IntPtr renderPart);
public static ovrAvatarBlendShapeParams ovrAvatarSkinnedMeshRender_GetBlendShapeParams(IntPtr renderPart)
{
IntPtr ptr = ovrAvatarSkinnedMeshRender_GetBlendShapeParams_Native(renderPart);
return (ovrAvatarBlendShapeParams)Marshal.PtrToStructure(ptr, typeof(ovrAvatarBlendShapeParams));
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatarSkinnedMeshRender_GetBlendShapeParams")]
private static extern IntPtr ovrAvatarSkinnedMeshRender_GetBlendShapeParams_Native(IntPtr renderPart);
public static ovrAvatarRenderPart_ProjectorRender ovrAvatarRenderPart_GetProjectorRender(IntPtr renderPart)
{
IntPtr ptr = ovrAvatarRenderPart_GetProjectorRender_Native(renderPart);
return (ovrAvatarRenderPart_ProjectorRender)Marshal.PtrToStructure(ptr, typeof(ovrAvatarRenderPart_ProjectorRender));
}
public static ovrAvatarPBSMaterialState[] ovrAvatar_GetBodyPBSMaterialStates(IntPtr renderPart)
{
IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(uint)));
IntPtr intPtr2 = ovrAvatar_GetBodyPBSMaterialStates_Native(renderPart, intPtr);
uint num = (uint)Marshal.ReadInt32(intPtr);
ovrAvatarPBSMaterialState[] array = new ovrAvatarPBSMaterialState[num];
for (int i = 0; i < array.Length; i++)
{
IntPtr ptr = new IntPtr(intPtr2.ToInt64() + i * Marshal.SizeOf(typeof(ovrAvatarPBSMaterialState)));
array[i] = (ovrAvatarPBSMaterialState)Marshal.PtrToStructure(ptr, typeof(ovrAvatarPBSMaterialState));
}
Marshal.FreeHGlobal(intPtr);
return array;
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatar_GetBodyPBSMaterialStates")]
private static extern IntPtr ovrAvatar_GetBodyPBSMaterialStates_Native(IntPtr avatar, IntPtr count);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatarRenderPart_GetProjectorRender")]
private static extern IntPtr ovrAvatarRenderPart_GetProjectorRender_Native(IntPtr renderPart);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern uint ovrAvatar_GetReferencedAssetCount(IntPtr avatar);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ovrAvatar_GetReferencedAsset(IntPtr avatar, uint index);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatar_SetLeftHandGesture(IntPtr avatar, ovrAvatarHandGesture gesture);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatar_SetRightHandGesture(IntPtr avatar, ovrAvatarHandGesture gesture);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatar_SetLeftHandCustomGesture(IntPtr avatar, uint jointCount, [In] ovrAvatarTransform[] customJointTransforms);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatar_SetRightHandCustomGesture(IntPtr avatar, uint jointCount, [In] ovrAvatarTransform[] customJointTransforms);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatar_UpdatePoseFromPacket(IntPtr avatar, IntPtr packet, float secondsFromStart);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatarPacket_BeginRecording(IntPtr avatar);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ovrAvatarPacket_EndRecording(IntPtr avatar);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern uint ovrAvatarPacket_GetSize(IntPtr packet);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern float ovrAvatarPacket_GetDurationSeconds(IntPtr packet);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatarPacket_Free(IntPtr packet);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern bool ovrAvatarPacket_Write(IntPtr packet, uint bufferSize, [Out] byte[] buffer);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ovrAvatarPacket_Read(uint bufferSize, [In] byte[] buffer);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
private static extern void ovrAvatar_SetInternalForceASTCTextures(bool value);
public static void ovrAvatar_SetForceASTCTextures(bool value)
{
ovrAvatar_SetInternalForceASTCTextures(value);
}
public static void ovrAvatar_OverrideExpressiveLogic(IntPtr avatar, ovrAvatarBlendShapeParams blendParams)
{
IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ovrAvatarBlendShapeParams)));
Marshal.StructureToPtr(blendParams, intPtr, false);
ovrAvatar_OverrideExpressiveLogic_Native(avatar, intPtr);
Marshal.FreeHGlobal(intPtr);
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatar_OverrideExpressiveLogic")]
private static extern void ovrAvatar_OverrideExpressiveLogic_Native(IntPtr avatar, IntPtr state);
public static void ovrAvatar_SetVisemes(IntPtr avatar, ovrAvatarVisemes visemes)
{
IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ovrAvatarVisemes)));
Marshal.StructureToPtr(visemes, intPtr, false);
ovrAvatar_SetVisemes_Native(avatar, intPtr);
Marshal.FreeHGlobal(intPtr);
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatar_SetVisemes")]
private static extern void ovrAvatar_SetVisemes_Native(IntPtr avatar, IntPtr visemes);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatar_UpdateWorldTransform(IntPtr avatar, ovrAvatarTransform transform);
public static void ovrAvatar_UpdateGazeTargets(ovrAvatarGazeTargets targets)
{
IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ovrAvatarGazeTargets)));
Marshal.StructureToPtr(targets, intPtr, false);
ovrAvatar_UpdateGazeTargets_Native(intPtr);
Marshal.FreeHGlobal(intPtr);
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatar_UpdateGazeTargets")]
private static extern void ovrAvatar_UpdateGazeTargets_Native(IntPtr targets);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatar_RemoveGazeTargets(uint targetCount, uint[] ids);
public static void ovrAvatar_UpdateLights(ovrAvatarLights lights)
{
IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ovrAvatarLights)));
Marshal.StructureToPtr(lights, intPtr, false);
ovrAvatar_UpdateLights_Native(intPtr);
Marshal.FreeHGlobal(intPtr);
}
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrAvatar_UpdateLights")]
private static extern void ovrAvatar_UpdateLights_Native(IntPtr lights);
[DllImport("libovravatar", CallingConvention = CallingConvention.Cdecl)]
public static extern void ovrAvatar_RemoveLights(uint lightCount, uint[] ids);
public static bool SendEvent(string name, string param = "", string source = "")
{
try
{
if (ovrPluginVersion == null)
{
string text = ovrp_GetVersion();
if (!string.IsNullOrEmpty(text))
{
ovrPluginVersion = new Version(text.Split('-')[0]);
}
else
{
ovrPluginVersion = new Version(0, 0, 0);
}
}
if (ovrPluginVersion >= OVRP_1_30_0.version)
{
return OVRP_1_30_0.ovrp_SendEvent2(name, param, (source.Length != 0) ? source : "avatar_sdk") == Result.Success;
}
return false;
}
catch (Exception)
{
return false;
}
}
[DllImport("OVRPlugin", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrp_GetVersion")]
private static extern IntPtr _ovrp_GetVersion();
public static string ovrp_GetVersion()
{
return Marshal.PtrToStringAnsi(_ovrp_GetVersion());
}
}
}