예제 #1
0
        public bool Import(BinaryReader reader, int version)
        {
            m_MaterialHash = reader.ReadInt32();
            if (version < 01052001)
            {
                reader.ReadInt32(); //MyMeshDrawTechnique
            }
            int nCount = reader.ReadInt32();

            for (int i = 0; i < nCount; ++i)
            {
                m_indices.Add(reader.ReadInt32());
            }

            bool bMatDesc = reader.ReadBoolean();
            bool bRes     = true;

            if (bMatDesc)
            {
                m_MaterialDesc = new MyMaterialDescriptor();
                bRes           = m_MaterialDesc.Read(reader, version);

                bRes &= Enum.TryParse(m_MaterialDesc.Technique, out Technique);
                if (m_MaterialDesc.Technique == "FOLIAGE")
                {
                    Technique = MyMeshDrawTechnique.ALPHA_MASKED;
                }
            }
            else
            {
                m_MaterialDesc = null;
            }

            return(bRes);
        }
예제 #2
0
        public bool Import(BinaryReader reader, int version)
        {
            m_MaterialHash = reader.ReadInt32();
            if (version < 01052001)
                reader.ReadInt32(); //MyMeshDrawTechnique

            int nCount = reader.ReadInt32();
            for (int i = 0; i < nCount; ++i)
            {
                m_indices.Add(reader.ReadInt32());
            }

            bool bMatDesc = reader.ReadBoolean();
            bool bRes = true;
            if (bMatDesc)
            {
                m_MaterialDesc = new MyMaterialDescriptor();
                bRes = m_MaterialDesc.Read(reader, version);

                bRes &= Enum.TryParse(m_MaterialDesc.Technique, out Technique);
                if (m_MaterialDesc.Technique == "FOLIAGE")
                {
                    Technique = MyMeshDrawTechnique.ALPHA_MASKED;
                }
            }
            else
            {
                m_MaterialDesc = null;
            }

            return bRes;
        }
예제 #3
0
        internal static MyMeshMaterialId GetMaterialId(MyMaterialDescriptor importDesc, string contentPath, string assetFile = null)
        {
            MyMeshMaterialInfo desc;
            if(importDesc != null)
            {
                desc = new MyMeshMaterialInfo
                {
                    Name = X.TEXT(importDesc.MaterialName),
                    ContentPath = contentPath,
                    ColorMetal_Texture = X.TEXT(importDesc.Textures.Get("ColorMetalTexture", "")),
                    NormalGloss_Texture = X.TEXT(importDesc.Textures.Get("NormalGlossTexture", "")),
                    Extensions_Texture = X.TEXT(importDesc.Textures.Get("AddMapsTexture", "")),
                    Alphamask_Texture = X.TEXT(importDesc.Textures.Get("AlphamaskTexture", null)),
                    Technique = importDesc.Technique,
                    Facing = importDesc.Facing,
                    WindScaleAndFreq = importDesc.WindScaleAndFreq
                };
            }
            else
            {
                return NullMaterialId;
            }

            return GetMaterialId(ref desc, assetFile);
        }
예제 #4
0
        internal static MyMeshMaterialId GetMaterialId(MyMaterialDescriptor importDesc, string contentPath)
        {
            MyMeshMaterialInfo desc;
            if(importDesc != null)
            {
                desc = new MyMeshMaterialInfo
                {
                    Name = X.TEXT(importDesc.MaterialName),
                    ContentPath = contentPath,
                    ColorMetal_Texture = MyStringId.GetOrCompute(importDesc.Textures.Get("ColorMetalTexture", "")),
                    NormalGloss_Texture = MyStringId.GetOrCompute(importDesc.Textures.Get("NormalGlossTexture", "")),
                    Extensions_Texture = MyStringId.GetOrCompute(importDesc.Textures.Get("AddMapsTexture", "")),
                    Alphamask_Texture = MyStringId.GetOrCompute(importDesc.Textures.Get("AlphamaskTexture", null)),
                    Technique = importDesc.Technique
                };
            }
            else
            {
                return NullMaterialId;
            }

            return GetMaterialId(ref desc);
        }