public void draw(Matrix4 model, Matrix4 view, Matrix4 projection) { Matrix3 normalMatrix = new Matrix3(Matrix4.Transpose(Matrix4.Invert(model))); // Shader shader.SetMatrix4("model", model); shader.SetMatrix4("view", view); shader.SetMatrix3("normalMatrix", normalMatrix); shader.SetInt("isLighting", 0); // Fonts fontDrawing.DrawingPrimitives.Clear(); fontDrawing.ProjectionMatrix = projection; // Vertex buffer int attribPos = shader.GetAttribLocation("inPosition"); int attribNorm = shader.GetAttribLocation("inNormal"); GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBuffer); GL.VertexAttribPointer(attribPos, 3, VertexAttribPointerType.Float, false, 6 * sizeof(float), 0); GL.VertexAttribPointer(attribNorm, 3, VertexAttribPointerType.Float, false, 6 * sizeof(float), 3 * sizeof(float)); GL.EnableVertexAttribArray(attribPos); GL.EnableVertexAttribArray(attribNorm); // Drawing options GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); // Axes int ptrDraw = 0; GL.BindBuffer(BufferTarget.ElementArrayBuffer, axesBuffer); for (int iAxis = 0; iAxis != 3; ++iAxis) { shader.SetVector3("objectColor", LMSModel.convertColor(axesColors[iAxis])); GL.DrawElements(PrimitiveType.Lines, 2, DrawElementsType.UnsignedInt, ptrDraw * sizeof(uint)); ptrDraw += 2; } // Box shader.SetVector3("objectColor", LMSModel.convertColor(boxColor)); GL.BindBuffer(BufferTarget.ElementArrayBuffer, boxBuffer); GL.DrawElements(PrimitiveType.Quads, 12, DrawElementsType.UnsignedInt, 0); // Tetra for (int iAxis = 0; iAxis != 3; ++iAxis) { Color4 color = axesColors[iAxis]; shader.SetVector3("objectColor", LMSModel.convertColor(color)); GL.BindBuffer(BufferTarget.ElementArrayBuffer, tetrahedronBuffers[iAxis]); GL.DrawElements(PrimitiveType.Triangles, 12, DrawElementsType.UnsignedInt, 0); // Label Vector4 position = Vector4.Zero; position[iAxis] = lengthAxis + heightTetra + shiftLabel; position.W = 1.0f; position *= model * view; fontRenderOptions.Colour = (Color)color; fontDrawing.Print(font, axesNames[iAxis], position.Xyz, QFontAlignment.Justify, fontRenderOptions); } fontDrawing.RefreshBuffers(); fontDrawing.Draw(); }
public ResponseAnalyzer() { InitializeComponent(); comboBoxTemplateType.SelectedIndex = 0; comboBoxTestlabSelectionMode.SelectedIndex = 0; modelRenderer_ = new LMSModel(); lastMousePosition_ = new int[2] { 0, 0 }; ToolTip toolTip = new ToolTip(); toolTip.InitialDelay = 200; toolTip.ShowAlways = true; toolTip.SetToolTip(buttonAddTemplateObject, "Press A to add a template object"); toolTip.SetToolTip(buttonRemoveTemplateObject, "Press D to remove a template object"); toolTip.SetToolTip(buttonEditTemplateSelection, "Press E to edit a template object"); toolTip.SetToolTip(buttonCopyTemplateObjects, "Press C to copy all the template objects from the selected chart"); toolTip.SetToolTip(numericTemplateNormalization, "Press F1 to fill it out automatically based on the selected lines"); }