Ejemplo n.º 1
0
        public void upscaleImage(ME3SaltTexture2D inTex)
        {
            numMipMaps++;
            int propVal = properties["MipTailBaseIdx"].Value.IntValue;
            propVal++;
            properties["MipTailBaseIdx"].Value.IntValue = propVal;

            using (MemoryStream rawStream = new MemoryStream(properties["MipTailBaseIdx"].raw))
            {
                rawStream.Seek(rawStream.Length - 4, SeekOrigin.Begin);
                rawStream.WriteValueS32(propVal);
                properties["MipTailBaseIdx"].raw = rawStream.ToArray();
            }

            // update Sizes
            propVal = (int)privateimgList[0].imgSize.width;
            properties["SizeX"].Value.IntValue = propVal;
            using (MemoryStream rawStream = new MemoryStream(properties["SizeX"].raw))
            {
                rawStream.Seek(rawStream.Length - 4, SeekOrigin.Begin);
                rawStream.WriteValueS32(propVal);
                properties["SizeX"].raw = rawStream.ToArray();
            }

            properties["SizeY"].Value.IntValue = (int)privateimgList[0].imgSize.height;
            using (MemoryStream rawStream = new MemoryStream(properties["SizeY"].raw))
            {
                rawStream.Seek(rawStream.Length - 4, SeekOrigin.Begin);
                rawStream.WriteValueS32(propVal);
                properties["SizeY"].raw = rawStream.ToArray();
            }

            properties["OriginalSizeX"].Value.IntValue = propVal;
            using (MemoryStream rawStream = new MemoryStream(properties["OriginalSizeX"].raw))
            {
                rawStream.Seek(rawStream.Length - 4, SeekOrigin.Begin);
                rawStream.WriteValueS32(propVal);
                properties["OriginalSizeX"].raw = rawStream.ToArray();
            }
            properties["OriginalSizeY"].Value.IntValue = propVal;
            using (MemoryStream rawStream = new MemoryStream(properties["OriginalSizeY"].raw))
            {
                rawStream.Seek(rawStream.Length - 4, SeekOrigin.Begin);
                rawStream.WriteValueS32(propVal);
                properties["OriginalSizeY"].raw = rawStream.ToArray();
            }
        }
Ejemplo n.º 2
0
        public void CopyImgList(ME3SaltTexture2D inTex, ME3PCCObject pcc)
        {
            imageData = inTex.imageData;
            privateimgList = inTex.privateimgList;
            numMipMaps = inTex.numMipMaps;

            //Copy Properties
            byte[] buff;
            using (MemoryStream tempMem = new MemoryStream())
            {
                tempMem.WriteBytes(headerData);
                for (int i = 0; i < inTex.properties.Count; i++)
                {
                    SaltPropertyReader.Property prop = inTex.properties.ElementAt(i).Value;

                    if (prop.Name == "UnpackMin")
                    {
                        for (int j = 0; j < inTex.UnpackNum; j++)
                        {
                            tempMem.WriteValueS64(pcc.addName2(prop.Name));
                            tempMem.WriteValueS64(pcc.addName2(prop.TypeVal.ToString()));
                            tempMem.WriteValueS32(prop.Size);
                            tempMem.WriteValueS32(j);
                            tempMem.WriteValueF32(prop.Value.FloatValue);
                        }
                        continue;
                    }

                    tempMem.WriteValueS64(pcc.addName2(prop.Name));

                    if (prop.Name == "None")
                        continue;


                    tempMem.WriteValueS64(pcc.addName2(prop.TypeVal.ToString()));
                    tempMem.WriteValueS64(prop.Size);

                    switch (prop.TypeVal)
                    {
                        case SaltPropertyReader.Type.FloatProperty:
                            tempMem.WriteValueF32(prop.Value.FloatValue);
                            break;
                        case SaltPropertyReader.Type.IntProperty:
                            tempMem.WriteValueS32(prop.Value.IntValue);
                            break;
                        case SaltPropertyReader.Type.NameProperty:
                            tempMem.WriteValueS64(pcc.addName2(prop.Value.StringValue));
                            // Heff: Modified to handle name references.
                            //var index = pcc.addName2(prop.Value.StringValue);
                            //tempMem.WriteValueS32(index);
                            //tempMem.WriteValueS32(prop.Value.NameValue.count);
                            break;
                        case SaltPropertyReader.Type.ByteProperty:
                            tempMem.WriteValueS64(pcc.addName2(prop.Value.StringValue));
                            tempMem.WriteValueS32(pcc.addName2(prop.Value.String2));
                            byte[] footer = new byte[4];
                            Buffer.BlockCopy(prop.raw, prop.raw.Length - 4, footer, 0, 4);
                            tempMem.WriteBytes(footer);
                            break;
                        case SaltPropertyReader.Type.BoolProperty:
                            tempMem.WriteValueBoolean(prop.Value.Boolereno);
                            break;
                        case SaltPropertyReader.Type.StructProperty:
                            tempMem.WriteValueS64(pcc.addName2(prop.Value.StringValue));
                            for (int k = 0; k < prop.Size; k++)
                                tempMem.WriteByte((byte)prop.Value.Array[k].IntValue);
                            break;
                        default:
                            throw new NotImplementedException("Property type: " + prop.TypeVal + ", not yet implemented. TELL ME ABOUT THIS!");
                    }
                }
                buff = tempMem.ToArray();
            }

            properties = new Dictionary<string, SaltPropertyReader.Property>();

            List<SaltPropertyReader.Property> tempProperties = SaltPropertyReader.ReadProp(pcc, buff, headerData.Length);
            for (int i = 0; i < tempProperties.Count; i++)
            {
                SaltPropertyReader.Property property = tempProperties[i];
                if (property.Name == "UnpackMin")
                    UnpackNum++;

                if (!properties.ContainsKey(property.Name))
                    properties.Add(property.Name, property);

                switch (property.Name)
                {
                    case "Format":
                        texFormat = Textures.Methods.ParseFormat(pcc.Names[property.Value.IntValue].Substring(3));
                        break;
                    case "TextureFileCacheName": arcName = property.Value.NameValue.Name; break;
                    case "LODGroup": LODGroup = property.Value.NameValue.Name; break;
                    case "None": dataOffset = (uint)(property.offsetval + property.Size); break;
                }
            }

            // if "None" property isn't found throws an exception
            if (dataOffset == 0)
                throw new Exception("\"None\" property not found");
        }
Ejemplo n.º 3
0
 public Textures.ITexture2D CreateTexture2D(int expID, string pathBIOGame, uint hash = 0)
 {
     ITexture2D temptex2D = new ME3SaltTexture2D(this, expID, pathBIOGame);
     if (hash != 0)
         temptex2D.Hash = hash;
     return temptex2D;
 }
Ejemplo n.º 4
0
        //unused
        private void replaceImageToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int n = listBox1.SelectedIndex;
            if (n <= 0)
                return;

            if (pcc.Exports[n].ClassName != "Texture2D")
                MessageBox.Show("Not a texture.");
            else
            {
                using (OpenFileDialog ofd = new OpenFileDialog())
                {
                    ofd.Filter = "DirectX images|*.dds";
                    if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        string path = Path.GetDirectoryName(pcc.pccFileName);
                        ME3PCCObject temp = new ME3PCCObject(pcc.pccFileName);
                        ME3SaltTexture2D tex2D = new ME3SaltTexture2D(temp, n, path);
                        string test = tex2D.imgList.Max(t => t.imgSize).ToString();
                        ImageFile im = KFreonLib.Textures.Creation.LoadAKImageFile(null, ofd.FileName);
                        tex2D.replaceImage(test, im, path);

                        ME3ExportEntry expEntry = temp.Exports[tex2D.pccExpIdx];
                        expEntry.SetData(tex2D.ToArray(expEntry.DataOffset, temp));
                        temp.saveToFile(temp.pccFileName);
                    }
                }
            }
            // Reload pcc?
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates a Texture2D from a bunch of stuff.
 /// </summary>
 /// <param name="texName">Name of texture to create.</param>
 /// <param name="pccs">List of PCC's containing texture.</param>
 /// <param name="ExpIDs">List of ExpID's of texture in PCC's. MUST have same number of elements as in PCC's.</param>
 /// <param name="WhichGame">Game target.</param>
 /// <param name="pathBIOGame">Path to BIOGame.</param>
 /// <param name="hash">Hash of texture.</param>
 /// <returns>Texture2D object.</returns>
 public static ITexture2D CreateTexture2D(string texName, List<string> pccs, List<int> ExpIDs, int WhichGame, string pathBIOGame, uint hash = 0)
 {
     ITexture2D temptex2D = null;
     switch (WhichGame)
     {
         case 1:
             temptex2D = new ME1Texture2D(texName, pccs, ExpIDs, pathBIOGame, WhichGame, hash);
             break;
         case 2:
             temptex2D = new ME2Texture2D(texName, pccs, ExpIDs, pathBIOGame,WhichGame, hash);
             break;
         case 3:
             temptex2D = new ME3SaltTexture2D(texName, pccs, ExpIDs, hash, pathBIOGame, WhichGame);
             //temptex2D = new ME3SaltTexture2D(new ME3PCCObject(pccs[0]), ExpIDs[0], pathBIOGame, hash);
             break;
     }
     if (hash != 0)
         temptex2D.Hash = hash;
     return temptex2D;
 }
Ejemplo n.º 6
0
        private void listView1_MouseClick(object sender, MouseEventArgs e)
        {
            ListView.SelectedIndexCollection n = listView1.SelectedIndices;
            if (n.Count != 1 || pcc == null)
                return;
            int index = Convert.ToInt32(listView1.Items[n[0]].Name);

            if (pcc.Exports[index].ClassName == ME3SaltTexture2D.className)
                tex2D = new ME3SaltTexture2D(pcc, index, ME3Directory.BIOGamePath);
            else
                tex2D = null;

            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                switch (pcc.Exports[index].ClassName)
                {
                    case "Sequence":
                        textureToolStripMenuItem.Visible = false;
                        soundsToolStripMenuItem.Visible = false;
                        contextMenuStrip1.Show(MousePosition);
                        break;
                    case "Texture2D":
                        soundsToolStripMenuItem.Visible = false;
                        textureToolStripMenuItem.Visible = true;
                        contextMenuStrip1.Show(MousePosition);
                        break;
                    //case "Level":
                    //    soundsToolStripMenuItem.Visible = false;
                    //    editToolStripMenuItem1.Visible = true;
                    //    inSequenceEditorToolStripMenuItem.Visible = false;
                    //    textureToolStripMenuItem.Visible = false;
                    //    contextMenuStrip1.Show(MousePosition);
                    //    break;
                    case "WwiseStream":
                        textureToolStripMenuItem.Visible = false;
                        soundsToolStripMenuItem.Visible = true;
                        contextMenuStrip1.Show(MousePosition);
                        break;
                    default:
                        soundsToolStripMenuItem.Visible = false;
                        textureToolStripMenuItem.Visible = false;
                        contextMenuStrip1.Show(MousePosition);
                        break;
                }
            }
        }