示例#1
0
        public override void Initialize()
        {
            Model     model                  = ContentManager.Get <Model>("Models/Leds");
            ModelMesh modelMesh              = model.FindMesh("Led");
            ModelMesh modelMesh2             = model.FindMesh("LedBulb");
            Matrix    boneAbsoluteTransform  = BlockMesh.GetBoneAbsoluteTransform(modelMesh.ParentBone);
            Matrix    boneAbsoluteTransform2 = BlockMesh.GetBoneAbsoluteTransform(modelMesh2.ParentBone);
            Matrix    m = Matrix.CreateRotationY(-(float)Math.PI / 2f) * Matrix.CreateRotationZ((float)Math.PI / 2f);

            m_standaloneBlockMesh = new BlockMesh();
            m_standaloneBlockMesh.AppendModelMeshPart(modelMesh.MeshParts[0], boneAbsoluteTransform * m, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_standaloneBlockMesh.AppendModelMeshPart(modelMesh2.MeshParts[0], boneAbsoluteTransform2 * m, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, new Color(48, 48, 48));
            for (int i = 0; i < 6; i++)
            {
                int    num = SetMountingFace(0, i);
                Matrix m2  = (i >= 4) ? ((i != 4) ? (Matrix.CreateRotationX((float)Math.PI) * Matrix.CreateTranslation(0.5f, 1f, 0.5f)) : Matrix.CreateTranslation(0.5f, 0f, 0.5f)) : (Matrix.CreateRotationX((float)Math.PI / 2f) * Matrix.CreateTranslation(0f, 0f, -0.5f) * Matrix.CreateRotationY((float)i * (float)Math.PI / 2f) * Matrix.CreateTranslation(0.5f, 0.5f, 0.5f));
                m_blockMeshesByData[num] = new BlockMesh();
                m_blockMeshesByData[num].AppendModelMeshPart(modelMesh.MeshParts[0], boneAbsoluteTransform * m2, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
                m_blockMeshesByData[num].AppendModelMeshPart(modelMesh2.MeshParts[0], boneAbsoluteTransform2 * m2, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, new Color(48, 48, 48));
                m_collisionBoxesByData[num] = new BoundingBox[1]
                {
                    m_blockMeshesByData[num].CalculateBoundingBox()
                };
            }
        }
示例#2
0
        public override void Initialize()
        {
            Model  model = ContentManager.Get <Model>("Models/Switch");
            Matrix boneAbsoluteTransform  = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Body").ParentBone);
            Matrix boneAbsoluteTransform2 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Lever").ParentBone);

            for (int i = 0; i < 6; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    int    num = (i << 1) | j;
                    Matrix m   = (i >= 4) ? ((i != 4) ? (Matrix.CreateRotationX((float)Math.PI) * Matrix.CreateTranslation(0.5f, 1f, 0.5f)) : Matrix.CreateTranslation(0.5f, 0f, 0.5f)) : (Matrix.CreateRotationX((float)Math.PI / 2f) * Matrix.CreateTranslation(0f, 0f, -0.5f) * Matrix.CreateRotationY((float)i * (float)Math.PI / 2f) * Matrix.CreateTranslation(0.5f, 0.5f, 0.5f));
                    Matrix m2  = Matrix.CreateRotationX((j == 0) ? MathUtils.DegToRad(30f) : MathUtils.DegToRad(-30f));
                    m_blockMeshesByData[num] = new BlockMesh();
                    m_blockMeshesByData[num].AppendModelMeshPart(model.FindMesh("Body").MeshParts[0], boneAbsoluteTransform * m, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
                    m_blockMeshesByData[num].AppendModelMeshPart(model.FindMesh("Lever").MeshParts[0], boneAbsoluteTransform2 * m2 * m, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
                    m_collisionBoxesByData[num] = new BoundingBox[1]
                    {
                        m_blockMeshesByData[num].CalculateBoundingBox()
                    };
                }
            }
            Matrix m3 = Matrix.CreateRotationY(-(float)Math.PI / 2f) * Matrix.CreateRotationZ((float)Math.PI / 2f);

            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Body").MeshParts[0], boneAbsoluteTransform * m3, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Lever").MeshParts[0], boneAbsoluteTransform2 * m3, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
        }
示例#3
0
        public override void Initialize()
        {
            Model     model = ContentManager.Get <Model>("Models/Crossbows");
            Matrix    boneAbsoluteTransform  = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Body").ParentBone);
            Matrix    boneAbsoluteTransform2 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("BowRelaxed").ParentBone);
            Matrix    boneAbsoluteTransform3 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("StringRelaxed").ParentBone);
            Matrix    boneAbsoluteTransform4 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("BowTensed").ParentBone);
            Matrix    boneAbsoluteTransform5 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("StringTensed").ParentBone);
            BlockMesh blockMesh = new BlockMesh();

            blockMesh.AppendModelMeshPart(model.FindMesh("Body").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, 0f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            blockMesh.AppendModelMeshPart(model.FindMesh("BowRelaxed").MeshParts[0], boneAbsoluteTransform2 * Matrix.CreateTranslation(0f, 0f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            blockMesh.AppendModelMeshPart(model.FindMesh("StringRelaxed").MeshParts[0], boneAbsoluteTransform3 * Matrix.CreateTranslation(0f, 0f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            BlockMesh blockMesh2 = new BlockMesh();

            blockMesh2.AppendModelMeshPart(model.FindMesh("Body").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, 0f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            blockMesh2.AppendModelMeshPart(model.FindMesh("BowTensed").MeshParts[0], boneAbsoluteTransform4 * Matrix.CreateTranslation(0f, 0f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            blockMesh2.AppendModelMeshPart(model.FindMesh("StringTensed").MeshParts[0], boneAbsoluteTransform5 * Matrix.CreateTranslation(0f, 0f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            for (int i = 0; i < 16; i++)
            {
                float factor = (float)i / 15f;
                m_standaloneBlockMeshes[i] = new BlockMesh();
                m_standaloneBlockMeshes[i].AppendBlockMesh(blockMesh);
                m_standaloneBlockMeshes[i].BlendBlockMesh(blockMesh2, factor);
            }
            base.Initialize();
        }
示例#4
0
        public override void Initialize()
        {
            Model  model = ContentManager.Get <Model>("Models/Campfire");
            Matrix boneAbsoluteTransform  = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Wood").ParentBone);
            Matrix boneAbsoluteTransform2 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Ashes").ParentBone);

            for (int i = 0; i < 16; i++)
            {
                m_meshesByData[i] = new BlockMesh();
                if (i == 0)
                {
                    m_meshesByData[i].AppendModelMeshPart(model.FindMesh("Ashes").MeshParts[0], boneAbsoluteTransform2 * Matrix.CreateScale(3f) * Matrix.CreateTranslation(0.5f, 0f, 0.5f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
                }
                else
                {
                    float scale   = MathUtils.Lerp(1.5f, 4f, (float)i / 15f);
                    float radians = (float)i * (float)Math.PI / 2f;
                    m_meshesByData[i].AppendModelMeshPart(model.FindMesh("Wood").MeshParts[0], boneAbsoluteTransform * Matrix.CreateScale(scale) * Matrix.CreateRotationY(radians) * Matrix.CreateTranslation(0.5f, 0f, 0.5f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
                    m_meshesByData[i].AppendModelMeshPart(model.FindMesh("Ashes").MeshParts[0], boneAbsoluteTransform2 * Matrix.CreateScale(scale) * Matrix.CreateRotationY(radians) * Matrix.CreateTranslation(0.5f, 0f, 0.5f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
                }
                BoundingBox boundingBox = m_meshesByData[i].CalculateBoundingBox();
                boundingBox.Min.X         = 0f;
                boundingBox.Min.Z         = 0f;
                boundingBox.Max.X         = 1f;
                boundingBox.Max.Z         = 1f;
                m_collisionBoxesByData[i] = new BoundingBox[1]
                {
                    boundingBox
                };
            }
            m_standaloneMesh.AppendModelMeshPart(model.FindMesh("Wood").MeshParts[0], boneAbsoluteTransform * Matrix.CreateScale(3f) * Matrix.CreateTranslation(0f, 0f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: true, flipNormals: false, Color.White);
            m_standaloneMesh.AppendModelMeshPart(model.FindMesh("Ashes").MeshParts[0], boneAbsoluteTransform2 * Matrix.CreateScale(3f) * Matrix.CreateTranslation(0f, 0f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: true, flipNormals: false, Color.White);
            base.Initialize();
        }
示例#5
0
        public override void Initialize()
        {
            Model  model = ContentManager.Get <Model>("Models/Fur");
            Matrix boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Fur").ParentBone);

            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Fur").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, 0f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Fur").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, 0f, 0f), makeEmissive: false, flipWindingOrder: true, doubleSided: false, flipNormals: false, new Color(128, 128, 160));
            base.Initialize();
        }
        public override void Initialize()
        {
            Model  model = ContentManager.Get <Model>("Models/FullBucket");
            Matrix boneAbsoluteTransform  = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Bucket").ParentBone);
            Matrix boneAbsoluteTransform2 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Contents").ParentBone);

            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Contents").MeshParts[0], boneAbsoluteTransform2 * Matrix.CreateRotationY(MathUtils.DegToRad(180f)) * Matrix.CreateTranslation(0f, -0.3f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, new Color(200, 130, 35));
            m_standaloneBlockMesh.TransformTextureCoordinates(Matrix.CreateTranslation(0.0625f, 0.4375f, 0f));
            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Bucket").MeshParts[0], boneAbsoluteTransform * Matrix.CreateRotationY(MathUtils.DegToRad(180f)) * Matrix.CreateTranslation(0f, -0.3f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            base.Initialize();
        }
示例#7
0
        public override void Initialize()
        {
            Model  model = ContentManager.Get <Model>(m_modelName);
            Matrix boneAbsoluteTransform  = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Post").ParentBone);
            Matrix boneAbsoluteTransform2 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Planks").ParentBone);

            for (int i = 0; i < 16; i++)
            {
                int    rotation    = GetRotation(i);
                bool   open        = GetOpen(i);
                bool   rightHanded = GetRightHanded(i);
                float  num         = (!rightHanded) ? 1 : (-1);
                Matrix identity    = Matrix.Identity;
                identity        *= Matrix.CreateScale(0f - num, 1f, 1f);
                identity        *= Matrix.CreateTranslation((0.5f - m_pivotDistance) * num, 0f, 0f) * Matrix.CreateRotationY(open ? (num * (float)Math.PI / 2f) : 0f) * Matrix.CreateTranslation((0f - (0.5f - m_pivotDistance)) * num, 0f, 0f);
                identity        *= Matrix.CreateTranslation(0f, 0f, 0f) * Matrix.CreateRotationY((float)rotation * (float)Math.PI / 2f) * Matrix.CreateTranslation(0.5f, 0f, 0.5f);
                m_blockMeshes[i] = new BlockMesh();
                m_blockMeshes[i].AppendModelMeshPart(model.FindMesh("Post").MeshParts[0], boneAbsoluteTransform * identity, makeEmissive: false, !rightHanded, doubleSided: false, flipNormals: false, m_postColor);
                m_blockMeshes[i].AppendModelMeshPart(model.FindMesh("Planks").MeshParts[0], boneAbsoluteTransform2 * identity, makeEmissive: false, !rightHanded, doubleSided: false, flipNormals: false, Color.White);
                if (m_doubleSided)
                {
                    m_blockMeshes[i].AppendModelMeshPart(model.FindMesh("Planks").MeshParts[0], boneAbsoluteTransform2 * identity, makeEmissive: false, rightHanded, doubleSided: false, flipNormals: true, Color.White);
                }
                m_coloredBlockMeshes[i] = new BlockMesh();
                m_coloredBlockMeshes[i].AppendBlockMesh(m_blockMeshes[i]);
                m_blockMeshes[i].TransformTextureCoordinates(Matrix.CreateTranslation((float)(DefaultTextureSlot % 16) / 16f, (float)(DefaultTextureSlot / 16) / 16f, 0f));
                m_coloredBlockMeshes[i].TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_coloredTextureSlot % 16) / 16f, (float)(m_coloredTextureSlot / 16) / 16f, 0f));
                BoundingBox boundingBox = m_blockMeshes[i].CalculateBoundingBox();
                boundingBox.Min.X   = MathUtils.Saturate(boundingBox.Min.X);
                boundingBox.Min.Y   = MathUtils.Saturate(boundingBox.Min.Y);
                boundingBox.Min.Z   = MathUtils.Saturate(boundingBox.Min.Z);
                boundingBox.Max.X   = MathUtils.Saturate(boundingBox.Max.X);
                boundingBox.Max.Y   = MathUtils.Saturate(boundingBox.Max.Y);
                boundingBox.Max.Z   = MathUtils.Saturate(boundingBox.Max.Z);
                m_collisionBoxes[i] = new BoundingBox[1]
                {
                    boundingBox
                };
            }
            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Post").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, -0.5f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, m_postColor);
            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Planks").MeshParts[0], boneAbsoluteTransform2 * Matrix.CreateTranslation(0f, -0.5f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            if (m_doubleSided)
            {
                m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Planks").MeshParts[0], boneAbsoluteTransform2 * Matrix.CreateTranslation(0f, -0.5f, 0f), makeEmissive: false, flipWindingOrder: true, doubleSided: false, flipNormals: true, Color.White);
            }
            m_standaloneColoredBlockMesh.AppendBlockMesh(m_standaloneBlockMesh);
            m_standaloneBlockMesh.TransformTextureCoordinates(Matrix.CreateTranslation((float)(DefaultTextureSlot % 16) / 16f, (float)(DefaultTextureSlot / 16) / 16f, 0f));
            m_standaloneColoredBlockMesh.TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_coloredTextureSlot % 16) / 16f, (float)(m_coloredTextureSlot / 16) / 16f, 0f));
            base.Initialize();
        }
示例#8
0
        public override void Initialize()
        {
            Model  model = ContentManager.Get <Model>(m_modelName);
            Matrix boneAbsoluteTransform  = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Sign").ParentBone);
            Matrix boneAbsoluteTransform2 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Post").ParentBone);
            Matrix boneAbsoluteTransform3 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Surface").ParentBone);

            for (int i = 0; i < 16; i++)
            {
                bool   hanging = GetHanging(i);
                Matrix m       = Matrix.CreateRotationY((float)GetDirection(i) * (float)Math.PI / 4f) * Matrix.CreateTranslation(0.5f, 0f, 0.5f);
                if (hanging)
                {
                    m *= Matrix.CreateScale(1f, -1f, 1f) * Matrix.CreateTranslation(0f, 1f, 0f);
                }
                m_directions[i] = m.Forward;
                BlockMesh blockMesh = new BlockMesh();
                blockMesh.AppendModelMeshPart(model.FindMesh("Sign").MeshParts[0], boneAbsoluteTransform * m, makeEmissive: false, hanging, doubleSided: false, flipNormals: false, Color.White);
                BlockMesh blockMesh2 = new BlockMesh();
                blockMesh2.AppendModelMeshPart(model.FindMesh("Post").MeshParts[0], boneAbsoluteTransform2 * m, makeEmissive: false, hanging, doubleSided: false, flipNormals: false, Color.White);
                m_blockMeshes[i] = new BlockMesh();
                m_blockMeshes[i].AppendBlockMesh(blockMesh);
                m_blockMeshes[i].AppendBlockMesh(blockMesh2);
                m_coloredBlockMeshes[i] = new BlockMesh();
                m_coloredBlockMeshes[i].AppendBlockMesh(m_blockMeshes[i]);
                m_blockMeshes[i].TransformTextureCoordinates(Matrix.CreateTranslation((float)(DefaultTextureSlot % 16) / 16f, (float)(DefaultTextureSlot / 16) / 16f, 0f));
                m_coloredBlockMeshes[i].TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_coloredTextureSlot % 16) / 16f, (float)(m_coloredTextureSlot / 16) / 16f, 0f));
                m_collisionBoxes[i]    = new BoundingBox[2];
                m_collisionBoxes[i][0] = blockMesh.CalculateBoundingBox();
                m_collisionBoxes[i][1] = blockMesh2.CalculateBoundingBox();
                m_surfaceMeshes[i]     = new BlockMesh();
                m_surfaceMeshes[i].AppendModelMeshPart(model.FindMesh("Surface").MeshParts[0], boneAbsoluteTransform3 * m, makeEmissive: false, hanging, doubleSided: false, flipNormals: false, Color.White);
                m_surfaceNormals[i] = -m.Forward;
                if (hanging)
                {
                    for (int j = 0; j < m_surfaceMeshes[i].Vertices.Count; j++)
                    {
                        Vector2 textureCoordinates = m_surfaceMeshes[i].Vertices.Array[j].TextureCoordinates;
                        textureCoordinates.Y = 1f - textureCoordinates.Y;
                        m_surfaceMeshes[i].Vertices.Array[j].TextureCoordinates = textureCoordinates;
                    }
                }
            }
            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Sign").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, -0.6f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Post").MeshParts[0], boneAbsoluteTransform2 * Matrix.CreateTranslation(0f, -0.6f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_standaloneColoredBlockMesh.AppendBlockMesh(m_standaloneBlockMesh);
            m_standaloneBlockMesh.TransformTextureCoordinates(Matrix.CreateTranslation((float)(DefaultTextureSlot % 16) / 16f, (float)(DefaultTextureSlot / 16) / 16f, 0f));
            m_standaloneColoredBlockMesh.TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_coloredTextureSlot % 16) / 16f, (float)(m_coloredTextureSlot / 16) / 16f, 0f));
            base.Initialize();
        }
示例#9
0
        public override void Initialize()
        {
            Model  model = ContentManager.Get <Model>("Models/Musket");
            Matrix boneAbsoluteTransform  = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Musket").ParentBone);
            Matrix boneAbsoluteTransform2 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Hammer").ParentBone);

            m_standaloneBlockMeshUnloaded = new BlockMesh();
            m_standaloneBlockMeshUnloaded.AppendModelMeshPart(model.FindMesh("Musket").MeshParts[0], boneAbsoluteTransform, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_standaloneBlockMeshUnloaded.AppendModelMeshPart(model.FindMesh("Hammer").MeshParts[0], boneAbsoluteTransform2, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_standaloneBlockMeshLoaded = new BlockMesh();
            m_standaloneBlockMeshLoaded.AppendModelMeshPart(model.FindMesh("Musket").MeshParts[0], boneAbsoluteTransform, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_standaloneBlockMeshLoaded.AppendModelMeshPart(model.FindMesh("Hammer").MeshParts[0], Matrix.CreateRotationX(0.7f) * boneAbsoluteTransform2, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            base.Initialize();
        }
示例#10
0
        public override void Initialize()
        {
            Model  model = ContentManager.Get <Model>("Models/Musket");
            Matrix boneAbsoluteTransform  = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Musket").ParentBone);
            Matrix boneAbsoluteTransform2 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Hammer").ParentBone);

            m_standaloneBlockMeshUnloaded = new BlockMesh();
            BlockMesh standaloneBlockMeshUnloaded  = m_standaloneBlockMeshUnloaded;
            ReadOnlyList <ModelMeshPart> meshParts = model.FindMesh("Musket").MeshParts;

            standaloneBlockMeshUnloaded.AppendModelMeshPart(meshParts[0], boneAbsoluteTransform, false, false, false, false, Color.Gray);
            BlockMesh standaloneBlockMeshUnloaded2 = m_standaloneBlockMeshUnloaded;

            meshParts = model.FindMesh("Hammer").MeshParts;
            standaloneBlockMeshUnloaded2.AppendModelMeshPart(meshParts[0], boneAbsoluteTransform2, false, false, false, false, Color.Gray);
            m_standaloneBlockMeshLoaded = new BlockMesh();
            BlockMesh standaloneBlockMeshLoaded = m_standaloneBlockMeshLoaded;

            meshParts = model.FindMesh("Musket").MeshParts;
            standaloneBlockMeshLoaded.AppendModelMeshPart(meshParts[0], boneAbsoluteTransform, false, false, false, false, Color.Gray);
            BlockMesh standaloneBlockMeshLoaded2 = m_standaloneBlockMeshLoaded;

            meshParts = model.FindMesh("Hammer").MeshParts;
            standaloneBlockMeshLoaded2.AppendModelMeshPart(meshParts[0], Matrix.CreateRotationX(0.7f) * boneAbsoluteTransform2, false, false, false, false, Color.Gray);
            base.Initialize();
        }
示例#11
0
        public override void Initialize()
        {
            Model model = ContentManager.Get <Model>("Models/Arrows");

            foreach (int enumValue in EnumUtils.GetEnumValues(typeof(ArrowType)))
            {
                if (enumValue > 15)
                {
                    throw new InvalidOperationException("Too many arrow types.");
                }
                Matrix    boneAbsoluteTransform  = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh(m_shaftNames[enumValue]).ParentBone);
                Matrix    boneAbsoluteTransform2 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh(m_stabilizerNames[enumValue]).ParentBone);
                Matrix    boneAbsoluteTransform3 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh(m_tipNames[enumValue]).ParentBone);
                BlockMesh blockMesh = new BlockMesh();
                blockMesh.AppendModelMeshPart(model.FindMesh(m_tipNames[enumValue]).MeshParts[0], boneAbsoluteTransform3 * Matrix.CreateTranslation(0f, m_offsets[enumValue], 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
                blockMesh.TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_tipTextureSlots[enumValue] % 16) / 16f, (float)(m_tipTextureSlots[enumValue] / 16) / 16f, 0f));
                BlockMesh blockMesh2 = new BlockMesh();
                blockMesh2.AppendModelMeshPart(model.FindMesh(m_shaftNames[enumValue]).MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, m_offsets[enumValue], 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
                blockMesh2.TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_shaftTextureSlots[enumValue] % 16) / 16f, (float)(m_shaftTextureSlots[enumValue] / 16) / 16f, 0f));
                BlockMesh blockMesh3 = new BlockMesh();
                blockMesh3.AppendModelMeshPart(model.FindMesh(m_stabilizerNames[enumValue]).MeshParts[0], boneAbsoluteTransform2 * Matrix.CreateTranslation(0f, m_offsets[enumValue], 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: true, flipNormals: false, Color.White);
                blockMesh3.TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_stabilizerTextureSlots[enumValue] % 16) / 16f, (float)(m_stabilizerTextureSlots[enumValue] / 16) / 16f, 0f));
                BlockMesh blockMesh4 = new BlockMesh();
                blockMesh4.AppendBlockMesh(blockMesh);
                blockMesh4.AppendBlockMesh(blockMesh2);
                blockMesh4.AppendBlockMesh(blockMesh3);
                m_standaloneBlockMeshes.Add(blockMesh4);
            }
            base.Initialize();
        }
示例#12
0
        public override void Initialize()
        {
            for (int i = 0; i < m_blockMeshesByVariant.Length; i++)
            {
                m_blockMeshesByVariant[i] = new BlockMesh();
            }
            Model  model = ContentManager.Get <Model>("Models/Torch");
            Matrix boneAbsoluteTransform  = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Torch").ParentBone);
            Matrix boneAbsoluteTransform2 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Flame").ParentBone);
            Matrix m = Matrix.CreateRotationX(0.6f) * Matrix.CreateRotationY(0f) * Matrix.CreateTranslation(0.5f, 0.15f, -0.05f);

            m_blockMeshesByVariant[0].AppendModelMeshPart(model.FindMesh("Torch").MeshParts[0], boneAbsoluteTransform * m, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_blockMeshesByVariant[0].AppendModelMeshPart(model.FindMesh("Flame").MeshParts[0], boneAbsoluteTransform2 * m, makeEmissive: true, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m = Matrix.CreateRotationX(0.6f) * Matrix.CreateRotationY((float)Math.PI / 2f) * Matrix.CreateTranslation(-0.05f, 0.15f, 0.5f);
            m_blockMeshesByVariant[1].AppendModelMeshPart(model.FindMesh("Torch").MeshParts[0], boneAbsoluteTransform * m, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_blockMeshesByVariant[1].AppendModelMeshPart(model.FindMesh("Flame").MeshParts[0], boneAbsoluteTransform2 * m, makeEmissive: true, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m = Matrix.CreateRotationX(0.6f) * Matrix.CreateRotationY((float)Math.PI) * Matrix.CreateTranslation(0.5f, 0.15f, 1.05f);
            m_blockMeshesByVariant[2].AppendModelMeshPart(model.FindMesh("Torch").MeshParts[0], boneAbsoluteTransform * m, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_blockMeshesByVariant[2].AppendModelMeshPart(model.FindMesh("Flame").MeshParts[0], boneAbsoluteTransform2 * m, makeEmissive: true, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m = Matrix.CreateRotationX(0.6f) * Matrix.CreateRotationY(4.712389f) * Matrix.CreateTranslation(1.05f, 0.15f, 0.5f);
            m_blockMeshesByVariant[3].AppendModelMeshPart(model.FindMesh("Torch").MeshParts[0], boneAbsoluteTransform * m, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_blockMeshesByVariant[3].AppendModelMeshPart(model.FindMesh("Flame").MeshParts[0], boneAbsoluteTransform2 * m, makeEmissive: true, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m = Matrix.CreateTranslation(0.5f, 0f, 0.5f);
            m_blockMeshesByVariant[4].AppendModelMeshPart(model.FindMesh("Torch").MeshParts[0], boneAbsoluteTransform * m, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_blockMeshesByVariant[4].AppendModelMeshPart(model.FindMesh("Flame").MeshParts[0], boneAbsoluteTransform2 * m, makeEmissive: true, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Torch").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, -0.25f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            for (int j = 0; j < 5; j++)
            {
                m_collisionBoxes[j] = new BoundingBox[1]
                {
                    m_blockMeshesByVariant[j].CalculateBoundingBox()
                };
            }
            base.Initialize();
        }
示例#13
0
        public override void Initialize()
        {
            Model  model = ContentManager.Get <Model>("Models/Lightbulbs");
            Matrix boneAbsoluteTransform  = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Top").ParentBone);
            Matrix boneAbsoluteTransform2 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Sides").ParentBone);

            for (int i = 0; i < 6; i++)
            {
                Matrix m = (i >= 4) ? ((i != 4) ? (Matrix.CreateRotationX((float)Math.PI) * Matrix.CreateTranslation(0.5f, 1f, 0.5f)) : Matrix.CreateTranslation(0.5f, 0f, 0.5f)) : (Matrix.CreateRotationX((float)Math.PI / 2f) * Matrix.CreateTranslation(0f, 0f, -0.5f) * Matrix.CreateRotationY((float)i * (float)Math.PI / 2f) * Matrix.CreateTranslation(0.5f, 0.5f, 0.5f));
                m_bulbBlockMeshes[i] = new BlockMesh();
                m_bulbBlockMeshes[i].AppendModelMeshPart(model.FindMesh("Top").MeshParts[0], boneAbsoluteTransform * m, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
                m_bulbBlockMeshes[i].TransformTextureCoordinates(Matrix.CreateTranslation(0.1875f, 0.25f, 0f));
                m_bulbBlockMeshesLit[i] = new BlockMesh();
                m_bulbBlockMeshesLit[i].AppendModelMeshPart(model.FindMesh("Top").MeshParts[0], boneAbsoluteTransform * m, makeEmissive: true, flipWindingOrder: false, doubleSided: false, flipNormals: false, new Color(255, 255, 230));
                m_bulbBlockMeshesLit[i].TransformTextureCoordinates(Matrix.CreateTranslation(0.9375f, 0f, 0f));
                m_sidesBlockMeshes[i] = new BlockMesh();
                m_sidesBlockMeshes[i].AppendModelMeshPart(model.FindMesh("Sides").MeshParts[0], boneAbsoluteTransform2 * m, makeEmissive: false, flipWindingOrder: false, doubleSided: true, flipNormals: false, Color.White);
                m_sidesBlockMeshes[i].TransformTextureCoordinates(Matrix.CreateTranslation(0.9375f, 0.1875f, 0f));
                m_collisionBoxes[i] = new BoundingBox[1]
                {
                    m_sidesBlockMeshes[i].CalculateBoundingBox()
                };
            }
            Matrix m2 = Matrix.CreateRotationY(-(float)Math.PI / 2f) * Matrix.CreateRotationZ((float)Math.PI / 2f);

            m_standaloneBulbBlockMesh.AppendModelMeshPart(model.FindMesh("Top").MeshParts[0], boneAbsoluteTransform * m2, makeEmissive: false, flipWindingOrder: false, doubleSided: true, flipNormals: false, Color.White);
            m_standaloneBulbBlockMesh.TransformTextureCoordinates(Matrix.CreateTranslation(0.1875f, 0.25f, 0f));
            m_standaloneSidesBlockMesh.AppendModelMeshPart(model.FindMesh("Sides").MeshParts[0], boneAbsoluteTransform2 * m2, makeEmissive: false, flipWindingOrder: false, doubleSided: true, flipNormals: false, Color.White);
            m_standaloneSidesBlockMesh.TransformTextureCoordinates(Matrix.CreateTranslation(0.9375f, 0.1875f, 0f));
        }
示例#14
0
        public override void Initialize()
        {
            Model  model = ContentManager.Get <Model>(m_modelName);
            Matrix boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Trapdoor").ParentBone);

            for (int i = 0; i < 16; i++)
            {
                int  rotation   = GetRotation(i);
                bool open       = GetOpen(i);
                bool upsideDown = GetUpsideDown(i);
                m_blockMeshesByData[i] = new BlockMesh();
                Matrix identity = Matrix.Identity;
                identity *= Matrix.CreateTranslation(0f, -0.0625f, 0.4375f) * Matrix.CreateRotationX(open ? (-(float)Math.PI / 2f) : 0f) * Matrix.CreateTranslation(0f, 0.0625f, -0.4375f);
                identity *= Matrix.CreateRotationZ(upsideDown ? ((float)Math.PI) : 0f);
                identity *= Matrix.CreateRotationY((float)rotation * (float)Math.PI / 2f);
                identity *= Matrix.CreateTranslation(new Vector3(0.5f, upsideDown ? 1 : 0, 0.5f));
                m_blockMeshesByData[i].AppendModelMeshPart(model.FindMesh("Trapdoor").MeshParts[0], boneAbsoluteTransform * identity, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
                m_blockMeshesByData[i].GenerateSidesData();
                m_collisionBoxesByData[i] = new BoundingBox[1]
                {
                    m_blockMeshesByData[i].CalculateBoundingBox()
                };
            }
            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Trapdoor").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, 0f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            base.Initialize();
        }
示例#15
0
        public override void Initialize()
        {
            Model  model = ContentManager.Get <Model>(m_modelName);
            Matrix boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Keg").ParentBone);

            FuseOffset = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Fuse").ParentBone).Translation + new Vector3(0.5f, 0f, 0.5f);
            BlockMesh blockMesh = new BlockMesh();

            blockMesh.AppendModelMeshPart(model.FindMesh("Keg").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0.5f, 0f, 0.5f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_blockMesh.AppendBlockMesh(blockMesh);
            if (m_isIncendiary)
            {
                m_blockMesh.TransformTextureCoordinates(Matrix.CreateTranslation(-0.25f, 0f, 0f));
            }
            m_collisionBoxes = new BoundingBox[1]
            {
                blockMesh.CalculateBoundingBox()
            };
            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Keg").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, -0.5f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            if (m_isIncendiary)
            {
                m_standaloneBlockMesh.TransformTextureCoordinates(Matrix.CreateTranslation(-0.25f, 0f, 0f));
            }
            base.Initialize();
        }
示例#16
0
        public OreChunk(Matrix transform, Matrix tcTransform, Color color, bool smooth, Materials type)
        {
            string name = type.ToStr();

            Id = type.ToString() + "OreChunk";
            DefaultDisplayName = name + Utils.Get("矿石块");
            var sb = new StringBuilder(Utils.Get("一块"));

            if (type == Materials.Mercury)
            {
                sb.Append(Utils.Get("氧化"));
            }
            name = char.ToLower(name[0], CultureInfo.CurrentCulture) + name.Substring(1);
            sb.Append(name).Append(" ore. When smelted in the furnace will turn into pure ");
            if (type == Materials.Mercury)
            {
                sb.Append(Utils.Get("液态"));
            }
            sb.Append(name).Append('.');
            DefaultDescription = sb.ToString();
            Color = color;
            var model = ContentManager.Get <Model>(smooth ? "Models/ChunkSmooth" : "Models/Chunk");

            m_standaloneBlockMesh.AppendModelMeshPart(model.Meshes[0].MeshParts[0], BlockMesh.GetBoneAbsoluteTransform(model.Meshes[0].ParentBone) * transform, false, false, false, false, color);
            m_standaloneBlockMesh.TransformTextureCoordinates(tcTransform);
        }
示例#17
0
        public override void Initialize()
        {
            Model  model = ContentManager.Get <Model>(m_modelName);
            Matrix boneAbsoluteTransform  = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Sign").ParentBone);
            Matrix boneAbsoluteTransform2 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Surface").ParentBone);

            for (int i = 0; i < 4; i++)
            {
                float     radians   = (float)Math.PI / 2f * (float)i;
                Matrix    m         = Matrix.CreateTranslation(0f, 0f, -15f / 32f) * Matrix.CreateRotationY(radians) * Matrix.CreateTranslation(0.5f, -0.3125f, 0.5f);
                BlockMesh blockMesh = new BlockMesh();
                blockMesh.AppendModelMeshPart(model.FindMesh("Sign").MeshParts[0], boneAbsoluteTransform * m, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
                m_blockMeshes[i] = new BlockMesh();
                m_blockMeshes[i].AppendBlockMesh(blockMesh);
                m_coloredBlockMeshes[i] = new BlockMesh();
                m_coloredBlockMeshes[i].AppendBlockMesh(m_blockMeshes[i]);
                m_blockMeshes[i].TransformTextureCoordinates(Matrix.CreateTranslation((float)(DefaultTextureSlot % 16) / 16f, (float)(DefaultTextureSlot / 16) / 16f, 0f));
                m_coloredBlockMeshes[i].TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_coloredTextureSlot % 16) / 16f, (float)(m_coloredTextureSlot / 16) / 16f, 0f));
                m_collisionBoxes[i]    = new BoundingBox[1];
                m_collisionBoxes[i][0] = blockMesh.CalculateBoundingBox();
                m_surfaceMeshes[i]     = new BlockMesh();
                m_surfaceMeshes[i].AppendModelMeshPart(model.FindMesh("Surface").MeshParts[0], boneAbsoluteTransform2 * m, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
                m_surfaceNormals[i] = -m.Forward;
            }
            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Sign").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, -0.6f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_standaloneColoredBlockMesh.AppendBlockMesh(m_standaloneBlockMesh);
            m_standaloneBlockMesh.TransformTextureCoordinates(Matrix.CreateTranslation((float)(DefaultTextureSlot % 16) / 16f, (float)(DefaultTextureSlot / 16) / 16f, 0f));
            m_standaloneColoredBlockMesh.TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_coloredTextureSlot % 16) / 16f, (float)(m_coloredTextureSlot / 16) / 16f, 0f));
            base.Initialize();
        }
示例#18
0
        public override void Initialize()
        {
            Model  model = ContentManager.Get <Model>(m_modelName);
            Matrix boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Door").ParentBone);

            for (int i = 0; i < 16; i++)
            {
                int   rotation    = GetRotation(i);
                bool  open        = GetOpen(i);
                bool  rightHanded = GetRightHanded(i);
                float num         = (!rightHanded) ? 1 : (-1);
                m_blockMeshesByData[i] = new BlockMesh();
                Matrix identity = Matrix.Identity;
                identity *= Matrix.CreateScale(0f - num, 1f, 1f);
                identity *= Matrix.CreateTranslation((0.5f - m_pivotDistance) * num, 0f, 0f) * Matrix.CreateRotationY(open ? (num * (float)Math.PI / 2f) : 0f) * Matrix.CreateTranslation((0f - (0.5f - m_pivotDistance)) * num, 0f, 0f);
                identity *= Matrix.CreateTranslation(0f, 0f, 0.5f - m_pivotDistance) * Matrix.CreateRotationY((float)rotation * (float)Math.PI / 2f) * Matrix.CreateTranslation(0.5f, 0f, 0.5f);
                m_blockMeshesByData[i].AppendModelMeshPart(model.FindMesh("Door").MeshParts[0], boneAbsoluteTransform * identity, makeEmissive: false, !rightHanded, doubleSided: false, flipNormals: false, Color.White);
                BoundingBox boundingBox = m_blockMeshesByData[i].CalculateBoundingBox();
                boundingBox.Max.Y         = 1f;
                m_collisionBoxesByData[i] = new BoundingBox[1]
                {
                    boundingBox
                };
            }
            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Door").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, -1f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            base.Initialize();
        }
示例#19
0
        public override void Initialize()
        {
            Model model = ContentManager.Get <Model>("Models/SpikedPlanks");

            string[] array = new string[2]
            {
                "SpikedPlankRetracted",
                "SpikedPlank"
            };
            for (int i = 0; i < 2; i++)
            {
                string name = array[i];
                Matrix boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh(name).ParentBone);
                for (int j = 0; j < 6; j++)
                {
                    int    num = SetMountingFace(SetSpikesState(0, i != 0), j);
                    Matrix m   = (j >= 4) ? ((j != 4) ? (Matrix.CreateRotationX((float)Math.PI) * Matrix.CreateTranslation(0.5f, 1f, 0.5f)) : Matrix.CreateTranslation(0.5f, 0f, 0.5f)) : (Matrix.CreateRotationX((float)Math.PI / 2f) * Matrix.CreateTranslation(0f, 0f, -0.5f) * Matrix.CreateRotationY((float)j * (float)Math.PI / 2f) * Matrix.CreateTranslation(0.5f, 0.5f, 0.5f));
                    m_blockMeshesByData[num] = new BlockMesh();
                    m_blockMeshesByData[num].AppendModelMeshPart(model.FindMesh(name).MeshParts[0], boneAbsoluteTransform * m, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
                    m_collisionBoxesByData[num] = new BoundingBox[1]
                    {
                        m_blockMeshesByData[num].CalculateBoundingBox()
                    };
                }
                Matrix identity = Matrix.Identity;
                m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh(name).MeshParts[0], boneAbsoluteTransform * identity, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            }
        }
示例#20
0
        public override void Initialize()
        {
            Model         model    = ContentManager.Get <Model>("Models/Slab");
            ModelMeshPart meshPart = model.FindMesh("Slab").MeshParts[0];
            Matrix        boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Slab").ParentBone);

            for (int i = 0; i < 2; i++)
            {
                Matrix matrix = boneAbsoluteTransform * Matrix.CreateTranslation(0.5f, (i == 0) ? 0f : 0.5f, 0.5f);
                m_uncoloredBlockMeshes[i] = new BlockMesh();
                m_uncoloredBlockMeshes[i].AppendModelMeshPart(meshPart, matrix, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
                m_uncoloredBlockMeshes[i].TransformTextureCoordinates(Matrix.CreateTranslation((float)(DefaultTextureSlot % 16) / 16f, (float)(DefaultTextureSlot / 16) / 16f, 0f));
                m_uncoloredBlockMeshes[i].GenerateSidesData();
                m_coloredBlockMeshes[i] = new BlockMesh();
                m_coloredBlockMeshes[i].AppendModelMeshPart(meshPart, matrix, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
                m_coloredBlockMeshes[i].TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_coloredTextureSlot % 16) / 16f, (float)(m_coloredTextureSlot / 16) / 16f, 0f));
                m_coloredBlockMeshes[i].GenerateSidesData();
            }
            m_standaloneUncoloredBlockMesh.AppendModelMeshPart(meshPart, boneAbsoluteTransform * Matrix.CreateTranslation(0f, -0.5f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_standaloneUncoloredBlockMesh.TransformTextureCoordinates(Matrix.CreateTranslation((float)(DefaultTextureSlot % 16) / 16f, (float)(DefaultTextureSlot / 16) / 16f, 0f));
            m_standaloneColoredBlockMesh.AppendModelMeshPart(meshPart, boneAbsoluteTransform * Matrix.CreateTranslation(0f, -0.5f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_standaloneColoredBlockMesh.TransformTextureCoordinates(Matrix.CreateTranslation((float)(m_coloredTextureSlot % 16) / 16f, (float)(m_coloredTextureSlot / 16) / 16f, 0f));
            m_collisionBoxes[0] = new BoundingBox[1]
            {
                new BoundingBox(new Vector3(0f, 0f, 0f), new Vector3(1f, 0.5f, 1f))
            };
            m_collisionBoxes[1] = new BoundingBox[1]
            {
                new BoundingBox(new Vector3(0f, 0.5f, 0f), new Vector3(1f, 1f, 1f))
            };
            base.Initialize();
        }
示例#21
0
        public override void Initialize()
        {
            Model  model = ContentManager.Get <Model>("Models/Wire");
            Matrix boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Wire").ParentBone);

            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Wire").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, -0.5f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_standaloneBlockMesh.TransformTextureCoordinates(Matrix.CreateTranslation(0.9375f, 0f, 0f));
            for (int i = 0; i < 6; i++)
            {
                Vector3 v  = CellFace.FaceToVector3(i);
                Vector3 v2 = new Vector3(0.5f, 0.5f, 0.5f) - 0.5f * v;
                Vector3 v3;
                Vector3 v4;
                if (v.X != 0f)
                {
                    v3 = new Vector3(0f, 1f, 0f);
                    v4 = new Vector3(0f, 0f, 1f);
                }
                else if (v.Y != 0f)
                {
                    v3 = new Vector3(1f, 0f, 0f);
                    v4 = new Vector3(0f, 0f, 1f);
                }
                else
                {
                    v3 = new Vector3(1f, 0f, 0f);
                    v4 = new Vector3(0f, 1f, 0f);
                }
                Vector3 v5 = v2 - 0.5f * v3 - 0.5f * v4;
                Vector3 v6 = v2 + 0.5f * v3 + 0.5f * v4 + 0.05f * v;
                m_collisionBoxesByFace[i] = new BoundingBox(Vector3.Min(v5, v6), Vector3.Max(v5, v6));
            }
        }
示例#22
0
        public Pipe(int id = 0) : base("Pipe" + id.ToString())
        {
            var           model  = ContentManager.Get <Model>("Models/Battery");
            var           meshes = new BlockMesh[6];
            int           i;
            BlockMesh     blockMesh;
            ModelMeshPart meshPart = model.FindMesh("Battery").MeshParts[0];
            Matrix        boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Battery").ParentBone);

            for (i = 0; i < 6; i++)
            {
                blockMesh = new BlockMesh();
                var vector = CellFace.FaceToVector3(i);
                blockMesh.AppendModelMeshPart(meshPart, boneAbsoluteTransform * Matrix.CreateTranslation(0f, -0.2f, 0f) * Matrix.CreateScale(1f, 0.66f, 1f) *
                                              ((i < 4) ? (Matrix.CreateTranslation(0f, -0.5f, 0f) * Matrix.CreateRotationX(i * 3.14159274f / 2f + 3.14159274f) * Matrix.CreateTranslation(0.5f, 0.5f, 0.5f)) : ((i != 4) ? (Matrix.CreateTranslation(0f, -0.5f, 0f) * Matrix.CreateRotationZ(-1.57079637f) * Matrix.CreateTranslation(0.5f, 0.5f, 0.5f)) : (Matrix.CreateTranslation(0f, -0.5f, 0f) * Matrix.CreateRotationZ(1.57079637f) * Matrix.CreateTranslation(0.5f, 0.5f, 0.5f)))), false, false, false, false, Color.LightGray);
                blockMesh.TransformTextureCoordinates(Matrix.CreateTranslation(-2f / 16f, 4f / 16f, 0f));
                blockMesh.TransformPositions(Matrix.CreateTranslation(new Vector3(0.5f)));
                meshes[i] = blockMesh;
            }
            for (i = 0; i < 63; i++)
            {
                Meshes[i] = new BlockMesh();
                for (int j = 0; j < 6; j++)
                {
                    if (((i + 1) >> j & 1) != 0)
                    {
                        Meshes[i].AppendBlockMesh(meshes[j]);
                    }
                }
            }
        }
        public override void Initialize()
        {
            Model  model = ContentManager.Get <Model>("Models/ChristmasTree");
            Matrix boneAbsoluteTransform  = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("StandTrunk").ParentBone);
            Matrix boneAbsoluteTransform2 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Leaves").ParentBone);
            Matrix boneAbsoluteTransform3 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Decorations").ParentBone);
            Color  color = BlockColorsMap.SpruceLeavesColorsMap.Lookup(4, 15);

            m_leavesBlockMesh.AppendModelMeshPart(model.FindMesh("Leaves").MeshParts[0], boneAbsoluteTransform2 * Matrix.CreateTranslation(0.5f, 0f, 0.5f), makeEmissive: false, flipWindingOrder: false, doubleSided: true, flipNormals: false, Color.White);
            m_standTrunkBlockMesh.AppendModelMeshPart(model.FindMesh("StandTrunk").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0.5f, 0f, 0.5f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_decorationsBlockMesh.AppendModelMeshPart(model.FindMesh("Decorations").MeshParts[0], boneAbsoluteTransform3 * Matrix.CreateTranslation(0.5f, 0f, 0.5f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_litDecorationsBlockMesh.AppendModelMeshPart(model.FindMesh("Decorations").MeshParts[0], boneAbsoluteTransform3 * Matrix.CreateTranslation(0.5f, 0f, 0.5f), makeEmissive: true, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("StandTrunk").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, -1f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Leaves").MeshParts[0], boneAbsoluteTransform2 * Matrix.CreateTranslation(0f, -1f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: true, flipNormals: false, color);
            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Decorations").MeshParts[0], boneAbsoluteTransform3 * Matrix.CreateTranslation(0f, -1f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            base.Initialize();
        }
示例#24
0
        public override void Initialize()
        {
            Model  model = ContentManager.Get <Model>("Models/Battery");
            Matrix boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Battery").ParentBone);

            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("Battery").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, -0.5f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_blockMesh.AppendModelMeshPart(model.FindMesh("Battery").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0.5f, 0f, 0.5f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_collisionBoxes[0] = m_blockMesh.CalculateBoundingBox();
        }
示例#25
0
        public override void Initialize()
        {
            Model  model  = m_smooth ? ContentManager.Get <Model>("Models/ChunkSmooth") : ContentManager.Get <Model>("Models/Chunk");
            Matrix matrix = BlockMesh.GetBoneAbsoluteTransform(model.Meshes[0].ParentBone) * m_transform;

            m_standaloneBlockMesh.AppendModelMeshPart(model.Meshes[0].MeshParts[0], matrix, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, m_color);
            m_standaloneBlockMesh.TransformTextureCoordinates(m_tcTransform);
            base.Initialize();
        }
示例#26
0
        public override void Initialize()
        {
            Model  model = ContentManager.Get <Model>(m_modelName);
            Matrix boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.Meshes[0].ParentBone);

            m_standaloneBlockMesh.AppendModelMeshPart(model.Meshes[0].MeshParts[0], boneAbsoluteTransform, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, m_color);
            m_standaloneBlockMesh.TransformTextureCoordinates(m_tcTransform);
            base.Initialize();
        }
示例#27
0
        public override void Initialize()
        {
            Model  model = ContentManager.Get <Model>("Models/Pumpkins");
            Matrix boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("JackOLantern").ParentBone);

            for (int i = 0; i < 4; i++)
            {
                float     radians   = (float)i * (float)Math.PI / 2f;
                BlockMesh blockMesh = new BlockMesh();
                blockMesh.AppendModelMeshPart(model.FindMesh("JackOLantern").MeshParts[0], boneAbsoluteTransform * Matrix.CreateRotationY(radians) * Matrix.CreateTranslation(0.5f, 0f, 0.5f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, new Color(232, 232, 232));
                blockMesh.AppendModelMeshPart(model.FindMesh("JackOLantern").MeshParts[0], boneAbsoluteTransform * Matrix.CreateRotationY(radians) * Matrix.CreateTranslation(0.5f, 0f, 0.5f), makeEmissive: true, flipWindingOrder: true, doubleSided: false, flipNormals: false, Color.White);
                m_blockMeshesByData[i] = blockMesh;
            }
            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("JackOLantern").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, -0.23f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, new Color(232, 232, 232));
            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("JackOLantern").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, -0.23f, 0f), makeEmissive: true, flipWindingOrder: true, doubleSided: false, flipNormals: false, Color.White);
            m_collisionBoxes[0] = m_blockMeshesByData[0].CalculateBoundingBox();
            base.Initialize();
        }
示例#28
0
        public static void AppendMesh(this BlockMesh blockMesh, string modelName, string meshName, Matrix boneTransform, Matrix tcTransform, Color color)
        {
            var model = ContentManager.Get <Model>(modelName);

            blockMesh.AppendModelMeshPart(model.FindMesh(meshName).MeshParts[0], BlockMesh.GetBoneAbsoluteTransform(model.FindMesh(meshName).ParentBone) * boneTransform, false, false, false, false, color);
            if (tcTransform != Matrix.Identity)
            {
                blockMesh.TransformTextureCoordinates(tcTransform);
            }
        }
示例#29
0
        public override void Initialize()
        {
            Model  model = ContentManager.Get <Model>("Models/Compass");
            Matrix boneAbsoluteTransform  = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Case").ParentBone);
            Matrix boneAbsoluteTransform2 = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Pointer").ParentBone);

            m_caseMesh.AppendModelMeshPart(model.FindMesh("Case").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, -0.01f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: true, flipNormals: false, Color.White);
            m_pointerMesh.AppendModelMeshPart(model.FindMesh("Pointer").MeshParts[0], boneAbsoluteTransform2 * Matrix.CreateTranslation(0f, -0.01f, 0f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            base.Initialize();
        }
示例#30
0
        public override void Initialize()
        {
            Model  model = ContentManager.Get <Model>("Models/GrassTrap");
            Matrix boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("GrassTrap").ParentBone);
            Color  color = BlockColorsMap.GrassColorsMap.Lookup(8, 15);

            m_blockMesh.AppendModelMeshPart(model.FindMesh("GrassTrap").MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0.5f, 0.75f, 0.5f), makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, Color.White);
            m_standaloneBlockMesh.AppendModelMeshPart(model.FindMesh("GrassTrap").MeshParts[0], boneAbsoluteTransform, makeEmissive: false, flipWindingOrder: false, doubleSided: false, flipNormals: false, color);
            m_collisionBoxes[0] = new BoundingBox(new Vector3(0f, 0.75f, 0f), new Vector3(1f, 0.95f, 1f));
            base.Initialize();
        }