本文整理汇总了C++中Box::GetEdge方法的典型用法代码示例。如果您正苦于以下问题:C++ Box::GetEdge方法的具体用法?C++ Box::GetEdge怎么用?C++ Box::GetEdge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Box
的用法示例。
在下文中一共展示了Box::GetEdge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateBorder
// Generates the border geometry for a single box.
void ElementBorder::GenerateBorder(Vertex*& vertices, Index*& indices, Index& index_offset, const Box& box, const Colourb* colours)
{
// The axis of extrusion for each of the edges.
Vector2f box_extrusions[4] =
{
Vector2f(0, -1 * box.GetEdge(Box::BORDER, Box::TOP)),
Vector2f(box.GetEdge(Box::BORDER, Box::RIGHT), 0),
Vector2f(0, box.GetEdge(Box::BORDER, Box::BOTTOM)),
Vector2f(-1 * box.GetEdge(Box::BORDER, Box::LEFT), 0)
};
// The position of each of the corners of the inner border.
Vector2f box_corners[4];
box_corners[0] = box.GetPosition(Box::PADDING);
box_corners[2] = box_corners[0] + box.GetSize(Box::PADDING);
box_corners[1] = Vector2f(box_corners[2].x, box_corners[0].y);
box_corners[3] = Vector2f(box_corners[0].x, box_corners[2].y);
for (int i = 0; i < 4; i++)
{
float border_width = box.GetEdge(Box::BORDER, (Box::Edge) i);
if (border_width <= 0)
continue;
vertices[0].position = box_corners[i];
vertices[1].position = box_corners[i] + box_extrusions[i] + box_extrusions[i == 0 ? 3 : i - 1];
vertices[2].position = box_corners[i == 3 ? 0 : i + 1];
vertices[3].position = vertices[2].position + box_extrusions[i] + box_extrusions[i == 3 ? 0 : i + 1];
vertices[0].colour = colours[i];
vertices[1].colour = colours[i];
vertices[2].colour = colours[i];
vertices[3].colour = colours[i];
indices[0] = index_offset;
indices[1] = index_offset + 3;
indices[2] = index_offset + 1;
indices[3] = index_offset;
indices[4] = index_offset + 2;
indices[5] = index_offset + 3;
vertices += 4;
indices += 6;
index_offset += 4;
}
}
示例2: GetSpacing
static float GetSpacing(const Box& box, Box::Edge edge)
{
return box.GetEdge(Box::PADDING, edge) +
box.GetEdge(Box::BORDER, edge) +
box.GetEdge(Box::MARGIN, edge);
}