public void setMaterial(int facadeID, Texture2D colorTexture, Texture2D normalTexture, Texture2D specularTexture, string colorTex, string normalTex, string specularTex) { Material mat = facades[facadeID].GetComponent <MeshRenderer>().material; FacadeSkin fs = new FacadeSkin(); fs.facadeID = facadeID; fs.normalTexturePath = normalTex; fs.specularTexturePath = specularTex; fs.colorTexturePath = colorTex; fs.bottomLeft = new Vector2(0, 0); fs.bottomRight = new Vector2(0, 1); fs.topLeft = new Vector2(1, 0); fs.topRight = new Vector2(1, 1); int facadeIndex = facadeSkins.FindIndex(item => item.facadeID == facadeID); if (facadeIndex == -1) { facadeSkins.Add(fs); } else { facadeSkins[facadeIndex] = fs; } if (colorTexture != null) { mat.SetTexture("_MainTex", colorTexture); mat.SetTexture("_BumpMap", normalTexture); mat.SetTexture("_SpecGlossMap", specularTexture); } }
public void setTextureCoordinate(int facadeID, Vector2 bottomLeft, Vector2 bottomRight, Vector2 topLeft, Vector2 topRight) { int facadeIndex = facadeSkins.FindIndex(item => item.facadeID == facadeID); FacadeSkin fs = facadeSkins[facadeIndex]; fs.bottomLeft = bottomLeft; fs.bottomRight = bottomRight; fs.topLeft = topLeft; fs.topRight = topRight; facadeSkins[facadeIndex] = fs; MeshFilter meshFilter = facades[facadeID].GetComponent <MeshFilter>(); if (isClockwise) { meshFilter.mesh.uv = new Vector2[] { bottomLeft, bottomRight, topRight, topLeft } } ; else { meshFilter.mesh.uv = new Vector2[] { bottomRight, bottomLeft, topLeft, topRight } }; } }
public static Material createMaterial(FacadeSkin skin) { Material mat = new Material(Shader.Find("Standard (Specular setup)")); Texture2D colortex = getTexture(skin.colorTexturePath); Texture2D normaltex = getTexture(skin.normalTexturePath); Texture2D speculartex = getTexture(skin.specularTexturePath); mat.SetTexture("_MainTex", colortex); mat.SetTexture("_BumpMap", normaltex); mat.SetFloat("_BumpScale", 1.0f); mat.SetFloat("_Glossiness", 0.1f); mat.SetTexture("_SpecGlossMap", speculartex); return mat; }
public void setMaterial(int facadeID, Texture2D colorTexture, Texture2D normalTexture, Texture2D specularTexture, string colorTex, string normalTex, string specularTex) { Material mat = facades[facadeID].GetComponent<MeshRenderer>().material; FacadeSkin fs = new FacadeSkin(); fs.facadeID = facadeID; fs.normalTexturePath = normalTex; fs.specularTexturePath = specularTex; fs.colorTexturePath = colorTex; fs.bottomLeft = new Vector2(0, 0); fs.bottomRight = new Vector2(0, 1); fs.topLeft = new Vector2(1, 0); fs.topRight = new Vector2(1, 1); int facadeIndex = facadeSkins.FindIndex(item => item.facadeID == facadeID); if (facadeIndex == -1) facadeSkins.Add(fs); else facadeSkins[facadeIndex] = fs; if (colorTexture != null) { mat.SetTexture("_MainTex", colorTexture); mat.SetTexture("_BumpMap", normalTexture); mat.SetTexture("_SpecGlossMap", specularTexture); } }