Beispiel #1
0
 public Face(ushort hammerId, Bsp bsp)
 {
     this.hammerFaceId = hammerId;
     this.bsp          = bsp;
     gatherDface_ts();
     gatherLightinfo();
 }
Beispiel #2
0
 private void ButtonRandom_Click(object sender, EventArgs e)
 {
     //this method is not accessible from the UI. It randomizes all lightmaps in a given bsp. (this power is too great to be handled by mere mortals)
     if (map != null)
     {
         map.file.Close();
     }
     map = new Bsp(new FileInfo(textBoxBsp.Text));
     surface.randoLightmaps(new Random());
 }
Beispiel #3
0
        public static readonly int classLength = 56; // 0x38

        public Dface_t(ushort planenum, Bsp bsp)     // send offset + 0x14
        //constructor that gets the basic face infos with a planenum and a bsp
        {
            this.planenum = planenum;
            bsp.file.Seek(bsp.offsets[7].Key + planenum * classLength, SeekOrigin.Begin); //seek to dface_t
            bsp.file.Seek(20, SeekOrigin.Current);                                        //seek to lighofs
            lightOfs = bsp.reader.ReadInt32();                                            //read light offset
            bsp.file.Seek(12, SeekOrigin.Current);                                        //seek to lightmap
            LightmapTextureWidth  = bsp.reader.ReadInt32() + 1;                           //read lightmap width
            LightmapTextureLength = bsp.reader.ReadInt32() + 1;                           //read lightmap length
            this.bsp = bsp;
            retrieveLightmap();
        }
Beispiel #4
0
        private void buttonLoad_Click(object sender, EventArgs e)
        {
            if (map != null)
            {
                map.file.Close();
            }

            try
            {
                FileInfo file = new FileInfo(textBoxBsp.Text);
                map = new Bsp(new FileInfo(textBoxBsp.Text));
                if (!map.valid)
                {
                    buttonUnload_Click(null, new EventArgs());
                    return;
                }

                //checks if there's data either for ldr or hdr lightmaps
                if (!map.LDR && !map.HDR)
                {
                    MessageBox.Show("VRAD must be run first on this BSP file!");
                    buttonUnload_Click(null, new EventArgs());
                }
                else
                {
                    //enables/disable available options for ldr/hdr
                    if (map.LDR)
                    {
                        radioButtonLDR.Enabled = true;
                    }
                    else
                    {
                        radioButtonLDR.Enabled = false;
                        radioButtonLDR.Checked = false;
                        radioButtonHDR.Checked = true;
                    }
                    if (map.HDR)
                    {
                        radioButtonHDR.Enabled = true;
                    }
                    else
                    {
                        radioButtonHDR.Enabled = false;
                        radioButtonHDR.Checked = false;
                        radioButtonLDR.Checked = true;
                    }
                    //fetchs the face, displays data and locks controls while editing
                    ushort planenum  = ushort.Parse(textBoxFaceID.Text);
                    int    numPlanes = map.offsets[7].Value / Dface_t.classLength;
                    if (planenum >= numPlanes)
                    {
                        MessageBox.Show("The faceID you entered is too big"); //if we were to use this offset into lump 7 we would exceed it
                        buttonUnload_Click(null, new EventArgs());
                        return;
                    }
                    surface = new Dface_t(planenum, map);

                    selectedX = 0;
                    selectedY = 0;

                    updateLightmapViewer();

                    textBoxBsp.ReadOnly     = true;
                    textBoxFaceID.ReadOnly  = true;
                    buttonBrowseBsp.Enabled = false;
                    buttonLoad.Enabled      = false;
                    buttonUnload.Enabled    = true;
                    buttonUpdate.Enabled    = true;

                    spinnerR.Enabled = true;
                    spinnerG.Enabled = true;
                    spinnerB.Enabled = true;
                    spinnerE.Enabled = true;

                    if (checkBoxOverexp.Checked)
                    {
                        timer1.Start();
                        overexposedHighlight = true;
                    }
                }
            }
            catch (ArgumentException)
            {
                MessageBox.Show("You must choose a bsp", "Error", MessageBoxButtons.OK);
            }
            catch (/*FormatException*/ Exception)
            {
                MessageBox.Show("You must enter a faceID\n\nLoad your map in-game and use the command \"mat_surfaceid 2\" to display faceIDs.\n\"mat_wireframe 3\" is also useful to see face divisions.", "Error", MessageBoxButtons.OK);
            }
        }
Beispiel #5
0
 public Face(Bsp bsp)
 {
     this.bsp = bsp;
     randoLightmap();
 }