protected SkinnedMeshRenderer CreateSkinnedMesh(ulong assetID, ovrAvatarVisibilityFlags visibilityMask, int thirdPersonLayer, int firstPersonLayer, int sortingOrder)
    {
        OvrAvatarAssetMesh meshAsset = (OvrAvatarAssetMesh)OvrAvatarSDKManager.Instance.GetAsset(assetID);

        if (meshAsset == null)
        {
            throw new Exception("Couldn't find mesh for asset " + assetID);
        }
        if ((visibilityMask & ovrAvatarVisibilityFlags.ThirdPerson) != 0)
        {
            this.gameObject.layer = thirdPersonLayer;
        }
        else
        {
            this.gameObject.layer = firstPersonLayer;
        }
        SkinnedMeshRenderer renderer = meshAsset.CreateSkinnedMeshRendererOnObject(gameObject);

        renderer.quality             = SkinQuality.Bone4;
        renderer.sortingOrder        = sortingOrder;
        renderer.updateWhenOffscreen = true;
        if ((visibilityMask & ovrAvatarVisibilityFlags.SelfOccluding) == 0)
        {
            renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
        }
        return(renderer);
    }
Ejemplo n.º 2
0
    protected SkinnedMeshRenderer CreateSkinnedMesh(ulong assetID, ovrAvatarVisibilityFlags visibilityMask, int thirdPersonLayer, int firstPersonLayer)
    {
        isBodyComponent = name.Contains("body");

        OvrAvatarAssetMesh meshAsset = (OvrAvatarAssetMesh)OvrAvatarSDKManager.Instance.GetAsset(assetID);

        if (meshAsset == null)
        {
            throw new Exception("Couldn't find mesh for asset " + assetID);
        }
        if ((visibilityMask & ovrAvatarVisibilityFlags.ThirdPerson) != 0)
        {
            this.gameObject.layer = thirdPersonLayer;
        }
        else
        {
            this.gameObject.layer = firstPersonLayer;
        }
        SkinnedMeshRenderer renderer = meshAsset.CreateSkinnedMeshRendererOnObject(gameObject);

#if UNITY_ANDROID
        renderer.quality = SkinQuality.Bone2;
#else
        renderer.quality = SkinQuality.Bone4;
#endif
        renderer.updateWhenOffscreen = true;
        if ((visibilityMask & ovrAvatarVisibilityFlags.SelfOccluding) == 0)
        {
            renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
        }

        gameObject.SetActive(false);

        return(renderer);
    }
Ejemplo n.º 3
0
    protected SkinnedMeshRenderer CreateSkinnedMesh(ulong assetID, ovrAvatarVisibilityFlags visibilityMask, int thirdPersonLayer, int firstPersonLayer)
    {
        isBodyComponent = name.Contains("body");

        OvrAvatarAssetMesh meshAsset = (OvrAvatarAssetMesh)OvrAvatarSDKManager.Instance.GetAsset(assetID);

        if (meshAsset == null)
        {
            throw new Exception("Couldn't find mesh for asset " + assetID);
        }
        if ((visibilityMask & ovrAvatarVisibilityFlags.ThirdPerson) != 0)
        {
            this.gameObject.layer = thirdPersonLayer;
        }
        else
        {
            this.gameObject.layer = firstPersonLayer;
        }
        SkinnedMeshRenderer renderer = meshAsset.CreateSkinnedMeshRendererOnObject(gameObject);

#if UNITY_ANDROID
        renderer.quality = SkinQuality.Bone2;
#else
        renderer.quality = SkinQuality.Bone4;
#endif
        renderer.updateWhenOffscreen = true;
        if ((visibilityMask & ovrAvatarVisibilityFlags.SelfOccluding) == 0)
        {
            renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
        }

        gameObject.SetActive(false);

        Rigidbody rigidbody = gameObject.AddComponent <Rigidbody>();
        rigidbody.useGravity = false;
        // rigidbody.isKinematic = true;
        BoxCollider box = gameObject.AddComponent <BoxCollider>();

        // box.isTrigger = true;
        if (isBodyComponent)
        {
            gameObject.AddComponent <BodyCollider>();
            box.center = new Vector3(0, 0.85f, 0.5f);
            box.size   = new Vector3(0.2f, 0.5f, 0.2f);
        }
        else
        {
            gameObject.AddComponent <HandCollider>();
            box.size *= 0.65f;
        }
        return(renderer);
    }
        private OvrAvatarSkinnedMeshPBSV2RenderComponent AddSkinnedMeshRenderPBSV2Component(GameObject gameObject, ovrAvatarRenderPart_SkinnedMeshRenderPBS_V2 skinnedMeshRenderPBSV2)
        {
            OvrAvatarSkinnedMeshPBSV2RenderComponent skinnedMeshRenderer = gameObject.AddComponent <OvrAvatarSkinnedMeshPBSV2RenderComponent>();
            OvrAvatarAssetMesh  meshAsset = (OvrAvatarAssetMesh)OvrAvatarSDKManager.Instance.GetAsset(skinnedMeshRenderPBSV2.meshAssetID);
            SkinnedMeshRenderer renderer  = meshAsset.CreateSkinnedMeshRendererOnObject(gameObject);

#if UNITY_ANDROID
            renderer.quality = SkinQuality.Bone2;
#else
            renderer.quality = SkinQuality.Bone4;
#endif
            renderer.updateWhenOffscreen        = true;
            skinnedMeshRenderer.mesh            = renderer;
            transform.GetChild(0).localPosition = Vector2.zero;
            transform.GetChild(0).localRotation = Quaternion.identity;
            transform.GetChild(0).GetComponentInChildren <OvrAvatarSkinnedMeshPBSV2RenderComponent>().gameObject.SetActive(false);
            var shader = Shader.Find("OvrAvatar/AvatarPBRV2Simple");
            renderer.sharedMaterial = CreateAvatarMaterial(gameObject.name + "_material", shader);
            SetMaterialOpaque(renderer.sharedMaterial);
            skinnedMeshRenderer.bones = renderer.bones;

            return(skinnedMeshRenderer);
        }