예제 #1
0
        static byte[] newsky     = new byte[128 * 256]; // newsky and topsky both pack in here, 128 bytes
        //  of newsky on the left of each scan, 128 bytes
        //  of topsky on the right, because the low-level
        //  drawers need 256-byte scan widths

        /*
         * =============
         * R_InitSky
         *
         * A sky texture is 256*128, with the right side being a masked overlay
         * ==============
         */
        public static void R_InitSky(model.texture_t mt)
        {
            int i, j;
            int src;

            src = (int)mt.offsets[0];

            for (i = 0; i < 128; i++)
            {
                for (j = 0; j < 128; j++)
                {
                    newsky[(i * 256) + j + 128] = mt.pixels[src + i * 256 + j + 128];
                }
            }

            for (i = 0; i < 128; i++)
            {
                for (j = 0; j < 131; j++)
                {
                    if (mt.pixels[src + i * 256 + (j & 0x7F)] != 0)
                    {
                        bottomsky[(i * 131) + j]  = mt.pixels[src + i * 256 + (j & 0x7F)];
                        bottommask[(i * 131) + j] = 0;
                    }
                    else
                    {
                        bottomsky[(i * 131) + j]  = 0;
                        bottommask[(i * 131) + j] = 0xff;
                    }
                }
            }

            r_skysource = newsky;
        }
예제 #2
0
        /*
         * ==================
         * R_InitTextures
         * ==================
         */
        public static void R_InitTextures()
        {
            int x, y, m;
            int dest;

            // create a simple checkerboard texture for the default
            r_notexture_mip        = new model.texture_t();
            r_notexture_mip.pixels = new byte[16 * 16 + 8 * 8 + 4 * 4 + 2 * 2];

            r_notexture_mip.width      = r_notexture_mip.height = 16;
            r_notexture_mip.offsets[0] = 0;
            r_notexture_mip.offsets[1] = r_notexture_mip.offsets[0] + 16 * 16;
            r_notexture_mip.offsets[2] = r_notexture_mip.offsets[1] + 8 * 8;
            r_notexture_mip.offsets[3] = r_notexture_mip.offsets[2] + 4 * 4;

            for (m = 0; m < 4; m++)
            {
                dest = (int)r_notexture_mip.offsets[m];
                for (y = 0; y < (16 >> m); y++)
                {
                    for (x = 0; x < (16 >> m); x++)
                    {
                        if ((y < (8 >> m)) ^ (x < (8 >> m)))
                        {
                            r_notexture_mip.pixels[dest++] = 0;
                        }
                        else
                        {
                            r_notexture_mip.pixels[dest++] = 0xff;
                        }
                    }
                }
            }
        }
예제 #3
0
        /*
         * ===============
         * R_TextureAnimation
         *
         * Returns the proper texture for a given time and base texture
         * ===============
         */
        public static model.texture_t R_TextureAnimation(model.texture_t @base)
        {
            int reletive;
            int count;

            if (currententity.frame != 0)
            {
                if (@base.alternate_anims != null)
                {
                    @base = @base.alternate_anims;
                }
            }

            if (@base.anim_total == 0)
            {
                return(@base);
            }

            reletive = (int)(client.cl.time * 10) % @base.anim_total;

            count = 0;
            while (@base.anim_min > reletive || @base.anim_max <= reletive)
            {
                @base = @base.anim_next;
                if (@base == null)
                {
                    sys_linux.Sys_Error("R_TextureAnimation: broken cycle");
                }
                if (++count > 100)
                {
                    sys_linux.Sys_Error("R_TextureAnimation: infinite cycle");
                }
            }

            return(@base);
        }