コード例 #1
0
        public override List<CustomBlockData> GenerateModel(byte metadata, BlockData me, BlockData Xpos, BlockData Xneg, BlockData Ypos, BlockData Yneg, BlockData Zpos, BlockData Zneg, BlockSource source, Point3 blockPosition)
        {
            List<CustomBlockData> dat = new List<CustomBlockData>();

            float s = 0.707f;
            Vector3 d = new Vector3(-0.02f, 0, -0.02f);

            dat.Add(new CustomBlockData()
            {
                Vertex1 = new Vector3(0, s, 0) - d,
                Vertex2 = new Vector3(s, s, s) - d,
                Vertex3 = new Vector3(s, 0, s) - d,
                Vertex4 = new Vector3(0, 0, 0) - d,

                Normal = new Vector3(1, 0, 1),
                Texture = Textures.GetTexturesForMetadata(metadata)[0]
            }.CreateUVsYFlipped());

            dat.Add(new CustomBlockData()
            {
                Vertex1 = new Vector3(0, s, 0) - d,
                Vertex2 = new Vector3(s, s, s) - d,
                Vertex3 = new Vector3(s, 0, s) - d,
                Vertex4 = new Vector3(0, 0, 0) - d,

                TriFlip = true,

                Normal = new Vector3(-1, 0, -1),
                Texture = Textures.GetTexturesForMetadata(metadata)[0]
            }.CreateUVsYFlipped());

            dat.Add(new CustomBlockData()
            {
                Vertex1 = new Vector3(s, s, 0),
                Vertex2 = new Vector3(0, s, s),
                Vertex3 = new Vector3(0, 0, s),
                Vertex4 = new Vector3(s, 0, 0),

                TriFlip = true,

                Normal = new Vector3(-1, 0, 1),
                Texture = Textures.GetTexturesForMetadata(metadata)[0]
            }.CreateUVsYFlipped());

            dat.Add(new CustomBlockData()
            {
                Vertex1 = new Vector3(s, s, 0),
                Vertex2 = new Vector3(0, s, s),
                Vertex3 = new Vector3(0, 0, s),
                Vertex4 = new Vector3(s, 0, 0),

                TriFlip = true,

                Normal = new Vector3(1, 0, -1),
                Texture = Textures.GetTexturesForMetadata(metadata)[0]
            }.CreateUVsYFlipped());

            return dat;
        }
コード例 #2
0
        public override List<CustomBlockData> GenerateModel(byte metadata, BlockData me, BlockData Xpos, BlockData Xneg, BlockData Ypos, BlockData Yneg, BlockData Zpos, BlockData Zneg, BlockSource source, Point3 blockPosition)
        {
            float onepix = 1f / 16f;
            float partStart = onepix * 7;
            float partEnd = onepix * 9;

            float tstart = 0.375f;
            float tend = 1f - tstart;

            List<BoundingBox> boxes = new List<BoundingBox>();

            //Pole
            boxes.Add(new BoundingBox(new Vector3(tstart, 0, tstart), new Vector3(tend, 1f, tend)));

            if (IsFence(Xpos))
            {
                boxes.Add(new BoundingBox(new Vector3(tend, 1f - onepix, partStart), new Vector3(1f, 1f - (onepix * 4), partEnd)));
                boxes.Add(new BoundingBox(new Vector3(tend, 1f - (onepix * 8), partStart), new Vector3(1f, 1f - (onepix * 11), partEnd)));
            }
            if (IsFence(Xneg))
            {
                boxes.Add(new BoundingBox(new Vector3(0, 1f - onepix, partStart), new Vector3(tstart, 1f - (onepix * 4), partEnd)));
                boxes.Add(new BoundingBox(new Vector3(0, 1f - (onepix * 8), partStart), new Vector3(tstart, 1f - (onepix * 11), partEnd)));
            }

            if (IsFence(Zpos))
            {
                boxes.Add(new BoundingBox(new Vector3(partStart, 1f - onepix, tend), new Vector3(partEnd, 1f - (onepix * 4), 1f)));
                boxes.Add(new BoundingBox(new Vector3(partStart, 1f - (onepix * 8), tend), new Vector3(partEnd, 1f - (onepix * 11), 1f)));
            }
            if (IsFence(Zneg))
            {
                boxes.Add(new BoundingBox(new Vector3(partStart, 1f - onepix, 0), new Vector3(partEnd, 1f - (onepix * 4), tstart)));
                boxes.Add(new BoundingBox(new Vector3(partStart, 1f - (onepix * 8), 0), new Vector3(partEnd, 1f - (onepix * 11), tstart)));
            }

            return GeometryGenerator.GenerateModel(boxes, source, blockPosition, false, this);
        }
コード例 #3
0
        public override List<CustomBlockData> GenerateModel(byte metadata, BlockData me, BlockData Xpos, BlockData Xneg, BlockData Ypos, BlockData Yneg, BlockData Zpos, BlockData Zneg, BlockSource source, Point3 blockPosition)
        {
            List<CustomBlockData> r = new List<CustomBlockData>();

            bool top = BitHelper.IsBitSet(metadata, 3);

            float h = .5f;
            float l = 0;

            if (top)
            {
                h = 1;
                l = .5f;
            }

            if (Block.CanBuild(Ypos, me))
            {
                r.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(0, h, 0),
                    Vertex2 = new Vector3(1, h, 0),
                    Vertex3 = new Vector3(1, h, 1),
                    Vertex4 = new Vector3(0, h, 1),

                    Texture = GetTextureForSide(BlockSide.Ypos, metadata),
                    Normal = new Vector3(0, 1, 0)
                }.CreateUVs());
            }

            if (Block.CanBuild(Yneg, me))
            {
                r.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(1, l, 1),
                    Vertex2 = new Vector3(0, l, 1),
                    Vertex3 = new Vector3(0, l, 0),
                    Vertex4 = new Vector3(1, l, 0),

                    Texture = GetTextureForSide(BlockSide.Yneg, metadata),
                    Normal = new Vector3(0, -1, 0)
                }.CreateUVs());
            }

            if (Block.CanBuild(Zneg, me))
            {
                r.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(0, l, 0),
                    Vertex2 = new Vector3(1, l, 0),
                    Vertex3 = new Vector3(1, h, 0),
                    Vertex4 = new Vector3(0, h, 0),

                    UV1 = new Vector2(0, l),
                    UV2 = new Vector2(1, l),
                    UV3 = new Vector2(1, h),
                    UV4 = new Vector2(0, h),

                    Texture = GetTextureForSide(BlockSide.Zneg, metadata),
                    Normal = new Vector3(0, 0, -1)
                });
            }

            if (Block.CanBuild(Zpos, me))
            {
                r.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(0, l, 1),
                    Vertex2 = new Vector3(1, l, 1),
                    Vertex3 = new Vector3(1, h, 1),
                    Vertex4 = new Vector3(0, h, 1),

                    UV1 = new Vector2(0, l),
                    UV2 = new Vector2(1, l),
                    UV3 = new Vector2(1, h),
                    UV4 = new Vector2(0, h),

                    Texture = GetTextureForSide(BlockSide.Zpos, metadata),
                    Normal = new Vector3(0, 0, 1)
                });
            }

            if (Block.CanBuild(Xneg, me))
            {
                r.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(0, l, 0),
                    Vertex2 = new Vector3(0, l, 1),
                    Vertex3 = new Vector3(0, h, 1),
                    Vertex4 = new Vector3(0, h, 0),

                    UV1 = new Vector2(0, l),
                    UV2 = new Vector2(1, l),
                    UV3 = new Vector2(1, h),
                    UV4 = new Vector2(0, h),

                    Texture = GetTextureForSide(BlockSide.Xneg, metadata),
                    Normal = new Vector3(-1, 0, 0)
                });
            }

            if (Block.CanBuild(Xpos, me))
            {
                r.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(1, l, 0),
                    Vertex2 = new Vector3(1, l, 1),
                    Vertex3 = new Vector3(1, h, 1),
                    Vertex4 = new Vector3(1, h, 0),

                    UV1 = new Vector2(0, l),
                    UV2 = new Vector2(1, l),
                    UV3 = new Vector2(1, h),
                    UV4 = new Vector2(0, h),

                    Texture = GetTextureForSide(BlockSide.Xpos, metadata),
                    Normal = new Vector3(1, 0, 0)
                });
            }

            return r;
        }
コード例 #4
0
        /// <summary>
        /// Can build side: Input1: Block at side, Input2: Base block
        /// </summary>
        public static List<CustomBlockData> GenerateModel(List<BoundingBox> boxes, BlockSource source, Point3 blockPos, bool removeCoveredFaces, IGeometryGeneratorSource i)
        {
            BlockData currentBlock = source.GetData(blockPos);

            Vector3[] norms = new Vector3[] { new Vector3(1, 0, 0), new Vector3(-1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, -1, 0), new Vector3(0, 0, 1), new Vector3(0, 0, -1) };

            Dictionary<Vector3, Dictionary<float, List<Face>>> faces = new Dictionary<Vector3, Dictionary<float, List<Face>>>();
            //Vector3 key: normal
            //float key: value of normal component

            //Foreach bounding box
            foreach (BoundingBox bb in boxes)
            {
                //Foreach normal (Minecraft normals)
                foreach (Vector3 normal in norms)
                {
                    //Get the face for the normal
                    Face face = GetFace(bb, normal);
                    face.TextureTag = bb.TextureTag;

                    //Store it using the important Normal component
                    float val = face.GetNormalValue();

                    if (float.IsNaN(val))
                        continue;

                    Dictionary<float, List<Face>> dict;
                    if (faces.ContainsKey(normal))
                    {
                        dict = faces[normal];
                    }
                    else
                    {
                        dict = new Dictionary<float, List<Face>>();
                        faces.Add(normal, dict);
                    }

                    if (dict.ContainsKey(val))
                        dict[val].Add(face);
                    else
                        dict.Add(val, new List<Face>() { face });
                }
            }

            List<CustomBlockData> datas = new List<CustomBlockData>();

            //Foreach normal
            foreach (KeyValuePair<Vector3, Dictionary<float, List<Face>>> pair in faces)
            {
                //Foreach normal component
                foreach (KeyValuePair<float, List<Face>> pair2 in pair.Value)
                {
                    //Check if we should build the side
                    if(pair2.Key == 0 && (pair.Key.X == -1 || pair.Key.Y == -1 || pair.Key.Z == -1)) //- sides
                    {
                        Point3 dir3 = pair.Key.ToPoint3();
                        Point3 atSide = blockPos + dir3;

                        BlockData atSideBlock = source.GetData(atSide);
                        if (!i.CanBuildSide(currentBlock, atSideBlock, blockPos, atSide))
                        {
                            continue;
                        }
                    }

                    if (pair2.Key == 1 && (pair.Key.X == 1 || pair.Key.Y == 1 || pair.Key.Z == 1)) //+ sides
                    {
                        Point3 dir3 = pair.Key.ToPoint3();
                        Point3 atSide = blockPos + dir3;

                        BlockData atSideBlock = source.GetData(atSide);
                        if (!i.CanBuildSide(currentBlock, atSideBlock, blockPos, atSide))
                        {
                            continue;
                        }
                    }

                    //pair2.Value contains the faces of the current Normal and Normal component value
                    //Let's calculate what we can see:
                    GpcPolygon polygon = new GpcPolygon();
                    foreach(Face face in pair2.Value)
                    {
                        GpcPolygon addPoly = new GpcPolygon();
                        addPoly.AddContour(new GpcVertexList(face.ConvertToPointList()), false);

                        polygon = polygon.Clip(GpcOperation.Union, addPoly);
                    }

                    //Remove the invisible parts
                    Vector3 inverseNormal = -pair.Key;
                    if (faces.ContainsKey(inverseNormal) && removeCoveredFaces)
                    {
                        if (faces[inverseNormal].ContainsKey(pair2.Key)) //There are faces, which make this face invisible
                        {
                            GpcPolygon invisible = new GpcPolygon();
                            foreach (Face face2 in faces[inverseNormal][pair2.Key])
                            {
                                GpcPolygon addPoly = new GpcPolygon();
                                addPoly.AddContour(new GpcVertexList(face2.ConvertToPointList()), false);

                                invisible = invisible.Clip(GpcOperation.Union, addPoly);
                            }

                            polygon = polygon.Clip(GpcOperation.Difference, invisible); //Remove the invisible parts
                        }
                    }

                    //Create the face
                    if (polygon.NofContours == 0)
                        continue;

                    foreach (GpcVertexList polys in polygon.Contour)
                    {
                        List<PolygonPoint> points = new List<PolygonPoint>();
                        foreach (GpcVertex vert in polys.Vertex)
                        {
                            points.Add(new PolygonPoint(vert.X, vert.Y));
                        }
                        Polygon triangulatorPoly = new Polygon(points);

                        //MAGIC :D
                        Triangulator.Triangulate(triangulatorPoly);

                        foreach (DelaunayTriangle tri in triangulatorPoly.Triangles)
                        {
                            CustomBlockData bd = new CustomBlockData();

                            bd.IsOneTriangle = true;
                            bd.Texture = i.GetTexture(pair2.Value[0]);

                            bd.Vertex1 = ConvertToVertexPosition(tri.Points[0], pair.Key, pair2.Key);
                            bd.Vertex2 = ConvertToVertexPosition(tri.Points[1], pair.Key, pair2.Key);
                            bd.Vertex3 = ConvertToVertexPosition(tri.Points[2], pair.Key, pair2.Key);

                            Vector2[] uvs = new Vector2[]{
                                new Vector2(tri.Points[0].Xf, tri.Points[0].Yf),
                                new Vector2(tri.Points[1].Xf, tri.Points[1].Yf),
                                new Vector2(tri.Points[2].Xf, tri.Points[2].Yf)
                            };

                            uvs = i.GetUVsForTriangle(uvs, pair2.Value[0]);

                            bd.UV1 = uvs[0];
                            bd.UV2 = uvs[1];
                            bd.UV3 = uvs[2];

                            bd.Normal = pair.Key;

                            datas.Add(bd);
                        }
                    }
                }
            }

            return datas;
        }
コード例 #5
0
        public override List<CustomBlockData> GenerateModel(byte metadata, BlockData me, BlockData Xpos, BlockData Xneg, BlockData Ypos, BlockData Yneg, BlockData Zpos, BlockData Zneg, BlockSource source, Point3 blockPosition)
        {
            List<CustomBlockData> l = new List<CustomBlockData>();

            float d = 0.01f;
            if (metadata == 0)
            {
                l.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(0, d, 0),
                    Vertex2 = new Vector3(1, d, 0),
                    Vertex3 = new Vector3(1, d, 1),
                    Vertex4 = new Vector3(0, d, 1),

                    Texture = GetTextureForSide(BlockSide.Ypos, metadata),

                    Normal = new Vector3(0, 1, 0)
                }.CreateUVs());
            }
            if (metadata == 1)
            {
                l.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(0, d, 0),
                    Vertex2 = new Vector3(1, d, 0),
                    Vertex3 = new Vector3(1, d, 1),
                    Vertex4 = new Vector3(0, d, 1),

                    Texture = GetTextureForSide(BlockSide.Ypos, metadata),

                    Normal = new Vector3(0, 1, 0)
                }.CreateUVsRotated90());
            }
            if (metadata == 2)
            {
                l.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(0, d, 0),
                    Vertex2 = new Vector3(1, d + 1, 0),
                    Vertex3 = new Vector3(1, d + 1, 1),
                    Vertex4 = new Vector3(0, d, 1),

                    Texture = GetTextureForSide(BlockSide.Ypos, metadata),

                    Normal = new Vector3(0, 1, 0)
                }.CreateUVsRotated90());
            }
            if (metadata == 3)
            {
                l.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(0, d + 1, 0),
                    Vertex2 = new Vector3(1, d, 0),
                    Vertex3 = new Vector3(1, d, 1),
                    Vertex4 = new Vector3(0, d + 1, 1),

                    Texture = GetTextureForSide(BlockSide.Ypos, metadata),

                    Normal = new Vector3(0, 1, 0)
                }.CreateUVsRotated90());
            }
            if (metadata == 4)
            {
                l.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(0, d+1, 0),
                    Vertex2 = new Vector3(1, d+1, 0),
                    Vertex3 = new Vector3(1, d, 1),
                    Vertex4 = new Vector3(0, d, 1),

                    Texture = GetTextureForSide(BlockSide.Ypos, metadata),

                    Normal = new Vector3(0, 1, 0)
                }.CreateUVs());
            }
            if (metadata == 5)
            {
                l.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(0, d, 0),
                    Vertex2 = new Vector3(1, d, 0),
                    Vertex3 = new Vector3(1, d + 1, 1),
                    Vertex4 = new Vector3(0, d + 1, 1),

                    Texture = GetTextureForSide(BlockSide.Ypos, metadata),

                    Normal = new Vector3(0, 1, 0)
                }.CreateUVs());
            }

            if (metadata == 6)
            {
                l.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(0, d, 0),
                    Vertex2 = new Vector3(1, d, 0),
                    Vertex3 = new Vector3(1, d, 1),
                    Vertex4 = new Vector3(0, d, 1),

                    Texture = GetTextureForSide(BlockSide.Ypos, metadata),

                    Normal = new Vector3(0, 1, 0)
                }.CreateUVsXYFliped());
            }
            if (metadata == 7)
            {
                l.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(0, d, 0),
                    Vertex2 = new Vector3(1, d, 0),
                    Vertex3 = new Vector3(1, d, 1),
                    Vertex4 = new Vector3(0, d, 1),

                    Texture = GetTextureForSide(BlockSide.Ypos, metadata),

                    Normal = new Vector3(0, 1, 0)
                }.CreateUVsYFlipped());
            }
            if (metadata == 8)
            {
                l.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(0, d, 0),
                    Vertex2 = new Vector3(1, d, 0),
                    Vertex3 = new Vector3(1, d, 1),
                    Vertex4 = new Vector3(0, d, 1),

                    Texture = GetTextureForSide(BlockSide.Ypos, metadata),

                    Normal = new Vector3(0, 1, 0)
                }.CreateUVsCrossFlip());
            }
            if (metadata == 9)
            {
                l.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(0, d, 0),
                    Vertex2 = new Vector3(1, d, 0),
                    Vertex3 = new Vector3(1, d, 1),
                    Vertex4 = new Vector3(0, d, 1),

                    Texture = GetTextureForSide(BlockSide.Ypos, metadata),

                    Normal = new Vector3(0, 1, 0)
                }.CreateUVs());
            }

            return l;
        }
コード例 #6
0
        public override List<CustomBlockData> GenerateModel(byte metadata, BlockData me, BlockData Xpos, BlockData Xneg, BlockData Ypos, BlockData Yneg, BlockData Zpos, BlockData Zneg, BlockSource source, Point3 blockPosition)
        {
            bool upsideDown = IsUpsideDown(metadata);

            List<BoundingBox> boxesToExport = new List<BoundingBox>();

            byte direction = GetType(metadata);

            float bottomBasePos = (upsideDown ? 0.5f : 0f);
            float topBasePos = (upsideDown ? 0f : 0.5f);

            boxesToExport.Add(new BoundingBox(new Vector3(0, bottomBasePos, 0), new Vector3(1, bottomBasePos + 0.5f, 1)));

            //Collect data from environment
            Vector3 descendingDir = MetaToDirection(direction);
            Vector3 rightFloatDir = Vector3.TransformNormal(descendingDir, Matrix.CreateRotationY((float)Math.PI / 2));
            rightFloatDir.X = (float)Math.Round(rightFloatDir.X, 4); rightFloatDir.Z = (float)Math.Round(rightFloatDir.Z, 4); //Fix small numbers

            Point3 facingDir = descendingDir.ToPoint3();
            Point3 rightDir = rightFloatDir.ToPoint3();

            BlockData frontBlock = source.GetData(blockPosition + facingDir);
            BlockData backBlock = source.GetData(blockPosition - facingDir);
            BlockData rightBlock = source.GetData(blockPosition + rightDir);
            BlockData leftBlock = source.GetData(blockPosition - rightDir);

            bool renderBaseStep = true;

            int littleCornerModel = -1;

            //Check if we need to make a corner
            {
                if (IsStairs(frontBlock))
                {
                    if (IsLeft(me.Metadata, frontBlock.Metadata))
                    {
                        bool leftOk = (IsStairs(leftBlock) && me.Metadata == leftBlock.Metadata);
                        bool rightOk = (IsStairs(rightBlock) && me.Metadata == rightBlock.Metadata);

                        if ((leftOk && !rightOk) || (!leftOk && rightOk))
                        {
                            int frontLittleStep = -1;
                            {
                                Point3 frontPos = blockPosition + facingDir;

                                BlockData me2 = source.GetData(frontPos);
                                byte direction2 = GetType(me2.Metadata);

                                Vector3 descendingDir2 = MetaToDirection(direction2);
                                Vector3 rightFloatDir2 = Vector3.TransformNormal(descendingDir2, Matrix.CreateRotationY((float)Math.PI / 2));
                                rightFloatDir2.X = (float)Math.Round(rightFloatDir2.X, 4); rightFloatDir2.Z = (float)Math.Round(rightFloatDir2.Z, 4); //Fix small numbers

                                Point3 facingDir2 = descendingDir2.ToPoint3();
                                Point3 rightDir2 = rightFloatDir2.ToPoint3();

                                BlockData backBlock2 = source.GetData(frontPos - facingDir2);
                                BlockData rightBlock2 = source.GetData(frontPos + rightDir2);
                                BlockData leftBlock2 = source.GetData(frontPos - rightDir2);

                                frontLittleStep = CheckLittleCorner(me2, backBlock2, leftBlock2, rightBlock2, direction2);

                            }

                            if (frontLittleStep == -1)
                            {
                                switch (direction)
                                {
                                    case 0:
                                        if (leftOk)
                                            littleCornerModel = 2;
                                        else
                                            littleCornerModel = 1;
                                        break;

                                    case 1:
                                        if (leftOk)
                                            littleCornerModel = 0;
                                        else
                                            littleCornerModel = 3;
                                        break;

                                    case 2:
                                        if (leftOk)
                                            littleCornerModel = 1;
                                        else
                                            littleCornerModel = 0;
                                        break;

                                    case 3:
                                        if (leftOk)
                                            littleCornerModel = 3;
                                        else
                                            littleCornerModel = 2;
                                        break;
                                }
                            }
                        }
                    }
                }
            }

            //Check if we need to make a small corner
            if (littleCornerModel == -1)  //It's not a corner so maybe..
            {
                littleCornerModel = CheckLittleCorner(me, backBlock, leftBlock, rightBlock, direction);
                renderBaseStep = (littleCornerModel == -1);
            }

            if (littleCornerModel != -1)
            {
                switch (littleCornerModel)
                {
                    case 0:
                        boxesToExport.Add(new BoundingBox(new Vector3(.5f, topBasePos, 0), new Vector3(1f, topBasePos + 0.5f, .5f)));
                        break;
                    case 1:
                        boxesToExport.Add(new BoundingBox(new Vector3(0, topBasePos, 0), new Vector3(.5f, topBasePos + 0.5f, .5f)));
                        break;

                    case 2:
                        boxesToExport.Add(new BoundingBox(new Vector3(0, topBasePos, 0.5f), new Vector3(.5f, topBasePos + 0.5f, 1)));
                        break;
                    case 3:
                        boxesToExport.Add(new BoundingBox(new Vector3(.5f, topBasePos, .5f), new Vector3(1f, topBasePos + 0.5f, 1f)));
                        break;
                }
            }

            if (renderBaseStep)
            {
                switch (direction) //Ascending...
                {
                    case 0: //east = +X
                        boxesToExport.Add(new BoundingBox(new Vector3(.5f, topBasePos, 0), new Vector3(1f, topBasePos + 0.5f, 1)));
                        break;
                    case 1: //west = -X
                        boxesToExport.Add(new BoundingBox(new Vector3(0, topBasePos, 0), new Vector3(.5f, topBasePos + 0.5f, 1)));
                        break;

                    case 2: //south = +Z
                        boxesToExport.Add(new BoundingBox(new Vector3(0, topBasePos, 0.5f), new Vector3(1f, topBasePos + 0.5f, 1)));
                        break;
                    case 3: //north = -Z
                        boxesToExport.Add(new BoundingBox(new Vector3(0, topBasePos, 0), new Vector3(1f, topBasePos + 0.5f, .5f)));
                        break;
                }
            }

            return GeometryGenerator.GenerateModel(boxesToExport, source, blockPosition, true, this);
        }
コード例 #7
0
        public override List<CustomBlockData> GenerateModel(byte metadata, BlockData me, BlockData Xpos, BlockData Xneg, BlockData Ypos, BlockData Yneg, BlockData Zpos, BlockData Zneg, BlockSource source, Point3 blockPosition)
        {
            List<CustomBlockData> data = new List<CustomBlockData>();

            string tex = "fire_layer_0";

            //Side X
            data.Add(new CustomBlockData()
            {
                Normal = new Vector3(1,0,0),
                Texture = tex,

                Vertex1 = new Vector3(1,0,0),
                Vertex2 = new Vector3(1,0,1),
                Vertex3 = new Vector3(1,1,1),
                Vertex4 = new Vector3(1,1,0),
            }.CreateUVs());

            data.Add(new CustomBlockData()
            {
                Normal = new Vector3(-1, 0, 0),
                Texture = tex,

                Vertex1 = new Vector3(0, 0, 0),
                Vertex2 = new Vector3(0, 0, 1),
                Vertex3 = new Vector3(0, 1, 1),
                Vertex4 = new Vector3(0, 1, 0),
            }.CreateUVs());

            //Side Z
            data.Add(new CustomBlockData()
            {
                Normal = new Vector3(0, 0, 1),
                Texture = tex,

                Vertex1 = new Vector3(0, 0, 1),
                Vertex2 = new Vector3(1, 0, 1),
                Vertex3 = new Vector3(1, 1, 1),
                Vertex4 = new Vector3(0, 1, 1),
            }.CreateUVs());

            data.Add(new CustomBlockData()
            {
                Normal = new Vector3(0, 0, -1),
                Texture = tex,

                Vertex1 = new Vector3(0, 0, 0),
                Vertex2 = new Vector3(1, 0, 0),
                Vertex3 = new Vector3(1, 1, 0),
                Vertex4 = new Vector3(0, 1, 0),
            }.CreateUVs());

            //X shape: X
            float shiftl = 0.25f;
            float shifth = 0.75f;

            data.Add(new CustomBlockData()
            {
                Texture = tex,

                Vertex2 = new Vector3(shiftl, 0, 0),
                Vertex1 = new Vector3(shiftl, 0, 1),
                Vertex4 = new Vector3(shifth, 1, 1),
                Vertex3 = new Vector3(shifth, 1, 0),

                TriFlip = true
            }.CreateUVs().CalculateNormal());

            data.Add(new CustomBlockData()
            {
                Texture = tex,

                Vertex1 = new Vector3(shifth, 0, 0),
                Vertex2 = new Vector3(shifth, 0, 1),
                Vertex3 = new Vector3(shiftl, 1, 1),
                Vertex4 = new Vector3(shiftl, 1, 0),

                TriFlip = true,
                KeepNormal = true
            }.CreateUVs().CalculateNormal());

            //X shape: Z
            data.Add(new CustomBlockData()
            {
                Texture = tex,

                Vertex1 = new Vector3(0, 0, shiftl),
                Vertex2 = new Vector3(1, 0, shiftl),
                Vertex3 = new Vector3(1, 1, shifth),
                Vertex4 = new Vector3(0, 1, shifth),

                TriFlip = true,
                KeepNormal = false
            }.CreateUVs().CalculateNormal());

            data.Add(new CustomBlockData()
            {
                Texture = tex,

                Vertex1 = new Vector3(0, 0, shifth),
                Vertex2 = new Vector3(1, 0, shifth),
                Vertex3 = new Vector3(1, 1, shiftl),
                Vertex4 = new Vector3(0, 1, shiftl),

                TriFlip = true,
                KeepNormal = true
            }.CreateUVs().CalculateNormal());

            return data;
        }
コード例 #8
0
        public override List<CustomBlockData> GenerateModel(byte metadata, BlockData me, BlockData Xpos, BlockData Xneg, BlockData Ypos, BlockData Yneg, BlockData Zpos, BlockData Zneg, BlockSource source, Point3 blockPosition)
        {
            List<CustomBlockData> mdl = new List<CustomBlockData>();

            bool zPos = Zpos.IsSolid || Zpos.ID == me.ID;
            bool zNeg = Zneg.IsSolid || Zneg.ID == me.ID;
            bool xPos = Xpos.IsSolid || Xpos.ID == me.ID;
            bool xNeg = Xneg.IsSolid || Xneg.ID == me.ID;

            float xStart = 0;
            float xEnd = 1;
            float zStart = 0;
            float zEnd = 1;

            if (!xPos && xNeg)
            {
                xStart = 0;
                xEnd = 0.5f;
            }
            else if (xPos && !xNeg)
            {
                xStart = .5f;
                xEnd = 1;
            }
            else if (xPos && xNeg)
            {
                xStart = 0;
                xEnd = 1;
            }
            else if (!xPos && !xNeg)
            {
                xStart = 0;
                xEnd = 0;
            }

            if (!zPos && zNeg)
            {
                zStart = 0;
                zEnd = 0.5f;
            }
            else if (zPos && !zNeg)
            {
                zStart = .5f;
                zEnd = 1;
            }
            else if (zPos && zNeg)
            {
                zStart = 0;
                zEnd = 1;
            }
            else if (!zPos && !zNeg)
            {
                zStart = 0;
                zEnd = 0;
            }

            if (!zPos && !zNeg && !xPos && !xNeg)
            {
                xStart = 0;
                xEnd = 1;
                zStart = 0;
                zEnd = 1;
            }

            #region X sides
            if (xStart != 0 || xEnd != 0)
            {
                mdl.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(xStart, 0, .5f),
                    Vertex2 = new Vector3(xStart, 1, .5f),
                    Vertex3 = new Vector3(xEnd, 1, .5f),
                    Vertex4 = new Vector3(xEnd, 0, .5f),

                    Normal = new Vector3(1, 0, 0),

                    Texture = _tex
                }.CreateUVsRotated90(xStart, 0, xEnd, 1));
                mdl.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(xStart, 0, .5f),
                    Vertex2 = new Vector3(xStart, 1, .5f),
                    Vertex3 = new Vector3(xEnd, 1, .5f),
                    Vertex4 = new Vector3(xEnd, 0, .5f),

                    Normal = new Vector3(1, 0, 0),

                    TriFlip = true,

                    Texture = _tex
                }.CreateUVsRotated90(xStart, 0, xEnd, 1));

                if (!source.GetData(new Point3(blockPosition.X, blockPosition.Y + 1, blockPosition.Z)).EqualsID(me))
                {
                    mdl.Add(new CustomBlockData()
                           {
                               Vertex1 = new Vector3(xStart, 0.99f, 0.45f),
                               Vertex2 = new Vector3(xEnd, 0.99f, 0.45f),
                               Vertex3 = new Vector3(xEnd, 0.99f, .55f),
                               Vertex4 = new Vector3(xStart, 0.99f, .55f),

                               Normal = new Vector3(0, 1, 0),

                               UV1 = new Vector2(.45f, 0),
                               UV2 = new Vector2(.45f, 1),
                               UV3 = new Vector2(.55f, 1),
                               UV4 = new Vector2(.55f, 0),

                               Texture = _tex

                           });
                }

                if (!source.GetData(new Point3(blockPosition.X, blockPosition.Y - 1, blockPosition.Z)).EqualsID(me))
                {
                    mdl.Add(new CustomBlockData()
                        {
                            Vertex1 = new Vector3(xStart, 0.01f, 0.45f),
                            Vertex2 = new Vector3(xEnd, 0.01f, 0.45f),
                            Vertex3 = new Vector3(xEnd, 0.01f, .55f),
                            Vertex4 = new Vector3(xStart, 0.01f, .55f),

                            Normal = new Vector3(0, 1, 0),

                            UV1 = new Vector2(.45f, 0),
                            UV2 = new Vector2(.45f, 1),
                            UV3 = new Vector2(.55f, 1),
                            UV4 = new Vector2(.55f, 0),

                            Texture = _tex

                        });
                }

                if (xPos && !xNeg)
                {
                    mdl.Add(new CustomBlockData()
                    {
                        Vertex1 = new Vector3(.5f, 0, .45f),
                        Vertex2 = new Vector3(.5f, .99f, .45f),
                        Vertex3 = new Vector3(.5f, .99f, .55f),
                        Vertex4 = new Vector3(.5f, 0, .55f),

                        Normal = new Vector3(1, 0, 0),

                        UV1 = new Vector2(.45f, 0),
                        UV2 = new Vector2(.45f, 1),
                        UV3 = new Vector2(.55f, 1),
                        UV4 = new Vector2(.55f, 0),

                        Texture = _texY
                    });
                }
                else if (!xPos && xNeg)
                {
                    mdl.Add(new CustomBlockData()
                    {
                        Vertex1 = new Vector3(.5f, 0, .45f),
                        Vertex2 = new Vector3(.5f, .99f, .45f),
                        Vertex3 = new Vector3(.5f, .99f, .55f),
                        Vertex4 = new Vector3(.5f, 0, .55f),

                        Normal = new Vector3(1, 0, 0),

                        UV1 = new Vector2(.45f, 0),
                        UV2 = new Vector2(.45f, 1),
                        UV3 = new Vector2(.55f, 1),
                        UV4 = new Vector2(.55f, 0),

                        Texture = _texY
                    });
                }
            }
            #endregion

            #region Z sides
            if (zStart != 0 || zEnd != 0)
            {
                mdl.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(.5f, 0, zStart),
                    Vertex2 = new Vector3(.5f, 1, zStart),
                    Vertex3 = new Vector3(.5f, 1, zEnd),
                    Vertex4 = new Vector3(.5f, 0, zEnd),

                    Normal = new Vector3(0, 0, 1),

                    Texture = _tex
                }.CreateUVsRotated90(zStart, 0, zEnd, 1));
                mdl.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(.5f, 0, zStart),
                    Vertex2 = new Vector3(.5f, 1, zStart),
                    Vertex3 = new Vector3(.5f, 1, zEnd),
                    Vertex4 = new Vector3(.5f, 0, zEnd),

                    Normal = new Vector3(0, 0, 1),

                    TriFlip = true,

                    Texture = _tex
                }.CreateUVsRotated90(zStart, 0, zEnd, 1));

                if (!source.GetData(new Point3(blockPosition.X, blockPosition.Y + 1, blockPosition.Z)).EqualsID(me))
                {
                    mdl.Add(new CustomBlockData()
                    {
                        Vertex1 = new Vector3(.45f, 1, zStart),
                        Vertex2 = new Vector3(.45f, 1, zEnd),
                        Vertex3 = new Vector3(.55f, 1, zEnd),
                        Vertex4 = new Vector3(.55f, 1, zStart),

                        Normal = new Vector3(0, 1, 0),

                        UV1 = new Vector2(.45f, zStart),
                        UV2 = new Vector2(.45f, zEnd),
                        UV3 = new Vector2(.55f, zEnd),
                        UV4 = new Vector2(.55f, zStart),

                        Texture = _tex
                    });
                }

                if (!source.GetData(new Point3(blockPosition.X, blockPosition.Y - 1, blockPosition.Z)).EqualsID(me))
                {
                    mdl.Add(new CustomBlockData()
                    {
                        Vertex1 = new Vector3(.45f, 0, zStart),
                        Vertex2 = new Vector3(.45f, 0, zEnd),
                        Vertex3 = new Vector3(.55f, 0, zEnd),
                        Vertex4 = new Vector3(.55f, 0, zStart),

                        Normal = new Vector3(0, 1, 0),

                        UV1 = new Vector2(.45f, zStart),
                        UV2 = new Vector2(.45f, zEnd),
                        UV3 = new Vector2(.55f, zEnd),
                        UV4 = new Vector2(.55f, zStart),

                        Texture = _tex
                    });
                }

                if (zPos && !zNeg)
                {
                    mdl.Add(new CustomBlockData()
                    {
                        Vertex1 = new Vector3(.45f, 0, .5f),
                        Vertex2 = new Vector3(.45f, 1, .5f),
                        Vertex3 = new Vector3(.55f, 1, .5f),
                        Vertex4 = new Vector3(.55f, 0, .5f),

                        Normal = new Vector3(1, 0, 0),

                        UV1 = new Vector2(.45f, 0),
                        UV2 = new Vector2(.45f, 1),
                        UV3 = new Vector2(.55f, 1),
                        UV4 = new Vector2(.55f, 0),

                        Texture = _texY
                    });
                }
                else if (!zPos && zNeg)
                {
                    mdl.Add(new CustomBlockData()
                    {
                        Vertex1 = new Vector3(.45f, 0, .5f),
                        Vertex2 = new Vector3(.45f, 1, .5f),
                        Vertex3 = new Vector3(.55f, 1, .5f),
                        Vertex4 = new Vector3(.55f, 0, .5f),

                        Normal = new Vector3(1, 0, 0),

                        UV1 = new Vector2(.45f, 0),
                        UV2 = new Vector2(.45f, 1),
                        UV3 = new Vector2(.55f, 1),
                        UV4 = new Vector2(.55f, 0),

                        Texture = _texY
                    });
                }
            }
            #endregion

            return mdl;
        }
コード例 #9
0
 public virtual List<CustomBlockData> GenerateModel(byte metadata, BlockData me, BlockData Xpos, BlockData Xneg, BlockData Ypos, BlockData Yneg, BlockData Zpos, BlockData Zneg, BlockSource source, Point3 blockPosition)
 {
     return new List<CustomBlockData>();
 }
コード例 #10
0
        public override List<CustomBlockData> GenerateModel(byte metadata, BlockData me, BlockData Xpos, BlockData Xneg, BlockData Ypos, BlockData Yneg, BlockData Zpos, BlockData Zneg, BlockSource source, Point3 blockPosition)
        {
            List<CustomBlockData> d = new List<CustomBlockData>();

            bool standing = (metadata == 5);

            float h = 0.625f;
            float ts = 1.0f - h;
            float s = 0.4375f;
            float s2 = 1f - s;

            float xDif = 0f;
            float zDif = 0f;

            if (!standing)
            {
                switch (metadata)
                {
                    case 1:
                        xDif = -0.5f;
                        break;
                    case 2:
                        xDif = 0.5f;
                        break;
                    case 3:
                        zDif = -0.5f;
                        break;
                    case 4:
                        zDif = 0.5f;
                        break;
                }

                //Bottom
                d.Add(new CustomBlockData()
                {
                    Texture = "torch_on",

                    Vertex1 = new Vector3(s + xDif, 0, s + zDif),
                    Vertex2 = new Vector3(s2 + xDif, 0, s + zDif),
                    Vertex3 = new Vector3(s2 + xDif, 0, s2 + zDif),
                    Vertex4 = new Vector3(s + xDif, 0, s2 + zDif),

                    Normal = new Vector3(0, -1, 0)
                }.CreateUVs(0.4375f, 0f, 0.5625f, 0.125f));
            }

            //Sides
            d.Add(new CustomBlockData()
            {
                Texture = "torch_on",

                Vertex2 = new Vector3(s2 + xDif, 0, s + zDif),
                Vertex1 = new Vector3(s2 + (xDif / 2), h, s + (zDif / 2)),
                Vertex4 = new Vector3(s2 + (xDif / 2), h, s2 + (zDif / 2)),
                Vertex3 = new Vector3(s2 + xDif, 0, s2 + zDif),

                Normal = new Vector3(1, 0, 0)
            }.CreateUVs(ts,s,1,s2).RotateUVs(270));
            d.Add(new CustomBlockData()
            {
                Texture = "torch_on",

                Vertex2 = new Vector3(s + xDif, 0, s + zDif),
                Vertex1 = new Vector3(s + (xDif / 2), h, s + (zDif / 2)),
                Vertex4 = new Vector3(s + (xDif / 2), h, s2 + (zDif / 2)),
                Vertex3 = new Vector3(s + xDif, 0, s2 + zDif),

                Normal = new Vector3(-1, 0, 0)
            }.CreateUVs(ts, s, 1, s2).RotateUVs(270));

            d.Add(new CustomBlockData()
            {
                Texture = "torch_on",

                Vertex2 = new Vector3(s + xDif, 0, s + zDif),
                Vertex1 = new Vector3(s + (xDif / 2), h, s + (zDif / 2)),
                Vertex4 = new Vector3(s2 + (xDif / 2), h, s + (zDif / 2)),
                Vertex3 = new Vector3(s2 + xDif, 0, s + zDif),

                Normal = new Vector3(0, 0, -1)
            }.CreateUVs(ts, s, 1, s2).RotateUVs(270));
            d.Add(new CustomBlockData()
            {
                Texture = "torch_on",

                Vertex2 = new Vector3(s + xDif, 0, s2 + zDif),
                Vertex1 = new Vector3(s + (xDif / 2), h, s2 + (zDif / 2)),
                Vertex4 = new Vector3(s2 + (xDif / 2), h, s2 + (zDif / 2)),
                Vertex3 = new Vector3(s2 + xDif, 0, s2 + zDif),

                Normal = new Vector3(0, 0, 1)
            }.CreateUVs(ts, s, 1, s2).RotateUVs(270));

            //Top
            d.Add(new CustomBlockData()
            {
                Texture = "torch_on",

                Vertex1 = new Vector3(s + (xDif / 2), h, s + (zDif / 2)),
                Vertex2 = new Vector3(s2 + (xDif / 2), h, s + (zDif / 2)),
                Vertex3 = new Vector3(s2 + (xDif / 2), h, s2 + (zDif / 2)),
                Vertex4 = new Vector3(s + (xDif / 2), h, s2 + (zDif / 2)),

                Normal = new Vector3(0,1,0)
            }.CreateUVs(0.4375f, 0.5f, 0.5625f, 0.625f));

            return d;
        }
コード例 #11
0
        public override List<CustomBlockData> GenerateModel(byte metadata, BlockData me, BlockData Xpos, BlockData Xneg, BlockData Ypos, BlockData Yneg, BlockData Zpos, BlockData Zneg, BlockSource source, Point3 blockPosition)
        {
            List<CustomBlockData> dat = new List<CustomBlockData>();

            float d = 0.01f;
            if (metadata == 2)
            {
                dat.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(0, 1, 1-d),
                    Vertex2 = new Vector3(0, 0, 1-d),
                    Vertex3 = new Vector3(1, 0, 1-d),
                    Vertex4 = new Vector3(1, 1, 1-d),

                    Normal = new Vector3(0, 0, -1),

                    Texture = "ladder"
                }.CreateUVsRotated90());
            }
            if (metadata == 3)
            {
                dat.Add(new CustomBlockData()
                {
                    Vertex1  =new Vector3(0,1,d),
                    Vertex2 = new Vector3(0,0,d),
                    Vertex3 = new Vector3(1,0,d),
                    Vertex4 = new Vector3(1,1,d),

                    Normal = new Vector3(0,0,1),

                    Texture = "ladder"
                }.CreateUVsRotated90());
            }
            if (metadata == 4)
            {
                dat.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(1-d, 1, 0),
                    Vertex2 = new Vector3(1-d, 0, 0),
                    Vertex3 = new Vector3(1-d, 0, 1),
                    Vertex4 = new Vector3(1-d, 1, 1),

                    Normal = new Vector3(-1, 0, 0),

                    Texture = "ladder"
                }.CreateUVsRotated90());
            }
            if (metadata == 5)
            {
                dat.Add(new CustomBlockData()
                {
                    Vertex1 = new Vector3(d, 1, 0),
                    Vertex2 = new Vector3(d, 0, 0),
                    Vertex3 = new Vector3(d, 0, 1),
                    Vertex4 = new Vector3(d, 1, 1),

                    Normal = new Vector3(1, 0, 0),

                    Texture = "ladder"
                }.CreateUVsRotated90());
            }

            return dat;
        }
コード例 #12
0
        public override List<CustomBlockData> GenerateModel(byte metadata, BlockData me, BlockData Xpos, BlockData Xneg, BlockData Ypos, BlockData Yneg, BlockData Zpos, BlockData Zneg, BlockSource source, Point3 blockPosition)
        {
            float height = 0.5625f;

            List<BoundingBox> bb = new List<BoundingBox>();

            bool head = ((metadata & 8) != 0);
            int direction = metadata & 3;

            bb.Add(new BoundingBox(new Vector3(0, 0, 0), new Vector3(1, height, 1), head ? "head" : "foot"));

            return GeometryGenerator.GenerateModel(bb, source, blockPosition, true, this);

               /* Dictionary<Vector3, BlockData> sideData = new Dictionary<Vector3, BlockData>();
            sideData.Add(new Vector3(-1, 0, 0), Xneg);
            sideData.Add(new Vector3(1, 0, 0), Xpos);
            sideData.Add(new Vector3(0, 1, 0), Ypos);
            sideData.Add(new Vector3(0, -1, 0), Yneg);
            sideData.Add(new Vector3(0, 0, 1), Zpos);
            sideData.Add(new Vector3(0, 0, -1), Zneg);

            List<CustomBlockData> d = new List<CustomBlockData>();

            bool head = ((metadata & 8) != 0);
            int direction = metadata & 3;

            float height = 0.5625f;

            Rotate rot = Rotate.None;
            Vector3 bedDir = new Vector3(0, 0, 0);
            switch (direction)
            {
                case 0:
                    rot = Rotate.Deg270;
                    bedDir.Z = 1;
                    break;
                case 1:
                    rot = Rotate.Deg180;
                    bedDir.X = -1;
                    break;
                case 2:
                    rot = Rotate.Deg90;
                    bedDir.Z = -1;
                    break;
                case 3:
                    bedDir.X = 1;
                    break;
            }

            //top
            d.Add(new CustomBlockData()
            {
                Vertex1 = new Vector3(0, height, 0),
                Vertex2 = new Vector3(1, height, 0),
                Vertex3 = new Vector3(1, height, 1),
                Vertex4 = new Vector3(0, height, 1),

                Normal = new Vector3(0, 1, 0),

                Texture = head ? "bed_head_top" : "bed_feet_top"
            }.CreateUVsRotated(rot));

            //bottom
            float h = 0.1875f;

            d.Add(new CustomBlockData()
            {
                Vertex1 = new Vector3(0, h, 0),
                Vertex2 = new Vector3(1, h, 0),
                Vertex3 = new Vector3(1, h, 1),
                Vertex4 = new Vector3(0, h, 1),

                Normal = new Vector3(0, -1, 0),

                Texture = "planks_oak"
            }.CreateUVsRotated(rot));

            //head
            if (head)
            {
                //end
                Vector3[] endVerts = BuildBasedOnNormal(bedDir, height);

                if (!sideData[bedDir].IsSolid)
                {
                    d.Add(new CustomBlockData()
                    {
                        Vertex1 = endVerts[3],
                        Vertex2 = endVerts[2],
                        Vertex3 = endVerts[1],
                        Vertex4 = endVerts[0],

                        Normal = bedDir,

                        Texture = "bed_head_end",
                    }.CreateUVs(0, 0, height, 1).RotateUVs(90));
                }

                //sides
                Vector3 sideNormalA;
                Vector3 sideNormalB;

                if (bedDir.X != 0)
                {
                    sideNormalA = new Vector3(0, 0, 1);
                    sideNormalB = new Vector3(0, 0, -1);
                }
                else
                {
                    sideNormalA = new Vector3(1, 0, 0);
                    sideNormalB = new Vector3(-1, 0, 0);
                }

                Vector3[] sideVertsA = BuildBasedOnNormal(sideNormalA, height);
                CustomBlockData sideA = new CustomBlockData()
                {
                    Vertex1 = sideVertsA[3],
                    Vertex2 = sideVertsA[2],
                    Vertex3 = sideVertsA[1],
                    Vertex4 = sideVertsA[0],

                    Normal = sideNormalA,

                    Texture = "bed_head_side",
                }.CreateUVs(0, 0, height, 1).RotateUVs(90);

                Vector3[] sideVertsB = BuildBasedOnNormal(sideNormalB, height);
                CustomBlockData sideB = new CustomBlockData()
                {
                    Vertex1 = sideVertsB[3],
                    Vertex2 = sideVertsB[2],
                    Vertex3 = sideVertsB[1],
                    Vertex4 = sideVertsB[0],

                    Normal = sideNormalB,

                    Texture = "bed_head_side",
                }.CreateUVs(0, 0, height, 1).RotateUVs(90);

                if (direction == 1 || direction == 2)
                {
                    sideA = sideA.FlipUVsX();
                    sideB = sideB.FlipUVsX();
                }

                if (!sideData[sideNormalA].IsSolid)
                {
                    d.Add(sideA);
                }
                if (!sideData[sideNormalB].IsSolid)
                {
                    d.Add(sideB);
                }
            }
            //feet
            else
            {
                //end
                Vector3[] endVerts = BuildBasedOnNormal(-bedDir, height);

                if (!sideData[-bedDir].IsSolid)
                {
                    d.Add(new CustomBlockData()
                    {
                        Vertex1 = endVerts[3],
                        Vertex2 = endVerts[2],
                        Vertex3 = endVerts[1],
                        Vertex4 = endVerts[0],

                        Normal = -bedDir,

                        Texture = "bed_feet_end",
                    }.CreateUVs(0, 0, height, 1).RotateUVs(90));
                }

                //sides
                Vector3 sideNormalA;
                Vector3 sideNormalB;

                if (bedDir.X != 0)
                {
                    sideNormalA = new Vector3(0, 0, 1);
                    sideNormalB = new Vector3(0, 0, -1);
                }
                else
                {
                    sideNormalA = new Vector3(1, 0, 0);
                    sideNormalB = new Vector3(-1, 0, 0);
                }

                Vector3[] sideVertsA = BuildBasedOnNormal(sideNormalA, height);
                CustomBlockData sideA = new CustomBlockData()
                {
                    Vertex1 = sideVertsA[3],
                    Vertex2 = sideVertsA[2],
                    Vertex3 = sideVertsA[1],
                    Vertex4 = sideVertsA[0],

                    Normal = sideNormalA,

                    Texture = "bed_feet_side",
                }.CreateUVs(0, 0, height, 1).RotateUVs(90);

                Vector3[] sideVertsB = BuildBasedOnNormal(sideNormalB, height);
                CustomBlockData sideB = new CustomBlockData()
                {
                    Vertex1 = sideVertsB[3],
                    Vertex2 = sideVertsB[2],
                    Vertex3 = sideVertsB[1],
                    Vertex4 = sideVertsB[0],

                    Normal = sideNormalB,

                    Texture = "bed_feet_side",
                }.CreateUVs(0, 0, height, 1).RotateUVs(90);

                if (direction == 1 || direction == 2)
                {
                    sideA = sideA.FlipUVsX();
                    sideB = sideB.FlipUVsX();
                }

                if (!sideData[sideNormalA].IsSolid)
                {
                    d.Add(sideA);
                }
                if (!sideData[sideNormalB].IsSolid)
                {
                    d.Add(sideB);
                }
            }

            return d;*/
        }
コード例 #13
0
 private static void SerializeCommitBlockListEntry(StringBuilder builder, byte[] block, BlockSource blockSource)
 {
     builder.Append((char)((int)block.Length + 32));
     builder.Append(DbListBlobObject.ToHexString(block));
     builder.Append((char)(48 + (ushort)blockSource));
 }
コード例 #14
0
 public void Reset()
 {
     m_source      = new BlockSource(m_reader);
     m_currenthash = null;
     m_currentfile = null;
 }
コード例 #15
0
ファイル: BlockFlags16.cs プロジェクト: mksbamford/Moonfxsh
 public BlockFlags16(short flags)
 {
     Type   = ( BlockType )(flags >> 8);
     Source = ( BlockSource )(flags & 0xFF);
 }
コード例 #16
0
        public override List<CustomBlockData> GenerateModel(byte metadata, BlockData me, BlockData Xpos, BlockData Xneg, BlockData Ypos, BlockData Yneg, BlockData Zpos, BlockData Zneg, BlockSource source, Point3 blockPosition)
        {
            List<CustomBlockData> data = new List<CustomBlockData>();

            string tex = GetTextureForStage(metadata);

            data.Add(new CustomBlockData()
            {
                Normal = new Vector3(1, 0, 0),
                TriFlip = true,
                DoubleSided = true,

                Texture = tex,

                Vertex1 = new Vector3(backFourPix, -onePix, 0),
                Vertex2 = new Vector3(backFourPix, topOnePix, 0),
                Vertex3 = new Vector3(backFourPix, topOnePix, 1f),
                Vertex4 = new Vector3(backFourPix, -onePix, 1f)
            }.CreateUVsRotated(90));

            data.Add(new CustomBlockData()
            {
                Normal = new Vector3(-1, 0, 0),
                TriFlip = true,
                DoubleSided = true,

                Texture = tex,

                Vertex1 = new Vector3(fourPix, -onePix, 0),
                Vertex2 = new Vector3(fourPix, topOnePix, 0),
                Vertex3 = new Vector3(fourPix, topOnePix, 1f),
                Vertex4 = new Vector3(fourPix, -onePix, 1f)
            }.CreateUVsRotated(90));

            data.Add(new CustomBlockData()
            {
                Normal = new Vector3(0, 0, -1),
                TriFlip = true,
                DoubleSided = true,

                Texture = tex,

                Vertex1 = new Vector3(0, -onePix, fourPix),
                Vertex2 = new Vector3(0, topOnePix, fourPix),
                Vertex3 = new Vector3(1, topOnePix, fourPix),
                Vertex4 = new Vector3(1, -onePix, fourPix)
            }.CreateUVsRotated(90));

            data.Add(new CustomBlockData()
            {
                Normal = new Vector3(0, 0, 1),
                TriFlip = true,
                DoubleSided = true,

                Texture = tex,

                Vertex1 = new Vector3(0, -onePix, backFourPix),
                Vertex2 = new Vector3(0, topOnePix, backFourPix),
                Vertex3 = new Vector3(1, topOnePix, backFourPix),
                Vertex4 = new Vector3(1, -onePix, backFourPix)
            }.CreateUVsRotated(90));

            return data;
        }