public void DrawCube(Matrix world, bool isSelected, float multiplier = 0.5f) { renderData.worldViewProjection = Matrix.Scaling(multiplier) * world * viewProjection; renderData.Color = isSelected ? selectedColor : normalColor; device.SetCullModeNone(); device.ApplyRasterState(); device.SetBlendStateAlphaBlend(); device.UpdateAllStates(); device.UpdateData(basicBuffer, renderData); device.DeviceContext.VertexShader.SetConstantBuffer(0, basicBuffer); basicShader.Apply(); Cube.Draw(device); }
public void RunMainLoop(Panel Panel) { RenderLoop.Run(Panel, () => { //Resizing if (device.MustResize) { device.Resize(); Camera.AspectRatio = (float)Panel.Width / Panel.Height; } Program.MainForm.KeyboardController(); sharpFPS.Update(); device.Clear(backgroundColor); if (ArchiveEditorFunctions.allowRender) { if (isDrawingUI) { viewProjection = Matrix.OrthoOffCenterRH(0, 640, -480, 0, -Camera.FarPlane, Camera.FarPlane); device.SetFillModeDefault(); device.SetCullModeDefault(); device.ApplyRasterState(); device.SetBlendStateAlphaBlend(); device.SetDefaultDepthState(); device.UpdateAllStates(); List <AssetUI> renderCommon = new List <AssetUI>(ArchiveEditorFunctions.renderableAssetSetCommon.Count); foreach (IRenderableAsset a in ArchiveEditorFunctions.renderableAssetSetCommon) { if (a is AssetUI ui) { renderCommon.Add(ui); } else if (a is AssetUIFT uift) { renderCommon.Add(uift); } } renderCommon = renderCommon.OrderBy(f => - f.PositionZ).ToList(); foreach (IRenderableAsset a in renderCommon) { a.Draw(this); } } else { if (playingFly) { flyToPlay.Play(); } Program.MainForm.SetToolStripStatusLabel(Camera.ToString() + " FPS: " + $"{sharpFPS.FPS:0.0000}"); Matrix view = Camera.ViewMatrix; viewProjection = view * Camera.ProjectionMatrix; frustum = new BoundingFrustum(view * Camera.BiggerFovProjectionMatrix); device.SetFillModeDefault(); device.SetCullModeDefault(); device.ApplyRasterState(); device.SetBlendStateAlphaBlend(); device.SetDefaultDepthState(); device.UpdateAllStates(); List <IRenderableAsset> renderJSP = new List <IRenderableAsset>(ArchiveEditorFunctions.renderableAssetSetJSP.Count); List <IRenderableAsset> renderCommon = new List <IRenderableAsset>(ArchiveEditorFunctions.renderableAssetSetCommon.Count); List <IRenderableAsset> renderTrans = new List <IRenderableAsset>(ArchiveEditorFunctions.renderableAssetSetTrans.Count); List <IRenderableAsset> renderLarge = new List <IRenderableAsset>(); renderJSP.AddRange(ArchiveEditorFunctions.renderableAssetSetJSP); renderCommon.AddRange(ArchiveEditorFunctions.renderableAssetSetCommon); renderTrans.AddRange(ArchiveEditorFunctions.renderableAssetSetTrans); renderCommon = renderCommon.OrderBy(f => f.GetDistance(Camera.Position)).Reverse().ToList(); renderTrans = renderTrans.OrderBy(f => f.GetDistance(Camera.Position)).Reverse().ToList(); foreach (IRenderableAsset a in renderJSP) { a.Draw(this); } foreach (IRenderableAsset a in renderCommon) { BoundingBox bb = a.GetBoundingBox(); if (bb.Width > 100) { renderLarge.Add(a); } else if (a is AssetPKUP assetPKUP && AssetPICK.pickEntries.Count == 0) { renderTrans.Add(a); }