Beispiel #1
0
        private void openBCOToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter = "BCO files (*.bco)|*.bco|All files (*.*)|*.*";

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                this.Text = "BCO Editor " + openFileDialog1.FileName;
                this.Update();

                trisListBox.Items.Clear();
                vertsListBox.Items.Clear();

                GL.DeleteLists(selectedList, 1);

                using (EndianBinaryReader reader = new EndianBinaryReader(File.Open(openFileDialog1.FileName, FileMode.Open)))
                {
                    BCO bco = new BCO();
                    bco.Parse(reader);
                    bcoInfo = bco.returnBCOInf();

                    foreach (BCOInformation bcoInformation in bcoInfo)
                    {
                        uint count = bcoInformation.unkOffs3 - bcoInformation.vertOffs;
                        count = count / 36;
                        uint count2 = bcoInformation.vertOffs - bcoInformation.triOffs;
                        count2 = count2 / 36;
                        uint count3 = bcoInformation.firstSectionOffs - 0x2C;
                        count3 = count3 / 8;
                        uint count4 = bcoInformation.triOffs - bcoInformation.firstSectionOffs;
                        count4 = count4 / 2;

                        BCOUnknown0 bcoUnk0 = new BCOUnknown0();
                        bcoUnk0.Parse(reader, count3);

                        BCOUnknown1 bcoUnk1 = new BCOUnknown1();
                        bcoUnk1.Parse(reader, count4);

                        BCOTris bcoTris = new BCOTris();
                        bcoTris.Parse(reader, count2);
                        bcoTriangles = bcoTris.returnTris();

                        BCOVerts bcoVerts = new BCOVerts();
                        bcoVerts.Parse(reader, count);
                        bcoListVerts = bcoVerts.returnBCOVerts();
                        vecList      = bcoVerts.returnVectors();

                        BCOUnknown2 bcoUnk2 = new BCOUnknown2();
                        bcoUnk2.Parse(reader, bcoInformation.unk7);
                    }

                    // first we draw verts
                    vertList = GL.GenLists(1);
                    GL.NewList(vertList, ListMode.Compile);
                    GL.Begin(BeginMode.Points);
                    foreach (BCOVert bcoVertic in bcoListVerts)
                    {
                        GL.Color3(Color.DeepSkyBlue);
                        GL.PointSize(2f);
                        GL.Vertex3(bcoVertic.xPos1, bcoVertic.yPos1, bcoVertic.zPos1);
                        GL.Vertex3(bcoVertic.xPos2, bcoVertic.yPos2, bcoVertic.zPos2);
                        GL.Vertex3(bcoVertic.xPos3, bcoVertic.yPos3, bcoVertic.zPos3);
                    }
                    GL.End();
                    GL.EndList();

                    // now we draw tris

                    int     index1, index2, index3;
                    Vector3 set1, set2, set3;

                    triList = GL.GenLists(1);
                    GL.NewList(triList, ListMode.Compile);
                    GL.Begin(BeginMode.Triangles);
                    foreach (BCOTri bcTri in bcoTriangles)
                    {
                        trisListBox.Items.Add(bcTri);

                        index1 = bcTri.index1;
                        index2 = bcTri.index2;
                        index3 = bcTri.index3;

                        set1 = vecList[index1];
                        set2 = vecList[index2];
                        set3 = vecList[index3];

                        MiscHacks misc      = new MiscHacks();
                        Color     faceColor = misc.returnColor(bcTri.collisionFlag);

                        GL.Color4(faceColor);
                        GL.Vertex3(set1.X, set1.Y, set1.Z);
                        GL.Vertex3(set2.X, set2.Y, set2.Z);
                        GL.Vertex3(set3.X, set3.Y, set3.Z);
                    }
                    GL.End();
                    GL.EndList();

                    reader.Close();
                }
            }
        }