unsafe void DrawAnimation(AnimationData data, int texId, int size)
        {
            TerrainAtlas1D atlas  = game.TerrainAtlas1D;
            int            index  = atlas.Get1DIndex(texId);
            int            rowNum = atlas.Get1DRowId(texId);
            byte *         temp   = stackalloc byte[size * size * 4];

            animPart.SetData(size, size, size * 4, (IntPtr)temp, false);

            if (data == null)
            {
                lavaAnim.Tick((int *)temp, size);
            }
            else
            {
                FastBitmap.MovePortion(data.FrameX + data.State * size,
                                       data.FrameY, 0, 0, animsBuffer, animPart, size);
            }
            api.UpdateTexturePart(atlas.TexIds[index], 0, rowNum * game.TerrainAtlas.elementSize, animPart);
        }
Пример #2
0
        unsafe void ApplyAnimation(AnimationData data)
        {
            data.Tick--;
            if (data.Tick >= 0)
            {
                return;
            }
            data.CurrentState++;
            data.CurrentState %= data.StatesCount;
            data.Tick          = data.TickDelay;

            TerrainAtlas1D atlas  = game.TerrainAtlas1D;
            int            texId  = (data.TileY << 4) | data.TileX;
            int            index  = atlas.Get1DIndex(texId);
            int            rowNum = atlas.Get1DRowId(texId);

            int        size = data.FrameSize;
            byte *     temp = stackalloc byte[size * size * 4];
            FastBitmap part = new FastBitmap(size, size, size * 4, (IntPtr)temp);

            FastBitmap.MovePortion(data.FrameX + data.CurrentState * size, data.FrameY, 0, 0, fastBmp, part, size);
            api.UpdateTexturePart(atlas.TexIds[index], 0, rowNum * game.TerrainAtlas.elementSize, part);
        }
Пример #3
0
        protected override void DrawModel( Player p )
        {
            // TODO: using 'is' is ugly, but means we can avoid creating
            // a string every single time held block changes.
            if( p is FakePlayer ) {
                col = game.World.IsLit( game.LocalPlayer.EyePosition )
                    ? game.World.Env.Sunlight : game.World.Env.Shadowlight;
                col = FastColour.Scale( col, 0.8f );
                block = ((FakePlayer)p).Block;
            } else {
                block = Utils.FastByte( p.ModelName );
            }

            CalcState( block );
            if( game.BlockInfo.IsAir[block] ) return;
            lastTexId = -1;
            atlas = game.TerrainAtlas1D;
            bool sprite = game.BlockInfo.IsSprite[block];

            if( sprite ) {
                SpriteXQuad( Side.Right, false, false );
                SpriteXQuad( Side.Right, false, true );
                SpriteZQuad( Side.Back, false, false );
                SpriteZQuad( Side.Back, false, true );

                SpriteZQuad( Side.Back, true, false );
                SpriteZQuad( Side.Back, true, true );
                SpriteXQuad( Side.Right, true, false );
                SpriteXQuad( Side.Right, true, true );
            } else {
                YQuad( 0, Side.Bottom, FastColour.ShadeYBottom );
                XQuad( maxBB.X - 0.5f, Side.Right, true, FastColour.ShadeX );
                ZQuad( minBB.Z - 0.5f, Side.Front, true, FastColour.ShadeZ );

                ZQuad( maxBB.Z - 0.5f, Side.Back, false, FastColour.ShadeZ );
                YQuad( height, Side.Top, 1.0f );
                XQuad( minBB.X - 0.5f, Side.Left, false, FastColour.ShadeX );
            }

            if( index == 0 ) return;
            graphics.BindTexture( lastTexId );
            TransformVertices();

            if( sprite ) graphics.FaceCulling = true;
            graphics.UpdateDynamicIndexedVb( DrawMode.Triangles, cache.vb, cache.vertices, index, index * 6 / 4 );
            if( sprite ) graphics.FaceCulling = false;
        }