Ejemplo n.º 1
0
        private void toolStripButtonPlane_Click(object sender, EventArgs e)
        {
            XmlDocument xmlDoc          = new XmlDocument();
            XmlElement  geometryElement = xmlDoc.CreateElement("Plane");

            geometryElement.Attributes.Append(XmlUtility.CreateAttribute(xmlDoc, "type", "Plane"));
            geometryElement.AppendChild(XmlUtility.CreateTransformComponent(xmlDoc, "0", "0"));
            geometryElement.AppendChild(XmlUtility.CreatePlaneRenderComponent(xmlDoc));

            if (RenderMethods.AddActor(geometryElement.OuterXml) > 0)
            {
                m_ProjectView.AddActorNode(geometryElement);
            }
        }
Ejemplo n.º 2
0
        private void toolStripButtonImport_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "All supported formats (*.fbx; *.dae; *.blend; *.3ds; *.ase; *.obj; *.ply; *.x; *.ms3d;)|" +
                            "*.fbx; *.dae; *.blend; *.3ds; *.ase; *.obj; *.ply; *.x; *.ms3d;|" +
                            "Autodesk FBX (*.fbx)|*.fbx|" + "Autodesk 3DS (*.3ds)|*.3ds|" + "Autodesk ASE (*.ase)|*.ase|" +
                            "Collada Model (*.dae)|*.dae|" + "Blender 3D (*.blend)|*.blend|" + "Stanford Polygon Library (*.ply)|*.ply|" +
                            "Wavefront Object (*.obj)|*.obj|" + "Milkshape 3D (*.ms3d)|*.ms3d";
            dialog.FilterIndex      = 1;
            dialog.RestoreDirectory = true;

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                string destFileName = m_ProjectLocation + @"\Models\" + Path.GetFileNameWithoutExtension(dialog.FileName) + ".model";
                if (!Directory.Exists(Path.GetDirectoryName(destFileName)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(destFileName));
                }

                LoadingProgressDialog loadDlg = new LoadingProgressDialog();
                loadDlg.SourceFileName = dialog.FileName;
                loadDlg.DestFileName   = destFileName;
                if (loadDlg.ShowDialog() == DialogResult.OK)
                {
                    string fileName = Path.GetFileNameWithoutExtension(destFileName);
                    fileName = fileName.First().ToString().ToUpper() + fileName.Substring(1);
                    XmlDocument xmlDoc       = new XmlDocument();
                    XmlElement  modelElement = xmlDoc.CreateElement(fileName);

                    modelElement.Attributes.Append(XmlUtility.CreateAttribute(xmlDoc, "type", "Model"));
                    modelElement.AppendChild(XmlUtility.CreateTransformComponent(xmlDoc));
                    modelElement.AppendChild(XmlUtility.CreateModelRenderComponent(xmlDoc, destFileName));

                    if (RenderMethods.AddActor(modelElement.OuterXml) > 0)
                    {
                        m_ProjectView.AddActorNode(modelElement);
                    }
                }
            }
        }