Exemplo n.º 1
0
    // Token: 0x060000CA RID: 202 RVA: 0x0000923C File Offset: 0x0000743C
    private global::System.Collections.IEnumerator FreeRenderModel(global::System.IntPtr pRenderModel)
    {
        yield return(new global::UnityEngine.WaitForSeconds(1f));

        using (global::SteamVR_RenderModel.RenderModelInterfaceHolder holder = new global::SteamVR_RenderModel.RenderModelInterfaceHolder())
        {
            global::Valve.VR.CVRRenderModels renderModels = holder.instance;
            renderModels.FreeRenderModel(pRenderModel);
            renderModels = null;
        }
        global::SteamVR_RenderModel.RenderModelInterfaceHolder holder = null;
        yield break;
    }
Exemplo n.º 2
0
 // Token: 0x060000C8 RID: 200 RVA: 0x00008C10 File Offset: 0x00006E10
 private bool SetModel(string renderModelName)
 {
     this.StripMesh(base.gameObject);
     using (global::SteamVR_RenderModel.RenderModelInterfaceHolder renderModelInterfaceHolder = new global::SteamVR_RenderModel.RenderModelInterfaceHolder())
     {
         bool flag = this.createComponents;
         if (flag)
         {
             bool flag2 = this.LoadComponents(renderModelInterfaceHolder, renderModelName);
             if (flag2)
             {
                 this.UpdateComponents();
                 return(true);
             }
             global::UnityEngine.Debug.Log("[" + base.gameObject.name + "] Render model does not support components, falling back to single mesh.");
         }
         bool flag3 = !string.IsNullOrEmpty(renderModelName);
         if (flag3)
         {
             global::SteamVR_RenderModel.RenderModel renderModel = global::SteamVR_RenderModel.models[renderModelName] as global::SteamVR_RenderModel.RenderModel;
             bool flag4 = renderModel == null || renderModel.mesh == null;
             if (flag4)
             {
                 global::Valve.VR.CVRRenderModels instance = renderModelInterfaceHolder.instance;
                 bool flag5 = instance == null;
                 if (flag5)
                 {
                     return(false);
                 }
                 bool flag6 = this.verbose;
                 if (flag6)
                 {
                     global::UnityEngine.Debug.Log("Loading render model " + renderModelName);
                 }
                 renderModel = this.LoadRenderModel(instance, renderModelName, renderModelName);
                 bool flag7 = renderModel == null;
                 if (flag7)
                 {
                     return(false);
                 }
                 global::SteamVR_RenderModel.models[renderModelName] = renderModel;
             }
             base.gameObject.AddComponent <global::UnityEngine.MeshFilter>().mesh             = renderModel.mesh;
             base.gameObject.AddComponent <global::UnityEngine.MeshRenderer>().sharedMaterial = renderModel.material;
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 3
0
    // Token: 0x060000D1 RID: 209 RVA: 0x000096E4 File Offset: 0x000078E4
    public void UpdateComponents()
    {
        global::UnityEngine.Transform transform = base.transform;
        bool flag = transform.childCount == 0;

        if (!flag)
        {
            using (global::SteamVR_RenderModel.RenderModelInterfaceHolder renderModelInterfaceHolder = new global::SteamVR_RenderModel.RenderModelInterfaceHolder())
            {
                global::Valve.VR.VRControllerState_t vrcontrollerState_t = (this.index != global::SteamVR_TrackedObject.EIndex.None) ? global::SteamVR_Controller.Input((int)this.index).GetState() : default(global::Valve.VR.VRControllerState_t);
                for (int i = 0; i < transform.childCount; i++)
                {
                    global::UnityEngine.Transform    child    = transform.GetChild(i);
                    global::Valve.VR.CVRRenderModels instance = renderModelInterfaceHolder.instance;
                    bool flag2 = instance == null;
                    if (flag2)
                    {
                        break;
                    }
                    global::Valve.VR.RenderModel_ComponentState_t renderModel_ComponentState_t = default(global::Valve.VR.RenderModel_ComponentState_t);
                    bool flag3 = !instance.GetComponentState(this.renderModelName, child.name, ref vrcontrollerState_t, ref this.controllerModeState, ref renderModel_ComponentState_t);
                    if (!flag3)
                    {
                        global::SteamVR_Utils.RigidTransform rigidTransform = new global::SteamVR_Utils.RigidTransform(renderModel_ComponentState_t.mTrackingToComponentRenderModel);
                        child.localPosition = rigidTransform.pos;
                        child.localRotation = rigidTransform.rot;
                        global::UnityEngine.Transform transform2 = child.FindChild("attach");
                        bool flag4 = transform2 != null;
                        if (flag4)
                        {
                            global::SteamVR_Utils.RigidTransform rigidTransform2 = new global::SteamVR_Utils.RigidTransform(renderModel_ComponentState_t.mTrackingToComponentLocal);
                            transform2.position = transform.TransformPoint(rigidTransform2.pos);
                            transform2.rotation = transform.rotation * rigidTransform2.rot;
                        }
                        bool flag5 = (renderModel_ComponentState_t.uProperties & 2U) > 0U;
                        bool flag6 = flag5 != child.gameObject.activeSelf;
                        if (flag6)
                        {
                            child.gameObject.SetActive(flag5);
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 4
0
    // Token: 0x060000C7 RID: 199 RVA: 0x00008BFA File Offset: 0x00006DFA
    private global::System.Collections.IEnumerator SetModelAsync(string renderModelName)
    {
        bool flag = string.IsNullOrEmpty(renderModelName);

        if (flag)
        {
            yield break;
        }
        using (global::SteamVR_RenderModel.RenderModelInterfaceHolder holder = new global::SteamVR_RenderModel.RenderModelInterfaceHolder())
        {
            global::Valve.VR.CVRRenderModels renderModels = holder.instance;
            bool flag2 = renderModels == null;
            if (flag2)
            {
                yield break;
            }
            uint     count = renderModels.GetComponentCount(renderModelName);
            bool     flag3 = count > 0U;
            string[] renderModelNames;
            if (flag3)
            {
                renderModelNames = new string[count];
                int i = 0;
                while ((long)i < (long)((ulong)count))
                {
                    uint capacity = renderModels.GetComponentName(renderModelName, (uint)i, null, 0U);
                    bool flag4    = capacity == 0U;
                    if (!flag4)
                    {
                        global::System.Text.StringBuilder componentName = new global::System.Text.StringBuilder((int)capacity);
                        bool flag5 = renderModels.GetComponentName(renderModelName, (uint)i, componentName, capacity) == 0U;
                        if (!flag5)
                        {
                            capacity = renderModels.GetComponentRenderModelName(renderModelName, componentName.ToString(), null, 0U);
                            bool flag6 = capacity == 0U;
                            if (!flag6)
                            {
                                global::System.Text.StringBuilder name = new global::System.Text.StringBuilder((int)capacity);
                                bool flag7 = renderModels.GetComponentRenderModelName(renderModelName, componentName.ToString(), name, capacity) == 0U;
                                if (!flag7)
                                {
                                    string s = name.ToString();
                                    global::SteamVR_RenderModel.RenderModel model = global::SteamVR_RenderModel.models[s] as global::SteamVR_RenderModel.RenderModel;
                                    bool flag8 = model == null || model.mesh == null;
                                    if (flag8)
                                    {
                                        renderModelNames[i] = s;
                                    }
                                    componentName = null;
                                    name          = null;
                                    s             = null;
                                    model         = null;
                                }
                            }
                        }
                    }
                    int num = i;
                    i = num + 1;
                }
            }
            else
            {
                global::SteamVR_RenderModel.RenderModel model2 = global::SteamVR_RenderModel.models[renderModelName] as global::SteamVR_RenderModel.RenderModel;
                bool flag9 = model2 == null || model2.mesh == null;
                if (flag9)
                {
                    renderModelNames = new string[]
                    {
                        renderModelName
                    };
                }
                else
                {
                    renderModelNames = new string[0];
                }
                model2 = null;
            }
            for (;;)
            {
                bool loading = false;
                foreach (string name2 in renderModelNames)
                {
                    bool flag10 = string.IsNullOrEmpty(name2);
                    if (!flag10)
                    {
                        global::System.IntPtr pRenderModel         = global::System.IntPtr.Zero;
                        global::Valve.VR.EVRRenderModelError error = renderModels.LoadRenderModel_Async(name2, ref pRenderModel);
                        bool flag11 = error == global::Valve.VR.EVRRenderModelError.Loading;
                        if (flag11)
                        {
                            loading = true;
                        }
                        else
                        {
                            bool flag12 = error == global::Valve.VR.EVRRenderModelError.None;
                            if (flag12)
                            {
                                global::Valve.VR.RenderModel_t renderModel = (global::Valve.VR.RenderModel_t)global::System.Runtime.InteropServices.Marshal.PtrToStructure(pRenderModel, typeof(global::Valve.VR.RenderModel_t));
                                global::UnityEngine.Material   material    = global::SteamVR_RenderModel.materials[renderModel.diffuseTextureId] as global::UnityEngine.Material;
                                bool flag13 = material == null || material.mainTexture == null;
                                if (flag13)
                                {
                                    global::System.IntPtr pDiffuseTexture = global::System.IntPtr.Zero;
                                    error = renderModels.LoadTexture_Async(renderModel.diffuseTextureId, ref pDiffuseTexture);
                                    bool flag14 = error == global::Valve.VR.EVRRenderModelError.Loading;
                                    if (flag14)
                                    {
                                        loading = true;
                                    }
                                }
                                material = null;
                            }
                        }
                        name2 = null;
                    }
                }
                string[] array  = null;
                bool     flag15 = loading;
                if (!flag15)
                {
                    break;
                }
                yield return(new global::UnityEngine.WaitForSeconds(0.1f));
            }
            renderModels     = null;
            renderModelNames = null;
        }
        global::SteamVR_RenderModel.RenderModelInterfaceHolder holder = null;
        bool success = this.SetModel(renderModelName);

        global::SteamVR_Utils.Event.Send("render_model_loaded", new object[]
        {
            this,
            success
        });
        yield break;
        yield break;
    }
Exemplo n.º 5
0
    // Token: 0x060000CD RID: 205 RVA: 0x000092E8 File Offset: 0x000074E8
    private bool LoadComponents(global::SteamVR_RenderModel.RenderModelInterfaceHolder holder, string renderModelName)
    {
        global::UnityEngine.Transform transform = base.transform;
        for (int i = 0; i < transform.childCount; i++)
        {
            global::UnityEngine.Transform child = transform.GetChild(i);
            child.gameObject.SetActive(false);
            this.StripMesh(child.gameObject);
        }
        bool flag = string.IsNullOrEmpty(renderModelName);
        bool result;

        if (flag)
        {
            result = true;
        }
        else
        {
            global::Valve.VR.CVRRenderModels instance = holder.instance;
            bool flag2 = instance == null;
            if (flag2)
            {
                result = false;
            }
            else
            {
                uint componentCount = instance.GetComponentCount(renderModelName);
                bool flag3          = componentCount == 0U;
                if (flag3)
                {
                    result = false;
                }
                else
                {
                    int num = 0;
                    while ((long)num < (long)((ulong)componentCount))
                    {
                        uint num2  = instance.GetComponentName(renderModelName, (uint)num, null, 0U);
                        bool flag4 = num2 == 0U;
                        if (!flag4)
                        {
                            global::System.Text.StringBuilder stringBuilder = new global::System.Text.StringBuilder((int)num2);
                            bool flag5 = instance.GetComponentName(renderModelName, (uint)num, stringBuilder, num2) == 0U;
                            if (!flag5)
                            {
                                transform = this.FindComponent(stringBuilder.ToString());
                                bool flag6 = transform != null;
                                if (flag6)
                                {
                                    transform.gameObject.SetActive(true);
                                }
                                else
                                {
                                    transform                  = new global::UnityEngine.GameObject(stringBuilder.ToString()).transform;
                                    transform.parent           = base.transform;
                                    transform.gameObject.layer = base.gameObject.layer;
                                    global::UnityEngine.Transform transform2 = new global::UnityEngine.GameObject("attach").transform;
                                    transform2.parent           = transform;
                                    transform2.localPosition    = global::UnityEngine.Vector3.zero;
                                    transform2.localRotation    = global::UnityEngine.Quaternion.identity;
                                    transform2.localScale       = global::UnityEngine.Vector3.one;
                                    transform2.gameObject.layer = base.gameObject.layer;
                                }
                                transform.localPosition = global::UnityEngine.Vector3.zero;
                                transform.localRotation = global::UnityEngine.Quaternion.identity;
                                transform.localScale    = global::UnityEngine.Vector3.one;
                                num2 = instance.GetComponentRenderModelName(renderModelName, stringBuilder.ToString(), null, 0U);
                                bool flag7 = num2 == 0U;
                                if (!flag7)
                                {
                                    global::System.Text.StringBuilder stringBuilder2 = new global::System.Text.StringBuilder((int)num2);
                                    bool flag8 = instance.GetComponentRenderModelName(renderModelName, stringBuilder.ToString(), stringBuilder2, num2) == 0U;
                                    if (!flag8)
                                    {
                                        global::SteamVR_RenderModel.RenderModel renderModel = global::SteamVR_RenderModel.models[stringBuilder2] as global::SteamVR_RenderModel.RenderModel;
                                        bool flag9 = renderModel == null || renderModel.mesh == null;
                                        if (flag9)
                                        {
                                            bool flag10 = this.verbose;
                                            if (flag10)
                                            {
                                                string text = "Loading render model ";
                                                global::System.Text.StringBuilder stringBuilder3 = stringBuilder2;
                                                global::UnityEngine.Debug.Log(text + ((stringBuilder3 != null) ? stringBuilder3.ToString() : null));
                                            }
                                            renderModel = this.LoadRenderModel(instance, stringBuilder2.ToString(), renderModelName);
                                            bool flag11 = renderModel == null;
                                            if (flag11)
                                            {
                                                goto IL_2BD;
                                            }
                                            global::SteamVR_RenderModel.models[stringBuilder2] = renderModel;
                                        }
                                        transform.gameObject.AddComponent <global::UnityEngine.MeshFilter>().mesh             = renderModel.mesh;
                                        transform.gameObject.AddComponent <global::UnityEngine.MeshRenderer>().sharedMaterial = renderModel.material;
                                    }
                                }
                            }
                        }
IL_2BD:
                        num++;
                    }
                    result = true;
                }
            }
        }
        return(result);
    }