Пример #1
0
        private void exportAsOBJToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int n = listBox2.SelectedIndex;

            if (n == -1)
            {
                return;
            }
            try
            {
                string         s = listBox2.SelectedItem.ToString();
                MODFile        m = new MODFile(LoadFile(s));
                SaveFileDialog d = new SaveFileDialog();
                d.Filter = "*.obj|*.obj";
                if (s.Contains(">"))
                {
                    d.FileName = Path.GetFileNameWithoutExtension(s.Split('>')[1]) + ".obj";
                }
                else
                {
                    d.FileName = Path.GetFileNameWithoutExtension(s) + ".obj";
                }
                if (d.ShowDialog() == DialogResult.OK)
                {
                    m.SaveToObj(d.FileName);
                    Log.WriteLine("Saved to " + d.FileName);
                }
            }
            catch { }
        }
Пример #2
0
 private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         string  s = listBox2.SelectedItem.ToString();
         MODFile m = new MODFile(LoadFile(s));
         engine.ClearScene();
         foreach (MODFile.MODObject ob in m.obj)
         {
             RenderObject o = new RenderObject(engine.device, RenderObject.RenderType.TriListWired, engine.defaultTexture, engine);
             List <RenderObject.VertexWired> tmp = new List <RenderObject.VertexWired>();
             foreach (MODFile.MODFace f in ob.faces)
             {
                 tmp.Add(MakeV(ob.vertices[f.f1 - 1]));
                 tmp.Add(MakeV(ob.vertices[f.f2 - 1]));
                 tmp.Add(MakeV(ob.vertices[f.f3 - 1]));
                 if ((f.flags & 0x8) != 0)
                 {
                     tmp.Add(MakeV(ob.vertices[f.f2 - 1]));
                     tmp.Add(MakeV(ob.vertices[f.f3 - 1]));
                     tmp.Add(MakeV(ob.vertices[f.f4 - 1]));
                 }
             }
             o.verticesWired = tmp.ToArray();
             o.InitGeometry();
             engine.objects.Add(o);
         }
         engine.ResetCameraDistance();
     }
     catch { }
 }