Esempio n. 1
0
        public void LoadValue(HaloMap Map, int parentOffset)
        {
            int length;

            Map.IO.In.BaseStream.Position = parentOffset + ValueData.Offset;
            fullOffset = (int)Map.IO.In.BaseStream.Position;
            HMap       = Map;
            switch (ValueData.Attributes)
            {
            case mValue.ObjectAttributes.Unicode:
                button1.Visible    = false;
                button2.Visible    = false;
                length             = ((mUnicode)ValueData).Length;
                txtValue.Text      = Map.IO.In.ReadUnicodeString(length);
                txtValue.MaxLength = length;
                break;

            case mValue.ObjectAttributes.String:
                button1.Visible    = false;
                button2.Visible    = false;
                length             = ((mString)ValueData).Length;
                txtValue.Text      = Map.IO.In.ReadAsciiString(length);
                txtValue.MaxLength = length;
                break;

            case mValue.ObjectAttributes.Float:
                floater       = true;
                txtValue.Text = Map.IO.In.ReadSingle().ToString();
                break;

            case mValue.ObjectAttributes.Int16:
                txtValue.Text = Map.IO.In.ReadInt16().ToString();
                break;

            case mValue.ObjectAttributes.UInt16:
                txtValue.Text = Map.IO.In.ReadUInt16().ToString();
                break;

            case mValue.ObjectAttributes.Int32:
                txtValue.Text = Map.IO.In.ReadInt32().ToString();
                break;

            case mValue.ObjectAttributes.UInt32:
                txtValue.Text = Map.IO.In.ReadUInt32().ToString();
                break;

            case mValue.ObjectAttributes.Byte:
                txtValue.Text = Map.IO.In.ReadByte().ToString();
                break;

            case mValue.ObjectAttributes.Undefined:
                floater       = true;
                txtValue.Text = Map.IO.In.ReadSingle().ToString();
                break;
            }
            Editted        = false;
            lbltype.Text   = ValueData.Attributes.ToString().ToLower();
            comboBox1.Text = ValueData.Attributes.ToString().ToLower();
            MD_value.Text  = "1";
        }
Esempio n. 2
0
        private void Map_Load(HaloMap map)
        {
            //Load
            cacheResources = new CacheResources(mapFile);

            //Prepare
            checkedTagIds.Clear();
            resourceManager.Clear();
            resourceLookup.Clear();
            tagTreeView.BeginUpdate();
            tagTreeView.Nodes.Clear();
            tagTreeView.PathSeparator = "\\";

            //Loop
            foreach (IndexEntry indexEntry in map.IndexEntries)
            {
                TreeView_CreateTagNode(tagTreeView, $"{indexEntry.Filename}.{ indexEntry.Root.FourCc}", indexEntry.Id);
                ITagGroup tagGroup = TagLookup.CreateTagGroup(indexEntry.Root);
                resourceLookup.Add($"{indexEntry.Filename}.{tagGroup.GroupName}", indexEntry.Id);
            }

            //End
            tagTreeView.TreeViewNodeSorter = new TagNodeSorter();
            tagTreeView.Sort();
            tagTreeView.EndUpdate();

            //Read sound cache file gestalt
            var ugh = mapFile.IndexEntries.Last;

            using (var reader = ugh.Data.GetVirtualStream().CreateReader())
            {
                reader.BaseStream.Seek(mapFile.IndexEntries.Last.Address, SeekOrigin.Begin);
                soundCacheFileGestalt.Read(reader);
            }
        }
Esempio n. 3
0
 public Node(HaloMap map, EndianReader er)
 {
     Name                 = map.StringTable.StringItems[map.StringTable.GetStringItemIndexByID(map, er.ReadInt32())].Name;
     ParentNodeIndex      = er.ReadInt16();
     FirstChildNodeIndex  = er.ReadInt16();
     NextSiblingNodeIndex = er.ReadInt16();
     ImportNodeIndex      = er.ReadInt16();
     DefaultTranslationX  = er.ReadSingle();
     DefaultTranslationY  = er.ReadSingle();
     DefaultTranslationZ  = er.ReadSingle();
     DefaultRotationI     = er.ReadSingle();
     DefaultRotationJ     = er.ReadSingle();
     DefaultRotationK     = er.ReadSingle();
     DefaultRotationW     = er.ReadSingle();
     InverseFowardI       = er.ReadSingle();
     InverseFowardJ       = er.ReadSingle();
     InverseFowardK       = er.ReadSingle();
     InverseLeftI         = er.ReadSingle();
     InverseLeftJ         = er.ReadSingle();
     InverseLeftK         = er.ReadSingle();
     InverseUpI           = er.ReadSingle();
     InverseUpJ           = er.ReadSingle();
     InverseUpK           = er.ReadSingle();
     InversePositionI     = er.ReadSingle();
     InversePositionJ     = er.ReadSingle();
     InversePositionK     = er.ReadSingle();
     InverseScale         = er.ReadSingle();
     DistanceFromParent   = er.ReadSingle();
 }
Esempio n. 4
0
        public BitmapInjectionForm(HaloMap.Map.Map Map, string Filename, ParsedBitmap ParsedBitm, int NumDDS)
        {
            InitializeComponent();

            this.bitm = ParsedBitm;
            this.filename = Filename;
            this.map = Map;

            // Load the DDS info & picture
            loadDDSInfo(filename, this.bitm);

            // Get the filename variable from the path / filename combo
            string fname = filename.Substring(filename.LastIndexOf('\\') + 1);

            // Populate Bitmap Injection box with number of bitmaps in current selection
            for (int i = 0; i < NumDDS; i++)
            {
                lbInjectionBitmap.Items.Add("Bitmap #" + i.ToString());
            }

            #region inject_Form
            this.Text = "Inject " + fname + " to...";
            if (lbInjectionBitmap.Items.Count > 0)
            {
                lbInjectionBitmap.SelectedIndex = 0;
            }

            #endregion
        }
Esempio n. 5
0
        private void openMapBToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Halo: Reach Map Files|*.map";
            if (openFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            Map2         = new HaloMap(openFileDialog.FileName);
            Map2         = map2;
            tagNameList2 = new TagNameList(string.Format("{0}\\Tag Lists\\{1}.taglist", (object)Application.StartupPath, (object)map2.Map_Header.internalName));
            if (AppSettings.Settings.Map_Folder != "")
            {
                map2.Map_Directory = AppSettings.Settings.Map_Folder;
            }
            label3.Text      = map2.Map_Header.internalName + " Tag Count: " + map2.Index_Items.Count.ToString();
            Map2.tagNameList = tagNameList2;
            treeView2.Nodes.Clear();
            map2.LoadTagsIntoTreeview(treeView2, false);
            if (map2.Map_Header.haloVersion == 12)
            {
                toolStripMenuItem2.Visible = true;
            }
            if (map2.Map_Header.haloVersion == 11)
            {
                toolStripMenuItem2.Visible = false;
            }
        }
Esempio n. 6
0
 public MetaParser(HaloMap map, int tagIndex)
 {
     Map             = map;
     TagIndex        = tagIndex;
     tagNameList     = new TagNameList(string.Format("{0}\\Tag Lists\\{1}.taglist", (object)Application.StartupPath, (object)Map.Map_Header.internalName));
     Map.tagNameList = tagNameList;
 }
Esempio n. 7
0
 public TableManager(MapHeader header, HaloMap map)
 {
     _header      = header;
     _map         = map;
     _chunkSize   = 32;
     _chunkOffset = _map.Magic(_header.TagTableInfo.HeaderAddress);
 }
Esempio n. 8
0
        public void LoadValue(HaloMap Map, int parentOffset)
        {
            base.Enabled = false;
            Map.IO.In.BaseStream.Position = parentOffset + ValueData.Offset;
            fullOffset     = (int)Map.IO.In.BaseStream.Position;
            HMap           = Map;
            ValueData.Size = Map.IO.In.ReadUInt32();
            Stream baseStream = Map.IO.In.BaseStream;

            baseStream.Position  += 8L;
            ValueData.Pointer     = Map.IO.In.ReadInt32() - Map.Map_Header.mapMagic;
            lblValueType.Text     = "data{" + ValueData.Size.ToString() + "}";
            txtArrayBox.MaxLength = (int)(ValueData.Size * 2);
            if (ValueData.Size > 0x400)
            {
                txtArrayBox.Text = "Data too long. Reading skipped.";
            }
            else if (((ValueData.Size > 0) && (ValueData.Pointer > 0)) && (ValueData.Pointer < Map.Map_Header.fileSize))
            {
                Map.IO.In.BaseStream.Position = ValueData.Pointer;
                txtArrayBox.Text = ExtraFunctions.BytesToHexString(Map.IO.In.ReadBytes((int)ValueData.Size));
                base.Enabled     = true;
            }
            Editted = false;
        }
Esempio n. 9
0
 private void ConvertToCache(Group tagGroup, HaloMap map, List <TagReference> tags)
 {
     foreach (var tagBlock in tagGroup.TagBlocks)
     {
         ConvertToCache(tagBlock, map, tags);
     }
 }
Esempio n. 10
0
        private void UpdateObjectList()
        {
            _view.tagView.Items.Clear();

            foreach (TagListEntry entry in _map.Tables.Tags.TagList)
            {
                TreeViewItem item = new TreeViewItem();

                foreach (ObjectListEntry objectEntry in _map.Tables.Objects.ObjectList)
                {
                    if (objectEntry.ObjectTag == entry)
                    {
                        TreeViewItem objectItem = new TreeViewItem();
                        objectItem.Header = "0x" + HaloMap.ToHex(objectEntry.Offset);
                        item.Items.Add(objectItem);
                    }
                }

                item.Header = entry.Tags[0].TagName;

                if (item.Items.Count > 0)
                {
                    item.Header += " (" + item.Items.Count + ")";
                }
                item.IsExpanded = false;
                _view.tagView.Items.Add(item);
            }
        }
Esempio n. 11
0
        public void LoadModelTag(HaloMap Map, int TagIndex)
        {
            map      = Map;
            tagIndex = TagIndex;

            // Load our model info for this tag
            mi = ModelFunctions.GetModelInfo(map, tagIndex);

            label1.Text = mi.Name;

            // Now lets clear our treeview
            treeView1.Nodes.Clear();

            // Now lets add our submaps to it
            for (int x = 0; x < mi.Regions.Count; x++)
            {
                TreeNode region = new TreeNode(mi.Regions[x].Name);
                for (int y = 0; y < mi.Regions[x].Permutations.Count; y++)
                {
                    TreeNode perm = new TreeNode(mi.Regions[x].Permutations[y].Name);
                    perm.Checked = true;
                    region.Nodes.Add(perm);
                }
                region.Checked = true;
                treeView1.Nodes.Add(region);
            }
        }
Esempio n. 12
0
        private void HaloMap_Closing(object sender, CancelEventArgs e)
        {
            LayoutDocument ld = (LayoutDocument)sender;
            HaloMap        mp = (HaloMap)ld.Content;

            mp.Dispose();
        }
Esempio n. 13
0
 public MetaParser(HaloMap map, int tagIndex)
 {
     //Set our instance of map to the parameter
     Map = map;
     //Set our instance of tag index to the parameter
     TagIndex = tagIndex;
 }
Esempio n. 14
0
 public void LoadBitmapTag(HaloMap Map, int TagIndex)
 {
     map = Map;
     Map.OpenIO();
     map.RawInformation.ExternalMaps.CreateIOs();
     map.RawInformation.ExternalMaps.OpenIOs();
     tagIndex = TagIndex;
     bi       = BitmapFunctions.GetBitmapInfo(map, tagIndex);
     listView1.Items.Clear();
     for (int i = 0; i < bi.bitmapList.Count; i++)
     {
         string[]     items = new string[] { i.ToString(), bi.bitmapList[i].Height.ToString(), bi.bitmapList[i].Width.ToString(), $"0x{bi.bitmapList[i].RawLength:X}", bi.bitmapList[i].Format.ToString(), bi.bitmapList[i].Type.ToString() };
         ListViewItem item  = new ListViewItem(items)
         {
             Tag = i
         };
         listView1.Items.Add(item);
     }
     if (listView1.Items.Count > 0)
     {
         listView1.FocusedItem = listView1.Items[0];
         listView1_SelectedIndexChanged(null, null);
     }
     map.RawInformation.ExternalMaps.CloseIOs();
     Map.CloseIO();
 }
Esempio n. 15
0
        public MetaEditorLiteHandler(HaloMap map, int Tag_Index)
        {
            //Set our Map instance
            Map = map;

            //Set our meta instance
            Meta = Map.IndexItems[Tag_Index];

            //Get our plugin path.
            string pluginPath = "";

            //If it's retail halo 3
            if (Map.Halo_Map_Version == HaloMap.HaloMapVersion.Halo3Retail)
            {
                pluginPath = Application.StartupPath + "\\plugins\\halo 3\\" +
                             Map.IndexItems[Tag_Index].Class.Replace(" ", "").Replace("<", "_").Replace(">", "_") +
                             ".alt";
            }
            else if (Map.Halo_Map_Version == HaloMap.HaloMapVersion.Halo3ODST)
            {
                pluginPath = Application.StartupPath + "\\plugins\\odst\\" +
                             Map.IndexItems[Tag_Index].Class.Replace(" ", "").Replace("<", "_").Replace(">", "_") +
                             ".alt";
            }

            //Create a new instance of our plugin parser.
            XmlParser xmlParser = new XmlParser();

            //Parse the plugin
            xmlParser.ParsePlugin(pluginPath);
        }
Esempio n. 16
0
        private void LoadObjectListEntry(GlobalTagEntry obj, byte[] entryData)
        {
            String tagName = HaloMap.ReadString(entryData, 0, 4);

            obj.Tag      = Tags.GetTag(tagName);
            obj.Unknown1 = HaloMap.ReadUint16(entryData, 4);
            obj.Unknown2 = HaloMap.ReadUint16(entryData, 6);
        }
Esempio n. 17
0
 public void SaveStructure(HaloMap map, int parentOffset)
 {
     if (cmbxChunks.Enabled)
     {
         int num = ReflexiveData.Pointer + (cmbxChunks.SelectedIndex * ReflexiveData.Size);
         TagEditorHandler.SaveChangedValues(map, pnlValues, num);
     }
 }
 public StringLocaleEditor(HaloMap map)
 {
     InitializeComponent();
     Map                        = map;
     Locale_Handler             = new LocaleHandler(Map);
     cmbxLanguage.SelectedIndex = 0;
     localeGrid.Focus();
 }
Esempio n. 19
0
 public void LoadValue(HaloMap Map, int parentOffset)
 {
     Map.IO.In.BaseStream.Position = parentOffset + ValueData.Offset;
     fullOffset = (int)Map.IO.In.BaseStream.Position;
     HMap       = Map;
     byte[] data = Map.IO.In.ReadBytes(ValueData.Length);
     txtArrayBox.Text = ExtraFunctions.BytesToHexString(data);
     Editted          = false;
 }
Esempio n. 20
0
 public void LoadValue(HaloMap Map, int parentOffset)
 {
     Map.IO.In.BaseStream.Position = parentOffset + ValueData.Offset;
     fullOffset    = (int)Map.IO.In.BaseStream.Position;
     HMap          = Map;
     floater       = true;
     txtValue.Text = Map.IO.In.ReadSingle().ToString();
     Editted       = false;
 }
 public PluginLayoutCreator(HaloMap map)
 {
     Map = map;
     Plugin_Scanning_Regions = new List <PluginScanningRegion>();
     Plugin_Data_Blocks      = new List <PluginDataBlock>();
     MetaHeader_Data_Blocks  = new List <MetaHeader_DataBlock>();
     Tag_Idents = new List <Tag_Ident>();
     Tag_Voids  = new List <Tag_Void>();
 }
Esempio n. 22
0
        public static void LoadPluginValues(HaloMap Map, Panel parentPanel, int parentOffset)
        {
            if (!((parentOffset <= 0) | (parentOffset > Map.Map_Header.fileSize)))
            {
                EndianIO iO = Map.IO;
                for (int i = 0; i < parentPanel.Controls.Count; i++)
                {
                    if (!((Map.IO != null) && Map.IO.Opened))
                    {
                        Map.OpenIO();
                    }
                    switch (parentPanel.Controls[i].Name)
                    {
                    case "uiTagBlock":
                        ((uiTagBlock)parentPanel.Controls[i]).LoadStructure(Map, parentOffset);
                        break;

                    case "uiBitmask":
                        ((uiBitmask)parentPanel.Controls[i]).LoadValue(Map, parentOffset);
                        break;

                    case "uiValue":
                        ((uiValue)parentPanel.Controls[i]).LoadValue(Map, parentOffset);
                        break;

                    case "uiSlider":
                        ((uiSlider)parentPanel.Controls[i]).LoadValue(Map, parentOffset);
                        break;

                    case "uiEnum":
                        ((uiEnum)parentPanel.Controls[i]).LoadValue(Map, parentOffset);
                        break;

                    case "uiIdent":
                        ((uiIdent)parentPanel.Controls[i]).LoadValue(Map, parentOffset);
                        break;

                    case "uiByteArray":
                        ((uiByteArray)parentPanel.Controls[i]).LoadValue(Map, parentOffset);
                        break;

                    case "uiTagData":
                        ((uiTagData)parentPanel.Controls[i]).LoadValue(Map, parentOffset);
                        break;

                    case "uiColor":
                        ((uiColor)parentPanel.Controls[i]).LoadValue(Map, parentOffset);
                        break;

                    case "uiStringID":
                        ((uiStringID)parentPanel.Controls[i]).LoadValue(Map, parentOffset);
                        break;
                    }
                }
                Map.CloseIO();
            }
        }
Esempio n. 23
0
 public SoffishViewModel(SoffishView inView)
 {
     _view       = inView;
     _map        = new HaloMap();
     _openDialog = new MapFileDialog(System.AppDomain.CurrentDomain.BaseDirectory);
     LoadCommand = new DelegateCommand <object>(LoadMap, null, "Load map");
     QuitCommand = new DelegateCommand <object>(Quit, null, "Quit");
     IsVisible   = Visibility.Hidden;
 }
Esempio n. 24
0
        public WinMetaEditor(MapForm sender, HaloMap.Map.Map map)
        {
            InitializeComponent();

            this.map = map;
            this.Owner = sender;
            mapForm = sender;
            this.Text = map.filePath.Substring(map.filePath.LastIndexOf('\\') + 1).ToUpper();
        }
Esempio n. 25
0
 public IdentSwapper(HaloMap map, ListView listView)
 {
     InitializeComponent();
     IdentGrid = listView;
     Map       = map;
     LoadClasses();
     SelectItem(cmbxClass, listView.SelectedItems[0].SubItems[3].Text);
     SelectItem(cmbxName, listView.SelectedItems[0].SubItems[4].Text);
 }
Esempio n. 26
0
            /// <summary>
            /// This form of initializing loads the RawPools.
            /// </summary>
            /// <param name="Map">The map to load the raw pools for</param>
            public RawPoolsList(HaloMap Map)
            {
                //Create our variable to hold the play index
                int playIndex = -1;

                for (int i = 0; i < Map.IndexItems.Count; i++)
                {
                    if (Map.IndexItems[i].Class == "play")
                    {
                        playIndex = i;
                        break;
                    }
                }

                //If we found the play tag..
                if (playIndex != -1)
                {
                    //Obtain the tag instance of the play tag
                    HaloMap.TagItem play_tag = Map.IndexItems[playIndex];

                    //Go to the tag offset + 24
                    Map.IO.In.BaseStream.Position = play_tag.Offset + 24;
                    int poolCount   = Map.IO.In.ReadInt32();
                    int poolPointer = Map.IO.In.ReadInt32() - Map.MapHeader.mapMagic;

                    //Loop for each chunk
                    for (int i = 0; i < poolCount; i++)
                    {
                        //Initialize our chunk
                        RawPool rawPool = new RawPool();

                        //Set our offset of our raw pool.
                        rawPool.ChunkOffset = poolPointer + (i * 88);

                        //Go to the chunk location.
                        Map.IO.In.BaseStream.Position  = poolPointer + (i * 88);
                        Map.IO.In.BaseStream.Position += 4;

                        //Read our external map index.
                        rawPool.ExternalMapIndex = Map.IO.In.ReadInt16();

                        //Go to our raw offset value's offset
                        Map.IO.In.BaseStream.Position += 2;
                        rawPool.RawOffset              = Map.IO.In.ReadUInt32();
                        rawPool.CompressedSize         = Map.IO.In.ReadUInt32();
                        rawPool.DecompressedSize       = Map.IO.In.ReadUInt32();

                        //Go to our raw chunk count offset
                        Map.IO.In.BaseStream.Position = poolPointer + (i * 88) + 84;
                        rawPool.RawChunkCount         = Map.IO.In.ReadInt16();

                        //Add it to our list
                        this.Add(rawPool);
                    }
                }
            }
Esempio n. 27
0
        private void LoadEntry(TagListEntry obj, byte[] entryData)
        {
            obj.Tags = new Tag[3];
            for (uint j = 0; j < 3; j++)
            {
                obj.Tags[j] = new Tag(HaloMap.ReadString(entryData, j * 4, 4));
            }

            obj.Unknown = HaloMap.ReadUint32(entryData, 12);
        }
Esempio n. 28
0
 public void SaveStructure(HaloMap map, int parentOffset)
 {
     //If the reflexive is enabled...
     if (comboChunks.Enabled)
     {
         //Obtain our offset for our chunk
         int chunkOffset = ReflexiveData.Pointer + (comboChunks.SelectedIndex * ReflexiveData.Size);
         //Save values.
         MetaEditorHandler.SaveChangedValues(map, pnlValues, chunkOffset);
     }
 }
Esempio n. 29
0
        /// <summary>
        /// This form of initializing sets our map instance.
        /// </summary>
        /// <param name="map">The map instance to set.</param>
        public PluginLayoutCreator(HaloMap map)
        {
            //Set our map instance
            Map = map;

            //Let's initialize our lists.
            Plugin_Scanning_Regions = new List <PluginScanningRegion>();
            Plugin_Data_Blocks      = new List <PluginDataBlock>();
            MetaHeader_Data_Blocks  = new List <MetaHeader_DataBlock>();
            Tag_Idents = new List <Tag_Ident>();
        }
Esempio n. 30
0
        public void LoadModelTag(HaloMap Map, int TagIndex)
        {
            map      = Map;
            tagIndex = TagIndex;

            mi = ModelFunctions.GetModelInfo(map, tagIndex);
            mi.InitializeBuffers(RenderHelper.renderer, map);

            RenderHelper.SetupModel(mi);
            RenderHelper.messageConsole.AddMessage("Model Loaded");
        }
Esempio n. 31
0
        private void btnStartProtect_Click(object sender, EventArgs e)
        {
            //Check our fields
            if (txtProtectedLocation.Text != "" && txtUnprotectedLocation.Text != "")
            {
                if (txtProtectedLocation.Text == txtUnprotectedLocation.Text)
                {
                    //Show our error Messagebox
                    MessageBox.Show("You cannot save the protected map in the path of the original map. Please choose somewhere else to save to.");
                }
                else
                {
                    //Let's protect our map..

                    //Get our idle button text
                    string idleButtonText = btnStartProtect.Text;

                    //Disable the button
                    btnStartProtect.Enabled = false;

                    //Set our status as copying the file
                    btnStartProtect.Text = "Copying Map file to save destination..";
                    Application.DoEvents();
                    //Start copying
                    if (File.Exists(txtProtectedLocation.Text))
                    {
                        File.Delete(txtProtectedLocation.Text);
                    }
                    File.Copy(txtUnprotectedLocation.Text, txtProtectedLocation.Text);


                    //Set our status as loading the map.
                    btnStartProtect.Text = "Loading map..";
                    Application.DoEvents();
                    //Let's load that map.
                    HaloMap map = new HaloMap(txtProtectedLocation.Text);



                    //Set our status as protecting the map
                    btnStartProtect.Text = "Protecting map..";
                    Application.DoEvents();
                    //Let's protect our map.
                    MapBuilder map_functions = new MapBuilder(map);
                    map_functions.ProtectMap();

                    //Enable our button
                    btnStartProtect.Enabled = true;

                    //Set our buttons text back as the original text
                    btnStartProtect.Text = idleButtonText;
                }
            }
        }
Esempio n. 32
0
        private void Map_Decompile(HaloMap map, string outputDirectory)
        {
            browseMapButton.Enabled = false;
            decompileButton.Enabled = false;

            MapDecompiler mapDecompiler = new MapDecompiler(map, outputDirectory)
            {
                Host = this
            };

            mapDecompiler.Start();
        }
Esempio n. 33
0
        /// <summary>
        /// Checks if a plane is in the viewing frustrum
        /// </summary>
        /// <param name="unitToCheck">Mesh</param>
        /// <returns>True if in view, false otherwise</returns>
        public bool IsInViewFrustum(HaloMap.RawData.BSPModel.BSPRawDataMetaChunk dataChunk )
        {
            Vector3 minVector = new Vector3(dataChunk.BoundingBox.MinX, dataChunk.BoundingBox.MinY, dataChunk.BoundingBox.MinZ);
            Vector3 maxVector = new Vector3(dataChunk.BoundingBox.MaxX, dataChunk.BoundingBox.MaxY, dataChunk.BoundingBox.MaxZ);
            int x = 0;
            int y = 0;
            int z = 0;
            #if DEBUG
            System.Windows.Forms.Form f = null;
            foreach (System.Windows.Forms.Form frm in System.Windows.Forms.Application.OpenForms)
            {
                if (frm.Name == "DebugInfo")
                    f = frm;
            }
            if (f != null)
            {
                f.Controls[0].Text =
                    minVector.X.ToString().PadLeft(10, ' ') + ", " +
                    minVector.Y.ToString().PadLeft(10, ' ') + ", " +
                    minVector.Y.ToString().PadLeft(10, ' ');
                f.Controls[1].Text =
                    maxVector.X.ToString().PadLeft(10, ' ') + ", " +
                    maxVector.Y.ToString().PadLeft(10, ' ') + ", " +
                    maxVector.Y.ToString().PadLeft(10, ' ');
            }
            #endif

            for (int count = 0; count < _frustumPlanes.Length; count++ )
            {
                Plane plane = _frustumPlanes[count];

                float a = plane.A * minVector.X + plane.B * minVector.Y + plane.C * minVector.Z + plane.D;
                float b = plane.A * maxVector.X + plane.B * maxVector.Y + plane.C * maxVector.Z + plane.D;
            #if DEBUG
                if (f != null)
                {
                    switch (count)
                    {
                        // Z
                        case 0:
                        case 1:
                            f.Controls[6 + count].Text = a.ToString().PadLeft(12, ' ') + " : " + b.ToString().PadRight(12, ' ');
                            break;
                        // X
                        case 2:
                        case 3:
                        // Y
                        case 4:
                        case 5:
                            f.Controls[count].Text = a.ToString().PadLeft(12, ' ') + " : " + b.ToString().PadRight(12, ' ');
                            break;
                    }
                }

            #endif
                if (a > 2 && b > 2)
                    switch (count)
                    {
                        case 0:
                            z--;
                            break;
                        case 1:
                            z++;
                            break;
                        case 2:
                            x--;
                            break;
                        case 3:
                            x++;
                            break;
                        case 4:
                            y--;
                            break;
                        case 5:
                            y++;
                            break;
                    }
                    //<= (-unitToCheck.Radius))
            }
            if (x != 0 || y != 0 || z != 0)
                return false;

            return true;
        }
Esempio n. 34
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CustomPluginEditor"/> class.
        /// </summary>
        /// <param name="map">The map.</param>
        /// <remarks></remarks>
        public RestoreSelection(Map map, HaloMap.Meta.Meta meta, ref string filename)
        {
            InitializeComponent();
            this.map = map;
            this.meta = meta;

            OpenFileDialog ofd = new OpenFileDialog();
            ofd.InitialDirectory = Globals.Prefs.pathExtractsFolder;
            ofd.FileName = filename;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                FileStream fs = new FileStream(ofd.FileName, FileMode.Open);
                BinaryReader br = new BinaryReader(fs);
                fStream = new MemoryStream((int)fs.Length);
                fStream.Write(br.ReadBytes((int)fs.Length), 0, (int)fs.Length);
                br.Close();
                fs.Close();

                tvSourceTags.loadMeta(meta, map.HaloVersion, fStream);
                /*
                tvSourceTags.Nodes.Clear();
                IFPIO ifpx = IFPHashMap.GetIfp(meta.type, map);

                // path stores parent offsets
                string path = string.Empty;

                // Creates a tree listing recursively
                TreeNode[] tns = CreateTree(ifpx.items, path);

                // Create a TreeViewCollection to be passed to our function
                baseTree = new TreeNode();
                baseTree.Nodes.AddRange(tns);

                // Checks the tree listing and removes any reflexives that have a 0 count in the file
                // Source Nodes
                FileStream fs = new FileStream(ofd.FileName, FileMode.Open);
                BinaryReader br = new BinaryReader(fs);
                fStream = new MemoryStream((int)fs.Length);
                fStream.Write(br.ReadBytes((int)fs.Length), 0, (int)fs.Length);
                br.Close();
                fs.Close();
                br = new BinaryReader(fStream);
                // Displays our created source tree
                tvSourceTags.Nodes.AddRange(verifyReflexives(br, baseTree.Nodes, 0));

                /*
                tns = new TreeNode[tncs.Count];
                tncs.CopyTo(tns, 0);
                tvSourceTags.Nodes.AddRange(tns);
                */

                // Destination Nodes
                /*
                BinaryReader br = new BinaryReader(meta.MS);
                tvDestTags.Nodes.AddRange(verifyReflexives(br, baseTree.Nodes, 0));
                */

            }
            else
                filename = null;
        }