本文整理汇总了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;
}
示例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)
//.........这里部分代码省略.........
示例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;
}