Beispiel #1
0
 private void treeView1_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
 {
     if (e.Node == null || e.Node.Parent == null)
     {
         return;
     }
     if (e.Node.Parent.Parent == matNode)
     {
         //If they selected a material property
         MatData m = (MatData)e.Node.Tag;
         Console.WriteLine(m.name);
         m.name      = e.Label;
         e.Node.Text = e.Label;
         Console.WriteLine(m.name);
     }
     treeView1_AfterSelect(treeView1, new TreeViewEventArgs(e.Node));
 }
Beispiel #2
0
        public void read(FileData f)
        {
            int nameOffset = f.readInt();

            matHash = f.readInt();
            int propertyCount = f.readInt();
            int propertyPos   = f.readInt();

            hasPat = (0 != f.readByte());
            f.skip(3);
            int patOffset     = f.readInt();
            int secondNameOff = f.readInt();

            matHash2 = f.readInt();

            f.seek(nameOffset);
            name = f.readString();

            if (secondNameOff != 0)
            {
                f.seek(secondNameOff);
                name2 = f.readString();
            }

            if (hasPat)
            {
                f.seek(patOffset);
                int patDataPos = f.readInt();
                if (patDataPos != 0)
                {
                    f.seek(patDataPos);
                    pat0.read(f);
                }
            }
            f.seek(propertyPos);
            for (int i = 0; i < propertyCount; i++)
            {
                int propOffset = f.readInt();
                int returnPos  = f.pos();
                f.seek(propOffset);
                MatData temp = new MatData();
                temp.read(f);
                properties.Add(temp);
                f.seek(returnPos);
            }
        }
Beispiel #3
0
        public void fill(MatData m)
        {
            //Display as color animation
            colorAnimList.Visible = true;
            colorAnimList.Items.Clear();
            int i = 0, max = (m.frames.Count - 1).ToString().Length;

            foreach (MatData.frame frame in m.frames)
            {
                Color         c  = Color.FromArgb((int)(frame.values[0] * 255), (int)(frame.values[1] * 255), (int)(frame.values[2] * 255), (int)(frame.values[3] * 255));
                colorKeyframe ck = new colorKeyframe(i++, c)
                {
                    maxLength = max
                };
                colorAnimList.Items.Add(ck);
            }
        }
Beispiel #4
0
 private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
 {
     colorList1.Visible   = false;
     matPropList1.Visible = false;
     if (e.Node == null)
     {
         return;
     }
     if (e.Node == headerNode)
     {
         //If they selected the header node
     }
     if (e.Node.Parent == null)
     {
         return;
     }
     if (e.Node.Parent == matNode)
     {
         //If they selected a material header
     }
     if (e.Node.Parent.Parent == null)
     {
         return;
     }
     if (e.Node.Parent.Parent == matNode)
     {
         //If they selected a material property
         MatData m = (MatData)e.Node.Tag;
         if (m.name == "effColorGain" || m.name == "colorGain" || m.name == "aoColorGain" || m.name == "finalColorGain")
         {
             colorList1.Visible = true;
             colorList1.fill(m);
         }
         else
         {
             matPropList1.Visible = true;
             matPropList1.fill(m);
         }
     }
 }
Beispiel #5
0
        public void Compile(List <string> f)
        {
            matEntries.Clear();
            visEntries.Clear();
            Nodes.Clear();
            unknown   = Convert.ToUInt32(f[1].Split(',')[1]);
            numFrames = Convert.ToUInt32(f[2].Split(',')[1]);
            frameRate = Convert.ToUInt32(f[3].Split(',')[1]);
            int l = 3;

            try
            {
                while (l < f.Count)
                {
                    if (f[l++].StartsWith("---"))
                    {
                        if (l >= f.Count)
                        {
                            break;
                        }
                        if (f[l].StartsWith("Material"))
                        {
                            l++;
                            MatEntry m = new MatEntry();
                            m.name = f[l];
                            l++;
                            m.matHash = Convert.ToInt32(f[l].Split(',')[1], 16);
                            l++;
                            m.hasPat = Convert.ToBoolean(f[l].Split(',')[1]);
                            l++;
                            if (!f[l].StartsWith("###"))
                            {
                                m.matHash2 = Convert.ToInt32(f[l].Split(',')[1], 16);
                                l++;
                            }
                            while (l < f.Count - 1 && (f[l].StartsWith("###") || string.IsNullOrWhiteSpace(f[l])))
                            {
                                if (f[++l].StartsWith("Material Property"))
                                {
                                    l++;
                                    MatData md = new MatData();
                                    md.name     = f[l++];
                                    md.unknown  = Convert.ToInt32(f[l++].Split(',')[1]);
                                    md.unknown2 = Convert.ToInt32(f[l++].Split(',')[1]);
                                    md.unknown3 = Convert.ToInt32(f[l++].Split(',')[1]);
                                    bool                 keyed        = (f[l++].Split(',')[1].Equals("Keyed") || f[l].Split(',')[1].Equals("keyed"));
                                    int                  lastFrame    = 0;
                                    MatData.frame        lastKeyframe = null;
                                    List <MatData.frame> frames       = new List <MatData.frame>();
                                    while (l < f.Count && !f[l].StartsWith("---") && !f[l].StartsWith("###"))
                                    {
                                        if (keyed)
                                        {
                                            int           currentFrame = frames.Count, fnum = Convert.ToInt32(f[l].Split(',')[0]);
                                            MatData.frame tempFrame = new MatData.frame();
                                            tempFrame.values = new float[f[l].Split(',').Length - 1];
                                            int i = 0;
                                            foreach (string value in (new List <string>(f[l].Split(',')).GetRange(1, f[l].Split(',').Length - 1)))
                                            {
                                                tempFrame.values[i++] = Convert.ToSingle(value);
                                            }
                                            if (lastKeyframe == null)
                                            {
                                                while (currentFrame <= fnum)
                                                {
                                                    frames.Add(tempFrame);
                                                    currentFrame = frames.Count;
                                                }
                                            }
                                            else
                                            {
                                                while (currentFrame <= fnum)
                                                {
                                                    List <float> thisFrame = new List <float>();
                                                    for (int k = 0; k < lastKeyframe.values.Length; k++)
                                                    {
                                                        float slope = (tempFrame.values[k] - lastKeyframe.values[k]) / (float)(fnum - lastFrame);
                                                        thisFrame.Add(lastKeyframe.values[k] + (slope * (currentFrame - lastFrame)));
                                                    }
                                                    frames.Add(new MatData.frame()
                                                    {
                                                        values = thisFrame.ToArray()
                                                    });
                                                    currentFrame = frames.Count;
                                                }
                                            }
                                            lastFrame    = fnum;
                                            lastKeyframe = tempFrame;
                                        }
                                        else
                                        {
                                            float[] values = new float[f[l].Split(',').Length];
                                            int     i      = 0;
                                            foreach (string value in f[l].Split(','))
                                            {
                                                values[i++] = Convert.ToSingle(value);
                                            }

                                            frames.Add(new MatData.frame()
                                            {
                                                values = values
                                            });
                                        }
                                        l++;
                                    }
                                    md.frames = frames;
                                    if (md.frames.Count > 0)
                                    {
                                        md.valueCount = md.frames[0].values.Length;
                                    }
                                    m.properties.Add(md);
                                }
                                else if (f[l + 1].StartsWith("PAT0"))
                                {
                                    l += 2;
                                    PatData p = new PatData();
                                    p.defaultTexId = Convert.ToInt32(f[l++].Split(',')[1]);
                                    int keyFrameCount = Convert.ToInt32(f[l++].Split(',')[1]);
                                    p.unknown = Convert.ToInt32(f[l++].Split(',')[1]);
                                    for (int i = 0; i < keyFrameCount; i++)
                                    {
                                        p.keyframes.Add(new PatData.keyframe()
                                        {
                                            frameNum = Convert.ToInt32(f[l].Split(',')[1]), texId = Convert.ToInt32(f[l++].Split(',')[3], 16)
                                        });
                                    }
                                    m.pat0 = p;
                                }
                            }
                            //while (l < f.Count && !f[l].StartsWith("---"))
                            //    l++;

                            matEntries.Add(m);
                        }
                        else if (f[l].StartsWith("VIS0"))
                        {
                            l++;
                            VisEntry v = new VisEntry();
                            v.name       = f[l++];
                            v.frameCount = Convert.ToInt32(f[l++].Split(',')[1]);
                            int keyframeCount = Convert.ToInt32(f[l++].Split(',')[1]);
                            v.unk1 = Convert.ToBoolean(f[l++].Split(',')[1]);
                            v.unk2 = Convert.ToBoolean(f[l++].Split(',')[1]);
                            for (int i = 0; i < keyframeCount; i++)
                            {
                                v.frames.Add(new VisEntry.frame()
                                {
                                    frameNum = Convert.ToInt16(f[l].Split(',')[1]), state = Convert.ToByte(f[l].Split(',')[3]), unknown = Convert.ToByte(f[l++].Split(',')[1])
                                });
                            }
                            visEntries.Add(v);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                MessageBox.Show($"Failed to build MTA\nError on line {l}\n{ex.ToString()}", "MTA Build Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //throw;
            }
        }