public static void LoadShaderForEntities1(Coocoo3DMain appBody, StorageFile storageFile, StorageFolder storageFolder, IList <MMD3DEntity> entities) { RPShaderPack shaderPack; lock (appBody.mainCaches.RPShaderPackCaches) { shaderPack = appBody.mainCaches.RPShaderPackCaches.GetOrCreate(storageFile.Path); if (shaderPack.Status != GraphicsObjectStatus.loaded) { if (shaderPack.loadLocker.GetLocker()) { string relativePath = storageFile.Name; _ = Task.Run(async() => { var task1 = shaderPack.Reload1(storageFolder, relativePath, appBody.RPAssetsManager, appBody.ProcessingList); appBody.RequireRender(); if (await task1) { } appBody.RequireRender(); shaderPack.loadLocker.FreeLocker(); }); } } } foreach (var entity in entities) { entity.rendererComponent.PODraw = shaderPack.PODraw; entity.rendererComponent.POSkinning = shaderPack.POSkinning; entity.rendererComponent.POParticleDraw = shaderPack.POParticleDraw; entity.rendererComponent.ParticleCompute = shaderPack.CSParticle; } appBody.RequireRender(); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedFrom(e); if (e.Parameter is Coocoo3DMain _appBody) { appBody = _appBody; lighting = _appBody.SelectedLighting[0]; appBody.FrameUpdated += FrameUpdated; _cachePos = lighting.Position; _cacheRot = QuaternionToEularYXZ(lighting.Rotation) / MathF.PI * 180; _cacheRotQ = lighting.Rotation; _cachedRange = lighting.Range; if (lighting.LightingType == LightingType.Directional) { radio1.IsChecked = true; } else if (lighting.LightingType == LightingType.Point) { radio2.IsChecked = true; } } else { Frame.Navigate(typeof(ErrorPropertiesPage), "显示属性错误"); } }
public static void NewLighting(Coocoo3DMain appBody) { //var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView(); //Lighting lighting = new Lighting(); //lighting.Name = resourceLoader.GetString("Object_Name_Lighting"); //lighting.lightingComponent.Color = new Vector4(3, 3, 3, 1); //lighting.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.570796326794f, 0); //lighting.Position = new Vector3(0, 1, 0); //lighting.lightingComponent.Range = 10; //if (appBody.CurrentScene.Lightings.Count > 0) // lighting.lightingComponent.LightingType = LightingType.Point; //appBody.CurrentScene.AddSceneObject(lighting); //appBody.RequireRender(); var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView(); GameObject lighting = new GameObject(); Components.LightingComponent lightingComponent = new Components.LightingComponent(); lighting.AddComponent(lightingComponent); lighting.Name = resourceLoader.GetString("Object_Name_Lighting"); lighting.Rotation = Quaternion.CreateFromYawPitchRoll(0, 1.570796326794f, 0); lighting.Position = new Vector3(0, 1, 0); lightingComponent.Color = new Vector4(3, 3, 3, 1); lightingComponent.Range = 10; appBody.CurrentScene.AddGameObject(lighting); appBody.RequireRender(); }
public static void Play(Coocoo3DMain appBody) { appBody.GameDriverContext.Playing = true; appBody.GameDriverContext.PlaySpeed = 1.0f; appBody.LatestRenderTime = DateTime.Now - appBody.GameDriverContext.FrameInterval; appBody.RequireRender(); }
public MainPage() { this.InitializeComponent(); appBody = new Coocoo3DMain(); worldViewer.AppBody = appBody; appBody.FrameUpdated += AppBody_FrameUpdated; }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (e.Parameter is Coocoo3DMain _appBody) { appBody = _appBody; appBody.FrameUpdated += FrameUpdated; _cachePos = appBody.camera.LookAtPoint; _cacheRot = appBody.camera.Angle; _cacheFOV = appBody.camera.Fov; _cacheDistance = appBody.camera.Distance; _cachePlaySpeed = appBody.GameDriverContext.PlaySpeed; var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView(); string raytracingSupportMsg; if (appBody.deviceResources.IsRayTracingSupport()) { raytracingSupportMsg = resourceLoader.GetString("Message_GPUSupportRayTracing"); } else { raytracingSupportMsg = resourceLoader.GetString("Message_GPUNotSupportRayTracing"); } VRayTracingSupport.Text = string.Format("{0}\n{1}", appBody.deviceResources.GetDeviceDescription(), raytracingSupportMsg); for (int i = 0; i < comboBox1Values.Length; i++) { comboBox1Values[i] = (uint)i; } vQuality.ItemsSource = comboBox1Values; } else { Frame.Navigate(typeof(ErrorPropertiesPage), "error"); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedFrom(e); if (e.Parameter is Coocoo3DMain _appBody) { appBody = _appBody; selectedGameObject = _appBody.SelectedGameObjects[0]; appBody.FrameUpdated += FrameUpdated; _cachePos = selectedGameObject.Position; _cacheRot = QuaternionToEularYXZ(selectedGameObject.Rotation) / MathF.PI * 180; _cacheRotQ = selectedGameObject.Rotation; foreach (var pair in selectedGameObject.components) { Type type1 = C2Control.componentToControl[(pair.Key)]; var menthod = type1.GetMethod("SetTarget", new Type[] { typeof(Components.Component), typeof(Coocoo3DMain) }); object inst = Activator.CreateInstance(type1); menthod?.Invoke(inst, new object[] { pair.Value, appBody }); pivot1.Items.Add(new PivotItem() { Header = pair.Key.Name, Content = inst }); } } else { Frame.Navigate(typeof(ErrorPropertiesPage), "显示属性错误"); } }
public static List <Texture2D> GetTextureList(Coocoo3DMain appBody, StorageFolder storageFolder, PMXFormat pmx) { List <Texture2D> textures = new List <Texture2D>(); List <string> paths = new List <string>(); List <string> relativePaths = new List <string>(); foreach (var vTex in pmx.Textures) { string relativePath = vTex.TexturePath.Replace("//", "\\").Replace('/', '\\'); string texPath = Path.Combine(storageFolder.Path, relativePath); paths.Add(texPath); relativePaths.Add(relativePath); } lock (appBody.mainCaches.TextureCaches) { for (int i = 0; i < pmx.Textures.Count; i++) { Texture2DPack tex = appBody.mainCaches.TextureCaches.GetOrCreate(paths[i]); if (tex.Status != GraphicsObjectStatus.loaded) { tex.Mark(GraphicsObjectStatus.loading); } tex.relativePath = relativePaths[i]; tex.folder = storageFolder; textures.Add(tex.texture2D); } } return(textures); }
public static async Task LoadVMD(Coocoo3DMain appBody, StorageFile storageFile, MMD3DEntity entity) { BinaryReader reader = new BinaryReader((await storageFile.OpenReadAsync()).AsStreamForRead()); VMDFormat motionSet = VMDFormat.Load(reader); entity.motionComponent.Reload(motionSet); appBody.RequireRender(true); }
public static void FastForward(Coocoo3DMain appBody) { if (appBody.Recording) { appBody.GameDriver = appBody._GeneralGameDriver; appBody.Recording = false; } appBody.GameDriverContext.Playing = true; appBody.GameDriverContext.PlaySpeed = 2.0f; }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); appBody = e.Parameter as Coocoo3DMain; if (appBody == null) { Frame.Navigate(typeof(ErrorPropertiesPage), "error"); return; } }
public static void Rear(Coocoo3DMain appBody) { if (appBody.Recording) { appBody.GameDriver = appBody._GeneralGameDriver; appBody.Recording = false; } appBody.GameDriverContext.PlayTime = 9999; appBody.GameDriverContext.RequireResetPhysics = true; appBody.RequireRender(true); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); appBody = e.Parameter as Coocoo3DMain; if (appBody == null) { Frame.Navigate(typeof(ErrorPropertiesPage), "error"); return; } appBody.OpenedStorageFolderChanged += AppBody_OpenedStorageFolderChanged; }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); appBody = e.Parameter as Coocoo3DMain; if (appBody == null) { Frame.Navigate(typeof(ErrorPropertiesPage), "error"); return; } viewSceneObjects.ItemsSource = appBody.CurrentScene.sceneObjects; }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (e.Parameter is Coocoo3DMain _appBody) { appBody = _appBody; } else { Frame.Navigate(typeof(ErrorPropertiesPage), "显示属性错误"); } }
public static void RemoveSceneObject(Coocoo3DMain appBody, Scene scene, ISceneObject sceneObject) { if (scene.sceneObjects.Remove(sceneObject)) { if (sceneObject is MMD3DEntity entity) { scene.RemoveSceneObject(entity); } else if (sceneObject is Lighting lighting) { scene.RemoveSceneObject(lighting); } } appBody.RequireRender(); }
public static async Task OpenResourceFolder(Coocoo3DMain appBody) { FolderPicker folderPicker = new FolderPicker() { FileTypeFilter = { "*" }, SuggestedStartLocation = PickerLocationId.ComputerFolder, ViewMode = PickerViewMode.Thumbnail, SettingsIdentifier = "ResourceFolder", }; StorageFolder folder = await folderPicker.PickSingleFolderAsync(); if (folder == null) { return; } appBody.OpenedStorageFolderChange(folder); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedFrom(e); if (e.Parameter is Coocoo3DMain _appBody) { appBody = _appBody; entity = _appBody.SelectedEntities[0]; appBody.FrameUpdated += FrameUpdated; _cacheP = entity.PositionNextFrame; _cacheR = QuaternionToEularYXZ(entity.RotationNextFrame) * 180 / MathF.PI; _cacheRQ = entity.RotationNextFrame; ViewMaterials.ItemsSource = entity.rendererComponent.Materials; ViewMorph.ItemsSource = entity.morphStateComponent.morphs; ViewBone.ItemsSource = entity.rendererComponent.bones; } else { Frame.Navigate(typeof(ErrorPropertiesPage), "显示属性错误"); } }
public static async Task LoadEntityIntoScene(Coocoo3DMain appBody, Scene scene, StorageFile pmxFile, StorageFolder storageFolder) { string pmxPath = pmxFile.Path; string relatePath = pmxFile.Name; ModelPack pack = null; lock (appBody.mainCaches.ModelPackCaches) { pack = appBody.mainCaches.ModelPackCaches.GetOrCreate(pmxPath); if (pack.LoadTask == null && pack.Status != GraphicsObjectStatus.loaded) { pack.LoadTask = Task.Run(async() => { BinaryReader reader = new BinaryReader((await pmxFile.OpenReadAsync()).AsStreamForRead()); pack.lastModifiedTime = (await pmxFile.GetBasicPropertiesAsync()).DateModified; pack.Reload2(reader); pack.folder = storageFolder; pack.relativePath = relatePath; reader.Dispose(); appBody.ProcessingList.AddObject(pack.GetMesh()); pack.Status = GraphicsObjectStatus.loaded; pack.LoadTask = null; }); } } if (pack.Status != GraphicsObjectStatus.loaded && pack.LoadTask != null) { await pack.LoadTask; } MMD3DEntity entity = new MMD3DEntity(); entity.Reload2(appBody.ProcessingList, pack, GetTextureList(appBody, storageFolder, pack.pmx), pmxPath); scene.AddSceneObject(entity); appBody.RequireRender(); appBody.mainCaches.ReloadTextures(appBody.ProcessingList, appBody.RequireRender); }
public static void Pause(Coocoo3DMain appBody) { appBody.GameDriverContext.Playing = false; }