コード例 #1
0
        // Insert middle texture
        public virtual void OnInsert()
        {
            // No middle texture yet?
            if (!Sidedef.MiddleRequired() && (string.IsNullOrEmpty(Sidedef.MiddleTexture) || (Sidedef.MiddleTexture[0] == '-')))
            {
                // Make it now
                mode.CreateUndo("Create middle texture");
                mode.SetActionResult("Created middle texture.");
                General.Settings.FindDefaultDrawSettings();
                Sidedef.SetTextureMid(General.Settings.DefaultTexture);

                // Update
                Sector.Changed = true;

                // Other side as well
                if (string.IsNullOrEmpty(Sidedef.Other.MiddleTexture) || (Sidedef.Other.MiddleTexture[0] == '-'))
                {
                    Sidedef.Other.SetTextureMid(General.Settings.DefaultTexture);

                    // Update
                    VisualSector othersector = mode.GetVisualSector(Sidedef.Other.Sector);
                    if (othersector is BaseVisualSector)
                    {
                        (othersector as BaseVisualSector).Changed = true;
                    }
                }
            }
        }
コード例 #2
0
        // Edit button released
        public virtual void OnEditEnd()
        {
            if (General.Interface.IsActiveWindow)
            {
                List <Linedef> linedefs = mode.GetSelectedLinedefs();
                DialogResult   result   = General.Interface.ShowEditLinedefs(linedefs);
                if (result == DialogResult.OK)
                {
                    foreach (Linedef l in linedefs)
                    {
                        if (l.Front != null)
                        {
                            VisualSector vs = mode.GetVisualSector(l.Front.Sector);
                            if (vs != null)
                            {
                                (vs as BaseVisualSector).Changed = true;
                            }
                        }

                        if (l.Back != null)
                        {
                            VisualSector vs = mode.GetVisualSector(l.Back.Sector);
                            if (vs != null)
                            {
                                (vs as BaseVisualSector).Changed = true;
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
        // Constructor
        public VisualMiddleDouble(BaseVisualMode mode, VisualSector vs, Sidedef s) : base(mode, vs, s)
        {
            // Set render pass
            this.RenderPass = RenderPass.Mask;

            // We have no destructor
            GC.SuppressFinalize(this);
        }
コード例 #4
0
        // Constructor
        public VisualMiddle3D(BaseVisualMode mode, VisualSector vs, Sidedef s) : base(mode, vs, s)
        {
            //mxd
            geometrytype = VisualGeometryType.WALL_MIDDLE_3D;
            partname     = "mid";

            // We have no destructor
            GC.SuppressFinalize(this);
        }
コード例 #5
0
        // Constructor
        public VisualUpper(BaseVisualMode mode, VisualSector vs, Sidedef s) : base(mode, vs, s)
        {
            //mxd
            geometrytype = VisualGeometryType.WALL_UPPER;
            partname     = "top";

            // We have no destructor
            GC.SuppressFinalize(this);
        }
コード例 #6
0
 // Constructor for sidedefs
 public BaseVisualGeometrySidedef(BaseVisualMode mode, VisualSector vs, Sidedef sd) : base(vs, sd)
 {
     this.mode    = mode;
     this.deltaz  = new Vector3D(0.0f, 0.0f, 1.0f);
     this.deltaxy = (sd.Line.End.Position - sd.Line.Start.Position) * sd.Line.LengthInv;
     if (!sd.IsFront)
     {
         this.deltaxy = -this.deltaxy;
     }
 }
コード例 #7
0
        private bool innerside;         //mxd

        #endregion

        #region ================== Properties

        #endregion

        #region ================== Constructor / Setup

        // Constructor
        public VisualFloor(BaseVisualMode mode, VisualSector vs) : base(mode, vs)
        {
            //mxd
            geometrytype         = VisualGeometryType.FLOOR;
            partname             = "floor";
            performautoselection = mode.UseSelectionFromClassicMode && vs != null && vs.Sector.Selected && (General.Map.ViewMode == ViewMode.FloorTextures || General.Map.ViewMode == ViewMode.Normal);

            // We have no destructor
            GC.SuppressFinalize(this);
        }
コード例 #8
0
        // Constructor
        public VisualFogBoundary(BaseVisualMode mode, VisualSector vs, Sidedef s) : base(mode, vs, s)
        {
            //mxd
            geometrytype = VisualGeometryType.FOG_BOUNDARY;

            // Set render pass
            this.RenderPass = RenderPass.Additive;

            // We have no destructor
            GC.SuppressFinalize(this);
        }
コード例 #9
0
        // Constructor
        public VisualMiddleDouble(BaseVisualMode mode, VisualSector vs, Sidedef s) : base(mode, vs, s)
        {
            //mxd
            geometrytype = VisualGeometryType.WALL_MIDDLE;
            partname     = "mid";

            // Set render pass
            this.RenderPass = RenderPass.Mask;

            // We have no destructor
            GC.SuppressFinalize(this);
        }
コード例 #10
0
 // Edit button released
 public virtual void OnEditEnd()
 {
     if (General.Interface.IsActiveWindow)
     {
         List <Sector> sectors = mode.GetSelectedSectors();
         DialogResult  result  = General.Interface.ShowEditSectors(sectors);
         if (result == DialogResult.OK)
         {
             // Rebuild sector
             foreach (Sector s in sectors)
             {
                 VisualSector vs = mode.GetVisualSector(s);
                 if (vs != null)
                 {
                     (vs as BaseVisualSector).UpdateSectorGeometry(true);
                 }
             }
         }
     }
 }
コード例 #11
0
        // Edit button released
        public virtual void OnEditEnd()
        {
            if (!General.Interface.IsActiveWindow)
            {
                return;
            }

            List <Sidedef> walls  = mode.GetSelectedWalls();
            DialogResult   result = General.Interface.ShowEditWalls(walls);

            if (result == DialogResult.OK)
            {
                foreach (Sidedef w in walls)
                {
                    VisualSector vs = mode.GetVisualSector(w.Sector);
                    if (vs != null)
                    {
                        (vs as BaseVisualSector).Changed = true;
                    }
                }
            }
        }
コード例 #12
0
 // Constructor
 public BaseVisualGeometrySector(BaseVisualMode mode, VisualSector vs) : base(vs)
 {
     this.mode = mode;
 }
コード例 #13
0
 // Constructor
 public VisualCeiling(BaseVisualMode mode, VisualSector vs) : base(mode, vs)
 {
 }
コード例 #14
0
 // Constructor
 public VisualCeiling(BaseVisualMode mode, VisualSector vs) : base(mode, vs)
 {
     // We have no destructor
     GC.SuppressFinalize(this);
 }
コード例 #15
0
ファイル: VisualMiddle3D.cs プロジェクト: paulyc/doombuilder
 // Constructor
 public VisualMiddle3D(BaseVisualMode mode, VisualSector vs, Sidedef s) : base(mode, vs, s)
 {
     // We have no destructor
     GC.SuppressFinalize(this);
 }
コード例 #16
0
 // Constructor
 public VisualLower(BaseVisualMode mode, VisualSector vs, Sidedef s) : base(mode, vs, s)
 {
 }
コード例 #17
0
 // Constructor
 public VisualFloor(BaseVisualMode mode, VisualSector vs) : base(mode, vs)
 {
 }
コード例 #18
0
        // This performs a single render pass
        private void RenderSinglePass(int pass)
        {
            int currentshaderpass = shaderpass;
            int highshaderpass    = shaderpass + 2;

            // Get geometry for this pass
            Dictionary <ImageData, BinaryHeap <VisualGeometry> > geopass = geometry[pass];

            // Begin rendering with this shader
            graphics.Shaders.World3D.BeginPass(shaderpass);

            // Render the geometry collected
            foreach (KeyValuePair <ImageData, BinaryHeap <VisualGeometry> > group in geopass)
            {
                ImageData curtexture;

                // What texture to use?
                if (group.Key is UnknownImage)
                {
                    curtexture = General.Map.Data.UnknownTexture3D;
                }
                else if ((group.Key != null) && group.Key.IsImageLoaded && !group.Key.IsDisposed)
                {
                    curtexture = group.Key;
                }
                else
                {
                    curtexture = General.Map.Data.Hourglass3D;
                }

                // Create Direct3D texture if still needed
                if ((curtexture.Texture == null) || curtexture.Texture.Disposed)
                {
                    curtexture.CreateTexture();
                }

                // Apply texture
                if (showlightonly)  // villsa
                {
                    if (!graphics.Shaders.Enabled)
                    {
                        graphics.Device.SetTexture(0, General.Map.Data.WhiteTexture.Texture);
                    }
                    graphics.Shaders.World3D.Texture1 = General.Map.Data.WhiteTexture.Texture;
                }
                else
                {
                    if (!graphics.Shaders.Enabled)
                    {
                        graphics.Device.SetTexture(0, curtexture.Texture);
                    }
                    graphics.Shaders.World3D.Texture1 = curtexture.Texture;
                }

                // Go for all geometry that uses this texture
                VisualSector sector = null;
                foreach (VisualGeometry g in group.Value)
                {
                    // Changing sector?
                    if (!object.ReferenceEquals(g.Sector, sector))
                    {
                        // Update the sector if needed
                        if (g.Sector.NeedsUpdateGeo)
                        {
                            g.Sector.Update();
                        }

                        // Only do this sector when a vertexbuffer is created
                        if (g.Sector.GeometryBuffer != null)
                        {
                            // Change current sector
                            sector = g.Sector;

                            // Set stream source
                            graphics.Device.SetStreamSource(0, sector.GeometryBuffer, 0, WorldVertex.Stride);
                        }
                        else
                        {
                            sector = null;
                        }
                    }

                    if (sector != null)
                    {
                        // Determine the shader pass we want to use for this object
                        int wantedshaderpass = (((g == highlighted) && showhighlight) || (g.Selected && showselection)) ? highshaderpass : shaderpass;

                        // Switch shader pass?
                        if (currentshaderpass != wantedshaderpass)
                        {
                            graphics.Shaders.World3D.EndPass();
                            graphics.Shaders.World3D.BeginPass(wantedshaderpass);
                            currentshaderpass = wantedshaderpass;
                        }

                        // villsa - mirror UVs if special flags are set
                        if (General.Map.FormatInterface.InDoom64Mode)
                        {
                            if (g.Sidedef != null)
                            {
                                // villsa - fixed 9/25/11
                                if (g.Sidedef.Line != null)
                                {
                                    if (g.Sidedef.Line.IsFlagSet("1073741824"))
                                    {
                                        graphics.Device.SetSamplerState(0, SamplerState.AddressU, TextureAddress.Mirror);
                                    }
                                    else
                                    {
                                        graphics.Device.SetSamplerState(0, SamplerState.AddressU, TextureAddress.Wrap);
                                    }

                                    if (g.Sidedef.Line.IsFlagSet("2147483648"))
                                    {
                                        graphics.Device.SetSamplerState(0, SamplerState.AddressV, TextureAddress.Mirror);
                                    }
                                    else
                                    {
                                        graphics.Device.SetSamplerState(0, SamplerState.AddressV, TextureAddress.Wrap);
                                    }
                                }
                            }
                        }

                        // Set the colors to use
                        if (!graphics.Shaders.Enabled)
                        {
                            graphics.Device.SetTexture(2, (g.Selected && showselection) ? selectionimage.Texture : null);
                            graphics.Device.SetTexture(3, ((g == highlighted) && showhighlight) ? highlightimage.Texture : null);
                        }
                        else
                        {
                            graphics.Shaders.World3D.SetHighlightColor(CalculateHighlightColor((g == highlighted) && showhighlight, (g.Selected && showselection)).ToArgb());
                            graphics.Shaders.World3D.ApplySettings();
                        }

                        // Render!
                        graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, g.VertexOffset, g.Triangles);

                        // villsa - reset samplers to default wrappings
                        if (General.Map.FormatInterface.InDoom64Mode)
                        {
                            graphics.Device.SetSamplerState(0, SamplerState.AddressU, TextureAddress.Wrap);
                            graphics.Device.SetSamplerState(0, SamplerState.AddressV, TextureAddress.Wrap);
                        }
                    }
                }
            }

            // Get things for this pass
            Dictionary <ImageData, List <VisualThing> > thingspass = things[pass];

            if (thingspass.Count > 0)
            {
                // Texture addressing
                graphics.Device.SetSamplerState(0, SamplerState.AddressU, TextureAddress.Clamp);
                graphics.Device.SetSamplerState(0, SamplerState.AddressV, TextureAddress.Clamp);
                graphics.Device.SetSamplerState(0, SamplerState.AddressW, TextureAddress.Clamp);

                // Render things collected
                foreach (KeyValuePair <ImageData, List <VisualThing> > group in thingspass)
                {
                    ImageData curtexture;

                    if (!(group.Key is UnknownImage))
                    {
                        // What texture to use?
                        if ((group.Key != null) && group.Key.IsImageLoaded && !group.Key.IsDisposed)
                        {
                            curtexture = group.Key;
                        }
                        else
                        {
                            curtexture = General.Map.Data.Hourglass3D;
                        }

                        // Create Direct3D texture if still needed
                        if ((curtexture.Texture == null) || curtexture.Texture.Disposed)
                        {
                            curtexture.CreateTexture();
                        }

                        // Apply texture
                        if (!graphics.Shaders.Enabled)
                        {
                            graphics.Device.SetTexture(0, curtexture.Texture);
                        }
                        graphics.Shaders.World3D.Texture1 = curtexture.Texture;

                        // Render all things with this texture
                        foreach (VisualThing t in group.Value)
                        {
                            // Update buffer if needed
                            t.Update();

                            // Only do this sector when a vertexbuffer is created
                            if (t.GeometryBuffer != null)
                            {
                                // Determine the shader pass we want to use for this object
                                int wantedshaderpass = (((t == highlighted) && showhighlight) || (t.Selected && showselection)) ? highshaderpass : shaderpass;

                                // Switch shader pass?
                                if (currentshaderpass != wantedshaderpass)
                                {
                                    graphics.Shaders.World3D.EndPass();
                                    graphics.Shaders.World3D.BeginPass(wantedshaderpass);
                                    currentshaderpass = wantedshaderpass;
                                }

                                // Set the colors to use
                                if (!graphics.Shaders.Enabled)
                                {
                                    graphics.Device.SetTexture(2, (t.Selected && showselection) ? selectionimage.Texture : null);
                                    graphics.Device.SetTexture(3, ((t == highlighted) && showhighlight) ? highlightimage.Texture : null);
                                }
                                else
                                {
                                    graphics.Shaders.World3D.SetHighlightColor(CalculateHighlightColor((t == highlighted) && showhighlight, (t.Selected && showselection)).ToArgb());
                                }

                                // Create the matrix for positioning / rotation
                                world = t.Orientation;
                                if (t.Billboard)
                                {
                                    world = Matrix.Multiply(world, billboard);
                                }
                                world = Matrix.Multiply(world, t.Position);
                                ApplyMatrices3D();
                                graphics.Shaders.World3D.ApplySettings();

                                // Apply buffer
                                graphics.Device.SetStreamSource(0, t.GeometryBuffer, 0, WorldVertex.Stride);

                                // Render!
                                graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, t.Triangles);
                            }
                        }
                    }
                }

                // Texture addressing
                graphics.Device.SetSamplerState(0, SamplerState.AddressU, TextureAddress.Wrap);
                graphics.Device.SetSamplerState(0, SamplerState.AddressV, TextureAddress.Wrap);
                graphics.Device.SetSamplerState(0, SamplerState.AddressW, TextureAddress.Wrap);
            }

            // Done rendering with this shader
            graphics.Shaders.World3D.EndPass();
        }
コード例 #19
0
 // Constructor
 public VisualMiddleDouble(BaseVisualMode mode, VisualSector vs, Sidedef s) : base(mode, vs, s)
 {
 }