Пример #1
0
        public void DrawShadowVolume(VideoDriver driver, bool isDebug = false)
        {
            lock (visibleShadowVerticesBufferLocker)
            {
                if (visibleShadowVerticesBuffer == null ||
                    visibleShadowVerticesBuffer.Count == 0)
                {
                    return;
                }

                driver.SetTransform(TransformationState.World, Matrix.Identity);

                if (isDebug)
                {
                    Material material = new Material();
                    material.Lighting = false;
                    material.Type     = MaterialType.TransparentVertexAlpha;

                    driver.SetMaterial(material);
                    for (int i = 0; i < visibleShadowVerticesBuffer.Count; i += 3)
                    {
                        driver.Draw3DTriangle(
                            visibleShadowVerticesBuffer[i],
                            visibleShadowVerticesBuffer[i + 1],
                            visibleShadowVerticesBuffer[i + 2],
                            new Color(0x80000000));
                    }

                    material.Wireframe       = true;
                    material.BackfaceCulling = false;
                    material.ZBuffer         = ComparisonFunc.Always;
                    driver.SetMaterial(material);
                    for (int i = 0; i < visibleShadowVerticesBuffer.Count; i += 3)
                    {
                        driver.Draw3DTriangle(
                            visibleShadowVerticesBuffer[i],
                            visibleShadowVerticesBuffer[i + 1],
                            visibleShadowVerticesBuffer[i + 2],
                            new Color(0x80ff0000));
                    }
                }
                else
                {
                    driver.DrawStencilShadowVolume(visibleShadowVerticesBuffer);
                    driver.DrawStencilShadow(false, shadowColor);
                }
            }
        }
Пример #2
0
		public void DrawShadowVolume(VideoDriver driver, bool isDebug = false)
		{
			lock (visibleShadowVerticesBufferLocker)
			{
				if (visibleShadowVerticesBuffer == null ||
					visibleShadowVerticesBuffer.Count == 0)
					return;

				driver.SetTransform(TransformationState.World, Matrix.Identity);

				if (isDebug)
				{
					Material material = new Material();
					material.Lighting = false;
					material.Type = MaterialType.TransparentVertexAlpha;

					driver.SetMaterial(material);
					for (int i = 0; i < visibleShadowVerticesBuffer.Count; i += 3)
						driver.Draw3DTriangle(
							visibleShadowVerticesBuffer[i],
							visibleShadowVerticesBuffer[i + 1],
							visibleShadowVerticesBuffer[i + 2],
							new Color(0x80000000));

					material.Wireframe = true;
					material.BackfaceCulling = false;
					material.ZBuffer = ComparisonFunc.Always;
					driver.SetMaterial(material);
					for (int i = 0; i < visibleShadowVerticesBuffer.Count; i += 3)
						driver.Draw3DTriangle(
							visibleShadowVerticesBuffer[i],
							visibleShadowVerticesBuffer[i + 1],
							visibleShadowVerticesBuffer[i + 2],
							new Color(0x80ff0000));
				}
				else
				{
					driver.DrawStencilShadowVolume(visibleShadowVerticesBuffer);
					driver.DrawStencilShadow(false, shadowColor);
				}
			}
		}