コード例 #1
0
    /// <summary>
    /// Generate and add texture to the mesh.
    /// </summary>
    public void SetTexture(int type)
    {
        textureIndex = type;

        ColorMixer background;
        ColorMixer stripe;
        Texture2D tex;
        Material mat = mainMat;

        int period;
        int width;

        switch (type) {

        case 0:
        default:
            // White purple rubber, bright yellow gap
            period = 82;
            width = 11;
            Settings.mappingDistance = 3;
            Settings.ScrollSpeed = 0.066f;

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(1f, 0.9f, 1f), 0.1f);
            background.InsertColorNode(new Color(1f, 0, 1f), 0.4f);
            background.InsertColorNode(new Color(0.4f, 0, 0.6f), 0.7f);
            background.InsertColorNode(new Color(0.4f, 0, 0.6f), 0.8f);
            background.InsertColorNode(new Color(1f, 0, 1f), 0.9f);
            background.InsertColorNode(new Color(1f, 0.9f, 1f), 1f);
            stripe.InsertColorNode(new Color(0.9f,0.9f,0.45f), 0);
            tex = MeshFactory.CreateStripedTexture(2048, period, width, 20, background, stripe);
            mat.mainTexture = tex;

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.5f), 0);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.2f, 1f), 0);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.2f, 0f), 1);
            tex = MeshFactory.CreateStripedTexture(2048, period, width, 20, background, stripe, true);
            mat.SetTexture("_BumpMap", tex);
            mat.EnableKeyword("_NORMALMAP");

            mat.DisableKeyword("_SPECGLOSSMAP");
            mat.DisableKeyword("_EMISSION");
            break;

        case 1:
            // White-blue rubber, silver metal wire
            period = 60;
            width = 8;
            Settings.mappingDistance = 4;
            Settings.ScrollSpeed = 0.05f;

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(Color.white, 0.0f);
            background.InsertColorNode(new Color(0.5f, 0.75f, 1f), 0.3f);
            background.InsertColorNode(Color.blue, 0.7f);
            background.InsertColorNode(Color.blue, 0.8f);
            background.InsertColorNode(new Color(0.5f, 0.75f, 1f), 0.9f);
            background.InsertColorNode(Color.white, 1f);
            stripe.InsertColorNode(new Color(0.5f,0.5f,0.5f), 0);
            tex = MeshFactory.CreateStripedTexture(2048, period, width, 20, background, stripe);
            mat.mainTexture = tex;

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(0.43f, 0.43f, 0.43f, 0.6f), 0);
            stripe.InsertColorNode(new Color(0.9f, 0.9f, 0.9f, 0.85f), 0);
            tex = MeshFactory.CreateStripedTexture(2048, period, width, 20, background, stripe);
            mat.SetTexture("_SpecGlossMap", tex);
            mat.EnableKeyword("_SPECGLOSSMAP");

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.5f), 0);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.25f), 0);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.75f), 1);
            tex = MeshFactory.CreateStripedTexture(2048, period, width, 20, background, stripe, true);
            mat.SetTexture("_BumpMap", tex);
            mat.EnableKeyword("_NORMALMAP");

            mat.DisableKeyword("_EMISSION");
            break;

        case 2:
            // Dark green shell, light green fluorescence
            period = 60;
            width = 8;
            Settings.mappingDistance = 4;
            Settings.ScrollSpeed = 0.08f;

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(0.081f, 0.1137f, 0.06f), 0f);
            stripe.InsertColorNode(new Color(0f, 0f, 0f), 0);
            tex = MeshFactory.CreateStripedTexture(2048, period, width, 20, background, stripe);
            mat.mainTexture = tex;

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(0f, 0f, 0f, 0f), 0);
            stripe.InsertColorNode(new Color(0.6f, 1f, 0.4f, 1f), 0);
            tex = MeshFactory.CreateStripedTexture(2048, period, width-2, 21, background, stripe);
            mat.SetTexture("_EmissionMap", tex);
            mat.SetColor("_EmissionColor", new Color(0.9f, 0.9f, 0.9f));
            mat.EnableKeyword("_EMISSION");

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.5f), 0);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.5f, 1f), 0);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.5f), 0.15f);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.5f), 0.85f);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0f), 1);
            tex = MeshFactory.CreateStripedTexture(2048, period, width, 20, background, stripe, true);
            mat.SetTexture("_BumpMap", tex);
            mat.EnableKeyword("_NORMALMAP");

            mat.DisableKeyword("_SPECGLOSSMAP");
            break;

        case 3:
            // Gold, bright lamp
            period = 60;
            width = 10;
            Settings.mappingDistance = 4;
            Settings.ScrollSpeed = 0.05f;

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(1f, 0.7f, 0.3f), 0f);
            stripe.InsertColorNode(new Color(0.125f, 0.125f, 0.1f), 0);
            tex = MeshFactory.CreateStripedTexture(2048, period, width-2, 21, background, stripe);
            mat.mainTexture = tex;

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(1f, 0.7f, 0.3f, 0.75f), 0);
            stripe.InsertColorNode(new Color(0.3f, 0.3f, 0.3f, 0.4f), 0);
            tex = MeshFactory.CreateStripedTexture(2048, period, width-2, 21, background, stripe);
            mat.SetTexture("_SpecGlossMap", tex);
            mat.EnableKeyword("_SPECGLOSSMAP");

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(0f, 0f, 0f, 0f), 0);
            stripe.InsertColorNode(new Color(1f, 1f, 0.8f, 1f), 0);
            tex = MeshFactory.CreateStripedTexture(2048, period, width-2, 21, background, stripe);
            mat.SetTexture("_EmissionMap", tex);
            mat.SetColor("_EmissionColor", new Color(0f, 0f, 0f));
            mat.EnableKeyword("_EMISSION");

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.5f), 0);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.5f, 1f), 0);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.5f), 0.15f);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.5f), 0.85f);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0f), 1);
            tex = MeshFactory.CreateStripedTexture(2048, period, width, 20, background, stripe, true);
            mat.SetTexture("_BumpMap", tex);
            mat.EnableKeyword("_NORMALMAP");
            break;

        case 4:
            // Grey stone, lava band
            period = 60;
            width = 10;
            Settings.mappingDistance = 4;
            Settings.ScrollSpeed = 0.05f;

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(0.25f, 0.25f, 0.25f), 0f);
            stripe.InsertColorNode(new Color(0.05f, 0.05f, 0.05f), 0);
            tex = MeshFactory.CreateStripedTexture(2048, period, width-2, 21, background, stripe);
            mat.mainTexture = tex;

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(0f, 0f, 0f, 0.25f), 0);
            stripe.InsertColorNode(new Color(0.25f, 0.25f, 0.25f, 0.5f), 0);
            tex = MeshFactory.CreateStripedTexture(2048, period, width-2, 21, background, stripe);
            mat.SetTexture("_SpecGlossMap", tex);
            mat.EnableKeyword("_SPECGLOSSMAP");

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(0f, 0f, 0f, 0f), 0);
            stripe.InsertColorNode(new Color(0.85f, 0.7f, 0.1f, 1f), 0.1f);
            stripe.InsertColorNode(new Color(1f, 0.05f, 0f, 1f), 0.3f);
            stripe.InsertColorNode(new Color(0f, 0f, 0f, 1f), 0.5f);
            stripe.InsertColorNode(new Color(0f, 0f, 0f, 1f), 0.6f);
            stripe.InsertColorNode(new Color(1f, 0.05f, 0f, 1f), 0.8f);
            stripe.InsertColorNode(new Color(0.85f, 0.7f, 0.1f, 1f), 1);
            tex = MeshFactory.CreateStripedTexture(2048, period, width-2, 21, background, stripe);
            mat.SetTexture("_EmissionMap", tex);
            mat.SetColor("_EmissionColor", new Color(1f, 1f, 1f));
            mat.EnableKeyword("_EMISSION");

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.5f), 0);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.5f, 1f), 0);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.5f), 0.15f);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.5f), 0.85f);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0f), 1);
            tex = MeshFactory.CreateStripedTexture(2048, period, width, 20, background, stripe, true);
            mat.SetTexture("_BumpMap", tex);
            mat.EnableKeyword("_NORMALMAP");
            break;

        case 5:
            // White plaster, black porcelain
            background = new ColorMixer();
            stripe = new ColorMixer();
            period = 60;
            width = 30;
            Settings.mappingDistance = 4;
            Settings.ScrollSpeed = 0.05f;

            background.InsertColorNode(Color.white, 0f);
            stripe.InsertColorNode(Color.black, 0f);
            tex = MeshFactory.CreateStripedTexture(2048, period, width-2, 21, background, stripe);
            mat.mainTexture = tex;

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(0.2f, 0.2f, 0.2f, 0.5f), 0);
            stripe.InsertColorNode(new Color(0.3f, 0.3f, 0.3f, 0.85f), 0);
            tex = MeshFactory.CreateStripedTexture(2048, period, width-2, 21, background, stripe);
            mat.SetTexture("_SpecGlossMap", tex);
            mat.EnableKeyword("_SPECGLOSSMAP");

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.5f), 0);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.1f, 1f), 0);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.5f), 0.1f);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.5f), 0.9f);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.1f, 0f), 1);
            tex = MeshFactory.CreateStripedTexture(2048, period, width, 20, background, stripe, true);
            mat.SetTexture("_BumpMap", tex);
            mat.EnableKeyword("_NORMALMAP");

            mat.DisableKeyword("_EMISSION");
            break;

        case 6:
            // Yellow-red-black rubber + light
            period = 82;
            width = 12;
            Settings.mappingDistance = 3;
            Settings.ScrollSpeed = 0.066f;

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(Color.yellow, 0.1f);
            background.InsertColorNode(Color.red, 0.4f);
            background.InsertColorNode(Color.black, 0.7f);
            background.InsertColorNode(Color.black, 0.8f);
            background.InsertColorNode(Color.red, 0.9f);
            background.InsertColorNode(Color.yellow, 1f);
            tex = MeshFactory.CreateStripedTexture(2048, period, 0, 20, background, stripe);
            mat.mainTexture = tex;

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(Color.black, 0f);
            stripe.InsertColorNode(Color.yellow, 0.1f);
            stripe.InsertColorNode(Color.red, 0.4f);
            stripe.InsertColorNode(Color.black, 0.7f);
            stripe.InsertColorNode(Color.black, 0.8f);
            stripe.InsertColorNode(Color.red, 0.9f);
            stripe.InsertColorNode(Color.yellow, 1f);
            tex = MeshFactory.CreateStripedTexture(2048, period, width-2, 21, background, stripe);
            mat.SetTexture("_EmissionMap", tex);
            mat.SetColor("_EmissionColor", new Color(0.5f, 0.5f, 0.5f));
            mat.EnableKeyword("_EMISSION");

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.5f), 0);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.1f, 0f), 0);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.5f), 0.2f);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.5f), 0.8f);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.1f, 1f), 1);
            tex = MeshFactory.CreateStripedTexture(2048, period, width, 20, background, stripe, true);
            mat.SetTexture("_BumpMap", tex);
            mat.EnableKeyword("_NORMALMAP");

            mat.DisableKeyword("_SPECGLOSSMAP");
            break;

        case 7:
            // White-yellow-orange plaster, black stripe
            period = 82;
            width = 11;
            Settings.mappingDistance = 3;
            Settings.ScrollSpeed = 0.066f;

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(1f, 1f, 0.8f), 0.1f);
            background.InsertColorNode(new Color(1f, 1f, 0f), 0.3f);
            background.InsertColorNode(new Color(1f, 0.3f, 0f), 0.7f);
            background.InsertColorNode(new Color(1f, 0.3f, 0f), 0.8f);
            background.InsertColorNode(new Color(1f, 1f, 0f), 0.93f);
            background.InsertColorNode(new Color(1f, 1f, 0.8f), 1f);
            stripe.InsertColorNode(new Color(0.1f, 0.1f, 0.1f), 0);
            tex = MeshFactory.CreateStripedTexture(2048, period, width, 20, background, stripe);
            mat.mainTexture = tex;

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(0.33f, 0.33f, 0.33f, 0.33f), 0);
            stripe.InsertColorNode(new Color(0.4f, 0.4f, 0.4f, 0.5f), 0);
            tex = MeshFactory.CreateStripedTexture(2048, period, width, 20, background, stripe);
            mat.SetTexture("_SpecGlossMap", tex);
            mat.EnableKeyword("_SPECGLOSSMAP");

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.5f), 0);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.2f, 1f), 0);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.2f, 0f), 1);
            tex = MeshFactory.CreateStripedTexture(2048, period, width, 20, background, stripe, true);
            mat.SetTexture("_BumpMap", tex);
            mat.EnableKeyword("_NORMALMAP");

            mat.DisableKeyword("_EMISSION");
            break;

        case 8:
            // White bone, metal band
            period = 82;
            width = 22;
            Settings.mappingDistance = 3;
            Settings.ScrollSpeed = 0.066f;

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(0.6f, 0.6f, 0.6f), 0f);
            stripe.InsertColorNode(new Color(0f, 0f, 0f), 0);
            tex = MeshFactory.CreateStripedTexture(2048, period, width, 20, background, stripe);
            mat.mainTexture = tex;

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(0f, 0f, 0f, 0.4f), 0);
            stripe.InsertColorNode(new Color(0.7f, 0.7f, 0.7f, 0.8f), 0);
            tex = MeshFactory.CreateStripedTexture(2048, period, width, 20, background, stripe);
            mat.SetTexture("_SpecGlossMap", tex);
            mat.EnableKeyword("_SPECGLOSSMAP");

            background = new ColorMixer();
            stripe = new ColorMixer();
            background.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.5f), 0);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.2f, 0f), 0);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.5f), 0.1f);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.5f, 0.5f), 0.9f);
            stripe.InsertColorNode(new Color(1f, 0.5f, 0.2f, 1f), 1);
            tex = MeshFactory.CreateStripedTexture(2048, period, width, 20, background, stripe, true);
            mat.SetTexture("_BumpMap", tex);
            mat.EnableKeyword("_NORMALMAP");

            mat.DisableKeyword("_EMISSION");
            break;
        }
    }