コード例 #1
0
        private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int    index = listBox1.SelectedIndex;
            string objIDStr;
            ushort objID;

            if (indexToObject.ContainsKey(index))
            {
                objIDStr = indexToObject[index];
            }
            else
            {
                objIDStr = "1"; // item box
            }
            objID = Convert.ToUInt16(objIDStr, 16);

            LevelObject trackObj = new LevelObject();

            trackObj.objID   = objID;
            trackObj.routeID = -1;

            MiscHacks misc = new MiscHacks();

            trackObj.modelName    = misc.returnModel(objID);
            trackObj.friendlyName = misc.returnName(objID);

            if (trackObj.modelName != "null")
            {
                FileBase objFB = new FileBase();
                if (File.Exists(Properties.Settings.Default.curDir + "/objects/" + trackObj.modelName + ".bmd"))
                {
                    objFB.Stream = new FileStream(Properties.Settings.Default.curDir + "/objects/" + trackObj.modelName + ".bmd", FileMode.Open);
                    rofl.Items.Add(trackObj);
                    rofl.Refresh();
                    Close();
                }
                else
                {
                    MessageBox.Show("File /objects/" + trackObj.modelName + ".bmd does not exist. Please add this file and it's dependencies before you can add this object.");
                    Close();
                    return;
                }
            }
            else
            {
                rofl.Items.Add(trackObj);
                rofl.Refresh();
                Close();
            }
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            // here we have to get the object's id from the textbox as a hex string
            // then we convert it to ushort (uint16) and then use that

            string value    = textBox1.Text;
            ushort objectID = Convert.ToUInt16(value, 16);

            LevelObject trackObj = new LevelObject();

            trackObj.objID   = objectID;
            trackObj.routeID = -1;
            MiscHacks misc = new MiscHacks();

            trackObj.modelName    = misc.returnModel(objectID);
            trackObj.friendlyName = misc.returnName(objectID);

            if (trackObj.modelName != "null")
            {
                FileBase objFB = new FileBase();
                if (File.Exists(Properties.Settings.Default.curDir + "/objects/" + trackObj.modelName + ".bmd"))
                {
                    objFB.Stream = new FileStream(Properties.Settings.Default.curDir + "/objects/" + trackObj.modelName + ".bmd", FileMode.Open);
                    rofl.Items.Add(trackObj);
                    rofl.Refresh();
                    Close();
                }
                else
                {
                    MessageBox.Show("File /objects/" + trackObj.modelName + ".bmd does not exist. Please add this file and it's depencies before you can add this object.");
                    Close();
                    return;
                }
            }
            else
            {
                rofl.Items.Add(trackObj);
                rofl.Refresh();
                Close();
            }
        }
コード例 #3
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();
                }
            }
        }