Beispiel #1
0
        private void Collider_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            var collider = sender as MapToolCore.Collider;
            ColliderRenderObject newObject = null;

            if (collider == null)
            {
                return;
            }
            switch (e.PropertyName)
            {
            case "Attribute":
                (collderNRenderObject[collider] as ColliderRenderObject).SetAttribute(collider.Attribute);
                break;

            case "Type":
                if (collderNRenderObject.ContainsKey(collider))
                {
                    objList.Remove(collderNRenderObject[collider]);
                    collderNRenderObject.Remove(collider);
                }
                switch (collider.Type)
                {
                case MapToolCore.ColliderType.Box:
                    newObject = new BoxColliderMeshObject(GraphicsDevice.Instance);
                    break;

                case MapToolCore.ColliderType.Sphere:
                    newObject = new SphareMesh(GraphicsDevice.Instance);
                    break;
                }
                if (newObject != null)
                {
                    newObject.Offset    = collider.Offset;
                    newObject.Transform = collider.Transform.Clone();
                    if (collider.FrameName != null && animMeshObj != null)
                    {
                        newObject.SetFrameMatrix(animMeshObj, collider.FrameName);
                    }
                    collderNRenderObject.Add(collider, newObject);
                    objList.Add(newObject);
                }
                break;

            case "FrameName":
                if (collderNRenderObject.ContainsKey(collider))
                {
                    (collderNRenderObject[collider] as ColliderRenderObject).SetFrameMatrix(animMeshObj, collider.FrameName);
                }
                break;

            case "Offset":
                if (collderNRenderObject.ContainsKey(collider))
                {
                    (collderNRenderObject[collider] as ColliderRenderObject).Offset = collider.Offset;
                }
                break;

            case "Transform":
                if (collderNRenderObject.ContainsKey(collider))
                {
                    (collderNRenderObject[collider] as ColliderRenderObject).Transform = collider.Transform.Clone();
                }
                break;
            }
            if (pgCollider.SelectedObject == collider)
            {
                pgCollider.Refresh();
            }

            renderView.Render();
        }
Beispiel #2
0
        private void btnJsonOpen_Click_1(object sender, EventArgs e)
        {
            var dialog = new OpenFileDialog();

            dialog.Filter = "anim meta data(*.json)|*.json;";
            if (dialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            try
            {
                var newMetaFile = Doc.AnimationMeshMeta.Load(dialog.FileName);
                //TODO: 파일 데이터를 읽어, X파일을 로딩한다.
                if (newMetaFile.MeshFilePath == null || newMetaFile.MeshFilePath.Length == 0)
                {
                    throw new Exception("Mesh File is empty");
                }
                objList.Clear();
                collderNRenderObject.Clear();
                listColliders.Items.Clear();
                LoadXMesh(MapToolCore.Environment.Instance.ProjectDirectory + newMetaFile.MeshFilePath);

                foreach (var item in newMetaFile.AnimationTable)
                {
                    dataGridView1.Rows.Add(item.Index.ToString(), item.ID);
                }
                listColliders.Items.AddRange(newMetaFile.ColliderList.ToArray());

                foreach (var item in newMetaFile.ColliderList)
                {
                    ColliderRenderObject newObject = null;
                    if (animMeshObj != null)
                    {
                        item.FrameNames = animMeshObj.FrameNames;
                    }
                    item.PropertyChanged += Collider_PropertyChanged;
                    switch (item.Type)
                    {
                    case MapToolCore.ColliderType.Box:
                        newObject = new BoxColliderMeshObject(GraphicsDevice.Instance);
                        break;

                    case MapToolCore.ColliderType.Sphere:
                        newObject = new SphareMesh(GraphicsDevice.Instance);
                        break;
                    }
                    if (newObject != null)
                    {
                        newObject.SetAttribute(item.Attribute);
                        newObject.Offset    = item.Offset;
                        newObject.Transform = item.Transform.Clone();
                        if (item.FrameName != null && animMeshObj != null)
                        {
                            newObject.SetFrameMatrix(animMeshObj, item.FrameName);
                        }
                        collderNRenderObject.Add(item, newObject);
                        objList.Add(newObject);
                    }
                }
                m_currentJsonPath = dialog.FileName;
                meta = newMetaFile;
            }
            catch (Exception ex)
            {
                MessageBox.Show($"파일을 열지 못했습니다.\n{ex.Message}");
                Console.WriteLine(ex.StackTrace);
            }
        }