Beispiel #1
0
 public void RemoveSceneObject(MMD3DEntity entity)
 {
     lock (this)
     {
         EntityRemoveList.Add(entity);
     }
 }
Beispiel #2
0
 public void AddSceneObject(MMD3DEntity entity)
 {
     lock (this)
     {
         EntityLoadList.Add(entity);
     }
     sceneObjects.Add(entity);
 }
Beispiel #3
0
        public static void Reload2(this MMD3DEntity entity, ProcessingList processingList, ModelPack modelPack, List <Texture2D> textures, string ModelPath)
        {
            var modelResource = modelPack.pmx;

            entity.Name        = string.Format("{0} {1}", modelResource.Name, modelResource.NameEN);
            entity.Description = string.Format("{0}\n{1}", modelResource.Description, modelResource.DescriptionEN);
            entity.ModelPath   = ModelPath;
            entity.motionComponent.ReloadEmpty();

            ReloadModel(entity, processingList, modelPack, textures);
        }
Beispiel #4
0
        public static void ReloadModel(this MMD3DEntity entity, ProcessingList processingList, ModelPack modelPack, List <Texture2D> textures)
        {
            entity.ComponentReady = false;
            var modelResource = modelPack.pmx;

            entity.morphStateComponent.Reload(modelResource);
            entity.boneComponent.Reload(modelResource);

            entity.rendererComponent.Reload(modelPack);
            processingList.AddObject(new MeshAppendUploadPack(entity.rendererComponent.meshAppend, entity.rendererComponent.meshPosData));
            //processingList.AddObject(entity.rendererComponent.meshParticleBuffer);
            entity.rendererComponent.textures = textures;

            entity.ComponentReady = true;
        }
Beispiel #5
0
 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), "显示属性错误");
     }
 }
Beispiel #6
0
 public void Preprocess()
 {
     lightings.Sort();
     for (int i = 0; i < entities.Count; i++)
     {
         MMD3DEntity entity = entities[i];
         entity.rendererComponent.position = entity.Position;
         entity.rendererComponent.rotation = entity.Rotation;
         rendererComponents.Add(entity.rendererComponent);
     }
     for (int i = 0; i < gameObjects.Count; i++)
     {
         GameObject        gameObject        = gameObjects[i];
         LightingComponent lightingComponent = gameObject.GetComponent <LightingComponent>();
         if (lightingComponent != null)
         {
             lightingComponent.Position = gameObject.Position;
             lightingComponent.Rotation = gameObject.Rotation;
             lightings.Add(lightingComponent.GetLightingData());
         }
     }
 }
Beispiel #7
0
        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);
        }
Beispiel #8
0
        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);
        }