当前位置: 首页>>代码示例>>C#>>正文


C# Mesh.LoadOBJ方法代码示例

本文整理汇总了C#中Mesh.LoadOBJ方法的典型用法代码示例。如果您正苦于以下问题:C# Mesh.LoadOBJ方法的具体用法?C# Mesh.LoadOBJ怎么用?C# Mesh.LoadOBJ使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mesh的用法示例。


在下文中一共展示了Mesh.LoadOBJ方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddTypeElement

    public bool AddTypeElement(System.Xml.Linq.XElement elemtype)
    {
        XAttribute fileAtt = elemtype.Attribute("file");
        if (fileAtt == null)
        {
            //Add error message here
            return false;
        }
        string filePath = Path.Combine(Path.GetDirectoryName(new Uri(elemtype.BaseUri).LocalPath), fileAtt.Value);
        filePath = Path.GetFullPath(filePath);

        //	Load the OBJ in
        var lStream = new FileStream(filePath, FileMode.Open);
        var lOBJData = OBJLoader.LoadOBJ(lStream);
        lStream.Close();
        meshData = new MeshData[(int)MeshLayer.Count];
        Mesh tempMesh = new Mesh();
        for (int i = 0; i < meshData.Length; i++)
        {
            tempMesh.LoadOBJ(lOBJData, ((MeshLayer)i).ToString());
            meshData[i] = new MeshData(tempMesh);
            tempMesh.Clear();
        }
        lStream = null;
        lOBJData = null;
        return true;
    }
开发者ID:christopherbauer,项目名称:armok-vision,代码行数:27,代码来源:MeshContent.cs

示例2: AddTypeElement

    public bool AddTypeElement(System.Xml.Linq.XElement elemtype)
    {
        XAttribute fileAtt = elemtype.Attribute("file");
        if (fileAtt == null)
        {
            //Add error message here
            return false;
        }

        if ((elemtype.Attribute("normal") != null
            || elemtype.Attribute("occlusion") != null
            || elemtype.Attribute("alpha") != null
            || elemtype.Attribute("pattern") != null
            ))
        {
            _normalTexture = new NormalContent();
            _normalTexture.ExternalStorage = storeContainer.shapeStore;
            if (!_normalTexture.AddTypeElement(elemtype))
                _normalTexture = null;
        }

        if ((elemtype.Attribute("metallic") != null
            || elemtype.Attribute("illumination") != null
            ))
        {
            _specialTexture = new SpecialMapContent();
            _specialTexture.ExternalStorage = storeContainer.specialStore;
            if (!_specialTexture.AddTypeElement(elemtype))
                _specialTexture = null;
        }

        if ((elemtype.Attribute("pattern") != null
            || elemtype.Attribute("specular") != null
            ))
        {
            _matTexture = new TextureContent();
            _matTexture.ExternalStorage = storeContainer.materialStore;
            if (!_matTexture.AddTypeElement(elemtype))
                _matTexture = null;
        }

        if (fileAtt.Value == "NONE")
        {
            //This means we don't want to actually store a mesh,
            //but still want to use the category.
            MeshData = new Dictionary<MeshLayer, CPUMesh>();
        }
        else
        {
            string filePath = Path.Combine(Path.GetDirectoryName(new Uri(elemtype.BaseUri).LocalPath), fileAtt.Value);
            filePath = Path.GetFullPath(filePath);

            //	Load the OBJ in
            if (!File.Exists(filePath))
                return false;
            var lStream = new FileStream(filePath, FileMode.Open);
            var lOBJData = OBJLoader.LoadOBJ(lStream);
            lStream.Close();
            MeshData = new Dictionary<MeshLayer, CPUMesh>();
            Mesh tempMesh = new Mesh();
            foreach(MeshLayer layer in Enum.GetValues(typeof(MeshLayer)))
            {
                MeshLayer translatedLayer;
                if (layer == MeshLayer.GrowthCutout1
                    || layer == MeshLayer.GrowthCutout2
                    || layer == MeshLayer.GrowthCutout3)
                    translatedLayer = MeshLayer.GrowthCutout;
                else if (layer == MeshLayer.GrowthMaterial1
                    || layer == MeshLayer.GrowthMaterial2
                    || layer == MeshLayer.GrowthMaterial3)
                    translatedLayer = MeshLayer.GrowthMaterial;
                else if (layer == MeshLayer.GrowthTransparent1
                    || layer == MeshLayer.GrowthTransparent2
                    || layer == MeshLayer.GrowthTransparent3)
                    translatedLayer = MeshLayer.GrowthTransparent;
                else translatedLayer = layer;
                tempMesh.LoadOBJ(lOBJData, (layer.ToString()));
                if (tempMesh == null || tempMesh.vertexCount == 0)
                    continue;
                tempMesh.name = filePath + "." + layer.ToString();
                if(translatedLayer == MeshLayer.GrowthCutout
                    || translatedLayer == MeshLayer.GrowthMaterial
                    || translatedLayer == MeshLayer.GrowthTransparent)
                {
                    for(int i = (int)translatedLayer; i < (int)translatedLayer + 4; i++)
                    {
                        //This is because the tree growths can be in any order
                        //So we just copy the un-numbered one onto the rest.
                        MeshData[(MeshLayer)i] = new CPUMesh(tempMesh);
                    }
                }
                else MeshData[layer] = new CPUMesh(tempMesh);
                tempMesh.Clear();
            }
            lStream = null;
            lOBJData = null;
        }

        XAttribute rotAtt = elemtype.Attribute("rotation");
        if (rotAtt == null)
//.........这里部分代码省略.........
开发者ID:JapaMala,项目名称:armok-vision,代码行数:101,代码来源:MeshContent.cs

示例3: AddTypeElement

    public bool AddTypeElement(System.Xml.Linq.XElement elemtype)
    {
        XAttribute fileAtt = elemtype.Attribute("file");
        if (fileAtt == null)
        {
            //Add error message here
            return false;
        }

        if (store != null
            && (elemtype.Attribute("normal") != null
            || elemtype.Attribute("occlusion") != null
            || elemtype.Attribute("alpha") != null
            ))
        {
            _normalTexture = new NormalContent();
            _normalTexture.ExternalStorage = store;
            if (!_normalTexture.AddTypeElement(elemtype))
                _normalTexture = null;
        }

        if (fileAtt.Value == "NONE")
        {
            //This means we don't want to actually store a mesh,
            //but still want to use the category.
            MeshData = new MeshData[(int)MeshLayer.Count];
        }
        else
        {
            string filePath = Path.Combine(Path.GetDirectoryName(new Uri(elemtype.BaseUri).LocalPath), fileAtt.Value);
            filePath = Path.GetFullPath(filePath);

            //	Load the OBJ in
            var lStream = new FileStream(filePath, FileMode.Open);
            var lOBJData = OBJLoader.LoadOBJ(lStream);
            lStream.Close();
            MeshData = new MeshData[(int)MeshLayer.Count];
            Mesh tempMesh = new Mesh();
            for (int i = 0; i < MeshData.Length; i++)
            {
                tempMesh.LoadOBJ(lOBJData, ((MeshLayer)i).ToString());
                MeshData[i] = new MeshData(tempMesh);
                tempMesh.Clear();
            }
            lStream = null;
            lOBJData = null;
        }

        XAttribute rotAtt = elemtype.Attribute("rotation");
        if (rotAtt == null)
            rotationType = RotationType.None;
        else
        {
            try
            {
                rotationType = (RotationType)Enum.Parse(typeof(RotationType), rotAtt.Value);
            }
            catch
            {
                rotationType = RotationType.None;
                Debug.Log("Unknown rotation value: " + rotAtt.Value);
            }
        }
        return true;
    }
开发者ID:Chronovore,项目名称:armok-vision,代码行数:65,代码来源:MeshContent.cs


注:本文中的Mesh.LoadOBJ方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。