-
Автор темы
- #1
Код:
void DrawTriangle(Vector pos, float size, Color color)
{
// Drawing a Triangle
Vector up, right, left, up_right, up_left;
Vector s_up, s_right, s_left, s_up_right, s_up_left;
up[0] = pos[0];
up[1] = pos[1];
up[2] = pos[2] + size / 2;
WorldToScreen(up, s_up);
up_left[0] = pos[0] - size / 2;
up_left[1] = pos[1] + size / 2;
up_left[2] = pos[2] - size / 2;
WorldToScreen(up_left, s_up_left);
up_right[0] = pos[0] + size / 2;
up_right[1] = pos[1] + size / 2;
up_right[2] = pos[2] - size / 2;
WorldToScreen(up_right, s_up_right);
right[0] = pos[0] + size / 2;
right[1] = pos[1] - size / 2;
right[2] = pos[2] - size / 2;
WorldToScreen(right, s_right);
left[0] = pos[0] - size / 2;
left[1] = pos[1] - size / 2;
left[2] = pos[2] - size / 2;
WorldToScreen(left, s_left);
DrawLine(s_right[0], s_right[1], s_left[0], s_left[1], color);
DrawLine(s_right[0], s_right[1], s_up_right[0], s_up_right[1], color);
DrawLine(s_left[0], s_left[1], s_up_left[0], s_up_left[1], color);
DrawLine(s_up_right[0], s_up_right[1], s_up_left[0], s_up_left[1], color);
DrawLine(s_right[0], s_right[1], s_up[0], s_up[1], color);
DrawLine(s_left[0], s_left[1], s_up[0], s_up[1], color);
DrawLine(s_up_left[0], s_up_left[1], s_up[0], s_up[1], color);
DrawLine(s_up_right[0], s_up_right[1], s_up[0], s_up[1], color);
}