本文整理汇总了C#中Sphere.IsIntersectsSphere方法的典型用法代码示例。如果您正苦于以下问题:C# Sphere.IsIntersectsSphere方法的具体用法?C# Sphere.IsIntersectsSphere怎么用?C# Sphere.IsIntersectsSphere使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sphere
的用法示例。
在下文中一共展示了Sphere.IsIntersectsSphere方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnSceneManagementGetLightsForCamera
//.........这里部分代码省略.........
//add directional lights
foreach( RenderLight light in SceneManager.Instance.RenderLights )
{
if( light.Type == RenderLightType.Directional && light.Visible )
list.Add( light );
}
uint groupMask = 0;
groupMask |= 1 << (int)SceneManager.SceneGraphGroups.Light;
int[] sceneGraphIndexes = SceneManager.Instance.SceneGraph.GetObjects( frustum, groupMask );
foreach( int sceneGraphIndex in sceneGraphIndexes )
{
SceneManager.SceneGraphObjectData data = SceneManager.Instance.SceneGraphObjects[ sceneGraphIndex ];
//Light
RenderLight light = data.Light;
if( light != null && light.Visible )
{
//clip volumes
if( !IsTotalClipVolumesContainsBounds( light.GetWorldBounds() ) )
list.Add( light );
}
}
}
//add objects never culled by the frustum
if( SceneManager.Instance.OverrideVisibleObjects == null && Map.Instance != null )
Map.Instance.Walk_AddObjectsWithDisabled_AllowSceneManagementCulling_Property( false, null, null, list );
}
foreach( RenderLight light in lightsToCheck )
{
if( !light.Visible )
continue;
bool allowCastShadows = light.CastShadows;
if( light.Type == RenderLightType.Point || light.Type == RenderLightType.Spot )
{
if( light.AttenuationFar <= .01f )
continue;
Sphere lightSphere = new Sphere( light.Position, light.AttenuationFar );
//fast culling. not cull everything.
if( !frustum.IsIntersectsFast( lightSphere ) )
continue;
//generate convex polyhedron for light volume
//and check intersection with camera frustum.
ConvexPolyhedron lightPolyhedron = light.GetInclusiveVolumeForCulling();
//draw light bounds
//RendererWorld.Instance.DefaultCamera.DebugGeometry.Color = new ColorValue( 1, 0, 1, .5f );
//RendererWorld.Instance.DefaultCamera.DebugGeometry.AddBounds( light.GetWorldBounds() );
//visualize light volumes
//{
// int[] i = new int[ lightPolyhedron.Faces.Length * 3 ];
// for( int n = 0; n < lightPolyhedron.Faces.Length; n++ )
// {
// i[ n * 3 + 0 ] = lightPolyhedron.Faces[ n ].Vertex0;
// i[ n * 3 + 1 ] = lightPolyhedron.Faces[ n ].Vertex1;
// i[ n * 3 + 2 ] = lightPolyhedron.Faces[ n ].Vertex2;
// }
// RendererWorld.Instance.DefaultCamera.DebugGeometry.Color = new ColorValue( 1, 1, 0, .3f );
// RendererWorld.Instance.DefaultCamera.DebugGeometry.AddVertexIndexBuffer(
// lightPolyhedron.Vertices, i, Mat4.Identity, false, true );
//}
if( !ConvexPolyhedron.IsIntersects( frustumPolyhedron, lightPolyhedron ) )
continue;
//allowCastShadows
if( allowCastShadows )
{
Sphere frustumShadowSphere = new Sphere( camera.DerivedPosition,
SceneManager.Instance.ShadowFarDistance );
if( frustumShadowSphere.IsIntersectsSphere( lightSphere ) )
{
if( light.Type == RenderLightType.Spot )
{
Cone cone = new Cone( light.Position, light.Direction,
light.SpotlightOuterAngle / 2 );
if( !cone.IsIntersectsSphere( frustumShadowSphere ) )
allowCastShadows = false;
}
}
else
allowCastShadows = false;
}
}
outLights.Add( new RenderingLowLevelMethods.LightItem( light, allowCastShadows ) );
}
}
示例2: OnSceneManagementGetLightsForCamera
public override void OnSceneManagementGetLightsForCamera( Camera camera,
List<RenderingLowLevelMethods.LightItem> outLights )
{
Frustum frustum = FrustumUtils.GetFrustumByCamera( camera );
if( EngineDebugSettings.FrustumTest && camera.AllowFrustumTestMode )
{
frustum.HalfWidth *= .5f;
frustum.HalfHeight *= .5f;
}
ConvexPolyhedron frustumPolyhedron = GetConvexPolyhedronFromFrustum( ref frustum );
ICollection<RenderLight> list;
if( SceneManager.Instance.OverrideVisibleObjects != null )
list = SceneManager.Instance.OverrideVisibleObjects.Lights;
else
list = SceneManager.Instance.RenderLights;
foreach( RenderLight light in list )
{
if( !light.Visible )
continue;
bool allowCastShadows = true;
if( light.Type == RenderLightType.Point || light.Type == RenderLightType.Spot )
{
if( light.AttenuationFar <= .01f )
continue;
Sphere lightSphere = new Sphere( light.Position, light.AttenuationFar );
//fast culling. not cull everything.
if( !frustum.IsIntersectsFast( lightSphere ) )
continue;
//generate convex polyhedron for light volume
//and check intersection with camera frustum.
ConvexPolyhedron lightPolyhedron = null;
if( light.Type == RenderLightType.Point )
lightPolyhedron = MakeConvexPolyhedronForPointLight( light );
else if( light.Type == RenderLightType.Spot )
lightPolyhedron = MakeConvexPolyhedronForSpotLight( light );
if( !ConvexPolyhedron.IsIntersects( frustumPolyhedron, lightPolyhedron ) )
continue;
//allowCastShadows
if( light.CastShadows )
{
Sphere frustumShadowSphere = new Sphere( camera.DerivedPosition,
SceneManager.Instance.ShadowFarDistance );
if( frustumShadowSphere.IsIntersectsSphere( lightSphere ) )
{
if( light.Type == RenderLightType.Spot )
{
Cone cone = new Cone( light.Position, light.Direction,
light.SpotlightOuterAngle / 2 );
if( !cone.IsIntersectsSphere( frustumShadowSphere ) )
allowCastShadows = false;
}
}
else
allowCastShadows = false;
}
}
outLights.Add( new RenderingLowLevelMethods.LightItem( light, allowCastShadows ) );
}
}