本文整理汇总了C#中BulletSharp.SoftBody.SoftBody.AppendTetra方法的典型用法代码示例。如果您正苦于以下问题:C# SoftBody.AppendTetra方法的具体用法?C# SoftBody.AppendTetra怎么用?C# SoftBody.AppendTetra使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BulletSharp.SoftBody.SoftBody
的用法示例。
在下文中一共展示了SoftBody.AppendTetra方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateFromTetGenData
public static SoftBody CreateFromTetGenData(SoftBodyWorldInfo worldInfo, string ele, string face, string node, bool faceLinks, bool tetraLinks, bool facesFromTetras)
{
CultureInfo culture = CultureInfo.InvariantCulture;
char[] separator = new[] { ' ' };
Vector3[] pos;
using (StringReader nodeReader = new StringReader(node))
{
string[] nodeHeader = nodeReader.ReadLine().Split(separator, StringSplitOptions.RemoveEmptyEntries);
int numNodes = int.Parse(nodeHeader[0]);
//int numDims = int.Parse(nodeHeader[1]);
//int numAttrs = int.Parse(nodeHeader[2]);
//bool hasBounds = !nodeHeader[3].Equals("0");
pos = new Vector3[numNodes];
for (int n = 0; n < numNodes; n++)
{
string[] nodeLine = nodeReader.ReadLine().Split(separator, StringSplitOptions.RemoveEmptyEntries);
pos[int.Parse(nodeLine[0])] = new Vector3(
float.Parse(nodeLine[1], culture),
float.Parse(nodeLine[2], culture),
float.Parse(nodeLine[3], culture));
}
}
SoftBody psb = new SoftBody(worldInfo, pos.Length, pos, null);
/*
if (!string.IsNullOrEmpty(face))
{
throw new NotImplementedException();
}
*/
if (!string.IsNullOrEmpty(ele))
{
using (StringReader eleReader = new StringReader(ele))
{
string[] eleHeader = eleReader.ReadLine().Split(separator, StringSplitOptions.RemoveEmptyEntries);
int numTetras = int.Parse(eleHeader[0]);
//int numCorners = int.Parse(eleHeader[1]);
//int numAttrs = int.Parse(eleHeader[2]);
for (int n = 0; n < numTetras; n++)
{
string[] eleLine = eleReader.ReadLine().Split(separator, StringSplitOptions.RemoveEmptyEntries);
//int index = int.Parse(eleLine[0], culture);
int ni0 = int.Parse(eleLine[1], culture);
int ni1 = int.Parse(eleLine[2], culture);
int ni2 = int.Parse(eleLine[3], culture);
int ni3 = int.Parse(eleLine[4], culture);
psb.AppendTetra(ni0, ni1, ni2, ni3);
if (tetraLinks)
{
psb.AppendLink(ni0, ni1, null, true);
psb.AppendLink(ni1, ni2, null, true);
psb.AppendLink(ni2, ni0, null, true);
psb.AppendLink(ni0, ni3, null, true);
psb.AppendLink(ni1, ni3, null, true);
psb.AppendLink(ni2, ni3, null, true);
}
}
}
}
//Console.WriteLine("Nodes: {0}", psb.Nodes.Count);
//Console.WriteLine("Links: {0}", psb.Links.Count);
//Console.WriteLine("Faces: {0}", psb.Faces.Count);
//Console.WriteLine("Tetras: {0}", psb.Tetras.Count);
return psb;
}