/// <summary> /// Clears the screen to a specific color. /// </summary> /// <param name="red">Red component of the color (0-255).</param> /// <param name="green">Green component of the color (0-255).</param> /// <param name="blue">Blue component of the color (0-255).</param> /// <returns>true if successful, false otherwise.</returns> public bool Clear(Int32 red, Int32 green, Int32 blue) { if (device == null) { return(false); } //Clear the backbuffer to a color device.Clear(ClearFlags.Target, System.Drawing.Color.FromArgb(red, green, blue), 1.0f, 0); // Check for alt+tab try { device.TestCooperativeLevel(); } catch (DeviceLostException) { } catch (DeviceNotResetException) { Reset(); } return(true); }
public void DisplayLevel(int level) { int characterStart = 30; int characterSpacing = 15; Vector3 displayPosition = new Vector3((float)this.Width / 2 - characterStart, (float)this.Height / 2, 0f); int digit; NixieSprite nixie = new NixieSprite(nixiesTileSet); //Render the level indicator device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); device.BeginScene(); using (D3D.Sprite d3dSprite = new D3D.Sprite(device)) { d3dSprite.Begin(D3D.SpriteFlags.AlphaBlend); //Show the letter L nixie.Draw(d3dSprite, NixieSprite.NixieCharacters.L, displayPosition); //Show the letter E displayPosition.X -= characterSpacing; nixie.Draw(d3dSprite, NixieSprite.NixieCharacters.E, displayPosition); //Show the letter V displayPosition.X -= characterSpacing; nixie.Draw(d3dSprite, NixieSprite.NixieCharacters.V, displayPosition); //Show the letter E displayPosition.X -= characterSpacing; nixie.Draw(d3dSprite, NixieSprite.NixieCharacters.E, displayPosition); //Show the letter L displayPosition.X -= characterSpacing; nixie.Draw(d3dSprite, NixieSprite.NixieCharacters.L, displayPosition); displayPosition.X = (float)this.Width / 2 + 40; for (int digitCount = 1; digitCount <= maxLevelDigits; digitCount++) { digit = level % 10; level /= 10; nixie.Draw(d3dSprite, (NixieSprite.NixieCharacters)digit, displayPosition); displayPosition.X -= characterSpacing; } d3dSprite.End(); } device.EndScene(); device.Present(); Thread.Sleep(3000); //wait for 3 seconds }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { ReadMouse(); ReadKeyboard(); d3ddevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, System.Drawing.Color.Cyan, 1.0f, 0); //theta += Geometry.DegreeToRadian(1); d3ddevice.BeginScene(); d3ddevice.Transform.World = Matrix.Translation(-spacing - .5f, -spacing - .5f, -spacing - .5f); for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { for (int z = 0; z < 3; z++) { rubixCube.GetBlock(x, y, z).draw(x * spacing, y * spacing, z * spacing); } } } d3ddevice.EndScene(); PositionCamera(); d3ddevice.Present(); this.Invalidate(); }
public void RenderOnScreen(Microsoft.DirectX.Direct3D.Device d3dDevice, float elapsedTime) { d3dDevice.BeginScene(); //Cargamos para renderizar el unico modelo que tenemos, un Quad que ocupa toda la pantalla, con la textura de todo lo dibujado antes d3dDevice.VertexFormat = CustomVertex.PositionTextured.Format; d3dDevice.SetStreamSource(0, screenQuadVB, 0); //Ver si el efecto de alarma esta activado, configurar Technique del shader segun corresponda //Cargamos parametros en el shader de Post-Procesado this.postProcessMerge.SetValue("escenaTextura", this.escena); if (cant_pasadas == 0) { this.postProcessMerge.SetValue("propulsoresTextura", this.propulsores); } else { this.postProcessMerge.SetValue("propulsoresTextura", this.propulsoresBlurAux2); } this.postProcessMerge.Technique = "TechniqueMerge"; //Limiamos la pantalla y ejecutamos el render del shader d3dDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); this.postProcessMerge.Begin(FX.None); this.postProcessMerge.BeginPass(0); d3dDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2); this.postProcessMerge.EndPass(); this.postProcessMerge.End(); //DrawText.drawText("Desfase: " + TGCVector3.PrintVector3(desfase), 0, 500, Color.White); //Terminamos el renderizado de la escena RenderFPS(); RenderAxis(); d3dDevice.EndScene(); d3dDevice.Present(); }
/// <summary> /// 用单一颜色覆盖整个viewport /// </summary> /// <param name="color">指定的颜色</param> public static void ClearDevice(Color color) { Device.BeginScene(); Device.Clear(ClearFlags.Target, color, 1f, 0); Device.EndScene(); Device.Present(); }
public static void Render() { if (!dGDevice.Disposed) { dGDevice.Clear(ClearFlags.Target, System.Drawing.Color.Black, 1.0f, 0); dGDevice.BeginScene(); m_ZOrderedSprites.Sort(Sprite.ComparisonZOrder); foreach (Sprite s in m_ZOrderedSprites) { s.Render(); } foreach (Text2D t in m_Text2Ds) { t.Render(); } dGDevice.EndScene(); dGDevice.Present(); } else { Quit(); } }
public override void render(float elapsedTime) { #region CAMBIO DE RENDER TARGET Postproceso.CambiarRenderState(); Microsoft.DirectX.Direct3D.Device d3dDevice = GuiController.Instance.D3dDevice; d3dDevice.Clear(ClearFlags.ZBuffer | ClearFlags.Target, Color.Black, 1.0f, 0); // pongo los rendering states d3dDevice.RenderState.ZBufferEnable = true; d3dDevice.RenderState.ZBufferWriteEnable = true; d3dDevice.RenderState.ZBufferFunction = Compare.LessEqual; d3dDevice.RenderState.AlphaBlendEnable = true; #endregion InputManager.ManejarInput(); InteractionManager.UpdateElementos(); InteractionManager.RenderElementos(); setUsersVars(); renderizar(); GuiController.Instance.FpsCounterEnable = true; Postproceso.RenderPostProcesado(); // Volver a dibujar FPS GuiController.Instance.Text3d.drawText("FPS: " + HighResolutionTimer.Instance.FramesPerSecond, 0, 0, Color.Yellow); GuiController.Instance.AxisLines.render(); coordenadasMouse(); }
/// <summary> /// 使用指定颜色清理viewport,然后绘制在Render中准备好的内容 /// </summary> public static void Present(Color color) { Device.BeginScene(); Device.Clear(ClearFlags.Target, color, 1f, 0); Render.Invoke(); Device.EndScene(); Device.Present(); }
private void MainForm_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { try { if (dxEnable) { device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); device.BeginScene(); obj.Draw(device, worldMatrix); device.Transform.World = worldMatrix; LineTo(ref device, new Vector3(0, 0, -1), new Vector3(0, 0, 1), Color.Blue); LineTo(ref device, new Vector3(1, 0, -1), new Vector3(1, 0, 1), Color.Blue); LineTo(ref device, new Vector3(-1, 0, -1), new Vector3(-1, 0, 1), Color.Blue); LineTo(ref device, new Vector3(0.5f, 0, -1), new Vector3(0.5f, 0, 1), Color.Blue); LineTo(ref device, new Vector3(-0.5f, 0, -1), new Vector3(-0.5f, 0, 1), Color.Blue); LineTo(ref device, new Vector3(0, -1, 0), new Vector3(0, 1, 0), Color.Red); LineTo(ref device, new Vector3(-1, 0, 0), new Vector3(1, 0, 0), Color.Blue); LineTo(ref device, new Vector3(-1, 0, 1), new Vector3(1, 0, 1), Color.Blue); LineTo(ref device, new Vector3(-1, 0, 0.5f), new Vector3(1, 0, 0.5f), Color.Blue); LineTo(ref device, new Vector3(-1, 0, -1), new Vector3(1, 0, -1), Color.Blue); LineTo(ref device, new Vector3(-1, 0, -0.5f), new Vector3(1, 0, -0.5f), Color.Blue); device.EndScene(); device.Present(); this.Invalidate(); if (bDrawObj) { obj.Step(); toolform.label6.Text = "" + obj.PotentialEnergy; toolform.label14.Text = "" + (obj.PotentialEnergy + obj.KineticEnergyW); toolform.label13.Text = "" + obj.KineticEnergyW; } ReadKeyboard(); UpdateInputState(); } if (bResized) { bResized = false; dxEnable = false; InitializeDevice(); InitializeLights(); InitializeCamera(); InitializeObjects(); dxEnable = true; } } catch (Exception er) { MessageBox.Show(er.Message); } }
public void Render() { device.Clear(ClearFlags.Target, Color.DarkSlateGray, 1, 0); device.BeginScene(); device.VertexFormat = CustomVertex.PositionNormalColored.Format; device.DrawUserPrimitives(PrimitiveType.TriangleList, vertex.Length / 3, vertex); device.EndScene(); device.Present(); }
private void Form1_Paint(object sender, PaintEventArgs e) { device.Clear(ClearFlags.Target, Color.Chartreuse, 1, 0); device.BeginScene(); device.SetTexture(0, texture); device.VertexFormat = CustomVertex.PositionTextured.Format; device.DrawUserPrimitives(PrimitiveType.TriangleList, vertex.Length / 3, vertex); device.EndScene(); device.Present(); }
/// <summary> /// 绘制在Render中准备好的内容 /// </summary> /// <param name="auto_clear">绘制之前是否用黑色清理整个viewport</param> public static void Present(bool auto_clear) { Device.BeginScene(); if (auto_clear) { Device.Clear(ClearFlags.Target, Color.Black, 1f, 0); } Render.Invoke(); Device.EndScene(); Device.Present(); }
public void PreRender(bool invisibilidadActivada) { Invisibilidad.Technique = "DefaultTechnique"; pOldRT = D3DDevice.GetRenderTarget(0); pSurf = g_pRenderTarget.GetSurfaceLevel(0); if (invisibilidadActivada) { D3DDevice.SetRenderTarget(0, pSurf); } pOldDS = D3DDevice.DepthStencilSurface; if (invisibilidadActivada) { D3DDevice.DepthStencilSurface = g_pDepthStencil; } D3DDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); pSurf.Dispose(); }
private void Form1_MouseClick_1(object sender, MouseEventArgs e) { device.Clear(ClearFlags.Target, Color.CornflowerBlue, 0, 1); device.BeginScene(); using (Sprite s = new Sprite(device)) { s.Begin(SpriteFlags.AlphaBlend); s.Draw2D(texture_blood, new Rectangle(0, 0, 200, 200), new Rectangle(0, 0, 0, 0), new Point(0, 0), 0f, new Point(e.X - 100, e.Y - 100), Color.White); s.End(); } device.EndScene(); device.Present(); int toDel = -1; for (int i = 0; i < ch.Count; i++) { Characters cat = ch[i]; if ((e.X >= cat.CharacterCoordinates.X && e.X <= cat.CharacterCoordinates.X + 150) && (e.Y >= cat.CharacterCoordinates.Y && e.Y <= cat.CharacterCoordinates.Y + 150)) { using (soundPlayer4 = new SoundPlayer(@"C:\Users\андрей\Documents\Visual Studio 2015\Projects\NewGame\NewGame\bin\Debug\Gun.wav")) { soundPlayer4.Play(); } toDel = i; newHit(); newScore(50); break; } if (hits % 5 == 0) { // newLevel(1); } } if (toDel != -1) { ch.Remove(ch[toDel]); } }
public virtual void Render() { renderDevice.Clear(ClearFlags.Target, Color.Black, 1.0F, 0); renderDevice.BeginScene(); foreach (GameEntity entity in entities) { entity.Render(); } renderDevice.EndScene(); renderDevice.Present(renderSurface); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { device.Clear(ClearFlags.Target, Color.Navy, 1.0f, 0); device.BeginScene(); device.VertexFormat = CustomVertex.PositionColored.Format; device.Transform.World = Matrix.Translation(MyMaticeX, MyMaticeY, MyMaticeZ); device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, vertices); device.EndScene(); device.Present(); this.Invalidate(); ReadKeyboard(); }
} //take any texture image as bg. private void Render() { device.Clear(ClearFlags.Target, Color.CornflowerBlue, 0, 1); device.BeginScene(); using (Sprite s = new Sprite(device)) { s.Begin(SpriteFlags.AlphaBlend); s.Draw2D(texture, new Rectangle(0, 0, 0, 0), new Rectangle(0, 0, device.Viewport.Width, device.Viewport.Height), new Point(0, 0), 0f, new Point(0, 0), Color.DarkSlateGray); font.DrawText(s, "TYCS-6070", new Point(0, 0), Color.White); s.End(); } device.EndScene(); device.Present(); }
/// <summary> /// 绘制屏幕 /// </summary> public void Render() { if (d3dDevice == null) { return; } d3dDevice.Clear(ClearFlags.Target, Color.YellowGreen, 1f, 0); //当前场景绘制 if (currentScene != null) { currentScene.Draw(); } d3dDevice.Present(); }
public void Render() { if (DXDevice == null) { return; } DXDevice.Clear(Direct3D.ClearFlags.Target, Color.Gray, 1, 0); DXDevice.BeginScene(); DXDevice.VertexFormat = Direct3D.CustomVertex.PositionColored.Format; DXDevice.SetStreamSource(0, vb, 0); DXDevice.Indices = ib; DXDevice.Transform.World = Matrix.RotationY(angle); DXDevice.DrawIndexedPrimitives(Direct3D.PrimitiveType.TriangleList, 0, 0, vertices.Length, 0, indexes.Length / 3); DXDevice.EndScene(); DXDevice.Present(); angle += 0.02f; }
private void Render() { CustomVertex.TransformedColored[] vertexes = new CustomVertex.TransformedColored[3]; vertexes[0].Position = new Vector4(240, 110, 0, 1.0f); //first point vertexes[0].Color = System.Drawing.Color.FromArgb(0, 255, 0).ToArgb(); vertexes[1].Position = new Vector4(380, 420, 0, 1.0f); //second point vertexes[1].Color = System.Drawing.Color.FromArgb(0, 0, 255).ToArgb(); vertexes[2].Position = new Vector4(110, 420, 0, 1.0f); //third point vertexes[2].Color = System.Drawing.Color.FromArgb(255, 0, 0).ToArgb(); device.Clear(ClearFlags.Target, Color.CornflowerBlue, 1.0f, 0); device.BeginScene(); device.VertexFormat = CustomVertex.TransformedColored.Format; device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, vertexes); device.EndScene(); device.Present(); }
public bool Render() { if (p_D3DDevice == null) { return(false); } p_D3DDevice.Clear(ClearFlags.Target, System.Drawing.Color.Black, 1.0f, 0); p_D3DDevice.BeginScene(); DrawScene(); p_D3DDevice.EndScene(); p_D3DDevice.Present(); return(true); }
public void Render() { try { Microsoft.DirectX.Direct3D.Device device = GameAppFramework.GetGameAppFramework().Device; device.Clear(ClearFlags.Target, Color.HotPink, 0, 1); device.BeginScene(); using (Sprite MenuSprite = new Sprite(device)) { MenuSprite.Begin(SpriteFlags.AlphaBlend); MenuSprite.Draw2D(background, new Rectangle(0, 0, 0, 0), new Rectangle(0, 0, device.Viewport.Width, device.Viewport.Height), new Point(0, 0), 0f, new Point(0, 0), Color.White); font.DrawText(MenuSprite, "Press Space to START", new Point((device.Viewport.Width / 2) - 200, device.Viewport.Height / 2), Color.White); font.DrawText(MenuSprite, "Press Escape to END", new Point((device.Viewport.Width / 2) - 200, (device.Viewport.Height / 2) + 100), Color.White); MenuSprite.End(); } device.EndScene(); device.Present(); } catch (Exception e) { }; }
public void OnFrameRender(Microsoft.DirectX.Direct3D.Device device, double totalTime, float elapsedTime) { currentTime = totalTime; bool beginSceneCalled = false; if (scenery != null) { scenery.RenderTextures(device, totalTime, elapsedTime); } // Clear the render target and the zbuffer device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, 0x00424B79, 1.0f, 0); try { device.BeginScene(); beginSceneCalled = true; // Get the world matrix //Matrix worldMatrix = worldCenter * camera.WorldMatrix; Framework.Instance.Device.RenderState.Ambient = System.Drawing.Color.FromArgb(148, 148, 148); scenery.OnFrameRender(device, totalTime, elapsedTime); birds.OnFrameRender(device, totalTime, elapsedTime); if (airplaneMesh != null) { airplaneMesh.OnFrameRender(device, totalTime, elapsedTime); } transparentObjectManager.OnFrameRender(device, totalTime, elapsedTime); cursor3d.OnFrameRender(device, totalTime, elapsedTime); selectedObject.OnFrameRender(device, totalTime, elapsedTime); // Show UI hud.OnRender(elapsedTime); } finally { if (beginSceneCalled) { device.EndScene(); } } }
private void Render() { // check new settings LoadSettings(); // print stats PrintStats(); // check for camera movement HandleInput(); // keep up the frame time Toolbox.FrameTime.NextFrame(); // rotate the landscape angle += rotateSpeed * Toolbox.FrameTime.Time; // clear device device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); // render scene device.BeginScene(); device.Transform.World = Matrix.Translation(-SIZE / 2, 0, -SIZE / 2) * Matrix.RotationY(angle); int numSubSets = mesh.GetAttributeTable().Length; for (int i = 0; i < numSubSets; ++i) { mesh.DrawSubset(0); } device.EndScene(); // show scene device.Present(); this.Invalidate(); }
/// <summary> /// Se toma todo lo dibujado antes, que se guardo en una textura, y se le aplica un shader para distorsionar la imagen /// </summary> private void drawPostProcess(Microsoft.DirectX.Direct3D.Device d3dDevice) { //Arrancamos la escena d3dDevice.BeginScene(); //Cargamos para renderizar el unico modelo que tenemos, un Quad que ocupa toda la pantalla, con la textura de todo lo dibujado antes d3dDevice.VertexFormat = CustomVertex.PositionTextured.Format; d3dDevice.SetStreamSource(0, screenQuadVB, 0); //Ver si el efecto de oscurecer esta activado, configurar Technique del shader segun corresponda effect.Technique = "RainTechnique"; if (!presentacion && lloviendo) { effect.Technique = "RainTechnique"; } else { effect.Technique = "DefaultTechnique"; } //Cargamos parametros en el shader de Post-Procesado effect.SetValue("render_target2D", renderTarget2D); effect.SetValue("textura_alarma", lluviaTexture.D3dTexture); effect.SetValue("time", this.ElapsedTime); //Limiamos la pantalla y ejecutamos el render del shader d3dDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); effect.Begin(FX.None); effect.BeginPass(0); d3dDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2); effect.EndPass(); effect.End(); //Terminamos el renderizado de la escena d3dDevice.EndScene(); d3dDevice.Present(); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { deltaTime = hrt.ElapsedTime; ProcessInputState(); UpdateSprite(deltaTime); device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Blue, 1.0f, 0); device.BeginScene(); using (Sprite sprite = new Sprite(device)) { sprite.Begin(SpriteFlags.None); //Set rotation center for sprite spriteCenter.X = spritePosition.X + tileSet.ExtentX; spriteCenter.Y = spritePosition.Y + tileSet.ExtentY; //Spin, Shift, Stretch :-) sprite.Transform = Matrix.RotationZ(angle) * Matrix.Translation(spriteCenter); sprite.Draw(tileSet.Texture, tilePosition, spriteCenter, spritePosition, Color.FromArgb(255, 255, 255, 255)); sprite.End(); } device.EndScene(); device.Present(); this.Invalidate(); }
private void Render() { device.Clear(ClearFlags.Target, Color.Blue, 0, 1); device.Present(); }
protected void Paint() { float xOffset = 0; float yOffset = 0; int i = 0; currentTime = DateTime.Now; TimeSpan elapsedTimeSpan = currentTime.Subtract(lastTime); lastTime = currentTime; fpsFrameCount += 1; fpsMillisecondsCount += elapsedTimeSpan.Milliseconds; if (fpsMillisecondsCount >= 1000) { fpsRate = fpsFrameCount / (fpsMillisecondsCount / 1000); fpsMillisecondsCount = 0; fpsFrameCount = 0; } // motion TimeSpan runTimeSpan = currentTime.Subtract(runTime); device.Clear(ClearFlags.Target, Color.Black, 1.0f, 0); device.BeginScene(); for (i = 0; i < rails.Length; i++) { device.SetStreamSource(0, vb_RedRail[i], 0); device.Transform.World = Matrix.Translation((0) + LeftRightOffset - (1 * 7), (0) + UpDownOffset, zoom); device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 100, 0, indices.Length / 3); } text.DrawText(null, string.Format("fps: {0}", fpsRate), new Point(10, 20), Color.White); text.DrawText(null, string.Format("scan rate: {0} ms", timerDelay), new Point(10, 40), Color.White); text.DrawText(null, string.Format("pluse per sec: {0}", PulseRate_CountPerSec), new Point(10, 60), Color.White); text.DrawText(null, string.Format("link per sec: {0}", LinkRate_CountPerSec), new Point(10, 80), Color.White); for (i = 0; i < links.Length; i++) { xOffset = LeftRightOffset + links[i].center_loc_x;// -(i * (cGripperStepPluse * 2)); yOffset = UpDownOffset + links[i].center_loc_y; if (i == 0) { device.SetStreamSource(0, vb_Link_Blue, 0); } else if (i == 99) { device.SetStreamSource(0, vb_Link_Green, 0); } else if (i == 199) { device.SetStreamSource(0, vb_Link_Orange, 0); } //else if (i == 3) //{ // device.SetStreamSource(0, vb_Link_Orange, 0); //} else { device.SetStreamSource(0, vb_Link_White, 0); } // handle orientation if (rails[links[i].currentRail].directionOfTravel == (int)ClassDef.clsRail.direction.right) { device.Transform.World = Matrix.Translation(xOffset, yOffset, zoom); } else if (rails[links[i].currentRail].directionOfTravel == (int)ClassDef.clsRail.direction.left) { device.Transform.World = Matrix.Translation(xOffset, yOffset, zoom); } else if (rails[links[i].currentRail].directionOfTravel == (int)ClassDef.clsRail.direction.up) { // device.Transform.World *= Matrix.RotationZ(90f); device.Transform.World = Matrix.Translation(xOffset, yOffset, zoom); } else if (rails[links[i].currentRail].directionOfTravel == (int)ClassDef.clsRail.direction.down) { //device.Transform.World *= Matrix.RotationZ(90f); device.Transform.World = Matrix.RotationZ(1.5708f) * Matrix.Translation(xOffset, yOffset, zoom); } device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 100, 0, indices.Length / 3); } device.EndScene(); device.Present(); this.Invalidate(); ReadKeyboard(); }
/// <summary> /// The render. /// </summary> /// <remarks></remarks> private void Render() { if (pause) { return; } device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); device.BeginScene(); cam.move(); SetupMatrices(); device.Material = DefaultMaterial; device.Transform.World = Matrix.Identity; device.RenderState.CullMode = Cull.Clockwise; // Raw.ParsedModel.DisplayedInfo.Draw(ref device, ref bsp.SkyBox); Material m = new Material(); device.RenderState.CullMode = Cull.None; device.RenderState.FillMode = FillMode.WireFrame; device.RenderState.AlphaBlendEnable = false; device.RenderState.AlphaTestEnable = false; device.Material = DefaultMaterial; dxcoll.DrawMeshes(ref device); if (sphereDisplayAll) { device.Material = BlueMaterial; dxcoll.DrawSpheres(ref device); device.Transform.World = Matrix.Identity; } if (planeDisplayAll) { for (int i = 0; i < mList.Count; i++) { m.Ambient = Color.FromArgb(130, (24 - (i % 25)) * 10, i % 25 * 10); m.Diffuse = m.Ambient; device.Material = m; device.SetTexture(0, null); device.RenderState.AlphaBlendEnable = true; device.RenderState.AlphaTestEnable = true; device.RenderState.DestinationBlend = Blend.Zero; device.RenderState.SourceBlend = Blend.One; device.RenderState.FillMode = FillMode.Solid; mList[i].DrawSubset(0); } // Draw normals device.SetStreamSource(0, Vb, 0); device.Transform.World = Matrix.Identity; device.VertexFormat = CustomVertex.PositionColored.Format; device.DrawPrimitives(PrimitiveType.LineList, 0, normalVertices.Length / 2); } else { m.Ambient = Color.Red; m.Diffuse = Color.Red; device.Material = m; device.SetTexture(0, null); device.RenderState.AlphaBlendEnable = true; device.RenderState.AlphaTestEnable = true; device.RenderState.DestinationBlend = Blend.Zero; device.RenderState.SourceBlend = Blend.One; device.RenderState.FillMode = FillMode.Solid; mList[planeDisplay].DrawSubset(0); // Draw normals device.SetStreamSource(0, Vb, 0); device.Transform.World = Matrix.Identity; device.VertexFormat = CustomVertex.PositionColored.Format; int tpd = planeDisplay; int mesh = 0; while (tpd >= coll.Meshes[mesh].SurfaceData.Length) { tpd -= coll.Meshes[mesh++].SurfaceData.Length; } short s = (short)coll.Meshes[mesh].SurfaceData[tpd].Plane; if (s >= 0) { device.DrawPrimitives(PrimitiveType.LineList, coll.Meshes[mesh].SurfaceData[tpd].Plane * 2, 1); } } device.EndScene(); // Update the screen device.Present(); }
/// <summary> /// The render. /// </summary> /// <remarks></remarks> private void Render() { if (pause) { return; } device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); device.BeginScene(); cam.move(); SetupMatrices(); MoveSpawnsWithKeyboard(); device.RenderState.FillMode = FillMode.WireFrame; device.Material = DefaultMaterial; device.RenderState.Lighting = true; device.RenderState.CullMode = Cull.None; render.device.SetTexture(0, null); render.device.RenderState.AlphaBlendEnable = true; render.device.RenderState.AlphaTestEnable = true; render.device.RenderState.DestinationBlend = Blend.DestinationAlpha; render.device.RenderState.SourceBlend = Blend.SourceAlpha; device.Transform.World = Matrix.Identity; //Raw.ParsedModel.DisplayedInfo.Draw(ref device, ref bsp.SkyBox); dxcoll.Draw(ref device); if (currentMode == editingModes.Point) { device.RenderState.FillMode = FillMode.Point; device.Material = BlueMaterial; device.RenderState.PointSize = 4; dxcoll.Draw(ref device); #region Render Spheres over selected points device.Material = GreenMaterial; device.RenderState.FillMode = FillMode.WireFrame; device.VertexFormat = CustomVertex.PositionColored.Format; device.RenderState.AlphaBlendEnable = false; device.RenderState.AlphaTestEnable = false; device.SetTexture(0, null); for (int i = 0; i < SelectedPoints.Count; i++) { device.Transform.World = Matrix.Translation(coll.Vertices[SelectedPoints[i]].X, coll.Vertices[SelectedPoints[i]].Y, coll.Vertices[SelectedPoints[i]].Z); sphere.DrawSubset(0); } #endregion } else if (currentMode == editingModes.Surface) { if (currentSurface != -1) { device.RenderState.Lighting = false; device.RenderState.ZBufferEnable = false; device.RenderState.CullMode = Cull.None; device.RenderState.AlphaBlendEnable = true; device.TextureState[0].ColorOperation = TextureOperation.SelectArg1; device.TextureState[0].AlphaOperation = TextureOperation.SelectArg1; device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor; device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor; //device.Material = GreenMaterial; device.RenderState.FillMode = FillMode.Solid; device.Transform.World = Matrix.Identity; device.DrawIndexedUserPrimitives(PrimitiveType.TriangleFan, 0, coll.Vertices.Length, polygons[currentSurface].indices.Length - 2, polygons[currentSurface].indices, true, coll.Vertices); } } device.EndScene(); // Update the screen device.Present(); }