散开卡片网格的“弧形”

矩形等于

我有n卡数。每张卡的a宽度单位。
许多流行的纸牌游戏在“呈扇形”位置显示一手纸牌(参见下图),我也想这样做。通过使用以下公式,我可以将卡成弧形放置:

// NOTE: UE4 uses a left-handed, Z-up coordinate system.
//  (+X = Forward, +Y = Right, and +Z = Up)

// NOTE: Card meshes have their pivot points in the center of the mesh
//  (meshSize * 0.5f = local origin of mesh)

// n = Number of card meshes
// a = Width of each card mesh

const auto arcWidth = 0.8f;
const auto arcHeight = 0.15f;
const auto rotationAngle = 30.f;
const auto deltaAngle = 180.f;
const auto delta = FMath::DegreesToRadians(deltaAngle) / (float)(n);
const auto halfDelta = delta * 0.5f;
const auto halfMeshWidth = a * 0.5f;
const auto radius = halfMeshWidth + (rotationAngle / FMath::Tan(halfDelta));

for (unsigned y = 0; y < n; y++)
{
    auto ArcX = (radius * arcWidth) * FMath::Cos(((float)y * delta) + halfDelta);
    auto ArcY = (radius * arcHeight) * FMath::Sin(((float)y * delta) + halfDelta);
    auto ArcVector = FVector(0.f, ArcX, ArcY);

    // Draw a line from the world origin to the card origin
    DrawDebugLine(GetWorld(), FVector::ZeroVector, ArcVector, FColor::Magenta, true, -1.f, 0, 2.5f);
}

这是《炉石传说》的5张卡片示例: 炉石传说中的五张牌

这是《杀戮尖塔》的5张卡片示例: 5卡牌杀入尖塔

但是我正在产生的结果很好……次优: 在此处输入图片说明

No matter how I tweak the variables, the cards on the far left and far right side are getting squashed together into the hand. I imagine this has to do with how the points of a circle are distributed, and then squashed downwards (via arcHeight) to form an ellipse? In any case, you can see that the results are far from similar, even though if you look closely at the example references, you can see that an arc exists from the center of each card (before those cards are rotated in local space).

What can I do to achieve a more evenly spaced arc?

user3386109

您的分布确实看起来像椭圆。您需要一个非常大的圆圈,该圆圈的中心偏离屏幕底部。类似于下面的圆圈,其中黑色矩形是您绘制卡片的屏幕区域,绿色点是卡片位置。请注意,圆的半径较大,并且卡片之间的角度较小。

在此处输入图片说明

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章