コード例 #1
0
ファイル: MainForm.cs プロジェクト: yakoder/sims3tools
        void loadVPXY(Stream data)
        {
            try
            {
                rcol = new GenericRCOLResource(0, data);
            }
            catch { rcol = null; }
            if (rcol == null || rcol.ChunkEntries.Count != 1 || rcol.ChunkEntries[0].RCOLBlock.Tag != "VPXY")
            {
                throw new Exception("RCOL was not a VPXY resource.");
            }
            vpxy = rcol.ChunkEntries[0].RCOLBlock as VPXY;
            if (vpxy == null)
            {
                throw new Exception("VPXY resource contains invalid RCOL Chunk.");
            }

            FillPartsTLP();

            nudLowerX.Value = new Decimal(vpxy.Bounds.Min.X);
            nudLowerY.Value = new Decimal(vpxy.Bounds.Min.Y);
            nudLowerZ.Value = new Decimal(vpxy.Bounds.Min.Z);
            nudUpperX.Value = new Decimal(vpxy.Bounds.Max.X);
            nudUpperY.Value = new Decimal(vpxy.Bounds.Max.Y);
            nudUpperZ.Value = new Decimal(vpxy.Bounds.Max.Z);

            tbcFTPT.Enabled       = ckbModular.Checked = vpxy.Modular;
            tbcFTPT.TGIBlocks     = vpxy.TGIBlocks;
            tbcFTPT.SelectedIndex = vpxy.Modular && vpxy.FTPTIndex < vpxy.TGIBlocks.Count ? (int)vpxy.FTPTIndex : -1;

            rcol.ResourceChanged += new EventHandler(rcol_ResourceChanged);
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: falerin/Sims4Tools
        void loadVPXY(Stream data)
        {
            try
            {
                rcol = new GenericRCOLResource(0, data);
            }
            catch { rcol = null; }
            if (rcol == null || rcol.ChunkEntries.Count != 1 || rcol.ChunkEntries[0].RCOLBlock.Tag != "VPXY")
            {
                throw new Exception("RCOL was not a VPXY resource.");
            }
            vpxy = rcol.ChunkEntries[0].RCOLBlock as VPXY;
            if (vpxy == null)
            {
                throw new Exception("VPXY resource contains invalid RCOL Chunk.");
            }

            FillPartsTLP();

            nudLowerX.Value = new Decimal(vpxy.Bounds.Min.X);
            nudLowerY.Value = new Decimal(vpxy.Bounds.Min.Y);
            nudLowerZ.Value = new Decimal(vpxy.Bounds.Min.Z);
            nudUpperX.Value = new Decimal(vpxy.Bounds.Max.X);
            nudUpperY.Value = new Decimal(vpxy.Bounds.Max.Y);
            nudUpperZ.Value = new Decimal(vpxy.Bounds.Max.Z);

            tbcFTPT.Enabled = ckbModular.Checked = vpxy.Modular;
            tbcFTPT.TGIBlocks = vpxy.TGIBlocks;
            tbcFTPT.SelectedIndex = vpxy.Modular && vpxy.FTPTIndex < vpxy.TGIBlocks.Count ? (int)vpxy.FTPTIndex : -1;

            rcol.ResourceChanged += new EventHandler(rcol_ResourceChanged);
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: falerin/Sims4Tools
 void FillLinkedPartsTLP(int offset, VPXY.Entry00 entry)
 {
     tlpLinkedParts.SuspendLayout();
     //ClearLinkedPartsTLP(false);// should never be needed
     lLPtbc = new List<TGIBlockCombo>();
     int tabindex = 1;
     for (int i = 0; i < entry.TGIIndexes.Count; i++)
     {
         AddTableRowTBC(tlpLinkedParts, offset + 1 + i, entry.TGIIndexes[i], ref tabindex);
     }
     tlpLPControls.Enabled = tlpLinkedParts.Enabled = true;
     tlpLinkedParts.ResumeLayout();
 }
コード例 #4
0
ファイル: TattForm.cs プロジェクト: htgiddings/tattooinator
        private void TattooGo_button_Click(object sender, EventArgs e)
        {
            float sortOrder;

            try
            {
                sortOrder = float.Parse(CASPsortOrder.Text);
            }
            catch
            {
                MessageBox.Show("Please enter a valid number for Sort Order in CAS");
                return;
            }
            if (String.CompareOrdinal(TattooName.Text, " ") <= 0)
            {
                MessageBox.Show("Please enter a name for the tattoo");
                return;
            }
            if (dds == null)
            {
                MessageBox.Show("Please select an image for the tattoo");
                return;
            }
            ulong  tatInstance;
            string tatName;

            if (TattooName.Text.IndexOf("uutattoo") < 0)
            {
                tatName = "uutattoo" + TattooName.Text;
            }
            else
            {
                tatName = TattooName.Text;
            }
            if (String.CompareOrdinal(TattooInstance.Text, " ") > 0)
            {
                if (!UInt64.TryParse(TattooInstance.Text, System.Globalization.NumberStyles.HexNumber, System.Globalization.CultureInfo.InvariantCulture, out tatInstance))
                {
                    MessageBox.Show("Please enter a valid Tattoo Instance number in hexidecimal, or leave it blank");
                    return;
                }
            }
            else
            {
                tatInstance = FNVhash.FNV64(tatName);
            }

            PleaseWait_label.Visible = true;
            this.Refresh();

            uint  tatGroup     = FNVhash.FNV24(tatName);
            ulong txtcInstance = FNVhash.FNV64(tatName + "TattooTemplate_Top_diffuse");

            Package myPack;

            myPack = (Package)Package.NewPackage(0);

            NameMapResource.NameMapResource myMap = new NameMapResource.NameMapResource(0, null);
            myMap.Add(tatInstance, tatName);
            myMap.Add(tatGroup, tatName);
            myMap.Add(txtcInstance, tatName + "TattooTemplate_Top_diffuse");

            XmlDocument doc1 = PresetBuilder.presetXML(tatName, tatInstance, presets[0],
                                                       ChannelR_checkBox.Checked, ChannelG_checkBox.Checked, ChannelB_checkBox.Checked, ChannelA_checkBox.Checked);
            XmlDocument doc2 = PresetBuilder.presetXML(tatName, tatInstance, presets[1],
                                                       ChannelR_checkBox.Checked, ChannelG_checkBox.Checked, ChannelB_checkBox.Checked, ChannelA_checkBox.Checked);
            XmlDocument doc3 = PresetBuilder.presetXML(tatName, tatInstance, presets[2],
                                                       ChannelR_checkBox.Checked, ChannelG_checkBox.Checked, ChannelB_checkBox.Checked, ChannelA_checkBox.Checked);

            CASPartResource.CASPartResource myCasp;
            myCasp = new CASPartResource.CASPartResource(0, null);
            CASPartResource.CASPartResource.Preset pre1 = new CASPartResource.CASPartResource.Preset(0, null, doc1.OuterXml, 1);
            CASPartResource.CASPartResource.Preset pre2 = new CASPartResource.CASPartResource.Preset(0, null, doc2.OuterXml, 2);
            CASPartResource.CASPartResource.Preset pre3 = new CASPartResource.CASPartResource.Preset(0, null, doc3.OuterXml, 3);
            myCasp.Presets = new CASPartResource.CASPartResource.PresetList(null);
            myCasp.Presets.Add(pre1);
            myCasp.Presets.Add(pre2);
            myCasp.Presets.Add(pre3);
            myCasp.Unknown1     = tatName;
            myCasp.SortPriority = sortOrder;
            myCasp.Clothing     = ClothingType.TattooTemplate;
            myCasp.DataType     = DataTypeFlags.Body;
            myCasp.AgeGender    = new AgeGenderFlags(0, null, (CASPtodder_checkBox.Checked ? AgeFlags.Toddler : 0) |
                                                     (CASPchild_checkBox.Checked ? AgeFlags.Child : 0) | (CASPteen_checkBox.Checked ? AgeFlags.Teen : 0) |
                                                     (CASPadult_checkBox.Checked ? AgeFlags.YoungAdult | AgeFlags.Adult : 0) |
                                                     (CASPelder_checkBox.Checked ? AgeFlags.Elder : 0),
                                                     (CASPfemale_checkBox.Checked ? GenderFlags.Female : 0) | (CASPmale_checkBox.Checked ? GenderFlags.Male : 0),
                                                     0, 0);
            myCasp.ClothingCategory = ClothingCategoryFlags.Athletic | ClothingCategoryFlags.Career | ClothingCategoryFlags.Everyday |
                                      ClothingCategoryFlags.FireFighting | ClothingCategoryFlags.Formalwear | ClothingCategoryFlags.Makeover |
                                      ClothingCategoryFlags.MartialArts | ClothingCategoryFlags.Naked | ClothingCategoryFlags.Outerwear |
                                      ClothingCategoryFlags.SkinnyDippingTowel | ClothingCategoryFlags.Sleepwear | ClothingCategoryFlags.Swimwear |
                                      ClothingCategoryFlags.Singed | ClothingCategoryFlags.ValidForMaternity;
            myCasp.CasPart1Index         = 2;
            myCasp.CasPart2Index         = 2;
            myCasp.BlendInfoFatIndex     = 3;
            myCasp.BlendInfoFitIndex     = 4;
            myCasp.BlendInfoThinIndex    = 5;
            myCasp.BlendInfoSpecialIndex = 6;
            myCasp.OverlayPriority       = 2u;
            myCasp.VPXYIndexes           = new ByteIndexList(null);
            myCasp.VPXYIndexes.Add(7);
            myCasp.Diffuse1Indexes = new ByteIndexList(null);
            myCasp.Diffuse1Indexes.Add(8);
            myCasp.Specular1Indexes = new ByteIndexList(null);
            myCasp.Specular1Indexes.Add(9);
            myCasp.BONDIndexes = new ByteIndexList(null);
            myCasp.BONDIndexes.AddRange(new List <byte> {
                2, 2, 2, 2, 2
            });
            myCasp.Unknown4  = "bare";
            myCasp.TGIBlocks = new CountedTGIBlockList(null);
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.DDS, 0, tatInstance));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.XML, 0, 0xF7FC14B9EA85B390));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, 0, 0, 0));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.BBLN, 0, 0xCBE03A305F80FF50));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.BBLN, 0, 0xCBE032305F80F1F8));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.BBLN, 0, 0x540F4B31F0B42342));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.BBLN, 0, 0x82F02E48897E22B4));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.VPXY, 1, tatGroup));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.TXTC, tatGroup, txtcInstance));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.TXTC, tatGroup, 0xCBF29CE484222325));

            uint  fakeType     = (uint)tatInstance;
            uint  fakeGroup    = (uint)(tatInstance >> 32);
            ulong fakeInstance = (ulong)ResourceTypes.DDS << 32;

            TxtcResource.TxtcResource txtc = TattooTextureCompositor.TattooTxtc(new TGIBlock(0, null, fakeType, fakeGroup, fakeInstance));

            VPXY vpxy = new VPXY(0, null, 4, null, 2,
                                 new BoundingBox(0, null, new Vertex(0, null, -.0060f, 1.7157f, -.0060f), new Vertex(0, null, .0060f, 1.7277f, .0060f)),
                                 new byte[] { 0, 0, 0, 0 }, 0, 0, new TGIBlockList(null));
            GenericRCOLResource vpxyRcol = new GenericRCOLResource(0, null);

            vpxyRcol.Version      = 3;
            vpxyRcol.PublicChunks = 1;
            vpxyRcol.ChunkEntries = new GenericRCOLResource.ChunkEntryList(null);
            GenericRCOLResource.ChunkEntry vpxyChunk = new GenericRCOLResource.ChunkEntry(0, null, new TGIBlock(0, null, "ITG", (uint)ResourceTypes.VPXY, 1, tatGroup), vpxy);
            vpxyRcol.ChunkEntries.Add(vpxyChunk);
            IResourceIndexEntry rs = myPack.AddResource(new TGIBlock(0, null, (uint)ResourceTypes.KEY, 0, tatInstance), myMap.Stream, true);

            rs.Compressed = (ushort)0xFFFF;
            rs            = myPack.AddResource(new TGIBlock(0, null, (uint)ResourceTypes.CASP, 0, tatInstance), myCasp.Stream, true);
            rs.Compressed = (ushort)0xFFFF;
            rs            = myPack.AddResource(new TGIBlock(0, null, (uint)ResourceTypes.TXTC, tatGroup, txtcInstance), txtc.Stream, true);
            rs.Compressed = (ushort)0xFFFF;
            rs            = myPack.AddResource(new TGIBlock(0, null, (uint)ResourceTypes.VPXY, 1, tatGroup), vpxyRcol.Stream, true);
            rs.Compressed = (ushort)0xFFFF;
            MemoryStream ms = new MemoryStream();

            doc1.Save(ms);
            rs            = myPack.AddResource(new TGIBlock(0, null, (uint)ResourceTypes.XML, 0, tatInstance), ms, true);
            rs.Compressed = (ushort)0xFFFF;
            MemoryStream ms2 = new MemoryStream();

            dds.UseDXT          = false;
            dds.AlphaDepth      = 8;
            dds.GenerateMipmaps = true;
            dds.Save(ms2);
            rs            = myPack.AddResource(new TGIBlock(0, null, (uint)ResourceTypes.DDS, 0, tatInstance), ms2, true);
            rs.Compressed = (ushort)0xFFFF;
            if (thumbNail != null)
            {
                MemoryStream ms3 = new MemoryStream();
                thumbNail.Save(ms3, System.Drawing.Imaging.ImageFormat.Png);
                rs            = myPack.AddResource(new TGIBlock(0, null, (uint)ResourceTypes.THUM, 1, tatInstance), ms3, true);
                rs.Compressed = (ushort)0xFFFF;
            }

            PleaseWait_label.Visible = false;

            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter          = PackageFilter;
            saveFileDialog1.Title           = "Save as a new package";
            saveFileDialog1.FileName        = TattooName.Text + ".package";
            saveFileDialog1.FilterIndex     = 1;
            saveFileDialog1.CheckFileExists = false;
            saveFileDialog1.CheckPathExists = true;
            saveFileDialog1.OverwritePrompt = true;
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                myPack.SaveAs(saveFileDialog1.FileName);
            }
            ms.Dispose();
            ms2.Dispose();
        }