private IEnumerator ApplyTexture2(Transform target, OSLibTexture textureData, OSLib library)
    {
        while(_assetBundleIsOpen)
            yield return new WaitForEndOfFrame();
        _assetBundleIsOpen = true;
        WWW www = WWW.LoadFromCacheOrDownload (library.GetAssetBundlePath (), library.GetVersion ());
        yield return www;

        AssetBundle assets = www.assetBundle;
        Texture2D texture = assets.LoadAsset (textureData.GetFilePath2 (),
                                         typeof (Texture2D)) as Texture2D;
        assets.Unload (false);
        target.GetComponent<Renderer>().material.mainTexture = texture;
        _assetBundleIsOpen=false;
    }
Beispiel #2
0
 public void AddTexure(OSLibTexture texture)
 {
     _textures.Add (texture);
 }
    private IEnumerator ApplyTexture(Transform target, OSLibTexture textureData, OSLib library)
    {
        while(_assetBundleIsOpen)
            yield return new WaitForEndOfFrame();
        _assetBundleIsOpen = true;
        WWW www = WWW.LoadFromCacheOrDownload (library.GetAssetBundlePath (), library.GetVersion ());
        yield return www;

        AssetBundle assets = www.assetBundle;

        Texture2D texture = assets.LoadAsset (textureData.GetFilePath (),
                                         typeof (Texture2D)) as Texture2D;
        Texture2D normalMap = null;
        if (textureData.GetNormalPath () != "")
            normalMap = assets.LoadAsset (textureData.GetNormalPath (),
                                                typeof (Texture2D)) as Texture2D;

        Texture2D hueMask = null;
        if (textureData.GetHueMaskPath () != "")
            hueMask = assets.LoadAsset (textureData.GetHueMaskPath (),
                                          typeof (Texture2D)) as Texture2D;

        Texture2D specularMask = null;
        if (textureData.GetSpecularMaskPath () != "")
            specularMask = assets.LoadAsset (textureData.GetSpecularMaskPath (),
                                        typeof (Texture2D)) as Texture2D;

        assets.Unload (false);
        target.GetComponent<Renderer>().material.mainTexture = texture;
        float scale = textureData.GetScale();
        /*if (target.name.CompareTo("plage")==0)
            scale/=2.0f;*/
        if (target.name.CompareTo("sol")==0)
            scale/=2.0f;
        if(target.GetComponent<Renderer>().material.shader.name == "Pointcube/StandardObjet")
        {
            target.GetComponent<Renderer>().material.SetTextureScale("_Diffuse",new Vector2(scale,scale));
            target.GetComponent<Renderer> ().material.SetTexture ("_Normal", normalMap);
            target.GetComponent<Renderer> ().material.SetTexture ("_Diffuse", texture);
            target.GetComponent<Renderer> ().material.SetTexture ("_HueMask", hueMask);
            target.GetComponent<Renderer> ().material.SetTexture ("_SpecMask", specularMask);

            Dictionary<string,float> preset;
            if(target.name == "plage" || target.name == "Plage")
            {
                preset = GameObject.Find ("MainScene").GetComponent<LoadShaderPresets>().getConfigPlage(texture.name);
            }
            else if(target.name == "margelle" || target.name == "Margelle")
            {
                preset = GameObject.Find ("MainScene").GetComponent<LoadShaderPresets>().getConfigMargelle(texture.name);
            }
            else if(target.name == "muret" || target.name == "Muret")
            {
                preset = GameObject.Find ("MainScene").GetComponent<LoadShaderPresets>().getConfigMuret(texture.name);
            }
            else
            {
                preset = null;
            }
            if(preset != null)
            {
                string[] keys = preset.Keys.ToArray();
                float red = 0;
                float green = 0;
                float blue = 0;
                foreach (string key in keys)
                {
                    switch(key)
                    {
                        case "Normallevel ":
                            target.GetComponent<Renderer> ().material.SetFloat("_Normallevel",preset[key]);
                            break ;
                        case "UVtranslation ":
                            target.GetComponent<Renderer> ().material.SetFloat("_UVtranslation",preset[key]);
                            break ;
                        case "UVRotation ":
                            target.GetComponent<AABBOutlineResizer>().setOffsetRotationUV(preset[key]);
                            //target.GetComponent<Renderer> ().material.SetFloat("_UVRotation",preset[key]);
                            break ;
                        case "UVTile ":
                            target.GetComponent<AABBOutlineResizer>().setOffsetTileUV(preset[key]);
                            //target.GetComponent<Renderer> ().material.SetFloat("_UVTile",preset[key]);
                            break ;
                        case "Blur ":
                                target.GetComponent<Renderer> ().material.SetFloat("_Blur",preset[key]);
                            break ;
                        case "gloss ":
                                target.GetComponent<Renderer> ().material.SetFloat("_gloss",preset[key]);
                            break ;
                        case "Specularlevel ":
                            target.GetComponent<Renderer> ().material.SetFloat("_Specularlevel",preset[key]);
                            break ;
                        case "Lightness ":
                            target.GetComponent<Renderer> ().material.SetFloat("_Ligntness",preset[key]);
                            break ;
                        case "HueMaskIntensity ":
                            target.GetComponent<Renderer> ().material.SetFloat("_HueMaskIntensity",preset[key]);
                            break ;
                        case "HuecolorR ":
                            red = preset[key];
                            break ;
                        case "HuecolorG ":
                            green = preset[key];
                            break ;
                        case "HuecolorB ":
                            blue = preset[key];
                            break ;
                        case "Huelevel ":
                            target.GetComponent<AABBOutlineResizer>().setHueLevel(preset[key]);;
                            break ;
                        case "Saturation ":
                            target.GetComponent<AABBOutlineResizer>().setSaturation(preset[key]);
                            break ;
                        case "Bulb ":
                            target.GetComponent<Renderer> ().material.SetFloat("_Bulb",preset[key]);
                            break ;
                        case "Reflexion ":
                            target.GetComponent<Renderer> ().material.SetFloat("_Reflexion",preset[key]);

                            if(preset[key] !=0)
                            {
                                Cubemap temp = Resources.Load("shaders/configs/Chrome 1") as Cubemap;
                                Debug.Log(temp.name  +  "    Reflexion");
                                target.GetComponent<Renderer> ().material.SetTexture("_CubeMap",temp);
                            }
                            break ;
                        case "Reflexionintensity ":
                            target.GetComponent<Renderer> ().material.SetFloat("_Reflexionintensity",preset[key]);
                            break ;
                        case "ReflexionBlur ":
                            target.GetComponent<Renderer> ().material.SetFloat("_ReflexionBlur",preset[key]);
                            break ;
                    }
                }
                Vector3 hue = new Vector3(red,green,blue);
                Color hueColor = new Color(red,green,blue,1.0f);
                if(target.name == "plage" || target.name == "Plage")
                {
                    target.GetComponent<AABBOutlineResizer>().setColorPlage(hue);
                }
                else if(target.name == "margelle" || target.name == "Margelle")
                {
                    target.GetComponent<AABBOutlineResizer>().setColorMargelle(hue);
                }
                else if(target.name == "muret" || target.name == "Muret")
                {
                    target.GetComponent<AABBOutlineResizer>().setColorMuret(hue);
                }

                //target.GetComponent<Renderer> ().material.SetColor("_Huecolor",hue);
                picker.GetComponent<HSVPicker>().currentColor = hueColor;
            }
        }
        else
        {
            target.GetComponent<Renderer>().material.SetTextureScale("_MainTex",new Vector2(scale,scale));
            target.GetComponent<Renderer> ().material.SetTexture ("_BumpMap", normalMap);
        }

        _assetBundleIsOpen=false;
    }
Beispiel #4
0
 protected bool IsTextureOfType(OSLibTexture tex)
 {
     return tex.GetTextureType ().Equals (_searchedType);
 }