本文整理汇总了C#中Light.Intersects方法的典型用法代码示例。如果您正苦于以下问题:C# Light.Intersects方法的具体用法?C# Light.Intersects怎么用?C# Light.Intersects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Light
的用法示例。
在下文中一共展示了Light.Intersects方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryBuildVaoForLight
private Tuple<DynamicVao, DynamicVao> TryBuildVaoForLight(Light light)
{
_hullVertices.Clear();
_shadowVertices.Clear();
_shadowIndices.Clear();
_hullIndices.Clear();
int numSegments = 0;
int shadowIndexOffset = 0;
int hullIndexOffset = 0;
int hullCount = _engine.Hulls.Count;
for (int i = 0; i < hullCount; i++)
{
Hull hull = _engine.Hulls[i];
if (!hull.Enabled || !hull.Valid || !light.Intersects(hull))
continue;
Polygon points = hull.WorldPoints;
Vector2 prevPoint = points[points.Count - 1];
int pointCount = points.Count;
numSegments += pointCount;
for (int j = 0; j < pointCount; j++)
{
Vector2 currentPoint = points[j];
_shadowVertices.Add(new VertexShadow(prevPoint, currentPoint, new Vector2(0.0f, 0.0f)));
_shadowVertices.Add(new VertexShadow(prevPoint, currentPoint, new Vector2(1.0f, 0.0f)));
_shadowVertices.Add(new VertexShadow(prevPoint, currentPoint, new Vector2(0.0f, 1.0f)));
_shadowVertices.Add(new VertexShadow(prevPoint, currentPoint, new Vector2(1.0f, 1.0f)));
_shadowIndices.Add(shadowIndexOffset * 4 + 0);
_shadowIndices.Add(shadowIndexOffset * 4 + 1);
_shadowIndices.Add(shadowIndexOffset * 4 + 2);
_shadowIndices.Add(shadowIndexOffset * 4 + 1);
_shadowIndices.Add(shadowIndexOffset * 4 + 3);
_shadowIndices.Add(shadowIndexOffset * 4 + 2);
prevPoint = currentPoint;
shadowIndexOffset++;
}
_hullVertices.AddRange(hull.WorldPoints);
int indexCount = hull.Indices.Count;
for (int j = 0; j < indexCount; j++)
_hullIndices.Add(hull.Indices[j] + hullIndexOffset);
hullIndexOffset += pointCount;
}
if (numSegments == 0)
return null;
Tuple<DynamicVao, DynamicVao> lightVaos;
if (!_lightsVaos.TryGetValue(light, out lightVaos))
{
lightVaos = Tuple.Create(
DynamicVao.New(_engine.Device, VertexShadow.Layout, _shadowVertices.Count, _shadowIndices.Count, useIndices: true),
DynamicVao.New(_engine.Device, VertexPosition2.Layout, _hullVertices.Count, _hullIndices.Count, useIndices: true));
_lightsVaos.Add(light, lightVaos);
}
lightVaos.Item1.SetVertices(_shadowVertices);
lightVaos.Item1.SetIndices(_shadowIndices);
lightVaos.Item2.SetVertices(_hullVertices);
lightVaos.Item2.SetIndices(_hullIndices);
return lightVaos;
}