// Internal method to draw triangle using the Alibre supplied IADAddOnCanvasDisplay interface (this is new in AD version 2019).
// This will use Hoops Visualize rendering engine that Alibre Design's rendering platform is now built on.
private bool DrawTriangle_Hoops(IADAddOnCanvasDisplay canvas, string imageFilePath, bool bDrawTexture)
{
long segment;
Array vertices = new float[] { -5.0f, 0.0f, 0.0f, 5.0f, 0.0f, 0.0f, 0.0f, 5.0f, 0.0f };
Array normals = new float[] { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f };
Array indices = new int[] { 3, 0, 1, 2 };
Array color = new float[] { 0.0f, 0.5f, 0.0f };
Array vertexUVs = new float[] { 0.0f, 0.0f, 1.0f, 1.0f, 0.5f, 1.0f };
float fltOffset = m_nGlobalDrawCounter * 5.0f; // Offset Triangle everytime
Array transform = new double [] {
1, 0, 0,
0, 1, 0,
0, 0, 1,
fltOffset, 0, 0 };
segment = canvas.AddSubSegment(0, "Triangle");
canvas.SetSegmentTransform(segment, true, ref transform);
canvas.SetSegmentColor(segment, 0, 128, 0, 255); // dark green
canvas.SetSegmentReflectivity(segment, 80);
if (!bDrawTexture)
{
// draw coloured mesh
canvas.DrawMesh(segment, ref vertices, ref normals, ref indices);
}
else
{
// draw textured
string textureName = "Wood";
canvas.DefineTexture(segment, textureName, ImageFormat.JPEG, m_imageFilePath);
canvas.SetFaceTexture(segment, textureName);
canvas.DrawTexturedMesh(segment, ref vertices, ref normals, ref vertexUVs, ref indices);
}
// Draw a triangular wire mesh
canvas.DrawPolyline(segment, ref vertices);
// EXAMPLE 1: set line weight
canvas.SetLineWeight(segment, 2.0f);
// EXAMPLE 2: Toggle foreground rendering
canvas.ToggleForegroundRendering(segment, true);
int radius = 15;
canvas.DrawMarker(segment, (float)vertices.GetValue(0), (float)vertices.GetValue(1), (float)vertices.GetValue(2), radius, MarkerType.MARKER_RECT);
canvas.DrawMarker(segment, (float)vertices.GetValue(3), (float)vertices.GetValue(4), (float)vertices.GetValue(5), radius, MarkerType.MARKER_RECT);
string text = DateTime.Now.ToString("HH:mm:ss");
segment = canvas.AddSubSegment(0, "Mesh Text");
canvas.DrawTextMesh(segment, text, 5, 5, 5, TextAlignment.TopLeft, "Miso", 20.0f, HOOPS.COLOR_ARGB(255, 0, 0, 255), true, false, false);
segment = canvas.AddSubSegment(0, "Screen Text");
canvas.DrawScreenText(segment, text, 200, 200, TextAlignment.TopLeft, "Miso", 20.0f, HOOPS.COLOR_ARGB(255, 0, 0, 255), true);
canvas.DrawScreenText(segment, "X = 1.25", 10, 10, TextAlignment.TopLeft, "Miso", 12.0f, HOOPS.COLOR_ARGB(255, 128, 128, 128), true);
canvas.DrawScreenText(segment, "Y = 0.00", 10, 30, TextAlignment.TopLeft, "Miso", 12.0f, HOOPS.COLOR_ARGB(255, 128, 128, 128), true);
canvas.DrawScreenText(segment, "Z = 2.76", 10, 50, TextAlignment.TopLeft, "Miso", 12.0f, HOOPS.COLOR_ARGB(255, 128, 128, 128), true);
return true;
}