本文整理汇总了C#中Vertices.GetRange方法的典型用法代码示例。如果您正苦于以下问题:C# Vertices.GetRange方法的具体用法?C# Vertices.GetRange怎么用?C# Vertices.GetRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vertices
的用法示例。
在下文中一共展示了Vertices.GetRange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: j2b2Fixture
Fixture j2b2Fixture(Body body, JObject fixtureValue)
{
if (null == fixtureValue)
return null;
//Fixture fixtureDef = new Fixture();
var restitution = jsonToFloat("restitution", fixtureValue);
var friction = jsonToFloat("friction", fixtureValue);
var density = jsonToFloat("density", fixtureValue);
var isSensor = fixtureValue["sensor"] == null ? false : (bool)fixtureValue["sensor"];
var categoryBits = fixtureValue["filter-categoryBits"] == null ? 0x0001 : (int)fixtureValue["filter-categoryBits"];
var maskBits = fixtureValue["filter-maskBits"] == null ? 0xffff : (int)fixtureValue["filter-maskBits"];
var groupIndex = fixtureValue["filter-groupIndex"] == null ? (short)0 : (short)fixtureValue["filter-groupIndex"];
Fixture fixture = null;
if (null != fixtureValue["circle"])
{
JObject circleValue = (JObject)fixtureValue["circle"];
var radius = jsonToFloat("radius", circleValue);
var position = jsonToVec("center", circleValue);
fixture = FixtureFactory.AttachCircle(radius, density, body, position);
}
else if (null != fixtureValue["edge"])
{
JObject edgeValue = (JObject)fixtureValue["edge"];
var m_vertex1 = (jsonToVec("vertex1", edgeValue));
var m_vertex2 = (jsonToVec("vertex2", edgeValue));
fixture = FixtureFactory.AttachEdge(m_vertex1, m_vertex2, body);
((EdgeShape)fixture.Shape).HasVertex0 = edgeValue["hasVertex0"] == null ? false : (bool)edgeValue["hasVertex0"];
((EdgeShape)fixture.Shape).HasVertex3 = edgeValue["hasVertex3"] == null ? false : (bool)edgeValue["hasVertex3"];
if (((EdgeShape)fixture.Shape).HasVertex0)
((EdgeShape)fixture.Shape).Vertex0 = (jsonToVec("vertex0", edgeValue));
if (((EdgeShape)fixture.Shape).HasVertex3)
((EdgeShape)fixture.Shape).Vertex3 = (jsonToVec("vertex3", edgeValue));
}
else if (null != fixtureValue["loop"])
{// support old
// format (r197)
JObject chainValue = (JObject)fixtureValue["loop"];
int numVertices = ((JArray)chainValue["x"]).Count;
Vertices vertices = new Vertices();
for (int i = 0; i < numVertices; i++)
vertices.Add(jsonToVec("vertices", chainValue, i));
fixture = FixtureFactory.AttachChainShape(vertices, body);
}
else if (null != fixtureValue["chain"])
{
JObject chainValue = (JObject)fixtureValue["chain"];
ChainShape chainShape = new ChainShape();
int numVertices = ((JArray)chainValue["vertices"]["x"]).Count;
Vertices vertices = new Vertices();
for (int i = 0; i < numVertices; i++)
vertices.Add(jsonToVec("vertices", chainValue, i));
// FPE. See http://www.box2d.org/forum/viewtopic.php?f=4&t=7973&p=35363
if (vertices[0] == vertices[vertices.Count - 1])
{
var vertices2 = new Vertices(numVertices - 1);
vertices2.AddRange(vertices.GetRange(0, numVertices - 1));
chainShape.CreateLoop(vertices2);
fixture = body.CreateFixture(chainShape);
}
else
fixture = FixtureFactory.AttachChainShape(vertices, body);
var fixtureChain = fixture.Shape as ChainShape;
var hasPrevVertex = chainValue["hasPrevVertex"] == null ? false : (bool)chainValue["hasPrevVertex"];
var hasNextVertex = chainValue["hasNextVertex"] == null ? false : (bool)chainValue["hasNextVertex"];
if (hasPrevVertex)
fixtureChain.PrevVertex = (jsonToVec("prevVertex", chainValue));
if (hasNextVertex)
fixtureChain.NextVertex = (jsonToVec("nextVertex", chainValue));
}
else if (null != fixtureValue["polygon"])
{
JObject polygonValue = (JObject)fixtureValue["polygon"];
Vertices vertices = new Vertices();
int numVertices = ((JArray)polygonValue["vertices"]["x"]).Count;
if (numVertices > Settings.MaxPolygonVertices)
{
Console.WriteLine("Ignoring polygon fixture with too many vertices.");
}
else if (numVertices < 2)
//.........这里部分代码省略.........