| Custom edges drawing
| |
Info & Tags |
| |
| Article #: |
5 |
| Created: |
2010-04-08 |
| Modified: |
2010-05-19 |
| Tags: |
eyeshot3, edges |
|
If you need to change the drawing style of your entity edges you can take the full control on the Entity.DrawEdges() method.
To do it you need first to subclass the required Eyeshot entity, then override the DrawEdges() method and avoid calling the base class implementation. To change color and thickness we recommend to call the provided functions. If you need custom edges only for selected entities you can easily check if the Selected property is true inside the DrawEdges() method and if not call the base class implementatation for standard edges drawing.

| C# |
using OpenGL;
using devDept.Geometry;
public class MyMesh : Mesh
{
public override void DrawEdges()
{
if (Edges != null)
{
Viewport.SetColorWireframe(Color.Red);
float[] prevThickness = new float[1];
gl.GetFloatv(gl.LINE_WIDTH, prevThickness);
gl.LineWidth(3);
gl.LineStipple(3, 0xAAAA);
gl.Enable(OpenGL.gl.LINE_STIPPLE);
gl.Begin(OpenGL.gl.LINES);
foreach (devDept.Eyeshot.Edge edge in Edges)
{
Vertices[edge.V1].DrawGL();
Vertices[edge.V2].DrawGL();
}
gl.End();
gl.Disable(OpenGL.gl.LINE_STIPPLE);
OpenGL.gl.LineWidth(prevThickness[0]);
}
}
} |
| Visual Basic |
Imports OpenGL
Imports devDept.Geometry
Public Class MyMesh
Inherits Mesh
Public Overloads Overrides Sub DrawEdges()
If Edges IsNot Nothing Then
Viewport.SetColorWireframe(Color.Red)
Dim prevThickness As Single() = New Single(0) {}
gl.GetFloatv(gl.LINE_WIDTH, prevThickness)
gl.LineWidth(3)
gl.LineStipple(3, &HAAAA)
gl.Enable(OpenGL.gl.LINE_STIPPLE)
gl.Begin(OpenGL.gl.LINES)
For Each edge As devDept.Eyeshot.Edge In Edges
Vertices(edge.V1).DrawGL()
Vertices(edge.V2).DrawGL()
Next
gl.[End]()
gl.Disable(OpenGL.gl.LINE_STIPPLE)
gl.LineWidth(prevThickness(0))
End If
End Sub
End Class |
|