/// <summary> /// /// </summary> /// <param name="arg"></param> protected override void DoRender(RenderEventArgs arg) { mat4 projection = arg.Camera.GetProjectionMatrix(); mat4 view = arg.Camera.GetViewMatrix(); mat4 model = this.GetModelMatrix().Value; this.SetUniform("mvp", projection * view * model); if (this.textColorRecord.IsMarked()) { this.SetUniform("textColor", this.textColor); this.textColorRecord.CancelMark(); } if (this.textRecord.IsMarked()) { TextModel textModel = this.textModel; if (textModel != null) { textModel.SetText(this.text, this.fontTexture); this.textRecord.CancelMark(); } } blendState.On(); base.DoRender(arg); blendState.Off(); }
private void renderedControl1_Rendered(object sender, RenderEventArgs e) { int tickCount = Environment.TickCount; float deltaTime = (tickCount - _previousTickCount) / 1000f; _previousTickCount = tickCount; _simulator.Update(deltaTime); _framesCount++; int secondsCount = (tickCount - _startTickCount)/1000; if(secondsCount != 0) label.Text = String.Format("FPS: {0}", _framesCount / secondsCount); //draw scene var render = e.Render; render.BeginScene(); render.Draw(() => { _simulator.ActorsFactory.AcceptVisit(_renderingVisitor); }, Lights.Point(new Vector3(0, 5, -6), new Vector3(1, 1, 1)), Cameras.LookAt(new Vector3(0, 15, -30), new Vector3(0, 0, 0), new Vector3(0, 1, 0)), Cameras.Perspective(render.GetAspectRatio()), Buffers.Clear(0.2f, 0.2f, 0.4f, 1), Buffers.ClearDepth(), Shaders.Phong ); render.EndScene(); renderedControl1.Invalidate(); }
/// <summary> /// /// </summary> /// <param name="arg"></param> protected override void DoRender(RenderEventArgs arg) { // RULE: 用于渲染UI元素的模型,其范围最好是在(-0.5, -0.5, -0.5)到(-0.5, -0.5, -0.5)之间,即保持其边长为1,且位于坐标系中心。这样,就可以用mat4 model = glm.scale(mat4.identity(), new vec3(this.Size.Width, this.Size.Height, 1));来设定其缩放比例了。简单方便。 mat4 projection = this.GetOrthoProjection(); //vec3 position = (this.camera.Position - this.camera.Target).normalize(); mat4 view = glm.lookAt(new vec3(0, 0, 1), new vec3(0, 0, 0), new vec3(0, 1, 0)); //float length = Math.Max(glText.Size.Width, glText.Size.Height) / 2; float length = this.Size.Height;// / 2; mat4 model = glm.scale(mat4.identity(), new vec3(length, length, length)); //model = mat4.identity(); var renderer = this.Renderer as Renderer; renderer.SetUniform("mvp", projection * view * model); if (this.textColorRecord.IsMarked()) { renderer.SetUniform("textColor", this.textColor); this.textColorRecord.CancelMark(); } if (this.textRecord.IsMarked()) { TextModel textModel = this.textModel; if (textModel != null) { textModel.SetText(this.text, this.fontTexture); this.textRecord.CancelMark(); } } blendState.On(); base.DoRender(arg); blendState.Off(); }
/// <summary> /// 在使用<see cref="VertexArrayObject"/>后,此方法只会执行一次。 /// </summary> /// <param name="e"></param> /// <param name="shaderProgram"></param> public override void Render(RenderEventArgs e, Shaders.ShaderProgram shaderProgram) { uint location = shaderProgram.GetAttributeLocation(this.VarNameInVertexShader); GL.BindBuffer(BufferTarget.ArrayBuffer, this.BufferID); GL.VertexAttribPointer(location, this.DataSize, this.DataType, false, 0, IntPtr.Zero); GL.EnableVertexAttribArray(location); }
protected override void DoRender(RenderEventArgs arg) { float deltaTime = (float)random.NextDouble() * 5; time += (float)random.NextDouble() * 5; IntPtr attractors = this.attractorBuffer.MapBufferRange( 0, 64 * Marshal.SizeOf(typeof(vec4)), MapBufferRangeAccess.MapWriteBit | MapBufferRangeAccess.MapInvalidateBufferBit); unsafe { var array = (vec4*)attractors.ToPointer(); for (int i = 0; i < 64; i++) { array[i] = new vec4( (float)(Math.Sin(time)) * 50.0f, (float)(Math.Cos(time)) * 50.0f, (float)(Math.Cos(time)) * (float)(Math.Sin(time)) * 5.0f, ParticleModel.attractor_masses[i]); } } this.attractorBuffer.UnmapBuffer(); // Activate the compute program and bind the position and velocity buffers computeProgram.Bind(); OpenGL.BindImageTexture(0, this.velocityTexture.Id, 0, false, 0, OpenGL.GL_READ_WRITE, OpenGL.GL_RGBA32F); OpenGL.BindImageTexture(1, this.positionTexture.Id, 0, false, 0, OpenGL.GL_READ_WRITE, OpenGL.GL_RGBA32F); // Set delta time computeProgram.SetUniform("dt", deltaTime); // Dispatch OpenGL.GetDelegateFor<OpenGL.glDispatchCompute>()(ParticleModel.particleGroupCount, 1, 1); }
protected override void DoRender(RenderEventArgs arg) { mat4 projection = arg.Camera.GetProjectionMatrix(); mat4 view = arg.Camera.GetViewMatrix(); mat4 inverseView = glm.inverse(view); //mat4 model = this.GetModelMatrix(); this.SetUniform("u_projectionMatrix", projection); this.SetUniform("u_viewMatrix", view); this.SetUniform("u_inverseViewNormalMatrix", new mat3(new vec3(view[0]), new vec3(view[1]), new vec3(view[2]))); this.SetUniform("u_passedTime", passedTime); this.SetUniform("u_waveParameters", WaterTextureRenderer.ToFloat(WaterTextureRenderer.waveParameters)); this.SetUniform("u_waveDirections", WaterTextureRenderer.ToFloat(WaterTextureRenderer.waveDirections)); this.cullfaceState.On(); this.backgroundRenderer.passedTime = passedTime; this.backgroundRenderer.Render(arg); this.waterTextureRenderer.passedTime = passedTime; this.waterTextureRenderer.Render(arg); base.DoRender(arg); this.cullfaceState.Off(); passedTime += deltaTime; }
/// <summary> /// 在三角形图元中拾取指定位置的Line /// </summary> /// <param name="arg">渲染参数</param> /// <param name="x">mouse position(Left Down is (0, 0)).</param> /// <param name="y">mouse position(Left Down is (0, 0)).</param> /// <param name="lastVertexId">三角形图元的最后一个顶点</param> /// <param name="modernRenderer">目标Renderer</param> /// <returns></returns> internal override uint[] Search(RenderEventArgs arg, int x, int y, uint lastVertexId, ZeroIndexRenderer modernRenderer) { // 创建临时索引 OneIndexBuffer buffer = Buffer.Create(IndexBufferElementType.UInt, 6, DrawMode.Lines, BufferUsage.StaticDraw); unsafe { var array = (uint*)buffer.MapBuffer(MapBufferAccess.WriteOnly); array[0] = lastVertexId - 1; array[1] = lastVertexId - 0; array[2] = lastVertexId - 2; array[3] = lastVertexId - 1; array[4] = lastVertexId - 0; array[5] = lastVertexId - 2; buffer.UnmapBuffer(); } // 用临时索引渲染此三角形图元(仅渲染此三角形图元) modernRenderer.Render4InnerPicking(arg, buffer); // id是拾取到的Line的Last Vertex Id uint id = ColorCodedPicking.ReadStageVertexId(x, y); buffer.Dispose(); // 对比临时索引,找到那个Line if (id + 2 == lastVertexId) { return new uint[] { id + 2, id, }; } else { return new uint[] { id - 1, id, }; } }
protected override void DoRender(RenderEventArgs e) { GL.BindTexture(GL.GL_TEXTURE_3D, this.textureName[0]); GL.ActiveTexture(GL.GL_TEXTURE0); //GL.Color(1f, 1f, 1f, 1f); GL.Begin(PrimitiveModes.QuadStrip); { GL.Vertex(this.positiveX, this.positiveY, this.positiveZ); GL.TexCoord3f(this.positiveTexX, this.positiveTexY, this.positiveTexZ); GL.Vertex(this.positiveX, this.positiveY, this.negativeZ); GL.TexCoord3f(this.positiveTexX, this.positiveTexY, this.negativeTexZ); GL.Vertex(this.negativeX, this.positiveY, this.positiveZ); GL.TexCoord3f(this.negativeTexX, this.positiveTexY, this.positiveTexZ); GL.Vertex(this.negativeX, this.positiveY, this.negativeZ); GL.TexCoord3f(this.negativeTexX, this.positiveTexY, this.negativeTexZ); GL.Vertex(this.negativeX, this.negativeY, this.positiveZ); GL.TexCoord3f(this.negativeTexX, this.negativeTexY, this.positiveTexZ); GL.Vertex(this.negativeX, this.negativeY, this.negativeZ); GL.TexCoord3f(this.negativeTexX, this.negativeTexY, this.negativeTexZ); GL.Vertex(this.positiveX, this.negativeY, this.positiveZ); GL.TexCoord3f(this.positiveTexX, this.negativeTexY, this.positiveTexZ); GL.Vertex(this.positiveX, this.negativeY, this.negativeZ); GL.TexCoord3f(this.positiveTexX, this.negativeTexY, this.negativeTexZ); } GL.End(); GL.BindTexture(GL.GL_TEXTURE_3D, 0); }
/// <summary> /// /// </summary> /// <param name="arg"></param> protected override void DoRender(RenderEventArgs arg) { this.SetUniform("billboardCenter_worldspace", this.WorldPosition); if (labelHeightRecord.IsMarked()) { this.SetUniform("labelHeight", this.LabelHeight); labelHeightRecord.CancelMark(); } if (textRecord.IsMarked()) { if (this.DataSource != null) { (this.DataSource as TextModel).SetText(this.text, this.fontTexture); } } if (discardTransparencyRecord.IsMarked()) { bool discard = this.DiscardTransparency; this.SetUniform("discardTransparency", discard); this.blendState.Enabled = discard; discardTransparencyRecord.CancelMark(); } int[] viewport = OpenGL.GetViewport(); this.SetUniform("viewportSize", new vec2(viewport[2], viewport[3])); mat4 projection = arg.Camera.GetProjectionMatrix(); mat4 view = arg.Camera.GetViewMatrix(); this.SetUniform("projection", projection); this.SetUniform("view", view); base.DoRender(arg); }
protected internal override void OnRender(RenderEventArgs e) { base.OnRender(e); e.Canvas.FillRectangle(0, 0, Size.Width, Size.Height, mvarBackgroundColor); #region Left Arrow e.Canvas.FillRectangle(0, 0, 8, Size.Height - 1, Colors.LightGray); e.Canvas.Color = Colors.Black; e.Canvas.DrawRectangle(0, 0, 8, Size.Height - 1); e.Canvas.DrawLine(8 - 1, 4, 0, Size.Height / 2); e.Canvas.DrawLine(8, Size.Height - 4, 0, Size.Height / 2); #endregion #region Thumb double thw = 9; double thx = (this.Size.Width * ((this.Value - this.Minimum) / (this.Maximum - this.Minimum))) - (thw * 2), thy = 0; e.Canvas.FillRectangle(9 + thx, thy, Size.Height - 1, Size.Height - 1, Colors.LightGray); e.Canvas.Color = Colors.Black; e.Canvas.DrawRectangle(9 + thx, thy, Size.Height - 1, Size.Height - 1); e.Canvas.Translate(0, 14); e.Canvas.DrawText("#", 9 + thx + 5, thy); e.Canvas.Translate(0, -14); #endregion #region Right Arrow e.Canvas.FillRectangle(Size.Width - 8, 0, 8, Size.Height - 1, Colors.LightGray); e.Canvas.Color = Colors.Black; e.Canvas.DrawRectangle(Size.Width - 8, 0, 8, Size.Height - 1); e.Canvas.DrawLine(Size.Width - 8 - 1, 4, Size.Width - 1, Size.Height / 2); e.Canvas.DrawLine(Size.Width - 8, Size.Height - 4, Size.Width - 1, Size.Height / 2); #endregion }
protected override void DoRender(RenderEventArgs arg) { mat4 projection = arg.Camera.GetProjectionMatrix(); mat4 view = arg.Camera.GetViewMatrix(); mat4 model = this.GetModelMatrix().Value; this.SetUniform("mvp", projection * view * model); base.DoRender(arg); }
protected override void DoRender(RenderEventArgs arg) { mat4 model = mat4.identity(); mat4 view = arg.Camera.GetViewMat4(); mat4 projection = arg.Camera.GetProjectionMat4(); this.SetUniform("mvp", projection * view * model); base.DoRender(arg); }
void glCanvas1_OpenGLDraw(object sender, PaintEventArgs e) { GL.ClearColor(0x87 / 255.0f, 0xce / 255.0f, 0xeb / 255.0f, 0xff / 255.0f); GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); var arg = new RenderEventArgs(RenderModes.Render, this.camera); element.Render(arg); uiAxis.Render(arg); }
private void RenderedControl1InitializeRender(object sender, RenderEventArgs e) { _boxModel = Models.Cube.Translated(-0.5f, -0.5f, -0.5f).Scaled(1, 1, 1).Allocate(e.Render); _planeModel = Models.PlaneXZ.Scaled(10, 5, 5).Allocate(e.Render); SetupSimulation(); //initializing the timer _startTickCount = Environment.TickCount; }
protected override void DoRender(RenderEventArgs arg) { mat4 projection = arg.Camera.GetProjectionMatrix(); mat4 view = arg.Camera.GetViewMatrix(); //mat4 model = this.GetModelMatrix(); this.SetUniform("u_projectionMatrix", projection); this.SetUniform("u_modelViewMatrix", view); base.DoRender(arg); }
protected override void DoRender(RenderEventArgs arg) { mat4 projection = arg.Camera.GetProjectionMatrix(); mat4 view = arg.Camera.GetViewMatrix(); mat4 model = glm.scale(mat4.identity(), this.Scale); this.SetUniform("projectionMatrix", projection); this.SetUniform("viewMatrix", view); this.SetUniform("modelMatrix", model); this.SetUniform("lineColor", this.LineColor.ToVec3()); base.DoRender(arg); }
void connector_BeforeOutput(object sender, RenderEventArgs e) { if (this.Connector.Request.RequestType == DataRequestType.Edit) { //create new action DataAction customAction = new DataAction("sayHello", "", null, null, null, null); customAction.Details = "Hello, World!"; //add it to actions collection and send to the client this.Connector.Request.DataActions.Add(customAction); } }
/// <summary> /// /// </summary> /// <param name="arg"></param> protected override void DoRender(RenderEventArgs arg) { if (arg.PickingGeometryType == PickingGeometryType.None) { base.DoRender(arg); } else { this.innerPickableRenderer.Render(arg); } }
private void renderedControl1_InitializeRender(object sender, RenderEventArgs e) { _boxModel = Models.Cube.Translated(-0.5f, -0.5f, -0.5f).Scaled(1, 1, 1).Allocate(e.Render); _planeModel = Models.PlaneXZ.Scaled(1, 1, 1); DigitalRuneAdaptorScene(); //initializing the timer _previousTickCount = Environment.TickCount; _startTickCount = _previousTickCount; }
protected override void DoRender(RenderEventArgs e) { // 去掉Camera,UI就不会旋转。 RenderEventArgs barArg = new RenderEventArgs(e.RenderMode, null); this.bar.Render(barArg); foreach (var item in this.numbers) { item.Render(barArg); } }
public override void RenderPostMain(Matrix transform, RenderEventArgs e) { if (m_pileBackTexture == null) { return; } var pileSize = new Vector3(Control.Region.Width, Control.Region.Height, m_pileHeight() * CardThickness); var transform1 = Control.BodyContainer.TransformToGlobal; GameApp.Service<Graphics.PileRenderer>().Draw(m_pileBackTexture, pileSize, Matrix.CreateTranslation(0, 0, -pileSize.Z) * transform1); }
protected override void DoRender(RenderEventArgs arg) { this.particleComputeRenderer.Render(arg); OpenGL.GetDelegateFor<OpenGL.glMemoryBarrier>()(OpenGL.GL_SHADER_IMAGE_ACCESS_BARRIER_BIT); // Clear, select the rendering program and draw a full screen quad mat4 view = arg.Camera.GetViewMatrix(); mat4 projection = arg.Camera.GetProjectionMatrix(); this.particleRenderer.SetUniform("mvp", projection * view); this.particleRenderer.Render(arg); }
void DemoColorCodedPickingElement_BeforeRendering(object sender, RenderEventArgs e) { if (e.RenderMode == RenderModes.HitTest) { this.currentShaderProgram = this.pickingShaderProgram; } else { this.currentShaderProgram = this.shaderProgram; } }
protected internal override void OnRender(RenderEventArgs e) { e.Canvas.Color = UniversalEditor.Colors.Black; if (mvarChecked) { e.Canvas.DrawText("[X] " + base.Text, base.Position.X, base.Position.Y); } else { e.Canvas.DrawText("[ ] " + base.Text, base.Position.X, base.Position.Y); } }
protected override void DoRender(RenderEventArgs e) { mat4 projectionMatrix, viewMatrix, modelMatrix; { IUILayout element = this as IUILayout; element.GetMatrix(out projectionMatrix, out viewMatrix, out modelMatrix, e.Camera); } this.axisElement.mvp = projectionMatrix * viewMatrix * modelMatrix; this.axisElement.Render(e); }
private void renderedControl1_InitializeRender(object sender, RenderEventArgs e) { _render = e.Render; _renderingVisitor = new RenderingVisitor(_render); _simulator = new DigitalRuneSimulator(); _simulator.AddForceEffect(new GravityForceEffect()); Samples.SetSimpleScene(_simulator); _previousTickCount = Environment.TickCount; _startTickCount = _previousTickCount; }
protected void DayPilotBubble1_RenderContent(object sender, RenderEventArgs e) { if (e is RenderResourceBubbleEventArgs) { RenderResourceBubbleEventArgs re = e as RenderResourceBubbleEventArgs; e.InnerHTML = "<b>Resource header details</b><br />Value: " + re.ResourceId; } else if (e is RenderCellBubbleEventArgs) { RenderCellBubbleEventArgs re = e as RenderCellBubbleEventArgs; e.InnerHTML = "<b>Cell details</b><br />Resource:" + re.ResourceId + "<br />From:" + re.Start + "<br />To: " + re.End; } }
void connector_BeforeOutput(object sender, RenderEventArgs e) { if (this.Connector.Request.StartIndex == 0) { e.Writer.WriteStartElement("head"); { //col 1 e.Writer.WriteStartElement("column"); { e.Writer.WriteAttributeString("width", "50"); e.Writer.WriteAttributeString("type", "ed"); e.Writer.WriteAttributeString("align", "right"); e.Writer.WriteAttributeString("color", "white"); e.Writer.WriteAttributeString("sort", "na"); e.Writer.WriteString("Sales"); } e.Writer.WriteEndElement(); //col 2 e.Writer.WriteStartElement("column"); { e.Writer.WriteAttributeString("width", "150"); e.Writer.WriteAttributeString("type", "ed"); e.Writer.WriteAttributeString("align", "left"); e.Writer.WriteAttributeString("color", "#d5f1ff"); e.Writer.WriteAttributeString("sort", "na"); e.Writer.WriteString("Book Title"); } e.Writer.WriteEndElement(); //col 3 e.Writer.WriteStartElement("column"); { e.Writer.WriteAttributeString("width", "100"); e.Writer.WriteAttributeString("type", "ed"); e.Writer.WriteAttributeString("align", "left"); e.Writer.WriteAttributeString("color", "#d5f1ff"); e.Writer.WriteAttributeString("sort", "na"); e.Writer.WriteString("Author"); } e.Writer.WriteEndElement(); } e.Writer.WriteEndElement(); /* <head> <column width="50" type="ed" align="right" color="white" sort="na">Sales</column> <column width="150" type="ed" align="left" color="#d5f1ff" sort="na">Book Title</column> <column width="100" type="ed" align="left" color="#d5f1ff" sort="na">Author</column> </head> */ } }
protected override void DoRender(RenderEventArgs arg) { this.SetUniform("projection", arg.Camera.GetProjectionMatrix()); this.SetUniform("view", arg.Camera.GetViewMatrix()); MarkableStruct<mat4> model = this.GetModelMatrix(); if (this.modelTicks != model.UpdateTicks) { this.SetUniform("model", model.Value); this.modelTicks = model.UpdateTicks; } base.DoRender(arg); }
protected internal override void OnRender(RenderEventArgs e) { base.OnRender(e); e.Canvas.Clear(mvarBackgroundColor); foreach (Control ctl in mvarControls) { BeforeRenderEventArgs bre = new BeforeRenderEventArgs(e.Canvas); ctl.OnBeforeRender(bre); RenderEventArgs re = new RenderEventArgs(e.Canvas); ctl.OnRender(re); ctl.OnAfterRender(re); } }