Ejemplo n.º 1
0
        public override SOMaterial Clone()
        {
            Material      copyM = UnityEngine.Object.Instantiate <Material>(meshMaterial);
            fMeshMaterial meshM = new fMeshMaterial(copyM);

            return(new UnitySOMeshMaterial(meshM));
        }
Ejemplo n.º 2
0
        public static fMeshMaterial CreateStandardMeshMaterial(Colorf c)
        {
            fMeshMaterial m = new fMeshMaterial(SafeLoadMaterial("StandardMaterials/standard_mesh"));

            m.color = c;
            return(m);
        }
Ejemplo n.º 3
0
 public UnitySOMeshMaterial(fMeshMaterial wrapMaterial) : base(false)
 {
     meshMaterial = wrapMaterial;
 }
Ejemplo n.º 4
0
        public static fMaterial ToMaterialf(SOMaterial m)
        {
            fMaterial unityMat = null;

            if (m.Type == SOMaterial.MaterialType.TextureMap)
            {
                unityMat       = new Material(Shader.Find("Standard"));
                unityMat.name  = m.Name;
                unityMat.color = m.RGBColor;
                //if (m.Alpha < 1.0f)
                //    MaterialUtil.SetupMaterialWithBlendMode(unityMat, MaterialUtil.BlendMode.Transparent);
                unityMat.mainTexture = m.MainTexture;
            }
            else if (m.Type == SOMaterial.MaterialType.PerVertexColor)
            {
                unityMat              = MaterialUtil.CreateStandardVertexColorMaterial(m.RGBColor);
                unityMat.renderQueue += m.RenderQueueShift;
                unityMat.SetInt("_Cull", (int)m.CullingMode);
            }
            else if (m.Type == SOMaterial.MaterialType.FlatShadedPerVertexColor)
            {
                unityMat              = MaterialUtil.CreateFlatShadedVertexColorMaterialF(m.RGBColor);
                unityMat.renderQueue += m.RenderQueueShift;
                unityMat.SetInt("_Cull", (int)m.CullingMode);
            }
            else if (m.Type == SOMaterial.MaterialType.TransparentRGBColor)
            {
                unityMat              = MaterialUtil.CreateTransparentMaterial(m.RGBColor);
                unityMat.renderQueue += m.RenderQueueShift;
            }
            else if (m.Type == SOMaterial.MaterialType.StandardRGBColor)
            {
                unityMat              = MaterialUtil.CreateStandardMaterial(m.RGBColor);
                unityMat.renderQueue += m.RenderQueueShift;
            }
            else if (m.Type == SOMaterial.MaterialType.UnlitRGBColor)
            {
                unityMat              = MaterialUtil.CreateFlatMaterial(m.RGBColor);
                unityMat.renderQueue += m.RenderQueueShift;
            }
            else if (m.Type == SOMaterial.MaterialType.DepthWriteOnly)
            {
                unityMat              = MaterialUtil.CreateDepthWriteOnly();
                unityMat.renderQueue += m.RenderQueueShift;
            }
            else if (m.Type == SOMaterial.MaterialType.StandardMesh)
            {
                fMeshMaterial meshMat = MaterialUtil.CreateStandardMeshMaterial(m.RGBColor);
                meshMat.renderQueue += m.RenderQueueShift;
                if (m is SOMeshMaterial)
                {
                    meshMat.InitializeFromSOMaterial(m as SOMeshMaterial);
                }
                unityMat = meshMat;
            }
            else if (m is UnitySOMeshMaterial)
            {
                unityMat = (m as UnitySOMeshMaterial).meshMaterial;
            }
            else if (m is UnitySOMaterial)
            {
                unityMat = (m as UnitySOMaterial).unityMaterial;
            }
            else
            {
                unityMat = MaterialUtil.CreateStandardMaterial(Color.black);
            }

            if ((m.Hints & SOMaterial.HintFlags.UseTransparentPass) != 0)
            {
                SetupMaterialWithBlendMode(unityMat, BlendMode.Transparent);
            }

            if (m.MaterialCustomizerF != null)
            {
                m.MaterialCustomizerF(unityMat);
            }

            return(unityMat);
        }