Example #1
0
        public static void XNARenderFloorToBatch(r_local.sector_t sector, r_local.SectorBatch batch)
        {
            if (sector.triangleList == null)
            {
                return;
            }
            if (sector.triangleList.Count == 0)
            {
                return;
            }
            float floorH = sector.floorheight >> DoomDef.FRACBITS;
            {
                batch.textureId = sector.floorpic;
                int   prevSource = r_data.flattranslationPrev[sector.floorpic];
                int   tempSource = r_data.flattranslation[sector.floorpic];
                float uOffset    = 0;
                float vOffset    = 0;
                int   textureId  = 0;             // tempSource;
                batch.isUVAnimated = false;
                switch (sector.special)
                {
                case 25:
                case 26:
                case 27:
                case 28:
                case 29:                         // Scroll_North
                    textureId = tempSource;
                    break;

                case 20:
                case 21:
                case 22:
                case 23:
                case 24:                         // Scroll_East
                    uOffset            = (float)((63 - ((p_tick.leveltime >> 1) & 63)) << (sector.special - 20) & 63) / 64.0f;
                    textureId          = tempSource;
                    batch.isUVAnimated = true;
                    break;

                case 30:
                case 31:
                case 32:
                case 33:
                case 34:                         // Scroll_South
                    textureId = tempSource;
                    break;

                case 35:
                case 36:
                case 37:
                case 38:
                case 39:                         // Scroll_West
                    textureId = tempSource;
                    break;

                case 4:                         // Scroll_EastLavaDamage
                    uOffset            = (float)(((63 - ((p_tick.leveltime >> 1) & 63)) << 3) & 63) / 64.0f;
                    textureId          = tempSource;
                    batch.isUVAnimated = true;
                    break;

                default:
                    textureId = tempSource;
                    break;
                }

                Texture2D texture = Game1.instance.floorTexturesById[textureId];

                batch.texture = texture;
                for (int i = 0; i < sector.triangleList.Count; i += 3)
                {
                    r_data.Vector2AndTags p1 = sector.triangleList[i + 0];
                    r_data.Vector2AndTags p2 = sector.triangleList[i + 1];
                    r_data.Vector2AndTags p3 = sector.triangleList[i + 2];
                    Vector3 v1 = new Vector3(p1.p, floorH);
                    Vector3 v2 = new Vector3(p2.p, floorH);
                    Vector3 v3 = new Vector3(p3.p, floorH);
                    if (Settings.Default.use_deferred)
                    {
                        batch.vertsPNT.Add(new VertexPositionNormalTexture(
                                               v1,
                                               Vector3.UnitZ,
                                               new Vector2(v1.X / 64.0f + uOffset, -v1.Y / 64.0f + vOffset)));
                        batch.vertsPNT.Add(new VertexPositionNormalTexture(
                                               v2,
                                               Vector3.UnitZ,
                                               new Vector2(v2.X / 64.0f + uOffset, -v2.Y / 64.0f + vOffset)));
                        batch.vertsPNT.Add(new VertexPositionNormalTexture(
                                               v3,
                                               Vector3.UnitZ,
                                               new Vector2(v3.X / 64.0f + uOffset, -v3.Y / 64.0f + vOffset)));
                    }
                    else
                    {
                        batch.vertsPT.Add(new VertexPositionTexture(
                                              v1,
                                              new Vector2(v1.X / 64.0f + uOffset, -v1.Y / 64.0f + vOffset)));
                        batch.vertsPT.Add(new VertexPositionTexture(
                                              v2,
                                              new Vector2(v2.X / 64.0f + uOffset, -v2.Y / 64.0f + vOffset)));
                        batch.vertsPT.Add(new VertexPositionTexture(
                                              v3,
                                              new Vector2(v3.X / 64.0f + uOffset, -v3.Y / 64.0f + vOffset)));
                    }
                }
            }
        }
Example #2
0
 public static void XNARenderCeilToBatch(r_local.sector_t sector, r_local.SectorBatch batch)
 {
     if (sector.triangleList == null)
     {
         return;
     }
     if (sector.triangleList.Count == 0)
     {
         return;
     }
     float ceilH = sector.ceilingheight >> DoomDef.FRACBITS;
     {
         if (skyflatnum == sector.ceilingpic)
         {
             batch.isSky = true;
             //batch.texture = Game1.instance.wallTextures[r_plane.skytexture];
             batch.texture = Game1.instance.wallTexturesById[r_plane.skytexture];
         }
         else
         {
             batch.isSky   = false;
             batch.texture = Game1.instance.floorTexturesById[sector.ceilingpic];
         }
         batch.textureId = sector.ceilingpic;
         for (int i = 0; i < sector.triangleList.Count; i += 3)
         {
             r_data.Vector2AndTags p1 = sector.triangleList[i + 0];
             r_data.Vector2AndTags p2 = sector.triangleList[i + 1];
             r_data.Vector2AndTags p3 = sector.triangleList[i + 2];
             int     t1 = p1.groupTag;
             int     t2 = p2.groupTag;
             int     t3 = p3.groupTag;
             Vector3 v1 = new Vector3(
                 p1.p.X,
                 p1.p.Y,
                 ceilH);
             Vector3 v2 = new Vector3(
                 p2.p.X,
                 p2.p.Y,
                 ceilH);
             Vector3 v3 = new Vector3(
                 p3.p.X,
                 p3.p.Y,
                 ceilH);
             if (Settings.Default.use_deferred)
             {
                 batch.vertsPNT.Add(new VertexPositionNormalTexture(
                                        v2,
                                        -Vector3.UnitZ,
                                        new Vector2(v2.X / (float)batch.texture.Width, -v2.Y / (float)batch.texture.Height)));
                 batch.vertsPNT.Add(new VertexPositionNormalTexture(
                                        v1,
                                        -Vector3.UnitZ,
                                        new Vector2(v1.X / (float)batch.texture.Width, -v1.Y / (float)batch.texture.Height)));
                 batch.vertsPNT.Add(new VertexPositionNormalTexture(
                                        v3,
                                        -Vector3.UnitZ,
                                        new Vector2(v3.X / (float)batch.texture.Width, -v3.Y / (float)batch.texture.Height)));
             }
             else
             {
                 batch.vertsPT.Add(new VertexPositionTexture(
                                       v2,
                                       new Vector2(v2.X / (float)batch.texture.Width, -v2.Y / (float)batch.texture.Height)));
                 batch.vertsPT.Add(new VertexPositionTexture(
                                       v1,
                                       new Vector2(v1.X / (float)batch.texture.Width, -v1.Y / (float)batch.texture.Height)));
                 batch.vertsPT.Add(new VertexPositionTexture(
                                       v3,
                                       new Vector2(v3.X / (float)batch.texture.Width, -v3.Y / (float)batch.texture.Height)));
             }
         }
     }
 }