public IResource Resolve(Uri uri) { // Very awkward here, because sometimes our "uri"s aren't // really URIs. They are just string identifiers that can // contain parameters extra information above just the // basic path. // But the level editor stuff wants to work with URIs because // it will switch back and forth between relative and absolute // filenames. IResource resource = null; string fileName = uri.LocalPath; if (fileName.Substring(fileName.Length - 6) == "<model") { resource = new ModelResource( new Uri(fileName.Substring(0, fileName.Length - 6)), ResourceTypes.Model); } else { string ext = Path.GetExtension(fileName).ToLower(); var res = m_gameEngine.Info.ResourceInfos.GetByType(ResourceTypes.Model); if (res.IsSupported(ext)) { resource = new ModelResource(uri, ResourceTypes.Model); } else if (m_gameEngine.Info.ResourceInfos.GetByType("ModelBookmark").IsSupported(ext)) { resource = new ModelBookmarkResource(uri); } } return(resource); }
public IResource Resolve(Uri uri) { // Very awkward here, because sometimes our "uri"s aren't // really URIs. They are just string identifiers that can // contain parameters extra information above just the // basic path. // But the level editor stuff wants to work with URIs because // it will switch back and forth between relative and absolute // filenames. IResource resource = null; string fileName = uri.LocalPath; if (fileName.Substring(fileName.Length-6) == "<model") { resource = new ModelResource( new Uri(fileName.Substring(0, fileName.Length-6)), ResourceTypes.Model); } else { string ext = Path.GetExtension(fileName).ToLower(); var res = m_gameEngine.Info.ResourceInfos.GetByType(ResourceTypes.Model); if (res.IsSupported(ext)) { resource = new ModelResource(uri, ResourceTypes.Model); } else if (m_gameEngine.Info.ResourceInfos.GetByType("ModelBookmark").IsSupported(ext)) { resource = new ModelBookmarkResource(uri); } } return resource; }
private bool GetTouchPadParam() { WVR_DeviceType type = WaveVR_Controller.Input(this.device).DeviceType; bool _connected = WaveVR_Controller.Input(this.device).connected; if (!_connected) { PrintDebugLog("Device is disconnect: "); return(false); } string parameterName = "GetRenderModelName"; IntPtr ptrParameterName = Marshal.StringToHGlobalAnsi(parameterName); IntPtr ptrResult = Marshal.AllocHGlobal(64); uint resultVertLength = 64; uint ret = Interop.WVR_GetParameters(type, ptrParameterName, ptrResult, resultVertLength); string renderModelName = Marshal.PtrToStringAnsi(ptrResult); Marshal.FreeHGlobal(ptrParameterName); Marshal.FreeHGlobal(ptrResult); if (ret == 0) { PrintDebugLog("Get render model name fail!"); return(false); } PrintDebugLog("current render model name: " + renderModelName); ModelResource modelResource = WaveVR_ControllerResourceHolder.Instance.getRenderModelResource(renderModelName, modelSpecify, mergeToOneBone); if ((modelResource == null) && (modelSpecify == ModelSpecify.MS_NonDominant)) { modelResource = WaveVR_ControllerResourceHolder.Instance.getRenderModelResource(renderModelName, ModelSpecify.MS_Dominant, mergeToOneBone); } if ((modelResource == null) || (modelResource.TouchSetting == null)) { PrintDebugLog("Get render model resource fail!"); return(false); } touchCenter = modelResource.TouchSetting.touchCenter; touchPtW = modelResource.TouchSetting.touchPtW; touchPtU = modelResource.TouchSetting.touchPtU; touchPtV = modelResource.TouchSetting.touchPtV; raidus = modelResource.TouchSetting.raidus; touchptHeight = modelResource.TouchSetting.touchptHeight; PrintDebugLog("touchCenter! x: " + touchCenter.x + " ,y: " + touchCenter.y + " ,z: " + touchCenter.z); PrintDebugLog("touchPtW! x: " + touchPtW.x + " ,y: " + touchPtW.y + " ,z: " + touchPtW.z); PrintDebugLog("touchPtU! x: " + touchPtU.x + " ,y: " + touchPtU.y + " ,z: " + touchPtU.z); PrintDebugLog("touchPtV! x: " + touchPtV.x + " ,y: " + touchPtV.y + " ,z: " + touchPtV.z); PrintDebugLog("raidus: " + raidus); PrintDebugLog("Floating distance : " + touchptHeight); return(true); }
public IResource Resolve(Uri uri) { IResource resource = null; string fileName = uri.LocalPath; string ext = Path.GetExtension(fileName).ToLower(); var res = m_gameEngine.Info.ResourceInfos.GetByType(ResourceTypes.Model); if(res.IsSupported(ext)) resource = new ModelResource(uri,ResourceTypes.Model); return resource; }
private static int ModelLoaderLoad(IntPtr path, IntPtr buffer, int bufferSize) { var pathstr = Marshal.PtrToStringUni(path); var res = new ModelResource(); if (res.Load(pathstr) && res.Copy(buffer, bufferSize)) { EffekseerSystem.Instance.modelList.Add(res); return(res.ModelData.bytes.Length); } return(0); }
public void GivenTheModelNamedBox01HasAResourceCalledBoxModel(string modelName, string resourceName) { Model m1 = ScenarioContext.Current.Get<Model>(modelName); ModelResource r1 = new ModelResource(ModelType.MESH); r1.Name = resourceName; m1.Resource = r1; //also add the ModelResource to the ScenarioContext to get it later ScenarioContext.Current.Set<ModelResource>(r1, resourceName); }
public async Task <IActionResult> AddModel([FromBody] ModelResource modelResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var model = mapper.Map <ModelResource, Model>(modelResource); context.Add(model); await context.SaveChangesAsync(); return(Ok(modelResource)); }
public async Task <IActionResult> CreateModel([FromBody] ModelResource modelResource) { var model = _mapper.Map <ModelResource, Model>(modelResource); if (model == null) { return(BadRequest()); } _modelRepository.CreateModel(model); await _unitOfWork.CompleteAsync(); return(Ok(_mapper.Map <Model, ModelResource>(model))); }
public IResource Resolve(Uri uri) { IResource resource = null; string fileName = uri.LocalPath; string ext = Path.GetExtension(fileName).ToLower(); var res = m_gameEngine.Info.ResourceInfos.GetByType(ResourceTypes.Model); if (res.IsSupported(ext)) { resource = new ModelResource(uri, ResourceTypes.Model); } return(resource); }
public async Task <IActionResult> CreateModel([FromBody] ModelResource modelResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var model = mapper.Map <ModelResource, Model>(modelResource); model.CreationDate = DateTime.Now; context.Models.Add(model); await context.SaveChangesAsync(); var result = mapper.Map <Model, ModelResource>(model); return(Ok(result)); }
public IResource Resolve(Uri uri) { IResource resource = null; try { string fileName = uri.LocalPath; string ext = Path.GetExtension(fileName).ToLower(); if (ext ==".atgi" || ext == ".dae") { resource = new ModelResource(uri,ResourceTypes.Geometry); } } catch (System.IO.IOException e) { Outputs.WriteLine(OutputMessageType.Warning, "Could not load resource: " + e.Message); } return resource; }
public void GivenTheCurrentSceneContainsAModelResourceListWithAMeshResourceNamed(ModelType type, string modelName) { IDTFScene currentScene = ScenarioContext.Current.Get<IDTFScene>(); ModelResource m1 = null; switch (type) { case ModelType.MESH: m1 = new ModelResource(ModelType.MESH); break; case ModelType.LINE_SET: m1 = new ModelResource(ModelType.LINE_SET); break; } m1.Name = modelName; currentScene.ModelResources.Add(modelName, m1); ScenarioContext.Current.Set<ModelResource>(m1, modelName); }
private static int ModelLoaderLoad(IntPtr path, IntPtr buffer, int bufferSize) { var pathstr = Marshal.PtrToStringUni(path); // HACK var combinedPath = CombinePathForResource(currentLoadingEffectPath, pathstr); var res = new ModelResource(); if (!res.Load(combinedPath, pathstr, EffekseerSystem.Instance.assetBundle)) { return(0); } if (res.Copy(buffer, bufferSize)) { EffekseerSystem.Instance.modelList.Add(res); return(res.modelData.bytes.Length); } return(-res.modelData.bytes.Length); }
public IResource Resolve(Uri uri) { IResource resource = null; try { string fileName = uri.LocalPath; string ext = Path.GetExtension(fileName).ToLower(); if (ext == ".atgi" || ext == ".dae") { resource = new ModelResource(uri, ResourceTypes.Geometry); } } catch (System.IO.IOException e) { Outputs.WriteLine(OutputMessageType.Warning, "Could not load resource: " + e.Message); } return(resource); }
public AStaticMesh(ModelResource mesh, Material material) { Model = mesh; Material = material; }
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); }
private bool GetTouchPadParam(ModelResource curr, string modelFolderPath, ModelSpecify ms) { if (curr == null) { PrintWarningLog("Model resource is null!"); return(false); } string TouchPadJsonPath = modelFolderPath + "/"; if (ms == ModelSpecify.MS_Dominant) { TouchPadJsonPath += "Touchpad.json"; } else { TouchPadJsonPath += "Touchpad01.json"; } if (!File.Exists(TouchPadJsonPath)) { PrintWarningLog(TouchPadJsonPath + " is not found!"); return(false); } StreamReader json_sr = new StreamReader(TouchPadJsonPath); string JsonString = json_sr.ReadToEnd(); PrintInfoLog("Touchpad json: " + JsonString); json_sr.Close(); if (JsonString.Equals("")) { PrintWarningLog("JsonString is empty!"); return(false); } curr.TouchSetting = new TouchSetting(); try { SimpleJSON.JSONNode jsNodes = SimpleJSON.JSONNode.Parse(JsonString); string xvalue = ""; string yvalue = ""; string zvalue = ""; string floatingStr = ""; xvalue = jsNodes["center"]["x"].Value; yvalue = jsNodes["center"]["y"].Value; zvalue = jsNodes["center"]["z"].Value; if (xvalue.Equals("") || yvalue.Equals("") || zvalue.Equals("")) { PrintWarningLog("Touch Center pointer is not found!"); return(false); } curr.TouchSetting.touchCenter = new Vector3(float.Parse(xvalue), float.Parse(yvalue), float.Parse(zvalue)); PrintDebugLog("Touch Center pointer is found! x: " + curr.TouchSetting.touchCenter.x + " ,y: " + curr.TouchSetting.touchCenter.y + " ,z: " + curr.TouchSetting.touchCenter.z); xvalue = jsNodes["up"]["x"].Value; yvalue = jsNodes["up"]["y"].Value; zvalue = jsNodes["up"]["z"].Value; if (xvalue.Equals("") || yvalue.Equals("") || zvalue.Equals("")) { PrintWarningLog("Touch Up pointer is not found!"); return(false); } curr.TouchSetting.touchForward = new Vector3(float.Parse(xvalue), float.Parse(yvalue), float.Parse(zvalue)); PrintDebugLog("Touch Up pointer is found! x: " + curr.TouchSetting.touchForward.x + " ,y: " + curr.TouchSetting.touchForward.y + " ,z: " + curr.TouchSetting.touchForward.z); xvalue = jsNodes["right"]["x"].Value; yvalue = jsNodes["right"]["y"].Value; zvalue = jsNodes["right"]["z"].Value; if (xvalue.Equals("") || yvalue.Equals("") || zvalue.Equals("")) { PrintWarningLog("Touch right pointer is not found!"); return(false); } curr.TouchSetting.touchRight = new Vector3(float.Parse(xvalue), float.Parse(yvalue), float.Parse(zvalue)); PrintDebugLog("Touch right pointer is found! x: " + curr.TouchSetting.touchRight.x + " ,y: " + curr.TouchSetting.touchRight.y + " ,z: " + curr.TouchSetting.touchRight.z); floatingStr = jsNodes["FloatingDistance"].Value; if (floatingStr.Equals("")) { PrintWarningLog("floatingStr is not found!"); return(false); } curr.TouchSetting.touchptHeight = float.Parse(floatingStr); PrintInfoLog("Floating distance : " + curr.TouchSetting.touchptHeight); curr.TouchSetting.touchPtW = (curr.TouchSetting.touchForward - curr.TouchSetting.touchCenter).normalized; //analog +y direction. curr.TouchSetting.touchPtU = (curr.TouchSetting.touchRight - curr.TouchSetting.touchCenter).normalized; //analog +x direction. curr.TouchSetting.touchPtV = Vector3.Cross(curr.TouchSetting.touchPtU, curr.TouchSetting.touchPtW).normalized; curr.TouchSetting.raidus = (curr.TouchSetting.touchForward - curr.TouchSetting.touchCenter).magnitude; PrintInfoLog("touchPtW! x: " + curr.TouchSetting.touchPtW.x + " ,y: " + curr.TouchSetting.touchPtW.y + " ,z: " + curr.TouchSetting.touchPtW.z); PrintInfoLog("touchPtU! x: " + curr.TouchSetting.touchPtU.x + " ,y: " + curr.TouchSetting.touchPtU.y + " ,z: " + curr.TouchSetting.touchPtU.z); PrintInfoLog("touchPtV! x: " + curr.TouchSetting.touchPtV.x + " ,y: " + curr.TouchSetting.touchPtV.y + " ,z: " + curr.TouchSetting.touchPtV.z); PrintInfoLog("raidus: " + curr.TouchSetting.raidus); } catch (Exception e) { Log.e(LOG_TAG, "JsonParse failed: " + e.ToString()); return(false); } return(true); }
void readNativeData(ModelResource curr, bool mergeTo, string modelFolderPath, ModelSpecify ms) { PrintDebugLog("--- thread start ---"); PrintInfoLog("Render model name: " + curr.renderModelName + ", merge = " + curr.mergeToOne); IntPtr ptrError = Marshal.AllocHGlobal(64); string FBXFile = modelFolderPath + "/"; if (ms == ModelSpecify.MS_Dominant) { FBXFile += "controller00.fbx"; } else { FBXFile += "controller01.fbx"; } bool ret = false; uint sessionid = 0; uint sectionCount = 0; string errorCode = ""; if (File.Exists(FBXFile)) { ret = Interop.WVR_OpenMesh(FBXFile, ref sessionid, ptrError, mergeTo); errorCode = Marshal.PtrToStringAnsi(ptrError); if (!ret) { PrintWarningLog("FBX parse failed: " + errorCode); return; } } else { PrintWarningLog("FBX is not found"); return; } PrintInfoLog("FBX parse succeed, sessionid = " + sessionid); bool finishLoading = Interop.WVR_GetSectionCount(sessionid, ref sectionCount); if (!finishLoading || sectionCount == 0) { PrintWarningLog("failed to load mesh"); return; } curr.sectionCount = sectionCount; curr.FBXInfo = new FBXInfo_t[curr.sectionCount]; curr.SectionInfo = new MeshInfo_t[curr.sectionCount]; for (int i = 0; i < curr.sectionCount; i++) { curr.FBXInfo[i] = new FBXInfo_t(); curr.SectionInfo[i] = new MeshInfo_t(); curr.FBXInfo[i].meshName = Marshal.AllocHGlobal(256); } ret = Interop.WVR_GetMeshData(sessionid, curr.FBXInfo); if (!ret) { for (int i = 0; i < sectionCount; i++) { Marshal.FreeHGlobal(curr.FBXInfo[i].meshName); } curr.SectionInfo = null; curr.FBXInfo = null; Interop.WVR_ReleaseMesh(sessionid); return; } for (uint i = 0; i < curr.sectionCount; i++) { curr.SectionInfo[i]._vectice = new Vector3[curr.FBXInfo[i].verticeCount]; for (int j = 0; j < curr.FBXInfo[i].verticeCount; j++) { curr.SectionInfo[i]._vectice[j] = new Vector3(); } curr.SectionInfo[i]._normal = new Vector3[curr.FBXInfo[i].normalCount]; for (int j = 0; j < curr.FBXInfo[i].verticeCount; j++) { curr.SectionInfo[i]._normal[j] = new Vector3(); } curr.SectionInfo[i]._uv = new Vector2[curr.FBXInfo[i].uvCount]; for (int j = 0; j < curr.FBXInfo[i].verticeCount; j++) { curr.SectionInfo[i]._uv[j] = new Vector2(); } curr.SectionInfo[i]._indice = new int[curr.FBXInfo[i].indiceCount]; for (int j = 0; j < curr.FBXInfo[i].verticeCount; j++) { curr.SectionInfo[i]._indice[j] = new int(); } bool active = false; bool tret = Interop.WVR_GetSectionData(sessionid, i, curr.SectionInfo[i]._vectice, curr.SectionInfo[i]._normal, curr.SectionInfo[i]._uv, curr.SectionInfo[i]._indice, ref active); if (!tret) { continue; } curr.SectionInfo[i]._active = active; PrintInfoLog("i = " + i + ", name = " + Marshal.PtrToStringAnsi(curr.FBXInfo[i].meshName) + ", active = " + curr.SectionInfo[i]._active); PrintInfoLog("i = " + i + ", relative transform = [" + curr.FBXInfo[i].matrix.m0 + " , " + curr.FBXInfo[i].matrix.m1 + " , " + curr.FBXInfo[i].matrix.m2 + " , " + curr.FBXInfo[i].matrix.m3 + "] "); PrintInfoLog("i = " + i + ", relative transform = [" + curr.FBXInfo[i].matrix.m4 + " , " + curr.FBXInfo[i].matrix.m5 + " , " + curr.FBXInfo[i].matrix.m6 + " , " + curr.FBXInfo[i].matrix.m7 + "] "); PrintInfoLog("i = " + i + ", relative transform = [" + curr.FBXInfo[i].matrix.m8 + " , " + curr.FBXInfo[i].matrix.m9 + " , " + curr.FBXInfo[i].matrix.m10 + " , " + curr.FBXInfo[i].matrix.m11 + "] "); PrintInfoLog("i = " + i + ", relative transform = [" + curr.FBXInfo[i].matrix.m12 + " , " + curr.FBXInfo[i].matrix.m13 + " , " + curr.FBXInfo[i].matrix.m14 + " , " + curr.FBXInfo[i].matrix.m15 + "] "); PrintInfoLog("i = " + i + ", vertice count = " + curr.FBXInfo[i].verticeCount + ", normal count = " + curr.FBXInfo[i].normalCount + ", uv count = " + curr.FBXInfo[i].uvCount + ", indice count = " + curr.FBXInfo[i].indiceCount); } Interop.WVR_ReleaseMesh(sessionid); curr.isTouchSetting = GetTouchPadParam(curr, modelFolderPath, ms); curr.parserReady = true; PrintDebugLog("--- thread end ---"); }
public bool addRenderModel(string renderModel, string ModelFolder, ModelSpecify ms, bool merge) { if (isRenderModelExist(renderModel, ms, merge)) { return(false); } string FBXFile = ModelFolder + "/"; string imageFile = ModelFolder + "/"; if (ms == ModelSpecify.MS_Dominant) { FBXFile += "controller00.fbx"; imageFile += "controller00.png"; } else { FBXFile += "controller01.fbx"; imageFile += "controller01.png"; } if (!File.Exists(FBXFile)) { return(false); } if (!File.Exists(imageFile)) { return(false); } PrintDebugLog("--- start ---"); ModelResource newMR = new ModelResource(); newMR.renderModelName = renderModel; newMR.mergeToOne = merge; newMR.parserReady = false; newMR.modelSpecify = ms; renderModelList.Add(newMR); mthread = new Thread(() => readNativeData(newMR, merge, ModelFolder, ms)); mthread.Start(); PrintDebugLog("--- Read image file start ---"); byte[] imgByteArray = File.ReadAllBytes(imageFile); PrintDebugLog("--- Read image file end ---"); PrintDebugLog("--- Load image start ---"); Texture2D modelpng = new Texture2D(2, 2, TextureFormat.BGRA32, false); bool retLoad = modelpng.LoadImage(imgByteArray); if (retLoad) { PrintDebugLog("--- Load image end ---, size: " + imgByteArray.Length); } else { PrintWarningLog("failed to load texture"); } newMR.modelTexture = modelpng; PrintDebugLog("--- Parse battery image start ---"); newMR.isBatterySetting = getBatteryIndicatorParam(newMR, ModelFolder, ms); PrintDebugLog("--- Parse battery image end ---"); PrintDebugLog("--- end ---"); return(true); }
private void onLoadController(WVR_DeviceType type) { mLoadingState = LoadingState.LoadingState_LOADING; PrintDebugLog("Pos: " + this.transform.localPosition.x + " " + this.transform.localPosition.y + " " + this.transform.localPosition.z); PrintDebugLog("Rot: " + this.transform.localEulerAngles); if (Interop.WVR_GetWaveRuntimeVersion() < 2) { PrintDebugLog("onLoadController in old service"); if (defaultModel != null) { controllerSpawned = Instantiate(defaultModel, this.transform); controllerSpawned.transform.parent = this.transform; } mLoadingState = LoadingState.LoadingState_NOT_LOADED; return; } string parameterName = "GetRenderModelName"; ptrParameterName = Marshal.StringToHGlobalAnsi(parameterName); ptrResult = Marshal.AllocHGlobal(64); uint resultVertLength = 64; uint retOfRenderModel = Interop.WVR_GetParameters(type, ptrParameterName, ptrResult, resultVertLength); if (retOfRenderModel == 0) { PrintDebugLog("Can not find render model."); if (defaultModel != null) { PrintDebugLog("Can't load controller model from DS, load default model"); controllerSpawned = Instantiate(defaultModel, this.transform); controllerSpawned.transform.parent = this.transform; mLoadingState = LoadingState.LoadingState_NOT_LOADED; } Marshal.FreeHGlobal(ptrParameterName); Marshal.FreeHGlobal(ptrResult); return; } renderModelName = Marshal.PtrToStringAnsi(ptrResult); int deviceIndex = -1; parameterName = "backdoor_get_device_index"; ptrParameterName = Marshal.StringToHGlobalAnsi(parameterName); IntPtr ptrResultDeviceIndex = Marshal.AllocHGlobal(2); Interop.WVR_GetParameters(type, ptrParameterName, ptrResultDeviceIndex, 2); int _out = 0; bool _ret = int.TryParse(Marshal.PtrToStringAnsi(ptrResultDeviceIndex), out _out); if (_ret) { deviceIndex = _out; } PrintInfoLog("get controller id from runtime is " + renderModelName + ", deviceIndex = " + deviceIndex); // 1. check if there are assets in private folder string renderModelFolderPath = Interop.WVR_DeployRenderModelAssets(deviceIndex, renderModelName); mLoadingState = (renderModelFolderPath != "") ? LoadingState.LoadingState_LOADING : LoadingState.LoadingState_NOT_LOADED; if (renderModelFolderPath != "") { bool retModel = false; modelResource = null; renderModelNamePath = renderModelFolderPath + "Model"; retModel = WaveVR_ControllerResourceHolder.Instance.addRenderModel(renderModelName, renderModelNamePath, modelSpecify, mergeToOneBone); if (retModel) { PrintDebugLog("Add " + renderModelName + " with " + modelSpecify + " model sucessfully!"); } modelResource = WaveVR_ControllerResourceHolder.Instance.getRenderModelResource(renderModelName, modelSpecify, mergeToOneBone); if ((modelResource == null) && (modelSpecify == ModelSpecify.MS_NonDominant)) { retModel = WaveVR_ControllerResourceHolder.Instance.addRenderModel(renderModelName, renderModelNamePath, ModelSpecify.MS_Dominant, mergeToOneBone); if (retModel) { PrintDebugLog("Add " + renderModelName + " Dominant model sucessfully!"); } modelResource = WaveVR_ControllerResourceHolder.Instance.getRenderModelResource(renderModelName, ModelSpecify.MS_Dominant, mergeToOneBone); } if (modelResource != null) { mLoadingState = LoadingState.LoadingState_LOADING; PrintDebugLog("Starting load " + renderModelName + " with <" + modelResource.modelSpecify + "> model!"); ImgMaterial = new Material(Shader.Find("Unlit/Texture")); wfef = new WaitForEndOfFrame(); StartCoroutine(SpawnRenderModel()); } else { PrintDebugLog("Model is null!"); if (defaultModel != null) { PrintDebugLog("Can't load controller model from DS, load default model"); controllerSpawned = Instantiate(defaultModel, this.transform); controllerSpawned.transform.parent = this.transform; mLoadingState = LoadingState.LoadingState_LOADED; } } } Marshal.FreeHGlobal(ptrParameterName); Marshal.FreeHGlobal(ptrResult); }