internal void DrawLevel() { if (!loaded) { return; } cam.FOV = (float)(Math.PI / 4); cam.Aspect = panel1.Width / (float)panel1.Height; cam.DrawDistance = 10000; Matrix projection = Matrix.PerspectiveFovRH(cam.FOV, cam.Aspect, 1, cam.DrawDistance); Matrix view = cam.ToMatrix(); d3ddevice.SetTransform(TransformState.Projection, projection); d3ddevice.SetTransform(TransformState.View, view); Text = "X=" + cam.Position.X + " Y=" + cam.Position.Y + " Z=" + cam.Position.Z + " Pitch=" + cam.Pitch.ToString("X") + " Yaw=" + cam.Yaw.ToString("X") + " Interval=" + interval + (cam.mode == 1 ? " Distance=" + cam.Distance : ""); d3ddevice.SetRenderState(RenderState.FillMode, (int)EditorOptions.RenderFillMode); d3ddevice.SetRenderState(RenderState.CullMode, (int)EditorOptions.RenderCullMode); d3ddevice.Material = new Material { Ambient = Color.White.ToRawColor4() }; d3ddevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black.ToRawColorBGRA(), 1, 0); d3ddevice.SetRenderState(RenderState.ZEnable, true); d3ddevice.BeginScene(); //all drawings after this line cam.DrawDistance = EditorOptions.RenderDrawDistance; cam.BuildFrustum(view, projection); EditorOptions.RenderStateCommonSetup(d3ddevice); MatrixStack transform = new MatrixStack(); List <RenderInfo> renderlist = new List <RenderInfo>(); if (LevelData.LevelItems != null) { for (int i = 0; i < LevelData.LevelItemCount; i++) { bool display = false; if (visibleToolStripMenuItem.Checked && LevelData.GetLevelitemAtIndex(i).Visible) { display = true; } else if (invisibleToolStripMenuItem.Checked && !LevelData.GetLevelitemAtIndex(i).Visible) { display = true; } else if (allToolStripMenuItem.Checked) { display = true; } if (display) { renderlist.AddRange(LevelData.GetLevelitemAtIndex(i).Render(d3ddevice, cam, transform)); } } } RenderInfo.Draw(renderlist, d3ddevice, cam); d3ddevice.EndScene(); // scene drawings go before this line transformGizmo.Draw(d3ddevice, cam); d3ddevice.Present(); }