protected void DrawPart(ModelPart part)
        {
            VertexP3fT2fC4b vertex = default(VertexP3fT2fC4b);

            for (int i = 0; i < part.Count; i++)
            {
                ModelVertex v = vertices[part.Offset + i];
                float       t = cosYaw * v.X - sinYaw * v.Z; v.Z = sinYaw * v.X + cosYaw * v.Z; v.X = t;           // Inlined RotY
                v.X *= scale; v.Y *= scale; v.Z *= scale;
                v.X += pos.X; v.Y += pos.Y; v.Z += pos.Z;

                FastColour col = part.Count == boxVertices ?
                                 cols[i >> 2] : FastColour.Scale(this.col, 0.7f);
                vertex.X = v.X; vertex.Y = v.Y; vertex.Z = v.Z;
                vertex.R = col.R; vertex.G = col.G; vertex.B = col.B; vertex.A = 255;

                vertex.U = v.U * uScale; vertex.V = v.V * vScale;
                int quadI = i & 3;
                if (quadI == 0 || quadI == 3)
                {
                    vertex.V -= 0.01f * vScale;
                }
                if (quadI == 2 || quadI == 3)
                {
                    vertex.U -= 0.01f * uScale;
                }
                cache.vertices[index++] = vertex;
            }
        }
        protected void DrawPart(ModelPart part)
        {
            VertexP3fT2fC4b vertex = default(VertexP3fT2fC4b);

            VertexP3fT2fC4b[] finVertices = game.ModelCache.vertices;

            for (int i = 0; i < part.Count; i++)
            {
                ModelVertex v = vertices[part.Offset + i];
                vertex.X      = v.X; vertex.Y = v.Y; vertex.Z = v.Z;
                vertex.Colour = cols[i >> 2];

                vertex.U = v.U * uScale; vertex.V = v.V * vScale;
                int quadI = i & 3;
                if (quadI == 0 || quadI == 3)
                {
                    vertex.V -= 0.01f * vScale;
                }
                if (quadI == 2 || quadI == 3)
                {
                    vertex.U -= 0.01f * uScale;
                }
                finVertices[index++] = vertex;
            }
        }
        protected void DrawPart(ModelPart part)
        {
            VertexP3fT2fC4b vertex = default(VertexP3fT2fC4b);

            VertexP3fT2fC4b[] finVertices = game.ModelCache.vertices;

            for (int i = 0; i < part.Count; i++)
            {
                ModelVertex v = vertices[part.Offset + i];
                float       t = cosYaw * v.X - sinYaw * v.Z; v.Z = sinYaw * v.X + cosYaw * v.Z; v.X = t;           // Inlined RotY
                v.X          *= scale; v.Y *= scale; v.Z *= scale;
                v.X          += pos.X; v.Y += pos.Y; v.Z += pos.Z;
                vertex.X      = v.X; vertex.Y = v.Y; vertex.Z = v.Z;
                vertex.Colour = part.Count == boxVertices ? cols[i >> 2] : otherCol;

                vertex.U = v.U * uScale; vertex.V = v.V * vScale;
                int quadI = i & 3;
                if (quadI == 0 || quadI == 3)
                {
                    vertex.V -= 0.01f * vScale;
                }
                if (quadI == 2 || quadI == 3)
                {
                    vertex.U -= 0.01f * uScale;
                }
                finVertices[index++] = vertex;
            }
        }
Beispiel #4
0
        public override void CreateParts()
        {
            vertices = new ModelVertex[boxVertices * 2];
            head     = MakeBoxBounds(-4, 0, -4, 4, 8, 4).RotOrigin(0, 4, 0);

            Head = BuildBox(head.TexOrigin(0, 0));
            Hat  = BuildBox(head.TexOrigin(32, 0).Expand(offset));
        }
Beispiel #5
0
 public SpiderModel( Game window )
     : base(window)
 {
     vertices = new ModelVertex[partVertices * 5];
     Head = MakeHead();
     Link = MakeLink();
     End = MakeEnd();
     LeftLeg = MakeLeg( -19/16f, -3/16f );
     RightLeg = MakeLeg( 3/16f, 19/16f );
 }
Beispiel #6
0
 public CreeperModel( Game window )
     : base(window)
 {
     vertices = new ModelVertex[partVertices * 6];
     Head = MakeHead();
     Torso = MakeTorso();
     LeftLegFront = MakeLeg( -4/16f, 0, -6/16f, -2/16f );
     RightLegFront = MakeLeg( 0, 4/16f, -6/16f, -2/16f );
     LeftLegBack = MakeLeg( -4/16f, 0, 2/16f, 6/16f );
     RightLegBack = MakeLeg( 0, 4/16f, 2/16f, 6/16f );
 }
Beispiel #7
0
 public ZombieModel( Game window )
     : base(window)
 {
     vertices = new ModelVertex[partVertices * 6];
     Head = MakeHead();
     Torso = MakeTorso();
     LeftLeg = MakeLeftLeg( 4/16f, 0f );
     RightLeg = MakeRightLeg( 0, 4/16f );
     LeftArm = MakeLeftArm( 8/16f, 4/16f );
     RightArm = MakeRightArm( 4/16f, 8/16f );
 }
 public SkeletonModel( Game window )
     : base(window)
 {
     vertices = new ModelVertex[boxVertices * 6];
     Head = MakeHead();
     Torso = MakeTorso();
     LeftLeg = MakeLeftLeg( 3/16f, 1/16f );
     RightLeg = MakeRightLeg( 1/16f, 3/16f );
     LeftArm = MakeLeftArm( 6/16f, 4/16f );
     RightArm = MakeRightArm( 4/16f, 6/16f );
 }
Beispiel #9
0
 public PigModel( Game window )
     : base(window)
 {
     vertices = new ModelVertex[boxVertices * 6];
     Head = MakeHead();
     Torso = MakeTorso();
     LeftLegFront = MakeLeg( -5/16f, -1/16f, -7/16f, -3/16f );
     RightLegFront = MakeLeg( 1/16f, 5/16f, -7/16f, -3/16f );
     LeftLegBack = MakeLeg( -5/16f, -1/16f, 5/16f, 9/16f );
     RightLegBack = MakeLeg( 1/16f, 5/16f, 5/16f, 9/16f );
 }
Beispiel #10
0
 void DrawArmPart(ModelPart part)
 {
     part.RotX += 1 / 16.0f; part.RotY -= 4 / 16.0f;
     if (game.ClassicArmModel)
     {
         DrawRotate(0, -90 * Utils.Deg2Rad, 120 * Utils.Deg2Rad, part, false);
     }
     else
     {
         DrawRotate(-20 * Utils.Deg2Rad, -70 * Utils.Deg2Rad, 135 * Utils.Deg2Rad, part, false);
     }
 }
Beispiel #11
0
 protected void DrawArmPart(ModelPart part)
 {
     part.RotX = armX / 16.0f; part.RotY = (armY + armY / 2) / 16.0f;
     if (game.ClassicArmModel)
     {
         DrawRotate(0, -90 * Utils.Deg2Rad, 120 * Utils.Deg2Rad, part, false);
     }
     else
     {
         DrawRotate(-20 * Utils.Deg2Rad, -70 * Utils.Deg2Rad, 135 * Utils.Deg2Rad, part, false);
     }
 }
Beispiel #12
0
 public ChickenModel( Game window )
     : base(window)
 {
     vertices = new ModelVertex[partVertices * 6 + planeVertices * 2 * 2];
     Head = MakeHead();
     Head2 = MakeHead2(); // TODO: Find a more appropriate name.
     Head3 = MakeHead3();
     Torso = MakeTorso();
     LeftLeg = MakeLeg( -3/16f, 0f, -2/16f, -1/16f );
     RightLeg = MakeLeg( 0f, 3/16f, 1/16f, 2/16f );
     LeftWing = MakeWing( -4/16f, -3/16f );
     RightWing = MakeWing( 3/16f, 4/16f );
 }
        protected void DrawRotate(float angleX, float angleY, float angleZ, ModelPart part, bool head)
        {
            float           cosX = (float)Math.Cos(-angleX), sinX = (float)Math.Sin(-angleX);
            float           cosY = (float)Math.Cos(-angleY), sinY = (float)Math.Sin(-angleY);
            float           cosZ = (float)Math.Cos(-angleZ), sinZ = (float)Math.Sin(-angleZ);
            float           x = part.RotX, y = part.RotY, z = part.RotZ;
            VertexP3fT2fC4b vertex = default(VertexP3fT2fC4b);

            VertexP3fT2fC4b[] finVertices = game.ModelCache.vertices;

            for (int i = 0; i < part.Count; i++)
            {
                ModelVertex v = vertices[part.Offset + i];
                v.X -= x; v.Y -= y; v.Z -= z;
                float t = 0;

                // Rotate locally
                if (Rotate == RotateOrder.ZYX)
                {
                    t = cosZ * v.X + sinZ * v.Y; v.Y = -sinZ * v.X + cosZ * v.Y; v.X = t;                     // Inlined RotZ
                    t = cosY * v.X - sinY * v.Z; v.Z = sinY * v.X + cosY * v.Z; v.X = t;                      // Inlined RotY
                    t = cosX * v.Y + sinX * v.Z; v.Z = -sinX * v.Y + cosX * v.Z; v.Y = t;                     // Inlined RotX
                }
                else if (Rotate == RotateOrder.XZY)
                {
                    t = cosX * v.Y + sinX * v.Z; v.Z = -sinX * v.Y + cosX * v.Z; v.Y = t;                     // Inlined RotX
                    t = cosZ * v.X + sinZ * v.Y; v.Y = -sinZ * v.X + cosZ * v.Y; v.X = t;                     // Inlined RotZ
                    t = cosY * v.X - sinY * v.Z; v.Z = sinY * v.X + cosY * v.Z; v.X = t;                      // Inlined RotY
                }

                // Rotate globally
                if (head)
                {
                    t = cosHead * v.X - sinHead * v.Z; v.Z = sinHead * v.X + cosHead * v.Z; v.X = t;                     // Inlined RotY
                }
                vertex.X      = v.X + x; vertex.Y = v.Y + y; vertex.Z = v.Z + z;
                vertex.Colour = cols[i >> 2];

                vertex.U = v.U * uScale; vertex.V = v.V * vScale;
                int quadI = i & 3;
                if (quadI == 0 || quadI == 3)
                {
                    vertex.V -= 0.01f * vScale;
                }
                if (quadI == 2 || quadI == 3)
                {
                    vertex.U -= 0.01f * vScale;
                }
                finVertices[index++] = vertex;
            }
        }
Beispiel #14
0
        protected void DrawPart( ModelPart part )
        {
            float vScale = _64x64 ? 64f : 32f;
            for( int i = 0; i < part.Count; i++ ) {
                ModelVertex model = vertices[part.Offset + i];
                Vector3 newPos = Utils.RotateY( model.X, model.Y, model.Z, cosA, sinA ) + pos;

                VertexPos3fTex2fCol4b vertex = default( VertexPos3fTex2fCol4b );
                vertex.X = newPos.X; vertex.Y = newPos.Y; vertex.Z = newPos.Z;
                vertex.R = col.R; vertex.G = col.G; vertex.B = col.B; vertex.A = 255;
                AdjustUV( model.U, model.V, vScale, i, ref vertex );
                cache.vertices[index++] = vertex;
            }
        }
Beispiel #15
0
        public override void DrawModel(Entity p)
        {
            ApplyTexture(p);
            HumanoidModel human = (HumanoidModel)game.ModelCache.Models[0].Instance;

            vertices = human.vertices;

            ModelPart part = human.Set.Head; part.RotY += 4 / 16f;

            DrawRotate(-p.HeadXRadians, 0, 0, part, true);
            part = human.Set.Hat; part.RotY += 4 / 16f;
            DrawRotate(-p.HeadXRadians, 0, 0, part, true);

            UpdateVB();
        }
 public SpiderModel( Game window )
     : base(window)
 {
     vertices = new ModelVertex[boxVertices * 5];
     Head = BuildBox( MakeBoxBounds( -4, 4, -11, 4, 12, -3 )
                     .SetTexOrigin( 32, 4 ) );
     Link = BuildBox( MakeBoxBounds( -3, 5, 3, 3, 11, -3 )
                    .SetTexOrigin( 0, 0 ) );
     End = BuildBox( MakeBoxBounds( -5, 4, 3, 5, 12, 15 )
                    .SetTexOrigin( 0, 12 ) );
     LeftLeg = BuildBox( MakeBoxBounds( -19, 7, -1, -3, 9, 1 )
                        .SetTexOrigin( 18, 0 ) );
     RightLeg = BuildBox( MakeBoxBounds( 3, 7, -1, 19, 9, 1 )
                        .SetTexOrigin( 18, 0 ) );
 }
Beispiel #17
0
        protected void DrawPart(ModelPart part)
        {
            VertexP3fT2fC4b vertex = default(VertexP3fT2fC4b);

            VertexP3fT2fC4b[] finVertices = game.ModelCache.vertices;

            for (int i = 0; i < part.Count; i++)
            {
                ModelVertex v = vertices[part.Offset + i];
                vertex.X      = v.X; vertex.Y = v.Y; vertex.Z = v.Z;
                vertex.Colour = cols[i >> 2];

                vertex.U             = (v.U & UVMask) * uScale - (v.U >> UVMaxShift) * 0.01f * uScale;
                vertex.V             = (v.V & UVMask) * vScale - (v.V >> UVMaxShift) * 0.01f * vScale;
                finVertices[index++] = vertex;
            }
        }
Beispiel #18
0
 public PigModel( Game window )
     : base(window)
 {
     vertices = new ModelVertex[boxVertices * 6];
     Head = BuildBox( MakeBoxBounds( -4, 8, -14, 4, 16, -6 )
                    .SetTexOrigin( 0, 0 ) );
     Torso = BuildRotatedBox( MakeRotatedBoxBounds( -5, 6, -8, 5, 14, 8 )
                             .SetTexOrigin( 28, 8 ) );
     LeftLegFront = BuildBox( MakeBoxBounds( -5, 0, -7, -1, 6, -3 )
                             .SetTexOrigin( 0, 16 ) );
     RightLegFront = BuildBox( MakeBoxBounds( 1, 0, -7, 5, 6, -3 )
                              .SetTexOrigin( 0, 16 ) );
     LeftLegBack = BuildBox( MakeBoxBounds( -5, 0, 5, -1, 6, 9 )
                            .SetTexOrigin( 0, 16 ) );
     RightLegBack = BuildBox( MakeBoxBounds( 1, 0, 5, 5, 6, 9 )
                             .SetTexOrigin( 0, 16 ) );
 }
Beispiel #19
0
        protected void DrawPart(ModelPart part)
        {
            float vScale = _64x64 ? 64f : 32f;

            for (int i = 0; i < part.Count; i++)
            {
                ModelVertex model  = vertices[part.Offset + i];
                Vector3     newPos = Utils.RotateY(model.X, model.Y, model.Z, cosA, sinA) + pos;

                FastColour            col    = GetCol(i, part.Count);
                VertexPos3fTex2fCol4b vertex = default(VertexPos3fTex2fCol4b);
                vertex.X = newPos.X; vertex.Y = newPos.Y; vertex.Z = newPos.Z;
                vertex.R = col.R; vertex.G = col.G; vertex.B = col.B; vertex.A = 255;
                AdjustUV(model.U, model.V, vScale, i, ref vertex);
                cache.vertices[index++] = vertex;
            }
        }
Beispiel #20
0
        protected override void RenderParts(Entity p)
        {
            HumanoidModel human = (HumanoidModel)game.ModelCache.Models[0].Instance;

            vertices = human.vertices;

            ModelPart part = human.Set.Head; part.RotY += 4 / 16f;

            DrawRotate(-p.HeadXRadians, 0, 0, part, true);
            UpdateVB();

            game.Graphics.AlphaTest = true;
            index = 0;
            part  = human.Set.Hat; part.RotY += 4 / 16f;
            DrawRotate(-p.HeadXRadians, 0, 0, part, true);
            UpdateVB();
        }
 public SkeletonModel( Game window )
     : base(window)
 {
     vertices = new ModelVertex[boxVertices * 6];
     Head = BuildBox( MakeBoxBounds( -4, 24, -4, 4, 32, 4 )
                     .SetTexOrigin( 0, 0 ) );
     Torso = BuildBox( MakeBoxBounds( -4, 12, -2, 4, 24, 2 )
                      .SetTexOrigin( 16, 16 ) );
     LeftLeg = BuildBox( MakeBoxBounds( -1, 0, -1, -3, 12, 1 )
                        .SetTexOrigin( 0, 16 ) );
     RightLeg = BuildBox( MakeBoxBounds( 1, 0, -1, 3, 12, 1 )
                             .SetTexOrigin( 0, 16 ) );
     LeftArm = BuildBox( MakeBoxBounds( -4, 12, -1, -6, 24, 1 )
                        .SetTexOrigin( 40, 16 ) );
     RightArm = BuildBox( MakeBoxBounds( 4, 12, -1, 6, 24, 1 )
                        .SetTexOrigin( 40, 16 ) );
 }
 public ZombieModel( Game window )
     : base(window)
 {
     vertices = new ModelVertex[boxVertices * 6];
     Head = BuildBox( MakeBoxBounds( -4, 24, -4, 4, 32, 4 )
                     .SetTexOrigin( 0, 0 ) );
     Torso =  BuildBox( MakeBoxBounds( -4, 12, -2, 4, 24, 2 )
                       .SetTexOrigin( 16, 16 ) );
     LeftLeg =  BuildBox( MakeBoxBounds( 0, 0, -2, -4, 12, 2 )
                         .SetTexOrigin( 0, 16 ) );
     RightLeg = BuildBox( MakeBoxBounds( 0, 0, -2, 4, 12, 2 )
                         .SetTexOrigin( 0, 16 ) );
     LeftArm = BuildBox( MakeBoxBounds( -4, 12, -2, -8, 24, 2 )
                        .SetTexOrigin( 40, 16 ) );
     RightArm = BuildBox( MakeBoxBounds( 4, 12, -2, 8, 24, 2 )
                         .SetTexOrigin( 40, 16 ) );
 }
 internal override void CreateParts()
 {
     vertices = new ModelVertex[boxVertices * 5];
     Head = BuildBox( MakeBoxBounds( -4, 4, -11, 4, 12, -3 )
                     .TexOrigin( 32, 4 )
                     .RotOrigin( 0, 8, -3 ) );
     Link = BuildBox( MakeBoxBounds( -3, 5, 3, 3, 11, -3 )
                     .TexOrigin( 0, 0 ) );
     End = BuildBox( MakeBoxBounds( -5, 4, 3, 5, 12, 15 )
                    .TexOrigin( 0, 12 ) );
     LeftLeg = BuildBox( MakeBoxBounds( -19, 7, -1, -3, 9, 1 )
                        .TexOrigin( 18, 0 )
                        .RotOrigin( -3, 8, 0 ) );
     RightLeg = BuildBox( MakeBoxBounds( 3, 7, -1, 19, 9, 1 )
                         .TexOrigin( 18, 0 )
                         .RotOrigin( 3, 8, 0 ) );
 }
        public CreeperModel( Game window )
            : base(window)
        {
            vertices = new ModelVertex[boxVertices * 6];
            Head =  BuildBox( MakeBoxBounds( -4, 18, -4, 4, 26, 4 )
                             .SetTexOrigin( 0, 0 ) );
            Torso = BuildBox( MakeBoxBounds( -4, 6, -2, 4, 18, 2 )
                             .SetTexOrigin( 16, 16 ) );

            LeftLegFront = BuildBox( MakeBoxBounds( -4, 0, -6, 0, 6, -2 )
                     .SetTexOrigin( 0, 16 ) );
            RightLegFront = BuildBox( MakeBoxBounds( 0, 0, -6, 4, 6, -2 )
                     .SetTexOrigin( 0, 16 ) );
            LeftLegBack = BuildBox( MakeBoxBounds( -4, 0, 2, 0, 6, 6 )
                     .SetTexOrigin( 0, 16 ) );
            RightLegBack = BuildBox( MakeBoxBounds( 0, 0, 2, 4, 6, 6 )
                     .SetTexOrigin( 0, 16 ) );
        }
Beispiel #25
0
 public SheepModel( Game window )
     : base(window)
 {
     vertices = new ModelVertex[boxVertices * 6 * ( Fur ? 2 : 1 )];
     Head = MakeHead();
     Torso = MakeTorso();
     LeftLegFront = MakeLeg( -5/16f, -1/16f, -7/16f, -3/16f );
     RightLegFront = MakeLeg( 1/16f, 5/16f, -7/16f, -3/16f );
     LeftLegBack = MakeLeg( -5/16f, -1/16f, 5/16f, 9/16f );
     RightLegBack = MakeLeg( 1/16f, 5/16f, 5/16f, 9/16f );
     if( Fur ) {
         FurHead = MakeFurHead();
         FurTorso = MakeFurTorso();
         FurLeftLegFront = MakeFurLeg( -5.5f/16f, -0.5f/16f, -7.5f/16f, -2.5f/16f );
         FurRightLegFront = MakeFurLeg( 0.5f/16f, 5.5f/16f, -7.5f/16f, -2.5f/16f );
         FurLeftLegBack = MakeFurLeg( -5.5f/16f, -0.5f/16f, 4.5f/16f, 9.5f/16f );
         FurRightLegBack = MakeFurLeg( 0.5f/16f, 5.5f/16f, 4.5f/16f, 9.5f/16f );
     }
 }
 public SheepModel( Game window )
     : base(window)
 {
     vertices = new ModelVertex[boxVertices * 6 * ( Fur ? 2 : 1 )];
     Head = BuildBox( MakeBoxBounds( -3, 16, -14, 3, 22, -6 )
                     .SetTexOrigin( 0, 0 ) );
     Torso = BuildRotatedBox( MakeRotatedBoxBounds( -4, 12, -8, 4, 18, 8 )
                             .SetTexOrigin( 28, 8 ) );
     LeftLegFront = BuildBox( MakeBoxBounds( -5, 0, -7, -1, 12, -3 )
                             .SetTexOrigin( 0, 16 ) );
     RightLegFront = BuildBox( MakeBoxBounds( 1, 0, -7, 5, 12, -3 )
                              .SetTexOrigin( 0, 16 ) );
     LeftLegBack = BuildBox( MakeBoxBounds( -5, 0, 5, -1, 12, 9 )
                            .SetTexOrigin( 0, 16 ) );
     RightLegBack = BuildBox( MakeBoxBounds( 1, 0, 5, 5, 12, 9 )
                             .SetTexOrigin( 0, 16 ) );
     if( Fur )
         MakeFurModel();
 }
Beispiel #27
0
 internal override void CreateParts()
 {
     vertices = new ModelVertex[boxVertices * 6];
     Head = BuildBox( MakeBoxBounds( -4, 8, -14, 4, 16, -6 )
                    .TexOrigin( 0, 0 )
                    .RotOrigin( 0, 12, -6 ) );
     Torso = BuildRotatedBox( MakeRotatedBoxBounds( -5, 6, -8, 5, 14, 8 )
                             .TexOrigin( 28, 8 ) );
     LeftLegFront = BuildBox( MakeBoxBounds( -5, 0, -7, -1, 6, -3 )
                             .TexOrigin( 0, 16 )
                             .RotOrigin( 0, 6, -5 ) );
     RightLegFront = BuildBox( MakeBoxBounds( 1, 0, -7, 5, 6, -3 )
                              .TexOrigin( 0, 16 )
                              .RotOrigin( 0, 6, -5 ) );
     LeftLegBack = BuildBox( MakeBoxBounds( -5, 0, 5, -1, 6, 9 )
                            .TexOrigin( 0, 16 )
                            .RotOrigin( 0, 6, 7 ) );
     RightLegBack = BuildBox( MakeBoxBounds( 1, 0, 5, 5, 6, 9 )
                             .TexOrigin( 0, 16 )
                             .RotOrigin( 0, 6, 7 ) );
 }
 internal override void CreateParts()
 {
     vertices = new ModelVertex[boxVertices * 6];
     Head = BuildBox( MakeBoxBounds( -4, 24, -4, 4, 32, 4 )
                     .TexOrigin( 0, 0 )
                     .RotOrigin( 0, 24, 0 ) );
     Torso = BuildBox( MakeBoxBounds( -4, 12, -2, 4, 24, 2 )
                      .TexOrigin( 16, 16 ) );
     LeftLeg = BuildBox( MakeBoxBounds( -1, 0, -1, -3, 12, 1 )
                        .TexOrigin( 0, 16 )
                        .RotOrigin( 0, 12, 0 ) );
     RightLeg = BuildBox( MakeBoxBounds( 1, 0, -1, 3, 12, 1 )
                         .TexOrigin( 0, 16 )
                         .RotOrigin( 0, 12, 0 ) );
     LeftArm = BuildBox( MakeBoxBounds( -4, 12, -1, -6, 24, 1 )
                        .TexOrigin( 40, 16 )
                        .RotOrigin( -5, 23, 0 ) );
     RightArm = BuildBox( MakeBoxBounds( 4, 12, -1, 6, 24, 1 )
                         .TexOrigin( 40, 16 )
                         .RotOrigin( 5, 23, 0 ) );
 }
Beispiel #29
0
        internal override void CreateParts()
        {
            vertices = new ModelVertex[boxVertices * 6];
            Head =  BuildBox( MakeBoxBounds( -4, 18, -4, 4, 26, 4 )
                             .TexOrigin( 0, 0 )
                             .RotOrigin( 0, 18, 0 ) );
            Torso = BuildBox( MakeBoxBounds( -4, 6, -2, 4, 18, 2 )
                             .TexOrigin( 16, 16 ) );

            LeftLegFront = BuildBox( MakeBoxBounds( -4, 0, -6, 0, 6, -2 )
                                    .TexOrigin( 0, 16 )
                                    .RotOrigin( 0, 6, -2 ) );
            RightLegFront = BuildBox( MakeBoxBounds( 0, 0, -6, 4, 6, -2 )
                                     .TexOrigin( 0, 16 )
                                     .RotOrigin( 0, 6, -2 ) );
            LeftLegBack = BuildBox( MakeBoxBounds( -4, 0, 2, 0, 6, 6 )
                                   .TexOrigin( 0, 16 )
                                   .RotOrigin( 0, 6, 2 ) );
            RightLegBack = BuildBox( MakeBoxBounds( 0, 0, 2, 4, 6, 6 )
                                    .TexOrigin( 0, 16 )
                                    .RotOrigin( 0, 6, 2 ) );
        }
 internal override void CreateParts()
 {
     vertices = new ModelVertex[boxVertices * 6 * ( Fur ? 2 : 1 )];
     Head = BuildBox( MakeBoxBounds( -3, 16, -14, 3, 22, -6 )
                     .TexOrigin( 0, 0 )
                     .RotOrigin( 0, 18, -8 ) );
     Torso = BuildRotatedBox( MakeRotatedBoxBounds( -4, 12, -8, 4, 18, 8 )
                             .TexOrigin( 28, 8 ) );
     LeftLegFront = BuildBox( MakeBoxBounds( -5, 0, -7, -1, 12, -3 )
                             .TexOrigin( 0, 16 )
                             .RotOrigin( 0, 12, -5 ) );
     RightLegFront = BuildBox( MakeBoxBounds( 1, 0, -7, 5, 12, -3 )
                              .TexOrigin( 0, 16 )
                              .RotOrigin( 0, 12, -5 ) );
     LeftLegBack = BuildBox( MakeBoxBounds( -5, 0, 5, -1, 12, 9 )
                            .TexOrigin( 0, 16 )
                            .RotOrigin( 0, 12, 7 ) );
     RightLegBack = BuildBox( MakeBoxBounds( 1, 0, 5, 5, 12, 9 )
                             .TexOrigin( 0, 16 )
                             .RotOrigin( 0, 12, 7 ) );
     if( Fur ) MakeFurModel();
 }
Beispiel #31
0
        internal override void CreateParts()
        {
            vertices = new ModelVertex[boxVertices * 6 + quadVertices * 2 * 2];
            Head = BuildBox( MakeBoxBounds( -2, 9, -6, 2, 15, -3 )
                            .TexOrigin( 0, 0 )
                            .RotOrigin( 0, 9, -4 ) );
            Head2 = BuildBox( MakeBoxBounds( -1, 9, -7, 1, 11, -5 )
                             .TexOrigin( 14, 4 ) // TODO: Find a more appropriate name.
                             .RotOrigin( 0, 9, -4 ) );
            Head3 = BuildBox( MakeBoxBounds( -2, 11, -8, 2, 13, -6 )
                             .TexOrigin( 14, 0 )
                             .RotOrigin( 0, 9, -4 ) );
            Torso = BuildRotatedBox( MakeRotatedBoxBounds( -3, 5, -4, 3, 11, 3 )
                                   .TexOrigin( 0, 9 ) );

            LeftLeg = MakeLeg( -3, 0, -2, -1 );
            RightLeg = MakeLeg( 0, 3, 1, 2 );
            LeftWing = BuildBox( MakeBoxBounds( -4, 7, -3, -3, 11, 3 )
                                .TexOrigin( 24, 13 )
                                .RotOrigin( -3, 11, 0 ) );
            RightWing = BuildBox( MakeBoxBounds( 3, 7, -3, 4, 11, 3 )
                                 .TexOrigin( 24, 13 )
                                 .RotOrigin( 3, 11, 0 ) );
        }
 protected void DrawRotate(float angleX, float angleY, float angleZ, ModelPart part)
 {
     DrawRotated(angleX, angleY, angleZ, part, false);
 }
        protected void DrawRotated(float angleX, float angleY, float angleZ, ModelPart part, bool head)
        {
            float           cosX = (float)Math.Cos(-angleX), sinX = (float)Math.Sin(-angleX);
            float           cosY = (float)Math.Cos(-angleY), sinY = (float)Math.Sin(-angleY);
            float           cosZ = (float)Math.Cos(-angleZ), sinZ = (float)Math.Sin(-angleZ);
            float           x = part.RotX, y = part.RotY, z = part.RotZ;
            VertexP3fT2fC4b vertex = default(VertexP3fT2fC4b);

            for (int i = 0; i < part.Count; i++)
            {
                ModelVertex v = vertices[part.Offset + i];
                v.X -= x; v.Y -= y; v.Z -= z;
                float t = 0;

                // Rotate locally
                if (Rotate == RotateOrder.ZYX)
                {
                    t = cosZ * v.X + sinZ * v.Y; v.Y = -sinZ * v.X + cosZ * v.Y; v.X = t;                     // Inlined RotZ
                    t = cosY * v.X - sinY * v.Z; v.Z = sinY * v.X + cosY * v.Z; v.X = t;                      // Inlined RotY
                    t = cosX * v.Y + sinX * v.Z; v.Z = -sinX * v.Y + cosX * v.Z; v.Y = t;                     // Inlined RotX
                }
                else if (Rotate == RotateOrder.XZY)
                {
                    t = cosX * v.Y + sinX * v.Z; v.Z = -sinX * v.Y + cosX * v.Z; v.Y = t;                     // Inlined RotX
                    t = cosZ * v.X + sinZ * v.Y; v.Y = -sinZ * v.X + cosZ * v.Y; v.X = t;                     // Inlined RotZ
                    t = cosY * v.X - sinY * v.Z; v.Z = sinY * v.X + cosY * v.Z; v.X = t;                      // Inlined RotY
                }

                // Rotate globally
                if (!head)
                {
                    v.X += x; v.Y += y; v.Z += z;
                    t    = cosYaw * v.X - sinYaw * v.Z; v.Z = sinYaw * v.X + cosYaw * v.Z; v.X = t;                      // Inlined RotY
                }
                else
                {
                    t = cosHead * v.X - sinHead * v.Z; v.Z = sinHead * v.X + cosHead * v.Z; v.X = t;                     // Inlined RotY
                    float tX = x, tZ = z;
                    t    = cosYaw * tX - sinYaw * tZ; tZ = sinYaw * tX + cosYaw * tZ; tX = t;                            // Inlined RotY
                    v.X += tX; v.Y += y; v.Z += tZ;
                }
                v.X *= scale; v.Y *= scale; v.Z *= scale;
                v.X += pos.X; v.Y += pos.Y; v.Z += pos.Z;

                FastColour col = part.Count == boxVertices ?
                                 cols[i >> 2] : FastColour.Scale(this.col, 0.7f);
                vertex.X = v.X; vertex.Y = v.Y; vertex.Z = v.Z;
                vertex.R = col.R; vertex.G = col.G; vertex.B = col.B; vertex.A = 255;

                vertex.U = v.U * uScale; vertex.V = v.V * vScale;
                int quadI = i & 3;
                if (quadI == 0 || quadI == 3)
                {
                    vertex.V -= 0.01f * vScale;
                }
                if (quadI == 2 || quadI == 3)
                {
                    vertex.U -= 0.01f * vScale;
                }
                cache.vertices[index++] = vertex;
            }
        }
Beispiel #34
0
 protected void DrawHeadRotate(float x, float y, float z, float angleX, float angleY, float angleZ, ModelPart part)
 {
     DrawRotated(x, y, z, angleX, angleY, angleZ, part, true);
 }
 protected void DrawRotate( float angleX, float angleY, float angleZ, ModelPart part )
 {
     DrawRotated( angleX, angleY, angleZ, part, false );
 }
        void MakeFurModel()
        {
            FurHead = BuildBox( MakeBoxBounds( -3, -3, -3, 3, 3, 3 )
                               .SetTexOrigin( 0, 0 )
                               .SetModelBounds( -3.5f, 15.5f, -12.5f, 3.5f, 22.5f, -5.5f ) );
            FurTorso = BuildRotatedBox( MakeRotatedBoxBounds( -4, 12, -8, 4, 18, 8 )
                                    .SetTexOrigin( 28, 8 )
                                    .SetModelBounds( -6f, 10.5f, -10f, 6f, 19.5f, 10f ) );
            BoxDescription legDesc = MakeBoxBounds( -2, -3, -2, 2, 3, 2  )
                .SetTexOrigin( 0, 16 );

            FurLeftLegFront = BuildBox( legDesc.SetModelBounds( -5.5f, 5.5f, -7.5f, -0.5f, 12.5f, -2.5f ) );
            FurRightLegFront = BuildBox( legDesc.SetModelBounds( 0.5f, 5.5f, -7.5f, 5.5f, 12.5f, -2.5f ) );
            FurLeftLegBack = BuildBox( legDesc.SetModelBounds( -5.5f, 5.5f, 4.5f, -0.5f, 12.5f, 9.5f ) );
            FurRightLegBack = BuildBox( legDesc.SetModelBounds( 0.5f, 5.5f, 4.5f, 5.5f, 12.5f, 9.5f ) );
        }
        protected void DrawRotated( float angleX, float angleY, float angleZ, ModelPart part, bool head )
        {
            float cosX = (float)Math.Cos( -angleX ), sinX = (float)Math.Sin( -angleX );
            float cosY = (float)Math.Cos( -angleY ), sinY = (float)Math.Sin( -angleY );
            float cosZ = (float)Math.Cos( -angleZ ), sinZ = (float)Math.Sin( -angleZ );
            float x = part.RotX, y = part.RotY, z = part.RotZ;
            VertexP3fT2fC4b vertex = default( VertexP3fT2fC4b );

            for( int i = 0; i < part.Count; i++ ) {
                ModelVertex v = vertices[part.Offset + i];
                v.X -= x; v.Y -= y; v.Z -= z;
                float t = 0;

                // Rotate locally
                if( Rotate == RotateOrder.ZYX ) {
                    t = cosZ * v.X + sinZ * v.Y; v.Y = -sinZ * v.X + cosZ * v.Y; v.X = t; // Inlined RotZ
                    t = cosY * v.X - sinY * v.Z; v.Z = sinY * v.X + cosY * v.Z; v.X = t;  // Inlined RotY
                    t = cosX * v.Y + sinX * v.Z; v.Z = -sinX * v.Y + cosX * v.Z; v.Y = t; // Inlined RotX
                } else if( Rotate == RotateOrder.XZY ) {
                    t = cosX * v.Y + sinX * v.Z; v.Z = -sinX * v.Y + cosX * v.Z; v.Y = t; // Inlined RotX
                    t = cosZ * v.X + sinZ * v.Y; v.Y = -sinZ * v.X + cosZ * v.Y; v.X = t; // Inlined RotZ
                    t = cosY * v.X - sinY * v.Z; v.Z = sinY * v.X + cosY * v.Z; v.X = t;  // Inlined RotY
                }

                // Rotate globally
                if( !head ) {
                    v.X += x; v.Y += y; v.Z += z;
                    t = cosYaw * v.X - sinYaw * v.Z; v.Z = sinYaw * v.X + cosYaw * v.Z; v.X = t;     // Inlined RotY
                } else {
                    t = cosHead * v.X - sinHead * v.Z; v.Z = sinHead * v.X + cosHead * v.Z; v.X = t; // Inlined RotY
                    float tX = x, tZ = z;
                    t = cosYaw * tX - sinYaw * tZ; tZ = sinYaw * tX + cosYaw * tZ; tX = t;           // Inlined RotY
                    v.X += tX; v.Y += y; v.Z += tZ;
                }
                v.X += pos.X; v.Y += pos.Y; v.Z += pos.Z;

                FastColour col = part.Count == boxVertices ?
                    cols[i >> 2] : FastColour.Scale( this.col, 0.7f );
                vertex.X = v.X; vertex.Y = v.Y; vertex.Z = v.Z;
                vertex.R = col.R; vertex.G = col.G; vertex.B = col.B; vertex.A = 255;

                vertex.U = v.U * uScale; vertex.V = v.V * vScale;
                int quadI = i & 3;
                if( quadI == 0 || quadI == 3 ) vertex.V -= 0.01f * vScale;
                if( quadI == 2 || quadI == 3 ) vertex.U -= 0.01f * vScale;
                cache.vertices[index++] = vertex;
            }
        }
Beispiel #38
0
        protected void DrawRotate(float x, float y, float z, float angleX, float angleY, float angleZ, ModelPart part)
        {
            float cosX = (float)Math.Cos(-angleX), sinX = (float)Math.Sin(-angleX);
            float cosY = (float)Math.Cos(-angleY), sinY = (float)Math.Sin(-angleY);
            float cosZ = (float)Math.Cos(-angleZ), sinZ = (float)Math.Sin(-angleZ);
            float vScale = _64x64 ? 64f : 32f;

            for (int i = 0; i < part.Count; i++)
            {
                ModelVertex model = vertices[part.Offset + i];
                Vector3     loc   = new Vector3(model.X - x, model.Y - y, model.Z - z);
                if (Rotate == RotateOrder.ZYX)
                {
                    loc = Utils.RotateZ(loc.X, loc.Y, loc.Z, cosZ, sinZ);
                    loc = Utils.RotateY(loc.X, loc.Y, loc.Z, cosY, sinY);
                    loc = Utils.RotateX(loc.X, loc.Y, loc.Z, cosX, sinX);
                }
                else if (Rotate == RotateOrder.XZY)
                {
                    loc = Utils.RotateX(loc.X, loc.Y, loc.Z, cosX, sinX);
                    loc = Utils.RotateZ(loc.X, loc.Y, loc.Z, cosZ, sinZ);
                    loc = Utils.RotateY(loc.X, loc.Y, loc.Z, cosY, sinY);
                }

                FastColour            col    = GetCol(i, part.Count);
                VertexPos3fTex2fCol4b vertex = default(VertexPos3fTex2fCol4b);
                Vector3 newPos = Utils.RotateY(loc.X + x, loc.Y + y, loc.Z + z, cosA, sinA) + pos;
                vertex.X = newPos.X; vertex.Y = newPos.Y; vertex.Z = newPos.Z;
                vertex.R = col.R; vertex.G = col.G; vertex.B = col.B; vertex.A = 255;
                AdjustUV(model.U, model.V, vScale, i, ref vertex);
                cache.vertices[index++] = vertex;
            }
        }
Beispiel #39
0
 protected void DrawRotate(float angleX, float angleY, float angleZ, ModelPart part, bool head)
 {
     DrawRotate(angleX, angleY, angleZ, part, head, false);
 }
Beispiel #40
0
        protected void DrawRotate( float x, float y, float z, float angleX, float angleY, float angleZ, ModelPart part )
        {
            float cosX = (float)Math.Cos( -angleX ), sinX = (float)Math.Sin( -angleX );
            float cosY = (float)Math.Cos( -angleY ), sinY = (float)Math.Sin( -angleY );
            float cosZ = (float)Math.Cos( -angleZ ), sinZ = (float)Math.Sin( -angleZ );
            float vScale = _64x64 ? 64f : 32f;

            for( int i = 0; i < part.Count; i++ ) {
                ModelVertex model = vertices[part.Offset + i];
                Vector3 loc = new Vector3( model.X - x, model.Y - y, model.Z - z );
                loc = Utils.RotateZ( loc.X, loc.Y, loc.Z, cosZ, sinZ );
                loc = Utils.RotateY( loc.X, loc.Y, loc.Z, cosY, sinY );
                loc = Utils.RotateX( loc.X, loc.Y, loc.Z, cosX, sinX );

                VertexPos3fTex2fCol4b vertex = default( VertexPos3fTex2fCol4b );
                Vector3 newPos = Utils.RotateY( loc.X + x, loc.Y + y, loc.Z + z, cosA, sinA ) + pos;
                vertex.X = newPos.X; vertex.Y = newPos.Y; vertex.Z = newPos.Z;
                vertex.R = col.R; vertex.G = col.G; vertex.B = col.B; vertex.A = 255;
                AdjustUV( model.U, model.V, vScale, i, ref vertex );

                cache.vertices[index++] = vertex;
            }
        }
Beispiel #41
0
        protected void DrawRotate(float angleX, float angleY, float angleZ, ModelPart part, bool head, bool rotNormal)
        {
            float cosX = (float)Math.Cos(-angleX), sinX = (float)Math.Sin(-angleX);
            float cosY = (float)Math.Cos(-angleY), sinY = (float)Math.Sin(-angleY);
            float cosZ = (float)Math.Cos(-angleZ), sinZ = (float)Math.Sin(-angleZ);
            float x = part.RotX, y = part.RotY, z = part.RotZ;
            VertexP3fT2fC4bN1v vertex = default(VertexP3fT2fC4bN1v);

            VertexP3fT2fC4bN1v[] finVertices = game.ModelCache.vertices;

            for (int i = 0; i < part.Count; i++)
            {
                ModelVertex v = vertices[part.Offset + i];
                v.X -= x; v.Y -= y; v.Z -= z;
                float t = 0;

                // Rotate locally
                if (Rotate == RotateOrder.ZYX)
                {
                    t = cosZ * v.X + sinZ * v.Y; v.Y = -sinZ * v.X + cosZ * v.Y; v.X = t;                     // Inlined RotZ
                    t = cosY * v.X - sinY * v.Z; v.Z = sinY * v.X + cosY * v.Z; v.X = t;                      // Inlined RotY
                    t = cosX * v.Y + sinX * v.Z; v.Z = -sinX * v.Y + cosX * v.Z; v.Y = t;                     // Inlined RotX
                }
                else if (Rotate == RotateOrder.XZY)
                {
                    t = cosX * v.Y + sinX * v.Z; v.Z = -sinX * v.Y + cosX * v.Z; v.Y = t;                     // Inlined RotX
                    t = cosZ * v.X + sinZ * v.Y; v.Y = -sinZ * v.X + cosZ * v.Y; v.X = t;                     // Inlined RotZ
                    t = cosY * v.X - sinY * v.Z; v.Z = sinY * v.X + cosY * v.Z; v.X = t;                      // Inlined RotY
                }
                else if (Rotate == RotateOrder.YZX)
                {
                    t = cosY * v.X - sinY * v.Z; v.Z = sinY * v.X + cosY * v.Z; v.X = t;                      // Inlined RotY
                    t = cosZ * v.X + sinZ * v.Y; v.Y = -sinZ * v.X + cosZ * v.Y; v.X = t;                     // Inlined RotZ
                    t = cosX * v.Y + sinX * v.Z; v.Z = -sinX * v.Y + cosX * v.Z; v.Y = t;                     // Inlined RotX
                }

                // Rotate globally
                if (head)
                {
                    t = cosHead * v.X - sinHead * v.Z; v.Z = sinHead * v.X + cosHead * v.Z; v.X = t;                     // Inlined RotY
                }
                vertex.X      = v.X + x; vertex.Y = v.Y + y; vertex.Z = v.Z + z;
                vertex.Colour = cols[i >> 2];
                if (!v.N)
                {
                    vertex.Normal = v.D;
                }
                float normalAngleX = angleX;
                float normalAngleY = angleY;
                float normalAngleZ = angleZ;
                if (rotNormal)
                {
                    normalAngleX = angleX;
                    normalAngleY = angleY;
                    normalAngleZ = -angleZ;
                }
                if (Rotate == RotateOrder.ZYX)
                {
                    Vector3 newNormal = vertex.Normal;
                    newNormal     = Utils.RotateZ(newNormal, -normalAngleZ);
                    newNormal     = Utils.RotateY(newNormal, -normalAngleY);
                    newNormal     = Utils.RotateX(newNormal, -normalAngleX);
                    vertex.Normal = newNormal;
                }
                else if (Rotate == RotateOrder.XZY)
                {
                    Vector3 newNormal = vertex.Normal;
                    newNormal     = Utils.RotateX(newNormal, -normalAngleX);
                    newNormal     = Utils.RotateZ(newNormal, -normalAngleZ);
                    newNormal     = Utils.RotateY(newNormal, -normalAngleY);
                    vertex.Normal = newNormal;
                }
                else if (Rotate == RotateOrder.YZX)
                {
                    Vector3 newNormal = vertex.Normal;
                    newNormal     = Utils.RotateY(newNormal, -normalAngleY);
                    newNormal     = Utils.RotateZ(newNormal, -normalAngleZ);
                    newNormal     = Utils.RotateX(newNormal, -normalAngleX);
                    vertex.Normal = newNormal;
                }

                v.N = true;

                vertex.U             = (v.U & UVMask) * uScale - (v.U >> UVMaxShift) * 0.01f * uScale;
                vertex.V             = (v.V & UVMask) * vScale - (v.V >> UVMaxShift) * 0.01f * vScale;
                finVertices[index++] = vertex;
            }
        }
        protected void DrawPart( ModelPart part )
        {
            VertexP3fT2fC4b vertex = default( VertexP3fT2fC4b );
            for( int i = 0; i < part.Count; i++ ) {
                ModelVertex v = vertices[part.Offset + i];
                float t = cosYaw * v.X - sinYaw * v.Z; v.Z = sinYaw * v.X + cosYaw * v.Z; v.X = t; // Inlined RotY
                v.X += pos.X; v.Y += pos.Y; v.Z += pos.Z;

                FastColour col = part.Count == boxVertices ?
                    cols[i >> 2] : FastColour.Scale( this.col, 0.7f );
                vertex.X = v.X; vertex.Y = v.Y; vertex.Z = v.Z;
                vertex.R = col.R; vertex.G = col.G; vertex.B = col.B; vertex.A = 255;

                vertex.U = v.U * uScale; vertex.V = v.V * vScale;
                int quadI = i & 3;
                if( quadI == 0 || quadI == 3 ) vertex.V -= 0.01f * vScale;
                if( quadI == 2 || quadI == 3 ) vertex.U -= 0.01f * uScale;
                cache.vertices[index++] = vertex;
            }
        }