protected override void DoRender(RenderEventArgs arg) { ICamera camera = arg.CameraStack.Peek(); mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); this.SetUniform(projectionMatrix, projection); this.SetUniform(viewMatrix, view); this.SetUniform(modelMatrix, model); if (this.RenderWireframe) { // render wireframe. this.SetUniform("renderWireframe", true); polygonMode.On(); polygonOffsetState.On(); base.DoRender(arg); polygonOffsetState.Off(); polygonMode.Off(); } if (this.RenderBody) { // render solid body. this.SetUniform("renderWireframe", false); base.DoRender(arg); } }
/// <summary> /// /// </summary> /// <param name="arg"></param> public void RenderBeforeChildren(RenderEventArgs arg) { this.PushProjectionViewMatrix(arg); this.PushModelMatrix(); polygonModeState.On(); polygonOffsetState.On(); DoRender(this.Positions, indexes, this.lineColor); polygonOffsetState.Off(); polygonModeState.Off(); this.PopModelMatrix(); this.PopProjectionViewMatrix(); }
public override void RenderBeforeChildren(RenderEventArgs arg) { if (!this.IsInitialized) { this.Initialize(); } this.RotationAngle += this.RotateSpeed; ICamera camera = arg.CameraStack.Peek(); mat4 projection = camera.GetProjectionMatrix(); mat4 view = camera.GetViewMatrix(); mat4 model = this.GetModelMatrix(); var method = this.RenderUnit.Methods[0]; // the only render unit in this node. ShaderProgram program = method.Program; program.SetUniform(projectionMatrix, projection); program.SetUniform(viewMatrix, view); program.SetUniform(modelMatrix, model); if (this.RenderWireframe) { // render wireframe. program.SetUniform("renderWireframe", true); polygonMode.On(); polygonOffsetState.On(); method.Render(); polygonOffsetState.Off(); polygonMode.Off(); } if (this.RenderBody) { // render solid body. program.SetUniform("renderWireframe", false); method.Render(); } }