private static void Render() { if (device == null) { return; } try { device.SetRenderState(RenderStates.ShadeMode, 1); device.RenderState.Lighting = false; device.Lights[0].Type = LightType.Directional; device.Lights[0].Diffuse = Color.White; device.Lights[0].Range = 100000; device.Lights[0].Direction = new Vector3(1, 1, -1); device.Lights[0].Enabled = true; device.RenderState.CullMode = Cull.None; device.SetRenderState(RenderStates.ZEnable, true); device.Clear(ClearFlags.Target, System.Drawing.Color.White, 1.0f, 0); device.Clear(ClearFlags.ZBuffer, System.Drawing.Color.Black, 1.0f, 0); device.BeginScene(); int iTime = Environment.TickCount; if (rotate) { fAngle = iTime * (2.0f * (float)Math.PI) / 10000.0f; } device.Transform.World = Matrix.RotationZ(fAngle); device.Transform.View = Matrix.LookAtLH(new Vector3(0.0f, CamDistance, CamDistance / 2) + CamOffset, new Vector3(0, 0, 0) + CamOffset, new Vector3(0.0f, 0.0f, 1.0f)); device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, 1.0f, 1.0f, 100000.0f); device.SetTexture(0, null); device.VertexFormat = CustomVertex.PositionColored.Format; device.RenderState.Lighting = false; if (Cubes != null) { for (int i = 0; i < Cubes.Count(); i++) { device.DrawUserPrimitives(PrimitiveType.LineList, 12, Cubes[i].verts); } } if (StatMesh != null) { StatMesh.DrawMesh(device); } device.SetTexture(0, DefaultTex); if (SkelMesh != null) { SkelMesh.DrawMesh(device, LOD); } device.EndScene(); device.Present(); } catch (DirectXException) { return; } }
private static void Render() { if (device == null) { return; } try { device.SetRenderState(RenderState.ShadeMode, true); device.SetRenderState(RenderState.Lighting, false); Light light = new Light() { Type = LightType.Directional, Diffuse = Color.White, Range = 100000, Direction = new Vector3(1, 1, -1) }; device.SetLight(0, light); device.SetRenderState(RenderState.CullMode, Cull.None); device.SetRenderState(RenderState.ZEnable, true); device.Clear(ClearFlags.Target, System.Drawing.Color.White, 1.0f, 0); device.Clear(ClearFlags.ZBuffer, System.Drawing.Color.Black, 1.0f, 0); device.BeginScene(); int iTime = Environment.TickCount; if (rotate) { fAngle = iTime * (2.0f * (float)Math.PI) / 10000.0f; } device.SetTransform(TransformState.World, Matrix.RotationZ(fAngle)); Matrix view = Matrix.LookAtLH(new Vector3(0.0f, CamDistance, CamDistance / 2) + CamOffset, new Vector3(0, 0, 0) + CamOffset, new Vector3(0.0f, 0.0f, 1.0f)); device.SetTransform(TransformState.View, view); device.SetTransform(TransformState.Projection, Matrix.PerspectiveFovLH((float)Math.PI / 4, 1.0f, 1.0f, 100000.0f)); device.SetTexture(0, null); RenderCoordsystem(device); device.VertexFormat = CustomVertex.PositionColored.Format; device.SetRenderState(RenderState.Lighting, false); device.SetTexture(0, DefaultTex); if (SKM != null) { SKM.DrawMesh(device, LOD); } device.EndScene(); device.Present(); } catch (SlimDXException) { return; } }