public static void DebugDraw() { MyLights.UpdateSortedLights(ref MyCamera.BoundingSphere, false); foreach (MyLight light in m_sortedLights) { //if (light.LightOn && light.Glare.Type == TransparentGeometry.MyLightGlare.GlareTypeEnum.Distant) { if ((light.LightType & MyLight.LightTypeEnum.PointLight) != 0) { MyDebugDraw.DrawSphereWireframe(Matrix.CreateScale(light.Range) * Matrix.CreateTranslation(light.PositionWithOffset), new Vector3(1, 0, 0), 1); } if ((light.LightType & MyLight.LightTypeEnum.Hemisphere) != 0) { Matrix rotationHotfix = Matrix.CreateFromAxisAngle(Vector3.UnitX, MathHelper.PiOver2); Matrix world = Matrix.CreateScale(light.Range) * rotationHotfix * Matrix.CreateWorld(light.Position, light.ReflectorDirection, light.ReflectorUp); MyDebugDraw.DrawHemisphereWireframe(world, new Vector3(1, 0, 0), 1); } if ((light.LightType & MyLight.LightTypeEnum.Spotlight) != 0 /* && light.ReflectorOn*/) { Vector4 color = Color.Aqua.ToVector4(); // MyDebugDraw.DrawAABB(ref bb, ref color, 1.0f); MyDebugDraw.DrawAxis(Matrix.CreateWorld(light.Position, Vector3.Up, Vector3.Forward), 2, 1); MyDebugDraw.DrawSphereWireframe(Matrix.CreateScale(light.Range) * Matrix.CreateTranslation(light.PositionWithOffset), new Vector3(1, 0, 0), 1); // Uncomment to show sphere for spot light //MyDebugDraw.DrawSphereWireframe(Matrix.CreateScale(light.ReflectorRange) * Matrix.CreateTranslation(light.Position), new Vector3(color.X, color.Y, color.Z), 0.25f); //MySimpleObjectDraw.DrawConeForLight(); MyStateObjects.WireframeRasterizerState.Apply(); SharpDX.Toolkit.Graphics.DepthStencilState.None.Apply(); MyDebugDraw.DrawModel(MySimpleObjectDraw.ModelCone, light.SpotWorld, Vector3.One, 1); } } } }
public void DebugDraw(float elapsedTime, Matrix worldMatrix) { Vector3 currentOffsetUntransformed, currentOffset; Offset.GetInterpolatedValue <Vector3>(elapsedTime, out currentOffsetUntransformed); Vector3.Transform(ref currentOffsetUntransformed, ref worldMatrix, out currentOffset); float currentSize; Size.GetInterpolatedValue <float>(elapsedTime, out currentSize); switch (Type) { case MyParticleEmitterType.Point: { MyDebugDraw.DrawSphereWireframe(currentOffset, 0.1f, new Vector3(1, 1, 0), 1.0f); } break; case MyParticleEmitterType.Line: { if (DirToCamera) { Vector3 dir = MyCamera.Position - currentOffset; dir.Normalize(); Matrix matrix = Matrix.CreateScale(currentSize) * MyMath.MatrixFromDir(dir); Vector3 currentOffsetScaled = Vector3.TransformNormal(Vector3.Forward, matrix); MyDebugDraw.DrawLine3D(worldMatrix.Translation, worldMatrix.Translation + currentOffsetScaled, Color.Yellow, Color.Yellow); } else { Vector3 currentOffsetScaled = Vector3.Transform(Vector3.Up * currentSize, worldMatrix); MyDebugDraw.DrawLine3D(worldMatrix.Translation, currentOffsetScaled, Color.Yellow, Color.Yellow); } } break; case MyParticleEmitterType.Sphere: { MyDebugDraw.DrawSphereWireframe(currentOffset, currentSize, new Vector3(1, 1, 0), 1.0f); } break; case MyParticleEmitterType.Box: { Matrix matrix = Matrix.CreateScale(currentSize) * Matrix.CreateTranslation(currentOffsetUntransformed) * worldMatrix; MyDebugDraw.DrawLowresBoxWireframe(matrix, new Vector3(1, 1, 0), 1.0f); } break; case MyParticleEmitterType.Hemisphere: { Vector3 worldPos = currentOffset; Matrix matrix; if (DirToCamera) { Matrix WorldView = worldMatrix * MyCamera.ViewMatrix; WorldView.Translation += currentOffsetUntransformed; Matrix newWorld = WorldView * Matrix.Invert(MyCamera.ViewMatrix); Vector3 dir = MyCamera.Position - newWorld.Translation; dir.Normalize(); matrix = Matrix.CreateScale(currentSize) * Matrix.CreateRotationX(MathHelper.PiOver2) * MyMath.MatrixFromDir(dir); matrix.Translation = newWorld.Translation; } else { matrix = Matrix.CreateScale(currentSize) * Matrix.CreateTranslation(currentOffsetUntransformed) * worldMatrix; } MyDebugDraw.DrawHemisphereWireframe(matrix, new Vector3(1, 1, 0), 1.0f); } break; case MyParticleEmitterType.Circle: { //No debug draw } break; default: System.Diagnostics.Debug.Assert(false); break; } }