Beispiel #1
0
        public TextureChunk(P3D parent)
        {
            Parent = parent;
            Application.Current.Dispatcher.BeginInvoke((Action)(() => addTreeItem()));
//            TreeItem = new TreeViewItem {Header = new P3DElementView(this, "Textures chunk")};
//            Parent.TreeItem.Items.Add(TreeItem);
        }
Beispiel #2
0
        /// <summary>
        /// Handles loading of file, starts parser on separate thread
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LoadButton_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog file   = new OpenFileDialog();
            bool?          result = file.ShowDialog();

            if (result == true)
            {
                string path = file.FileName;
                if (Path.GetExtension(path).ToLower() == ".p3d")
                {
                    ChangeStatus(new StatusUpdatedEventArguments("Loading p3d file", 10));
                    SelectedElement = null;
                    P3DViewItems.Clear();
                    itemInfo.Children.Clear();
                    P3DFile = new P3D(this);
                    P3DFile.StatusUpdated += new StatusUpdatedEventHandler(ChangeStatus);
                    Task.Run(() => P3DFile.LoadP3D(path));
                }
                else
                {
                    if (Path.GetExtension(path).ToLower() == ".3ds")
                    {
                        ChangeStatus(new StatusUpdatedEventArguments("Loading 3ds file", 10));
                        P3DViewItems.Clear();
                        itemInfo.Children.Clear();
                        File3DS = LIB3DS.lib3ds_file_open(path);
                        P3DFile = new P3D(this);
                        Task.Run(() => P3DFile.Load3DS(File3DS));
                        return;
                    }
                    MessageBox.Show("Format not supported");
                }
            }
        }
Beispiel #3
0
        // Token: 0x06000004 RID: 4 RVA: 0x000022B8 File Offset: 0x000004B8
        private static bool convertP3dFile(string srcPath, string dstPath = null, bool allowOverwriting = false)
        {
            if (!allowOverwriting && srcPath == dstPath)
            {
                Trace.WriteLine("Overwriting the source file is disabled.");
                return(false);
            }
            Trace.WriteLine(string.Format("Reading the p3d ('{0}')...", srcPath));
            P3D instance = P3D.GetInstance(srcPath);

            if (instance is MLOD)
            {
                Trace.WriteLine(string.Format("'{0}' is already in editable MLOD format", srcPath));
            }
            else
            {
                ODOL odol = instance as ODOL;
                if (odol != null)
                {
                    Trace.WriteLine("ODOL was loaded successfully.");
                    Trace.WriteLine("Start conversion...");
                    MLOD mlod = Conversion.ODOL2MLOD(odol);
                    Trace.WriteLine("Conversion successful.");
                    string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(srcPath);
                    string directoryName            = Path.GetDirectoryName(srcPath);
                    dstPath = (dstPath ?? Path.Combine(directoryName, fileNameWithoutExtension + "_mlod.p3d"));
                    Trace.WriteLine("Saving...");
                    mlod.writeToFile(dstPath, allowOverwriting);
                    Trace.WriteLine(string.Format("MLOD successfully saved to '{0}'", dstPath));
                    return(true);
                }
                Trace.WriteLine(string.Format("'{0}' could not be loaded.", srcPath));
            }
            return(false);
        }
Beispiel #4
0
 public TileBits(P3D size)
 {
     this.size = size;
     // make sure that the size (in direction y and z) are expanded to a power of two
     // calculate how many bits we need to shift left to emulate multiplication
     sizeShift = (0, Pow2(size.y), Pow2(size.z));
     // the enlarged size
     size2 = (size.x, (1 << sizeShift.y), (1 << sizeShift.z));
     bits  = new bool[size2.x * size2.y * size2.z];
 }
Beispiel #5
0
 public MeshesChunk(P3D parent)
 {
     Parent = parent;
     Application.Current.Dispatcher.BeginInvoke((Action)(() => addTreeItem()));
 }
Beispiel #6
0
 // this can be indexed with a P3D - 3D point
 public bool this[P3D p] {
     get { return(bits[p.z + ((p.y + (p.x << sizeShift.y)) << sizeShift.z)]); }
     set { bits[p.z + ((p.y + (p.x << sizeShift.y)) << sizeShift.z)] = value; }
 }