Ejemplo n.º 1
0
        protected BoxDescription MakeRotatedBoxBounds(int x1, int y1, int z1, int x2, int y2, int z2)
        {
            BoxDescription desc = default(BoxDescription)
                                  .SetModelBounds(x1, y1, z1, x2, y2, z2);

            desc.SidesW = Math.Abs(y2 - y1);
            desc.BodyW  = Math.Abs(x2 - x1);
            desc.BodyH  = Math.Abs(z2 - z1);
            return(desc);
        }
Ejemplo n.º 2
0
        /// <summary>Builds a box model assuming the follow texture layout:<br/>
        /// let SW = sides width, BW = body width, BH = body height<br/>
        /// ┏━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓ <br/>
        /// ┃┈┈┈┈┈SW┈┈┈┈┈┃┈┈┈┈┈BW┈┈┈┈┈┃┈┈┈┈┈BW┈┈┈┈┈┈┃┈┈┈┈┈┈┈┈┈┈┈┈┃ <br/>
        /// ┃S┈┈┈┈┈┈┈┈┈┈┈S┃S┈┈┈┈top┈┈┈┈S┃S┈┈bottom┈┈┈S┃┈┈┈┈┈┈┈┈┈┈┈┈┃ <br/>
        /// ┃W┈┈┈┈┈┈┈┈┈W┃W┈┈┈┈tex┈┈┈W┃W┈┈┈┈tex┈┈┈┈W┃┈┈┈┈┈┈┈┈┈┈┈┈┃ <br/>
        /// ┃┈┈┈┈┈SW┈┈┈┈┈┃┈┈┈┈┈BW┈┈┈┈┈┃┈┈┈┈┈BW┈┈┈┈┈┈┃┈┈┈┈┈┈┈┈┈┈┈┈┃ <br/>
        /// ┣━━━━━━━━━━━━━╋━━━━━━━━━━━━━╋━━━━━━━━━━━━━━╋━━━━━━━━━━━━┃ <br/>
        /// ┃┈┈┈┈┈SW┈┈┈┈┈┃┈┈┈┈┈BW┈┈┈┈┈┃┈┈┈┈┈BW┈┈┈┈┈┈┃┈┈┈┈┈SW┈┈┈┈┃ <br/>
        /// ┃B┈┈┈left┈┈┈┈┈B┃B┈┈front┈┈┈┈B┃B┈┈┈right┈┈┈┈B┃B┈┈┈back┈┈┈B┃ <br/>
        /// ┃H┈┈┈tex┈┈┈┈┈H┃H┈┈tex┈┈┈┈┈H┃H┈┈┈tex┈┈┈┈┈H┃H┈┈┈┈tex┈┈┈H┃ <br/>
        /// ┃┈┈┈┈┈SW┈┈┈┈┈┃┈┈┈┈┈BW┈┈┈┈┈┃┈┈┈┈┈BW┈┈┈┈┈┈┃┈┈┈┈┈SW┈┈┈┈┃ <br/>
        /// ┗━━━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━━━━━━━━━┛ </summary>
        protected ModelPart BuildBox(BoxDescription desc)
        {
            int   sidesW = desc.SidesW, bodyW = desc.BodyW, bodyH = desc.BodyH;
            float x1 = desc.X1, y1 = desc.Y1, z1 = desc.Z1;
            float x2 = desc.X2, y2 = desc.Y2, z2 = desc.Z2;
            int   x = desc.TexX, y = desc.TexY;

            YQuad(x + sidesW, y, bodyW, sidesW, x2, x1, z2, z1, y2);                          // top
            YQuad(x + sidesW + bodyW, y, bodyW, sidesW, x2, x1, z1, z2, y1);                  // bottom
            ZQuad(x + sidesW, y + sidesW, bodyW, bodyH, x2, x1, y1, y2, z1);                  // front
            ZQuad(x + sidesW + bodyW + sidesW, y + sidesW, bodyW, bodyH, x1, x2, y1, y2, z2); // back
            XQuad(x, y + sidesW, sidesW, bodyH, z2, z1, y1, y2, x2);                          // left
            XQuad(x + sidesW + bodyW, y + sidesW, sidesW, bodyH, z1, z2, y1, y2, x1);         // right
            return(new ModelPart(index - 6 * 4, 6 * 4));
        }
Ejemplo n.º 3
0
        public CustomModel(List <RawPart> inputParts) : base()
        {
            RawParts = inputParts;
            vertices = new ModelVertex[RawParts.Count * boxVertices];
            parts    = new List <ModelPart>();

            foreach (RawPart raw in RawParts)
            {
                BoxDescription desc = MakeBoxBounds(raw.X1, raw.Y1, raw.Z1,
                                                    raw.X2, raw.Y2, raw.Z2);
                desc.SetTexOrigin(raw.TexX, raw.TexY);

                ModelPart part;
                if (raw.Rotated)
                {
                    part = BuildRotatedBox(desc);
                }
                else
                {
                    part = BuildBox(desc);
                }
                parts.Add(part);
            }

            /*
             *
             * Set.Head = BuildBox( MakeBoxBounds( -4, 24, -4, 4, 32, 4 )
             *                  .SetTexOrigin( 0, 0 ) );
             * Set.Torso = BuildBox( MakeBoxBounds( -4, 12, -2, 4, 24, 2 )
             *                   .SetTexOrigin( 16, 16 ) );
             * Set.LeftLeg = BuildBox( MakeBoxBounds( 0, 0, -2, -4, 12, 2 )
             *                     .SetTexOrigin( 0, 16 ) );
             * Set.RightLeg = BuildBox( MakeBoxBounds( 0, 0, -2, 4, 12, 2 ).
             *                      SetTexOrigin( 0, 16 ) );
             * Set.Hat = BuildBox( MakeBoxBounds( -4, 24, -4, 4, 32, 4 )
             *                 .SetTexOrigin( 32, 0 )
             *                 .SetModelBounds( -4.5f, 23.5f, -4.5f, 4.5f, 32.5f, 4.5f ) );
             * Set.LeftArm = BuildBox( MakeBoxBounds( -4, 12, -2, -8, 24, 2 )
             *                     .SetTexOrigin( 40, 16 ) );
             * Set.RightArm = BuildBox( MakeBoxBounds( 4, 12, -2, 8, 24, 2 )
             *                      .SetTexOrigin( 40, 16 ) );
             */
        }
Ejemplo n.º 4
0
        /// <summary>Builds a box model assuming the follow texture layout:<br/>
        /// let SW = sides width, BW = body width, BH = body height<br/>
        /// ┏━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓ <br/>
        /// ┃┈┈┈┈┈SW┈┈┈┈┈┃┈┈┈┈┈BW┈┈┈┈┈┃┈┈┈┈┈BW┈┈┈┈┈┈┃┈┈┈┈┈┈┈┈┈┈┈┈┃ <br/>
        /// ┃S┈┈┈┈┈┈┈┈┈┈┈S┃S┈┈┈┈front┈┈┈S┃S┈┈┈back┈┈┈┈S┃┈┈┈┈┈┈┈┈┈┈┈┈┃ <br/>
        /// ┃W┈┈┈┈┈┈┈┈┈W┃W┈┈┈┈tex┈┈┈W┃W┈┈┈┈tex┈┈┈┈W┃┈┈┈┈┈┈┈┈┈┈┈┈┃ <br/>
        /// ┃┈┈┈┈┈SW┈┈┈┈┈┃┈┈┈┈┈BW┈┈┈┈┈┃┈┈┈┈┈BW┈┈┈┈┈┈┃┈┈┈┈┈┈┈┈┈┈┈┈┃ <br/>
        /// ┣━━━━━━━━━━━━━╋━━━━━━━━━━━━━╋━━━━━━━━━━━━━━╋━━━━━━━━━━━━┃ <br/>
        /// ┃┈┈┈┈┈SW┈┈┈┈┈┃┈┈┈┈┈BW┈┈┈┈┈┃┈┈┈┈┈SW┈┈┈┈┈┈┃┈┈┈┈┈SW┈┈┈┈┃ <br/>
        /// ┃B┈┈┈left┈┈┈┈┈B┃B┈┈bottom┈┈B┃B┈┈┈right┈┈┈┈B┃B┈┈┈┈top┈┈┈B┃ <br/>
        /// ┃H┈┈┈tex┈┈┈┈┈H┃H┈┈tex┈┈┈┈┈H┃H┈┈┈tex┈┈┈┈┈H┃H┈┈┈┈tex┈┈┈H┃ <br/>
        /// ┃┈┈┈┈┈SW┈┈┈┈┈┃┈┈┈┈┈BW┈┈┈┈┈┃┈┈┈┈┈SW┈┈┈┈┈┈┃┈┈┈┈┈SW┈┈┈┈┃ <br/>
        /// ┗━━━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━━━━━━━━━┛ </summary>
        protected ModelPart BuildRotatedBox(BoxDescription desc)
        {
            int   sidesW = desc.SidesW, bodyW = desc.BodyW, bodyH = desc.BodyH;
            float x1 = desc.X1, y1 = desc.Y1, z1 = desc.Z1;
            float x2 = desc.X2, y2 = desc.Y2, z2 = desc.Z2;
            int   x = desc.TexX, y = desc.TexY;

            ZQuad(x + sidesW, y, bodyW, sidesW, x2, x1, y1, y2, z1);                          // front
            ZQuad(x + sidesW + bodyW, y, bodyW, sidesW, x1, x2, y2, y1, z2);                  // back
            YQuad(x + sidesW + bodyW + sidesW, y + sidesW, bodyW, bodyH, x1, x2, z1, z2, y2); // top
            YQuad(x + sidesW, y + sidesW, bodyW, bodyH, x2, x1, z1, z2, y1);                  // bottom
            XQuad(x, y + sidesW, sidesW, bodyH, y2, y1, z2, z1, x2);                          // left
            XQuad(x + sidesW + bodyW, y + sidesW, sidesW, bodyH, y1, y2, z2, z1, x1);         // right

            // rotate left and right 90 degrees
            for (int i = index - 8; i < index; i++)
            {
                ModelVertex vertex = vertices[i];
                float       z      = vertex.Z; vertex.Z = vertex.Y; vertex.Y = z;
                vertices[i] = vertex;
            }
            return(new ModelPart(index - 6 * 4, 6 * 4));
        }