我不是關於如何設置這個了,我需要在這種情況下,盒子而不是球,因爲我想知道,如果激光在我的3D場景擊中敵艦清楚。這裏是我的球體代碼,我將如何將其更改爲包圍盒。因爲如果我使用球體進行激光處理,那麼即使球體距離實際激光很遠,球體也會很大並撞上一艘船。所有即時通訊問我是如何去設置這種方式的邊界框。邊框碰撞XNA C#
private bool Cannonfire(Model model1, Vector3 world1, Model model2, Vector3 world2)
{
for (int meshIndex1 = 0; meshIndex1 < model1.Meshes.Count; meshIndex1++)
{
BoundingSphere sphere1 = model1.Meshes[meshIndex1].BoundingSphere;
sphere1.Center = world1;
for (int meshIndex2 = 0; meshIndex2 < model2.Meshes.Count; meshIndex2++)
{
BoundingSphere sphere2 = model2.Meshes[meshIndex2].BoundingSphere;
sphere2.Center = world2;
if (sphere1.Intersects(sphere2))
return true;
}
}
return false;
}
那麼我該如何感謝任何幫助。
我想我可以做這個工作謝謝! – QuantumArchi 2013-03-04 16:03:32