我試圖將邊界球添加到模型以進行碰撞檢測。問題在於模型底部始終與球體中心在同一水平線上。有沒有辦法找到模型的中間(基於Y軸),以便我可以將它作爲球體的中心?認爲這將解決我的問題。提前致謝。放置邊界球的精度更高
protected BoundingSphere CalculateBoundingSphere()
{
BoundingSphere mergedSphere = new BoundingSphere();
BoundingSphere[] boundingSpheres;
int index = 0;
int meshCount = Model.Meshes.Count;
boundingSpheres = new BoundingSphere[meshCount];
foreach (ModelMesh mesh in Model.Meshes)
{
boundingSpheres[index++] = mesh.BoundingSphere;
}
mergedSphere = boundingSpheres[0];
if ((Model.Meshes.Count) > 1)
{
index = 1;
do
{
mergedSphere = BoundingSphere.CreateMerged(mergedSphere,
boundingSpheres[index]);
index++;
} while (index < Model.Meshes.Count);
}
return mergedSphere;
}
也。 – Giannis 2011-04-20 18:12:54
當球體用作模型時,邊界球正確放置。問題是像立方體等其他形狀。立方體的底部位於球體的中心。 – Giannis 2011-04-20 19:07:56