Example #1
0
 public static void Invalidate(this TRObjectTexture texture)
 {
     texture.AtlasAndFlag = 0;
     foreach (TRObjectTextureVert vert in texture.Vertices)
     {
         vert.XCoordinate = vert.YCoordinate = _nullCoord;
     }
 }
Example #2
0
        // See TextureTransportHandler.ResetUnusedTextures
        public static bool IsValid(this TRObjectTexture texture)
        {
            if (texture.AtlasAndFlag == 0)
            {
                int coords = 0;
                foreach (TRObjectTextureVert vert in texture.Vertices)
                {
                    coords += vert.XCoordinate.Whole + vert.XCoordinate.Fraction + vert.YCoordinate.Whole + vert.XCoordinate.Fraction;
                }
                return(coords > 0);
            }

            return(texture.AtlasAndFlag != ushort.MaxValue);
        }
Example #3
0
        private List <IndexedTRObjectTexture> LoadObjectTextures()
        {
            List <IndexedTRObjectTexture> textures = new List <IndexedTRObjectTexture>((int)Level.NumObjectTextures);

            for (int i = 0; i < Level.NumObjectTextures; i++)
            {
                TRObjectTexture texture = Level.ObjectTextures[i];
                if (texture.IsValid())
                {
                    textures.Add(new IndexedTRObjectTexture
                    {
                        Index          = i,
                        Classification = _levelClassifier,
                        Texture        = texture
                    });
                }
            }
            return(textures);
        }
Example #4
0
        private IndexedTRObjectTexture CreateTexture(Rectangle rectangle)
        {
            // Make a dummy texture object with the given bounds
            TRObjectTexture texture = new TRObjectTexture
            {
                AtlasAndFlag = 0,
                Attribute    = 0,
                Vertices     = new TRObjectTextureVert[]
                {
                    CreatePoint(0, 0),
                    CreatePoint(rectangle.Width, 0),
                    CreatePoint(rectangle.Width, rectangle.Height),
                    CreatePoint(0, rectangle.Height)
                }
            };

            return(new IndexedTRObjectTexture
            {
                Index = 0,
                Texture = texture
            });
        }