Beispiel #1
0
    public override void Initialize(string extraData)
    {
        base.Initialize(extraData);

        string[] strs = extraData.Split(' ');

        MeshData sign = new MeshData(BlockMeshes.FindMesh(strs[0] + "_Sign"));
        MeshData post = new MeshData(BlockMeshes.FindMesh(strs[0] + "_Post"));

        int paintedTexSlot = int.Parse(strs[1]);

        for (int i = 0; i < 16; i++)
        {
            bool      hanging = (i & 8) != 0;
            Matrix4x4 matrix  = Matrix4x4.Rotate(Quaternion.Euler(0, 45 * i, 0));
            if (hanging)
            {
                matrix *= Matrix4x4.Scale(new Vector3(1f, -1f, 1f)) * Matrix4x4.Translate(new Vector3(0f, 1f, 0f));
            }
            matrix         = Matrix4x4.Translate(new Vector3(0.5f, 0f, 0.5f)) * matrix;
            blockMeshes[i] = sign.Clone();
            blockMeshes[i].Append(post);
            blockMeshes[i].Transform(matrix);
            blockMeshes[i].WrapInTextureSlotTerrain(TextureSlot);

            paintedBlockMeshes[i] = sign.Clone();
            paintedBlockMeshes[i].Append(post);
            paintedBlockMeshes[i].Transform(matrix);
            paintedBlockMeshes[i].WrapInTextureSlotTerrain(paintedTexSlot);
        }
    }
Beispiel #2
0
    public override void Initialize(string extraData)
    {
        MeshData mesh = new MeshData(BlockMeshes.FindMesh("Torch"));

        meshes[0] = mesh.Clone();
        meshes[0].Transform(Matrix4x4.Rotate(Quaternion.Euler(34, 0, 0)) * Matrix4x4.Translate(new Vector3(0.5f, 0.15f, -0.05f)));
        meshes[1] = mesh.Clone();
        meshes[1].Transform(Matrix4x4.Rotate(Quaternion.Euler(34, 90, 0)) * Matrix4x4.Translate(new Vector3(-0.05f, 0.15f, 0.5f)));
        meshes[2] = mesh.Clone();
        meshes[2].Transform(Matrix4x4.Rotate(Quaternion.Euler(34, 180, 0)) * Matrix4x4.Translate(new Vector3(0.5f, 0.15f, 1.05f)));
        meshes[3] = mesh.Clone();
        meshes[3].Transform(Matrix4x4.Rotate(Quaternion.Euler(34, 270, 0)) * Matrix4x4.Translate(new Vector3(1.05f, 0.15f, 0.5f)));
        meshes[4] = mesh.Clone();
        meshes[4].Transform(Matrix4x4.Translate(new Vector3(0.5f, 0f, 0.5f)));
    }
Beispiel #3
0
    public override void Initialize(string extraData)
    {
        base.Initialize(extraData);
        //IsCubic = false;

        Matrix4x4 matrix = Matrix4x4.Translate(new Vector3(0.5f, 0f, 0.5f));

        float     y;
        Matrix4x4 m;
        Mesh      mesh;

        for (int i = 0; i < 24; i++)
        {
            y = 0;

            y -= GetRotation(i) * 90;

            m = Matrix4x4.Rotate(Quaternion.Euler(0, y, 0));
            switch ((i >> 3) & 3)
            {
            case 1:
                mesh = BlockMeshes.FindMesh("Stair0");
                break;

            case 0:
                mesh = BlockMeshes.FindMesh("Stair1");
                break;

            case 2:
                mesh = BlockMeshes.FindMesh("Stair2");
                break;

            default:
                throw new System.Exception("unknown stair module: " + ((i >> 3) & 3));
            }

            blockMeshes[i] = new MeshData(mesh);
            blockMeshes[i].Transform(matrix * m);
            if ((i & 4) != 0)
            {
                blockMeshes[i].FlipVertical();
            }
            paintedBlockMeshes[i] = blockMeshes[i].Clone();

            blockMeshes[i].WrapInTextureSlotTerrain(TextureSlot);
            paintedBlockMeshes[i].WrapInTextureSlotTerrain(BlocksData.paintedTextures[TextureSlot]);
        }
    }
Beispiel #4
0
    public override void Initialize(string extraData)
    {
        base.Initialize(extraData);
        //IsCubic = false;

        Mesh      slab   = BlockMeshes.FindMesh("Slab");
        Matrix4x4 matrix = Matrix4x4.Translate(new Vector3(0.5f, 0f, 0.5f));

        blockMeshes[0] = new MeshData(slab);
        blockMeshes[0].Transform(matrix);

        blockMeshes[1] = new MeshData(slab);
        blockMeshes[1].Transform(matrix);
        blockMeshes[1].FlipVertical();

        paintedBlockMeshes[0] = blockMeshes[0].Clone();
        paintedBlockMeshes[1] = blockMeshes[1].Clone();

        blockMeshes[0].WrapInTextureSlotTerrain(TextureSlot);
        blockMeshes[1].WrapInTextureSlotTerrain(TextureSlot);
        paintedBlockMeshes[0].WrapInTextureSlotTerrain(BlocksData.paintedTextures[TextureSlot]);
        paintedBlockMeshes[1].WrapInTextureSlotTerrain(BlocksData.paintedTextures[TextureSlot]);
    }
Beispiel #5
0
    public override void Initialize(string extraData)
    {
        base.Initialize(extraData);

        string[] strs = extraData.Split(' ');

        string modelName = strs[0];

        useAlphaTest = bool.Parse(strs[1]);
        bool doubleSidedPlanks = bool.Parse(strs[2]);

        unpaintedColor = new Color32(byte.Parse(strs[3]), byte.Parse(strs[4]), byte.Parse(strs[5]), 255);

        MeshData post = new MeshData(BlockMeshes.FindMesh(modelName + "_Post"));

        post.Transform(Matrix4x4.Translate(new Vector3(0.5f, 0f, 0.5f)));
        MeshData plank = new MeshData(BlockMeshes.FindMesh(modelName + "_Planks"));

        for (int i = 0; i < 16; i++)
        {
            MeshData data = MeshData.CreateEmpty();

            if ((i & 1) != 0)
            {
                MeshData data1 = plank.Clone();
                data1.Transform(Matrix4x4.Translate(new Vector3(0.5f, 0f, 0.5f)) * Matrix4x4.Rotate(Quaternion.identity));
                data.Append(data1);
                if (doubleSidedPlanks)
                {
                    data1.FlipWindingOrder();
                    data.Append(data1);
                }
            }
            if ((i & 2) != 0)
            {
                MeshData data1 = plank.Clone();
                data1.Transform(Matrix4x4.Translate(new Vector3(0.5f, 0f, 0.5f)) * Matrix4x4.Rotate(Quaternion.Euler(0, -180, 0)));
                data.Append(data1);
                if (doubleSidedPlanks)
                {
                    data1.FlipWindingOrder();
                    data.Append(data1);
                }
            }
            if ((i & 4) != 0)
            {
                MeshData data1 = plank.Clone();
                data1.Transform(Matrix4x4.Translate(new Vector3(0.5f, 0f, 0.5f)) * Matrix4x4.Rotate(Quaternion.Euler(0, 90, 0)));
                data.Append(data1);
                if (doubleSidedPlanks)
                {
                    data1.FlipWindingOrder();
                    data.Append(data1);
                }
            }
            if ((i & 8) != 0)
            {
                MeshData data1 = plank.Clone();
                data1.Transform(Matrix4x4.Translate(new Vector3(0.5f, 0f, 0.5f)) * Matrix4x4.Rotate(Quaternion.Euler(0, 270, 0)));
                data.Append(data1);
                if (doubleSidedPlanks)
                {
                    data1.FlipWindingOrder();
                    data.Append(data1);
                }
            }

            blockMeshes[i] = post.Clone();
            blockMeshes[i].Append(data);

            paintedBlockMeshes[i] = post.Clone();
            paintedBlockMeshes[i].Append(data);

            if (useAlphaTest)
            {
                blockMeshes[i].WrapInTextureSlot(TextureSlot);
                paintedBlockMeshes[i].WrapInTextureSlot(BlocksData.paintedTextures[TextureSlot]);
            }
            else
            {
                blockMeshes[i].WrapInTextureSlotTerrain(TextureSlot);
                paintedBlockMeshes[i].WrapInTextureSlotTerrain(BlocksData.paintedTextures[TextureSlot]);
            }
        }
    }
Beispiel #6
0
    public override void Initialize(string extraData)
    {
        Mesh blockMesh;

        switch (Index)
        {
        case 134:
            blockMesh = BlockMeshes.FindMesh("NandGate");
            break;

        case 135:
            blockMesh = BlockMeshes.FindMesh("NorGate");
            break;

        case 137:
            blockMesh = BlockMeshes.FindMesh("AndGate");
            break;

        case 140:
            blockMesh = BlockMeshes.FindMesh("NotGate");
            break;

        case 143:
            blockMesh = BlockMeshes.FindMesh("OrGate");
            break;

        case 145:
            blockMesh = BlockMeshes.FindMesh("DelayGate");
            break;

        case 146:
            blockMesh = BlockMeshes.FindMesh("SRLatch");
            break;

        case 156:
            blockMesh = BlockMeshes.FindMesh("XorGate");
            break;

        case 157:
            blockMesh = BlockMeshes.FindMesh("RandomGenerator");
            break;

        case 179:
            blockMesh = BlockMeshes.FindMesh("MotionDetector");
            break;

        case 180:
            blockMesh = BlockMeshes.FindMesh("DigitalToAnalogConverter");
            break;

        case 181:
            blockMesh = BlockMeshes.FindMesh("AnalogToDigitalConverter");
            break;

        case 183:
            blockMesh = BlockMeshes.FindMesh("SoundGenerator");
            break;

        case 184:
            blockMesh = BlockMeshes.FindMesh("Counter");
            break;

        case 186:
            blockMesh = BlockMeshes.FindMesh("MemoryBank");
            break;

        case 187:
            blockMesh = BlockMeshes.FindMesh("RealTimeClock");
            break;

        case 188:
            blockMesh = BlockMeshes.FindMesh("TruthTableCircuit");
            break;

        default:
            throw new System.Exception("unsupported electric gate: " + Index);
        }

        Matrix4x4 m;
        Matrix4x4 m2;

        Matrix4x4 half        = Matrix4x4.Translate(new Vector3(0.5f, 0.5f, 0.5f));
        Matrix4x4 inverseHalf = half.inverse;

        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 6; j++)
            {
                switch (j)
                {
                case 0:
                    m  = Matrix4x4.Rotate(Quaternion.Euler(0, 0, i * 90));
                    m2 = Matrix4x4.TRS(new Vector3(0.5f, -0.5f, 0f), Quaternion.Euler(90, 0, 0), Vector3.one);
                    break;

                case 1:
                    m  = Matrix4x4.Rotate(Quaternion.Euler(i * -90, 0, 0));
                    m2 = Matrix4x4.TRS(new Vector3(0f, -0.5f, 0.5f), Quaternion.Euler(90, 0, -270), Vector3.one);
                    break;

                case 2:
                    m  = Matrix4x4.Rotate(Quaternion.Euler(0, 0, i * -90));
                    m2 = Matrix4x4.TRS(new Vector3(-0.5f, -0.5f, 0f), Quaternion.Euler(90, 0, -180), Vector3.one);
                    break;

                case 3:
                    m  = Matrix4x4.Rotate(Quaternion.Euler(i * 90, 0, 0));
                    m2 = Matrix4x4.TRS(new Vector3(0f, -0.5f, -0.5f), Quaternion.Euler(90, 0, -90), Vector3.one);
                    break;

                case 4:
                    m  = Matrix4x4.Rotate(Quaternion.Euler(0, i * 90, 0));
                    m2 = Matrix4x4.Translate(new Vector3(0.5f, 0f, 0.5f));
                    break;

                case 5:
                    m  = Matrix4x4.Rotate(Quaternion.Euler(0, i * -90, 0));
                    m2 = Matrix4x4.TRS(new Vector3(0.5f, 0f, -0.5f), Quaternion.Euler(180, 0, 0), Vector3.one);
                    break;

                default:
                    throw new System.Exception();
                }

                MeshData data = new MeshData(blockMesh);
                data.Transform(half * m * m2 * inverseHalf);
                meshes[(j << 2) + i] = data;
            }
        }
    }