Exemple #1
0
        public static void Export(BF2CollisionMesh mesh, string filename)
        {
            StringBuilder sb            = new StringBuilder();
            int           count         = 1;
            int           vertexcounter = 1;

            foreach (Helper.BF2CollisionMeshGeometry geom in mesh.geometry)
            {
                foreach (Helper.BF2CollisionMeshSubGeometry subgeo in geom.subGeom)
                {
                    foreach (Helper.BF2CollisionMeshColData col in subgeo.colData)
                    {
                        List <RawVector3> list = new List <RawVector3>();
                        for (int i = 0; i < col.numFaces; i++)
                        {
                            ushort[] face = col.faces[i];
                            list.Add(col.vertices[face[0]].ToRawVec3());
                            list.Add(col.vertices[face[1]].ToRawVec3());
                            list.Add(col.vertices[face[2]].ToRawVec3());
                        }
                        WriteObject(sb, list, "Geometry" + (count++), vertexcounter);
                        vertexcounter += list.Count;
                    }
                }
            }
            File.WriteAllText(filename, sb.ToString());
        }
Exemple #2
0
        private void PickMesh()
        {
            if (tv2.SelectedNode == null)
            {
                return;
            }
            engineMeshExplorer.ClearScene();
            byte[] data = BF2FileSystem.GetFileFromNode(tv2.SelectedNode);
            if (data == null)
            {
                return;
            }
            string ending = Path.GetExtension(BF2FileSystem.GetPathFromNode(tv2.SelectedNode)).ToLower();

            switch (ending)
            {
            case ".staticmesh":
                BF2StaticMesh stm = new BF2StaticMesh(data);
                engineMeshExplorer.objects.AddRange(stm.ConvertForEngine(engineMeshExplorer, toolStripButton3.Checked, toolStripComboBox1.SelectedIndex));
                break;

            case ".bundledmesh":
                BF2BundledMesh bm = new BF2BundledMesh(data);
                engineMeshExplorer.objects.AddRange(bm.ConvertForEngine(engineMeshExplorer, toolStripButton3.Checked, toolStripComboBox1.SelectedIndex));
                break;

            case ".skinnedmesh":
                BF2SkinnedMesh skm = new BF2SkinnedMesh(data);
                engineMeshExplorer.objects.AddRange(skm.ConvertForEngine(engineMeshExplorer, toolStripButton3.Checked, toolStripComboBox1.SelectedIndex));
                break;

            case ".collisionmesh":
                BF2CollisionMesh cm = new BF2CollisionMesh(data);
                engineMeshExplorer.objects.AddRange(cm.ConvertForEngine(engineMeshExplorer));
                break;

            default:
                RenderObject o = new RenderObject(engineMeshExplorer.device, RenderObject.RenderType.TriListWired, engineMeshExplorer.defaultTexture, engineMeshExplorer);
                o.InitGeometry();
                engineMeshExplorer.objects.Add(o);
                break;
            }
            engineMeshExplorer.ResetCameraDistance();
        }