//todo: make it actually do what it says in that summary
 /// <summary>Gives this <see cref="OpaqueBlock"/> a mesh that can be combined and hidden with other blocks of the same type.</summary>
 /// <param name="face">Which <see cref="Block.Face"/> is this attribute describing?</param>
 /// <param name="posX">The 'x' component of the relative position of this face. (ie. the location of this face)</param>
 /// <param name="posY">The 'y' component of the relative position of this face. (ie. the location of this face)</param>
 /// <param name="posZ">The 'z' component of the relative position of this face. (ie. the location of this face)</param>
 /// <param name="rotX">The 'x' component of the relative rotation of this face in degrees. (ie. the spin around the x-axis)</param>
 /// <param name="rotY">The 'y' component of the relative rotation of this face in degrees. (ie. the spin around the y-axis)</param>
 /// <param name="rotZ">The 'z' component of the relative rotation of this face in degrees. (ie. the spin around the z-axis)</param>
 /// <param name="targets">Does this attribute apply to just the preview, just the original, or both?</param>
 public FlatFace(Block.Face face, float posX, float posY, float posZ, float rotX, float rotY, float rotZ, int identifier = 0, AppliesTo targets = AppliesTo.Both)
     : base(identifier, targets)
 {
     this.face = face;
     position  = new Vector3(posX, posY, posZ);
     rotation  = Quaternion.Euler(rotX, rotY, rotZ);
 }
 /// <summary>Assumes a 1x1x1 <see cref="Block"/> for a <see cref="Face"/>.</summary>
 /// <param name="face">Which <see cref="Block.Face"/> is this attribute describing?</param>
 /// <param name="posX">The 'x' component of the relative position of this face. (ie. the location of this face)</param>
 /// <param name="posY">The 'y' component of the relative position of this face. (ie. the location of this face)</param>
 /// <param name="posZ">The 'z' component of the relative position of this face. (ie. the location of this face)</param>
 /// <param name="rotX">The 'x' component of the relative rotation of this face. (ie. the spin around the x-axis)</param>
 /// <param name="rotY">The 'y' component of the relative rotation of this face. (ie. the spin around the y-axis)</param>
 /// <param name="rotZ">The 'z' component of the relative rotation of this face. (ie. the spin around the z-axis)</param>
 /// <param name="objPath">File path the the '.obj' file for the mesh of this block face.</param>
 /// <param name="targets">Does this attribute apply to just the preview, just the original, or both?</param>
 public Face(Block.Face face,
             float posX, float posY, float posZ,
             float rotX, float rotY, float rotZ,
             string objPath, int identifier = 0, AppliesTo targets = AppliesTo.Both)
     : base(identifier, targets)
 {
     this.face = face;
     Position  = new Vector3(posX, posY, posZ);
     Rotation  = Quaternion.Euler(rotX, rotY, rotZ);
     MeshPath  = objPath;
 }
            /// <summary>Assumes a 1x1x1 <see cref="Block"/> for a <see cref="FlatFace"/>.</summary>
            /// <param name="face">Which <see cref="Block.Face"/> is this attribute describing?</param>
            /// <param name="targets">Does this attribute apply to just the preview, just the original, or both?</param>
            public FlatFace(Block.Face face, int identifier = 0, AppliesTo targets = AppliesTo.Both)
                : this(face,

                       posX: (int)face == +1 ? +0.5f : (int)face == -1 ? -0.5f : 0,
                       posY: (int)face == +2 ? +0.5f : (int)face == -2 ? -0.5f : 0,
                       posZ: (int)face == +3 ? +0.5f : (int)face == -3 ? -0.5f : 0,

                       rotX: (int)face == +3 ? +90f : (int)face == -3 ? -90f
                          : (int)face == +2 ? 000f : (int)face == -2 ? 180f : 0,
                       rotY: 0,
                       rotZ: (int)face == +1 ? -90f : (int)face == -1 ? +90f : 0,

                       identifier, targets)
            {
            }
Exemplo n.º 4
0
    public virtual void BuildFace(Block.ID id, Block.Face face, Vector3 corner, Vector3 up, Vector3 right, bool reversed, List <Vector3> verts, List <Vector2> uvs, List <int> tris)
    {
        int index = verts.Count;

        verts.Add(corner);
        verts.Add(corner + up);
        verts.Add(corner + up + right);
        verts.Add(corner + right);


        Vector2 uvWidth = new Vector2(1f / 16f, 1f / 16f);
        // Vector2 uvCorner = new Vector2(0.0001f,0.77f);

        Vector2 uvCorner = Texture.getTexture(id, face);

        //uvCorner.x += (float)(1 - 1) / 16;

        uvs.Add(uvCorner);
        uvs.Add(new Vector2(uvCorner.x, uvCorner.y + uvWidth.y));
        uvs.Add(new Vector2(uvCorner.x + uvWidth.x, uvCorner.y + uvWidth.y));
        uvs.Add(new Vector2(uvCorner.x + uvWidth.x, uvCorner.y));


        if (reversed)
        {
            tris.Add(index + 0);
            tris.Add(index + 1);
            tris.Add(index + 2);
            tris.Add(index + 2);
            tris.Add(index + 3);
            tris.Add(index + 0);
        }
        else
        {
            tris.Add(index + 1);
            tris.Add(index + 0);
            tris.Add(index + 2);
            tris.Add(index + 3);
            tris.Add(index + 2);
            tris.Add(index + 0);
        }
    }
Exemplo n.º 5
0
    public static Vector2 getTexture(Block.ID id, Block.Face face)
    {
        Vector2 texture = new Vector2();
        int     index   = (int)face;

        switch (id)
        {
        case Block.ID.AIR:
            return(texture);

        case Block.ID.GRASS:
            return(grass[index]);

        case Block.ID.DIRT:
            return(dirt[0]);

        case Block.ID.STONE:
            return(stone[0]);

        case Block.ID.BEDROCK:
            return(bedrock[0]);

        case Block.ID.COBBLESTONE:
            return(cobblestone[0]);

        case Block.ID.GLASS:
            return(glass[0]);

        case Block.ID.OAK_LOG:
            return(oak_log[index]);

        case Block.ID.OAK_PLANKS:
            return(oak_planks[0]);

        case Block.ID.BRICKS:
            return(bricks[0]);

        case Block.ID.OAK_LEAVES:
            return(oak_leaves[0]);

        case Block.ID.MOSS_STONE:
            return(moss_stone[0]);

        case Block.ID.MOSS_BRICK:
            return(moss_brick[0]);

        case Block.ID.CRACKED_BRICK:
            return(cracked_brick[0]);

        case Block.ID.STONE_BRICK:
            return(stone_bricks[0]);

        case Block.ID.CLAY:
            return(clay[0]);

        case Block.ID.SANDSTONE:
            return(sandstone[index]);

        case Block.ID.SAND:
            return(sand[0]);

        case Block.ID.GRAVEL:
            return(gravel[0]);

        case Block.ID.BOOKCASE:
            return(bookcase[index]);

        case Block.ID.CURSOR_1:
            return(cursor[0]);
        }


        return(texture);
    }