31 lines
1.5 KiB
C#
31 lines
1.5 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using System;
|
|
using Oculus.Avatar;
|
|
|
|
public class OvrAvatarSkinnedMeshRenderPBSComponent : OvrAvatarRenderComponent {
|
|
|
|
internal void Initialize(ovrAvatarRenderPart_SkinnedMeshRenderPBS skinnedMeshRenderPBS, Shader shader, int thirdPersonLayer, int firstPersonLayer, int sortOrder)
|
|
{
|
|
if (shader == null)
|
|
{
|
|
shader = Shader.Find("OvrAvatar/AvatarSurfaceShaderPBS");
|
|
}
|
|
mesh = CreateSkinnedMesh(skinnedMeshRenderPBS.meshAssetID, skinnedMeshRenderPBS.visibilityMask, thirdPersonLayer, firstPersonLayer, sortOrder);
|
|
mesh.sharedMaterial = CreateAvatarMaterial(gameObject.name + "_material", shader);
|
|
bones = mesh.bones;
|
|
}
|
|
|
|
internal void UpdateSkinnedMeshRenderPBS(OvrAvatar avatar, IntPtr renderPart, Material mat)
|
|
{
|
|
ovrAvatarVisibilityFlags visibilityMask = CAPI.ovrAvatarSkinnedMeshRenderPBS_GetVisibilityMask(renderPart);
|
|
ovrAvatarTransform localTransform = CAPI.ovrAvatarSkinnedMeshRenderPBS_GetTransform(renderPart);
|
|
UpdateSkinnedMesh(avatar, bones, localTransform, visibilityMask, renderPart);
|
|
|
|
UInt64 albedoTextureID = CAPI.ovrAvatarSkinnedMeshRenderPBS_GetAlbedoTextureAssetID(renderPart);
|
|
UInt64 surfaceTextureID = CAPI.ovrAvatarSkinnedMeshRenderPBS_GetSurfaceTextureAssetID(renderPart);
|
|
mat.SetTexture("_Albedo", OvrAvatarComponent.GetLoadedTexture(albedoTextureID));
|
|
mat.SetTexture("_Surface", OvrAvatarComponent.GetLoadedTexture(surfaceTextureID));
|
|
}
|
|
}
|