Ejemplo n.º 1
0
        protected override void DrawModel( Player p )
        {
            int texId = p.MobTextureId <= 0 ? cache.PigTexId : p.MobTextureId;
            graphics.BindTexture( texId );
            DrawHeadRotate( -p.PitchRadians, 0, 0, Head );

            DrawPart( Torso );
            DrawRotate( p.anim.legXRot, 0, 0, LeftLegFront );
            DrawRotate( -p.anim.legXRot, 0, 0, RightLegFront );
            DrawRotate( -p.anim.legXRot, 0, 0, LeftLegBack );
            DrawRotate( p.anim.legXRot, 0, 0, RightLegBack );
            graphics.UpdateDynamicIndexedVb( DrawMode.Triangles, cache.vb, cache.vertices, index, index * 6 / 4 );
        }
        protected override void DrawModel( Player p )
        {
            int texId = p.MobTextureId <= 0 ? cache.SkeletonTexId : p.MobTextureId;
            graphics.BindTexture( texId );
            DrawHeadRotate( -p.PitchRadians, 0, 0, Head );

            DrawPart( Torso );
            DrawRotate( p.anim.legXRot, 0, 0, LeftLeg );
            DrawRotate( -p.anim.legXRot, 0, 0, RightLeg );
            DrawRotate( 90 * Utils.Deg2Rad, 0, p.anim.armZRot, LeftArm );
            DrawRotate( 90 * Utils.Deg2Rad, 0, -p.anim.armZRot, RightArm );
            graphics.UpdateDynamicIndexedVb( DrawMode.Triangles, cache.vb, cache.vertices, index, index * 6 / 4 );
        }
Ejemplo n.º 3
0
        protected override void DrawModel( Player p )
        {
            int texId = p.MobTextureId <= 0 ? cache.SpiderTexId : p.MobTextureId;
            graphics.BindTexture( texId );
            DrawHeadRotate( -p.PitchRadians, 0, 0, Head );

            DrawPart( Link );
            DrawPart( End );
            float rotX = (float)(Math.Sin( p.anim.walkTime ) * p.anim.swing * Math.PI);
            float rotZ = (float)(Math.Cos( p.anim.walkTime * 2 ) * p.anim.swing * Math.PI / 16f);
            float rotY = (float)(Math.Sin( p.anim.walkTime * 2 ) * p.anim.swing * Math.PI / 32f);
            Rotate = RotateOrder.XZY;

            DrawRotate( rotX, quarterPi + rotY,  eighthPi + rotZ, LeftLeg );
            DrawRotate( -rotX, eighthPi + rotY, eighthPi + rotZ, LeftLeg );
            DrawRotate( rotX, -eighthPi - rotY, eighthPi - rotZ, LeftLeg );
            DrawRotate( -rotX, -quarterPi - rotY, eighthPi - rotZ, LeftLeg );
            DrawRotate( rotX, -quarterPi + rotY, -eighthPi + rotZ, RightLeg );
            DrawRotate( -rotX, -eighthPi + rotY, -eighthPi + rotZ, RightLeg );
            DrawRotate( rotX, eighthPi - rotY, -eighthPi - rotZ, RightLeg );
            DrawRotate( -rotX, quarterPi - rotY, -eighthPi - rotZ, RightLeg );
            Rotate = RotateOrder.ZYX;
            graphics.UpdateDynamicIndexedVb( DrawMode.Triangles, cache.vb, cache.vertices, index, index * 6 / 4 );
        }
Ejemplo n.º 4
0
 protected override void DrawModel( Player p )
 {
     int texId = p.TextureId <= 0 ? cache.HumanoidTexId : p.TextureId;
 }
Ejemplo n.º 5
0
        public byte GetClosetPlayer( Player src )
        {
            Vector3 eyePos = src.EyePosition;
            Vector3 dir = Utils.GetDirVector( src.HeadYawRadians, src.PitchRadians );
            float closestDist = float.PositiveInfinity;
            byte targetId = 255;

            for( int i = 0; i < Players.Length - 1; i++ ) { // -1 because we don't want to pick against local player
                Player p = Players[i];
                if( p == null ) continue;

                float t0, t1;
                if( Intersection.RayIntersectsRotatedBox( eyePos, dir, p, out t0, out t1 ) && t0 < closestDist ) {
                    closestDist = t0;
                    targetId = (byte)i;
                }
            }
            return targetId;
        }
Ejemplo n.º 6
0
        /// <summary> Renders the model based on the given entity's position and orientation. </summary>
        public void Render( Player p )
        {
            index = 0;
            pos = p.Position;
            if( Bobbing ) pos.Y += p.anim.bobYOffset;
            World map = game.World;
            col = game.World.IsLit( Vector3I.Floor( p.EyePosition ) ) ? map.Sunlight : map.Shadowlight;
            uScale = 1 / 64f; vScale = 1 / 32f;

            cols[0] = col;
            cols[1] = FastColour.Scale( col, FastColour.ShadeYBottom );
            cols[2] = FastColour.Scale( col, FastColour.ShadeZ ); cols[3] = cols[2];
            cols[4] = FastColour.Scale( col, FastColour.ShadeX ); cols[5] = cols[4];

            cosYaw = (float)Math.Cos( p.YawDegrees * Utils.Deg2Rad );
            sinYaw = (float)Math.Sin( p.YawDegrees * Utils.Deg2Rad );
            cosHead = (float)Math.Cos( p.HeadYawDegrees * Utils.Deg2Rad );
            sinHead = (float)Math.Sin( p.HeadYawDegrees * Utils.Deg2Rad );

            graphics.SetBatchFormat( VertexFormat.P3fT2fC4b );
            DrawModel( p );
        }
Ejemplo n.º 7
0
 protected abstract void DrawModel( Player p );
Ejemplo n.º 8
0
 public override bool ShouldRender( Player p, FrustumCulling culling )
 {
     block = Utils.FastByte( p.ModelName );
     CalcState( block );
     return base.ShouldRender( p, culling );
 }
Ejemplo n.º 9
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;
        }
Ejemplo n.º 10
0
 /// <summary> Returns whether the model should be rendered based on the given entity's position. </summary>
 public virtual bool ShouldRender( Player p, FrustumCulling culling )
 {
     Vector3 pos = p.Position;
     AABB bb = PickingBounds;
     float maxLen = Math.Max( bb.Width, Math.Max( bb.Height, bb.Length ) );
     maxLen *= p.ModelScale;
     return culling.SphereInFrustum( pos.X, pos.Y + maxLen / 2, pos.Z, maxLen );
 }
Ejemplo n.º 11
0
        protected override void DrawModel( Player p )
        {
            int texId = p.TextureId <= 0 ? cache.HumanoidTexId : p.TextureId;
            graphics.BindTexture( texId );
            graphics.AlphaTest = false;

            SkinType skinType = p.SkinType;
            bool _64x64 = skinType != SkinType.Type64x32;
            uScale = p.uScale / 64f;
            vScale = p.vScale / (_64x64 ? 64 : 32);
            ModelSet model = skinType == SkinType.Type64x64Slim ? SetSlim :
                (skinType == SkinType.Type64x64 ? Set64 : Set);

            DrawHeadRotate( -p.PitchRadians, 0, 0, model.Head );
            DrawPart( model.Torso );

            DrawRotate( p.anim.legXRot, 0, 0, model.LeftLeg );
            DrawRotate( -p.anim.legXRot, 0, 0, model.RightLeg );
            Rotate = RotateOrder.XZY;
            DrawRotate( p.anim.leftXRot, 0, p.anim.leftZRot, model.LeftArm );
            DrawRotate( p.anim.rightXRot, 0, p.anim.rightZRot, model.RightArm );
            Rotate = RotateOrder.ZYX;
            graphics.UpdateDynamicIndexedVb( DrawMode.Triangles, cache.vb, cache.vertices, index, index * 6 / 4 );

            graphics.AlphaTest = true;
            index = 0;
            if( _64x64 ) {
                DrawPart( model.TorsoLayer );
                DrawRotate( p.anim.legXRot, 0, 0, model.LeftLegLayer );
                DrawRotate( -p.anim.legXRot, 0, 0, model.RightLegLayer );
                Rotate = RotateOrder.XZY;
                DrawRotate( p.anim.leftXRot, 0, p.anim.leftZRot, model.LeftArmLayer );
                DrawRotate( p.anim.rightXRot, 0, p.anim.rightZRot, model.RightArmLayer );
                Rotate = RotateOrder.ZYX;
            }
            DrawHeadRotate( -p.PitchRadians, 0, 0, model.Hat );
            graphics.UpdateDynamicIndexedVb( DrawMode.Triangles, cache.vb, cache.vertices, index, index * 6 / 4 );
        }
Ejemplo n.º 12
0
        protected override void DrawModel( Player p )
        {
            int texId = p.MobTextureId <= 0 ? cache.ChickenTexId : p.MobTextureId;
            graphics.BindTexture( texId );

            DrawHeadRotate( -p.PitchRadians, 0, 0, Head );
            DrawHeadRotate( -p.PitchRadians, 0, 0, Head2 );
            DrawHeadRotate( -p.PitchRadians, 0, 0, Head3 );

            DrawPart( Torso );
            DrawRotate( p.anim.legXRot, 0, 0, LeftLeg );
            DrawRotate( -p.anim.legXRot, 0, 0, RightLeg );
            DrawRotate( 0, 0, -Math.Abs( p.anim.armXRot ), LeftWing );
            DrawRotate( 0, 0, Math.Abs( p.anim.armXRot ), RightWing );
            graphics.UpdateDynamicIndexedVb( DrawMode.Triangles, cache.vb, cache.vertices, index, index * 6 / 4 );
        }