private void updateBatteryLevel()
        {
            if (batteryGO != null)
            {
                if (true)
                {
                    if ((modelResource == null) || (modelResource.batteryTextureList == null))
                    {
                        return;
                    }

                    bool found = false;
                    //WVR_DeviceType type = checkDeviceType();
                    float batteryP = Interop.WVR_GetDeviceBatteryPercentage(preferedModelName.Contains("Left") ? WVR_DeviceType.WVR_DeviceType_Controller_Left : WVR_DeviceType.WVR_DeviceType_Controller_Right);
                    if (batteryP < 0)
                    {
                        Debug.Log("[DEBUG] updateBatteryLevel BatteryPercentage is negative, return");
                        batteryGO.SetActive(false);
                        return;
                    }
                    foreach (BatteryIndicator bi in modelResource.batteryTextureList)
                    {
                        if (batteryP >= bi.min / 100 && batteryP <= bi.max / 100)
                        {
                            currentBattery = bi;
                            found          = true;
                            break;
                        }
                    }
                    if (found)
                    {
                        if (batteryMR != null)
                        {
                            batteryMR.material.mainTexture = currentBattery.batteryTexture;
                            //Debug.Log("[DEBUG] updateBatteryLevel battery level to " + currentBattery.level + ", battery percent: " + batteryP);
                            batteryGO.SetActive(true);
                        }
                        else
                        {
                            Debug.Log("[DEBUG] updateBatteryLevel Can't get battery mesh renderer");
                            batteryGO.SetActive(false);
                        }
                    }
                    else
                    {
                        batteryGO.SetActive(false);
                    }
                }
                //else
                //{
                //    batteryGO.SetActive(false);
                //}
            }
        }
        public override void ViewDidUnload()
        {
            base.ViewDidUnload();

            App.SeekiosChanged          -= App_SeekiosChanged;
            App.RemainingRequestChanged -= OnRemainingRequestChanged;
            App.Locator.ModeDontMove.SeekiosMovedNotified   -= ModeDontMove_SeekiosMovedNotified;
            App.Locator.ModeZone.OnSeekiosOutOfZoneNotified -= ModeZone_OnSeekiosOutOfZoneNotified;
            RefreshBatteryButton.TouchUpInside -= RefreshBatteryButton_TouchUpInside;
            HelpCreditCostButton.TouchDown     -= HelpCreditCostButton_TouchDown;
            NeedUpdateButton.TouchDown         -= NeedUpdateButton_TouchDown;

            SeekiosImageView.Dispose();
            CreditsTitleLabel.Dispose();
            NextRefillLabel.Dispose();
            LastRefreshBatteryLabel.Dispose();
            RefreshBatteryButton.Dispose();
            BatteryLabel.Dispose();
            BatteryIndicator.Dispose();
            RefreshBatteryButton.Dispose();
            //Tableview.Dispose();

            _seekiosSelected = null;
        }
Exemple #3
0
    bool getBatteryIndicatorParam(ModelResource curr, string modelFolderPath, ModelSpecify ms)
    {
        if (curr == null)
        {
            PrintWarningLog("Model resource is null!");
            return(false);
        }

        string batteryJsonFile = modelFolderPath + "/";

        if (ms == ModelSpecify.MS_Dominant)
        {
            batteryJsonFile += "BatteryIndicator.json";
        }
        else
        {
            batteryJsonFile += "BatteryIndicator01.json";
        }

        if (!File.Exists(batteryJsonFile))
        {
            PrintWarningLog(batteryJsonFile + " is not found!");
            return(false);
        }

        StreamReader json_sr = new StreamReader(batteryJsonFile);

        string JsonString = json_sr.ReadToEnd();

        PrintInfoLog("BatteryIndicator json: " + JsonString);
        json_sr.Close();

        if (JsonString.Equals(""))
        {
            PrintWarningLog("JsonString is empty!");
            return(false);
        }

        SimpleJSON.JSONNode jsNodes = SimpleJSON.JSONNode.Parse(JsonString);

        string tmpStr = "";

        tmpStr = jsNodes["LevelCount"].Value;

        if (tmpStr.Equals(""))
        {
            PrintWarningLog("Battery level is not found!");
            return(false);
        }

        int batteryLevel = int.Parse(tmpStr);

        PrintInfoLog("Battery level is " + batteryLevel);

        if (batteryLevel <= 0)
        {
            PrintWarningLog("Battery level is less or equal to 0!");
            return(false);
        }
        List <BatteryIndicator> batteryTextureList = new List <BatteryIndicator>();

        for (int i = 0; i < batteryLevel; i++)
        {
            string minStr  = jsNodes["BatteryLevel"][i]["min"].Value;
            string maxStr  = jsNodes["BatteryLevel"][i]["max"].Value;
            string pathStr = jsNodes["BatteryLevel"][i]["path"].Value;

            if (minStr.Equals("") || maxStr.Equals("") || pathStr.Equals(""))
            {
                PrintWarningLog("Min, Max or Path is not found!");
                batteryLevel = 0;
                batteryTextureList.Clear();
                return(false);
            }

            string batteryLevelFile = modelFolderPath + "/" + pathStr;

            if (!File.Exists(batteryLevelFile))
            {
                PrintWarningLog(batteryLevelFile + " is not found!");
                batteryLevel = 0;
                batteryTextureList.Clear();
                return(false);
            }

            BatteryIndicator tmpBI = new BatteryIndicator();
            tmpBI.level       = i;
            tmpBI.min         = float.Parse(minStr);
            tmpBI.max         = float.Parse(maxStr);
            tmpBI.texturePath = batteryLevelFile;

            byte[] imgByteArray = File.ReadAllBytes(batteryLevelFile);
            PrintDebugLog("Image size: " + imgByteArray.Length);

            tmpBI.batteryTexture = new Texture2D(2, 2, TextureFormat.BGRA32, false);
            tmpBI.textureLoaded  = tmpBI.batteryTexture.LoadImage(imgByteArray);

            PrintInfoLog("Battery Level: " + tmpBI.level + " min: " + tmpBI.min + " max: " + tmpBI.max + " path: " + tmpBI.texturePath + " loaded: " + tmpBI.textureLoaded);

            batteryTextureList.Add(tmpBI);
        }

        curr.batteryTextureList = batteryTextureList;
        PrintInfoLog("BatteryIndicator is ready!");
        return(true);
    }
        void ReleaseDesignerOutlets()
        {
            if (AlertImage != null)
            {
                AlertImage.Dispose();
                AlertImage = null;
            }

            if (AlertLabel != null)
            {
                AlertLabel.Dispose();
                AlertLabel = null;
            }

            if (BatteryBackgroundImage != null)
            {
                BatteryBackgroundImage.Dispose();
                BatteryBackgroundImage = null;
            }

            if (BatteryIndicator != null)
            {
                BatteryIndicator.Dispose();
                BatteryIndicator = null;
            }

            if (BatteryLabel != null)
            {
                BatteryLabel.Dispose();
                BatteryLabel = null;
            }

            if (CreditsFreeLabel != null)
            {
                CreditsFreeLabel.Dispose();
                CreditsFreeLabel = null;
            }

            if (CreditsLabel != null)
            {
                CreditsLabel.Dispose();
                CreditsLabel = null;
            }

            if (CreditsTitleLabel != null)
            {
                CreditsTitleLabel.Dispose();
                CreditsTitleLabel = null;
            }

            if (DateReloadSeekiosCredit != null)
            {
                DateReloadSeekiosCredit.Dispose();
                DateReloadSeekiosCredit = null;
            }

            if (HeadView != null)
            {
                HeadView.Dispose();
                HeadView = null;
            }

            if (HelpCreditCostButton != null)
            {
                HelpCreditCostButton.Dispose();
                HelpCreditCostButton = null;
            }

            if (LastRefreshBatteryLabel != null)
            {
                LastRefreshBatteryLabel.Dispose();
                LastRefreshBatteryLabel = null;
            }

            if (ModeImage != null)
            {
                ModeImage.Dispose();
                ModeImage = null;
            }

            if (ModeLabel != null)
            {
                ModeLabel.Dispose();
                ModeLabel = null;
            }

            if (NeedUpdateButton != null)
            {
                NeedUpdateButton.Dispose();
                NeedUpdateButton = null;
            }

            if (NextRefillLabel != null)
            {
                NextRefillLabel.Dispose();
                NextRefillLabel = null;
            }

            if (PowerSavingImage != null)
            {
                PowerSavingImage.Dispose();
                PowerSavingImage = null;
            }

            if (RefreshBatteryButton != null)
            {
                RefreshBatteryButton.Dispose();
                RefreshBatteryButton = null;
            }

            if (SeekiosImageView != null)
            {
                SeekiosImageView.Dispose();
                SeekiosImageView = null;
            }

            if (SeekiosLastPositionLabel != null)
            {
                SeekiosLastPositionLabel.Dispose();
                SeekiosLastPositionLabel = null;
            }

            if (SeekiosNameLabel != null)
            {
                SeekiosNameLabel.Dispose();
                SeekiosNameLabel = null;
            }

            if (Tableview != null)
            {
                Tableview.Dispose();
                Tableview = null;
            }
        }
    void getBatteryIndicatorParam()
    {
        isBatteryIndicatorReady = false;

        string batteryJsonFile = renderModelNamePath + "/" + "BatteryIndicator.json";

        if (!File.Exists(batteryJsonFile))
        {
            PrintDebugLog(batteryJsonFile + " is not found!");
            return;
        }

        StreamReader json_sr = new StreamReader(batteryJsonFile);

        string JsonString = json_sr.ReadToEnd();

        PrintDebugLog("BatteryIndicator json: " + JsonString);
        json_sr.Close();

        if (JsonString.Equals(""))
        {
            PrintDebugLog("JsonString is empty!");
            return;
        }

        SimpleJSON.JSONNode jsNodes = SimpleJSON.JSONNode.Parse(JsonString);

        string tmpStr = "";

        tmpStr = jsNodes["LevelCount"].Value;

        if (tmpStr.Equals(""))
        {
            PrintDebugLog("Battery level is not found!");
            return;
        }

        int batteryLevel = int.Parse(tmpStr);

        PrintDebugLog("Battery level is " + batteryLevel);

        if (batteryLevel <= 0)
        {
            PrintDebugLog("Battery level is less or equal to 0!");
            return;
        }

        for (int i = 0; i < batteryLevel; i++)
        {
            string minStr  = jsNodes["BatteryLevel"][i]["min"].Value;
            string maxStr  = jsNodes["BatteryLevel"][i]["max"].Value;
            string pathStr = jsNodes["BatteryLevel"][i]["path"].Value;

            if (minStr.Equals("") || maxStr.Equals("") || pathStr.Equals(""))
            {
                PrintDebugLog("Min, Max or Path is not found!");
                batteryLevel = 0;
                batteryTextureList.Clear();
                return;
            }

            string batteryLevelFile = renderModelNamePath + "/" + pathStr;

            if (!File.Exists(batteryLevelFile))
            {
                PrintDebugLog(batteryLevelFile + " is not found!");
                batteryLevel = 0;
                batteryTextureList.Clear();
                return;
            }

            BatteryIndicator tmpBI = new BatteryIndicator();
            tmpBI.level       = i;
            tmpBI.min         = float.Parse(minStr);
            tmpBI.max         = float.Parse(maxStr);
            tmpBI.texturePath = batteryLevelFile;

            byte[] imgByteArray = File.ReadAllBytes(batteryLevelFile);
            PrintDebugLog("Image size: " + imgByteArray.Length);

            tmpBI.batteryTexture = new Texture2D(2, 2, TextureFormat.BGRA32, false);
            tmpBI.textureLoaded  = tmpBI.batteryTexture.LoadImage(imgByteArray);

            PrintDebugLog("Battery Level: " + tmpBI.level + " min: " + tmpBI.min + " max: " + tmpBI.max + " path: " + tmpBI.texturePath + " loaded: " + tmpBI.textureLoaded);

            batteryTextureList.Add(tmpBI);
        }

        isBatteryIndicatorReady = true;
        PrintDebugLog("BatteryIndicator is ready!");
    }
        private void LoadModel(string renderModelName)
        {
            Debug.Log(transform.parent.parent.name + " Try LoadModel " + renderModelName);
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                Debug.LogWarning("LoadModel failed! This function only works in playing mode");
                return;
            }
#endif
            if (string.IsNullOrEmpty(loadedModelName) && string.IsNullOrEmpty(renderModelName))
            {
                return;
            }

            if (loadedModelName == renderModelName)
            {
                return;
            }

            if (m_loadingRenderModels.Contains(renderModelName))
            {
                return;
            }

            ClearModel();

            if (!m_isAppQuit && !string.IsNullOrEmpty(renderModelName))
            {
                Debug.Log(transform.parent.parent.name + " LoadModel " + renderModelName);
                m_loadingRenderModels.Add(renderModelName);

#if VIU_WAVEXR_ESSENCE_CONTROLLER_MODEL
                IntPtr ctrlModel = IntPtr.Zero;
                int    IntBits   = IntPtr.Size;

                WVR_Result r = Interop.WVR_GetCurrentControllerModel(preferedModelName.Contains("Left") ? WVR_DeviceType.WVR_DeviceType_Controller_Left : WVR_DeviceType.WVR_DeviceType_Controller_Right, ref ctrlModel, true);

                if (r == WVR_Result.WVR_Success)
                {
                    if (ctrlModel != IntPtr.Zero)
                    {
                        WVR_CtrlerModel ctrl = (WVR_CtrlerModel)Marshal.PtrToStructure(ctrlModel, typeof(WVR_CtrlerModel));

                        //Debug.Log("render model name = " + ctrl.name + " , load from asset = " + ctrl.loadFromAsset);

                        WVR_CtrlerCompInfoTable cit = ctrl.compInfos;

                        int szStruct = Marshal.SizeOf(typeof(WVR_CtrlerCompInfo));

                        //Debug.Log("Controller component size = " + cit.size);

                        modelResource.FBXInfo       = new FBXInfo_t[cit.size];
                        modelResource.sectionCount  = cit.size;
                        modelResource.SectionInfo   = new MeshInfo_t[cit.size];
                        modelResource.loadFromAsset = ctrl.loadFromAsset;

                        for (int i = 0; i < cit.size; i++)
                        {
                            WVR_CtrlerCompInfo wcci;

                            if (IntBits == 4)
                            {
                                wcci = (WVR_CtrlerCompInfo)Marshal.PtrToStructure(new IntPtr(cit.table.ToInt32() + (szStruct * i)), typeof(WVR_CtrlerCompInfo));
                            }
                            else
                            {
                                wcci = (WVR_CtrlerCompInfo)Marshal.PtrToStructure(new IntPtr(cit.table.ToInt64() + (szStruct * i)), typeof(WVR_CtrlerCompInfo));
                            }

                            modelResource.FBXInfo[i]     = new FBXInfo_t();
                            modelResource.SectionInfo[i] = new MeshInfo_t();

                            modelResource.FBXInfo[i].meshName    = Marshal.StringToHGlobalAnsi(wcci.name);
                            modelResource.SectionInfo[i]._active = wcci.defaultDraw;

                            //Debug.Log("Controller component name = " + wcci.name + ", tex index = " + wcci.texIndex + ", active= " + modelResource.SectionInfo[i]._active);

                            // local matrix
                            //Matrix4x4 lt = RigidTransform.toMatrix44(wcci.localMat, false);
                            //Matrix4x4 t = RigidTransform.RowColumnInverse(lt);
                            //Debug.Log(" matrix = (" + t.m00 + ", " + t.m01 + ", " + t.m02 + ", " + t.m03 + ")");
                            //Debug.Log(" matrix = (" + t.m10 + ", " + t.m11 + ", " + t.m12 + ", " + t.m13 + ")");
                            //Debug.Log(" matrix = (" + t.m20 + ", " + t.m21 + ", " + t.m22 + ", " + t.m23 + ")");
                            //Debug.Log(" matrix = (" + t.m30 + ", " + t.m31 + ", " + t.m32 + ", " + t.m33 + ")");

                            //curr.FBXInfo[i].matrix = RigidTransform.ToWVRMatrix(t, false);

                            WVR_VertexBuffer vertices = wcci.vertices;

                            if (vertices.dimension == 3)
                            {
                                uint verticesCount = (vertices.size / vertices.dimension);

                                //Debug.Log(" vertices size = " + vertices.size + ", dimension = " + vertices.dimension + ", count = " + verticesCount);

                                modelResource.SectionInfo[i]._vectice = new Vector3[verticesCount];
                                float[] verticeArray = new float[vertices.size];

                                Marshal.Copy(vertices.buffer, verticeArray, 0, verticeArray.Length);

                                int verticeIndex = 0;
                                int floatIndex   = 0;

                                while (verticeIndex < verticesCount)
                                {
                                    modelResource.SectionInfo[i]._vectice[verticeIndex]   = new Vector3();
                                    modelResource.SectionInfo[i]._vectice[verticeIndex].x = verticeArray[floatIndex++];
                                    modelResource.SectionInfo[i]._vectice[verticeIndex].y = verticeArray[floatIndex++];
                                    modelResource.SectionInfo[i]._vectice[verticeIndex].z = verticeArray[floatIndex++] * -1f;

                                    verticeIndex++;
                                }
                            }
                            else
                            {
                                Debug.Log("[WARNING] vertices buffer's dimension incorrect!");
                            }

                            // normals
                            WVR_VertexBuffer normals = wcci.normals;

                            if (normals.dimension == 3)
                            {
                                uint normalsCount = (normals.size / normals.dimension);
                                //Debug.Log(" normals size = " + normals.size + ", dimension = " + normals.dimension + ", count = " + normalsCount);
                                modelResource.SectionInfo[i]._normal = new Vector3[normalsCount];
                                float[] normalArray = new float[normals.size];

                                Marshal.Copy(normals.buffer, normalArray, 0, normalArray.Length);

                                int normalsIndex = 0;
                                int floatIndex   = 0;

                                while (normalsIndex < normalsCount)
                                {
                                    modelResource.SectionInfo[i]._normal[normalsIndex]   = new Vector3();
                                    modelResource.SectionInfo[i]._normal[normalsIndex].x = normalArray[floatIndex++];
                                    modelResource.SectionInfo[i]._normal[normalsIndex].y = normalArray[floatIndex++];
                                    modelResource.SectionInfo[i]._normal[normalsIndex].z = normalArray[floatIndex++];

                                    normalsIndex++;
                                }

                                //Debug.Log(" normals size = " + normals.size + ", dimension = " + normals.dimension + ", count = " + normalsCount);
                            }
                            else
                            {
                                Debug.Log("[WARNING] normals buffer's dimension incorrect!");
                            }

                            // texCoord
                            WVR_VertexBuffer texCoord = wcci.texCoords;

                            if (texCoord.dimension == 2)
                            {
                                uint uvCount = (texCoord.size / texCoord.dimension);
                                //Debug.Log(" texCoord size = " + texCoord.size + ", dimension = " + texCoord.dimension + ", count = " + uvCount);
                                modelResource.SectionInfo[i]._uv = new Vector2[uvCount];
                                float[] texCoordArray = new float[texCoord.size];

                                Marshal.Copy(texCoord.buffer, texCoordArray, 0, texCoordArray.Length);

                                int uvIndex    = 0;
                                int floatIndex = 0;

                                while (uvIndex < uvCount)
                                {
                                    modelResource.SectionInfo[i]._uv[uvIndex]   = new Vector2();
                                    modelResource.SectionInfo[i]._uv[uvIndex].x = texCoordArray[floatIndex++];
                                    modelResource.SectionInfo[i]._uv[uvIndex].y = texCoordArray[floatIndex++];

                                    uvIndex++;
                                }
                            }
                            else
                            {
                                Debug.Log("[WARNING] normals buffer's dimension incorrect!");
                            }

                            // indices
                            WVR_IndexBuffer indices = wcci.indices;
                            //Debug.Log(" indices size = " + indices.size);

                            modelResource.SectionInfo[i]._indice = new int[indices.size];
                            Marshal.Copy(indices.buffer, modelResource.SectionInfo[i]._indice, 0, modelResource.SectionInfo[i]._indice.Length);

                            uint indiceIndex = 0;

                            while (indiceIndex < indices.size)
                            {
                                int tmp = modelResource.SectionInfo[i]._indice[indiceIndex];
                                modelResource.SectionInfo[i]._indice[indiceIndex]     = modelResource.SectionInfo[i]._indice[indiceIndex + 2];
                                modelResource.SectionInfo[i]._indice[indiceIndex + 2] = tmp;
                                indiceIndex += 3;
                            }
                        }

                        // Controller texture section
                        WVR_CtrlerTexBitmapTable wctbt = ctrl.bitmapInfos;
                        //Debug.Log("Controller textures = " + wctbt.size);
                        int bmStruct = Marshal.SizeOf(typeof(WVR_CtrlerTexBitmap));
                        modelResource.modelTextureCount = (int)wctbt.size;
                        modelResource.modelTextureInfo  = new TextureInfo[wctbt.size];
                        modelResource.modelTexture      = new Texture2D[wctbt.size];

                        for (int mt = 0; mt < wctbt.size; mt++)
                        {
                            TextureInfo ct = new TextureInfo();

                            WVR_CtrlerTexBitmap wctb;

                            if (IntBits == 4)
                            {
                                wctb = (WVR_CtrlerTexBitmap)Marshal.PtrToStructure(new IntPtr(wctbt.table.ToInt32() + (bmStruct * mt)), typeof(WVR_CtrlerTexBitmap));
                            }
                            else
                            {
                                wctb = (WVR_CtrlerTexBitmap)Marshal.PtrToStructure(new IntPtr(wctbt.table.ToInt64() + (bmStruct * mt)), typeof(WVR_CtrlerTexBitmap));
                            }

                            //Debug.Log(" [" + mt + "] bitmap width = " + wctb.width);
                            //Debug.Log(" [" + mt + "] bitmap height = " + wctb.height);
                            //Debug.Log(" [" + mt + "] bitmap stride = " + wctb.stride);
                            //Debug.Log(" [" + mt + "] bitmap format = " + wctb.format);
                            // bitmap size
                            var rawImageSize = wctb.height * wctb.stride;

                            ct.modelTextureData = new byte[rawImageSize];
                            Marshal.Copy(wctb.bitmap, ct.modelTextureData, 0, ct.modelTextureData.Length);
                            ct.width  = (int)wctb.width;
                            ct.height = (int)wctb.height;
                            ct.stride = (int)wctb.stride;
                            ct.format = (int)wctb.format;
                            ct.size   = (int)rawImageSize;

                            modelResource.modelTextureInfo[mt] = ct;
                        }

                        // Touchpad section
                        //Debug.Log("[DEBUG] ---  Get touch info from runtime  ---");
                        WVR_TouchPadPlane wtpp = ctrl.touchpadPlane;

                        modelResource.TouchSetting = new TouchSetting();
                        modelResource.TouchSetting.touchCenter.x = wtpp.center.v0 * 100f;
                        modelResource.TouchSetting.touchCenter.y = wtpp.center.v1 * 100f;
                        modelResource.TouchSetting.touchCenter.z = (-1.0f * wtpp.center.v2) * 100f;
                        //Debug.Log(" touchCenter! x: " + modelResource.TouchSetting.touchCenter.x + " ,y: " + modelResource.TouchSetting.touchCenter.y + " ,z: " + modelResource.TouchSetting.touchCenter.z);

                        modelResource.TouchSetting.raidus = wtpp.radius * 100;

                        modelResource.TouchSetting.touchptHeight = wtpp.floatingDistance * 100;

                        modelResource.isTouchSetting = wtpp.valid;

                        modelResource.TouchSetting.touchPtU.x = wtpp.u.v0;
                        modelResource.TouchSetting.touchPtU.y = wtpp.u.v1;
                        modelResource.TouchSetting.touchPtU.z = wtpp.u.v2;

                        modelResource.TouchSetting.touchPtV.x = wtpp.v.v0;
                        modelResource.TouchSetting.touchPtV.y = -1.0f * wtpp.v.v1;
                        modelResource.TouchSetting.touchPtV.z = wtpp.v.v2;

                        modelResource.TouchSetting.touchPtW.x = wtpp.w.v0;
                        modelResource.TouchSetting.touchPtW.y = wtpp.w.v1;
                        modelResource.TouchSetting.touchPtW.z = -1.0f * wtpp.w.v2;
                        //Debug.Log(" Floating distance : " + modelResource.TouchSetting.touchptHeight);

                        //Debug.Log(" touchPtW! x: " + modelResource.TouchSetting.touchPtW.x + " ,y: " + modelResource.TouchSetting.touchPtW.y + " ,z: " + modelResource.TouchSetting.touchPtW.z);
                        //Debug.Log(" touchPtU! x: " + modelResource.TouchSetting.touchPtU.x + " ,y: " + modelResource.TouchSetting.touchPtU.y + " ,z: " + modelResource.TouchSetting.touchPtU.z);
                        //Debug.Log(" touchPtV! x: " + modelResource.TouchSetting.touchPtV.x + " ,y: " + modelResource.TouchSetting.touchPtV.y + " ,z: " + modelResource.TouchSetting.touchPtV.z);
                        //Debug.Log(" raidus: " + modelResource.TouchSetting.raidus);
                        //Debug.Log(" isTouchSetting: " + modelResource.isTouchSetting);

                        // Battery section

                        //Debug.Log("[DEBUG] ---  Get battery info from runtime  ---");
                        WVR_BatteryLevelTable wblt = ctrl.batteryLevels;

                        List <BatteryIndicator> batteryTextureList = new List <BatteryIndicator>();
                        modelResource.batteryTextureList = batteryTextureList;

                        //Debug.Log("Battery levels = " + wblt.size);

                        int btStruct = Marshal.SizeOf(typeof(WVR_CtrlerTexBitmap));
                        int sizeInt  = Marshal.SizeOf(typeof(int));

                        for (int b = 0; b < wblt.size; b++)
                        {
                            WVR_CtrlerTexBitmap batteryImage;
                            int batteryMin = 0;
                            int batteryMax = 0;

                            if (IntBits == 4)
                            {
                                batteryImage = (WVR_CtrlerTexBitmap)Marshal.PtrToStructure(new IntPtr(wblt.texTable.ToInt32() + (btStruct * b)), typeof(WVR_CtrlerTexBitmap));
                                batteryMin   = (int)Marshal.PtrToStructure(new IntPtr(wblt.minTable.ToInt32() + (sizeInt * b)), typeof(int));
                                batteryMax   = (int)Marshal.PtrToStructure(new IntPtr(wblt.maxTable.ToInt32() + (sizeInt * b)), typeof(int));
                            }
                            else
                            {
                                batteryImage = (WVR_CtrlerTexBitmap)Marshal.PtrToStructure(new IntPtr(wblt.texTable.ToInt64() + (btStruct * b)), typeof(WVR_CtrlerTexBitmap));
                                batteryMin   = (int)Marshal.PtrToStructure(new IntPtr(wblt.minTable.ToInt64() + (sizeInt * b)), typeof(int));
                                batteryMax   = (int)Marshal.PtrToStructure(new IntPtr(wblt.maxTable.ToInt64() + (sizeInt * b)), typeof(int));
                            }

                            BatteryIndicator tmpBI = new BatteryIndicator();
                            tmpBI.level = b;
                            tmpBI.min   = (float)batteryMin;
                            tmpBI.max   = (float)batteryMax;

                            var batteryImageSize = batteryImage.height * batteryImage.stride;

                            tmpBI.batteryTextureInfo = new TextureInfo();
                            tmpBI.batteryTextureInfo.modelTextureData = new byte[batteryImageSize];
                            Marshal.Copy(batteryImage.bitmap, tmpBI.batteryTextureInfo.modelTextureData, 0, tmpBI.batteryTextureInfo.modelTextureData.Length);
                            tmpBI.batteryTextureInfo.width  = (int)batteryImage.width;
                            tmpBI.batteryTextureInfo.height = (int)batteryImage.height;
                            tmpBI.batteryTextureInfo.stride = (int)batteryImage.stride;
                            tmpBI.batteryTextureInfo.format = (int)batteryImage.format;
                            tmpBI.batteryTextureInfo.size   = (int)batteryImageSize;
                            tmpBI.textureLoaded             = true;
                            //Debug.Log(" Battery Level[" + tmpBI.level + "] min: " + tmpBI.min + " max: " + tmpBI.max + " loaded: " + tmpBI.textureLoaded + " w: " + batteryImage.width + " h: " + batteryImage.height + " size: " + batteryImageSize);

                            batteryTextureList.Add(tmpBI);
                        }
                        modelResource.isBatterySetting = true;

                        //Debug.Log("WVR_ReleaseControllerModel, ctrlModel IntPtr = " + ctrlModel.ToInt32());

                        //Debug.Log("Call WVR_ReleaseControllerModel");
                        Interop.WVR_ReleaseControllerModel(ref ctrlModel);
                    }
                    else
                    {
                        Debug.Log("[WARNING] WVR_GetCurrentControllerModel return model is null");
                    }

                    wfef = new WaitForEndOfFrame();

                    ImgMaterial = new Material(Shader.Find("Unlit/Texture"));
                    StartCoroutine(SpawnRenderModel());
                }
#endif
            }
        }