안녕하세요 저는 XNA 4.0에서 개미에 대해 약간의 RPG를 작성하고 있습니다. LoadModel 클래스를 fbx 모델로드로 만들고 경계 영역을 작성했습니다. 모델 메쉬를 병합하여 만든 모델에 하나의 일반적인 경계 구가 있습니다. 이제 게임에서 내 영역을 나타내는 추가 구형 모델을 만들었습니다. 메쉬 이름이 "BoundingSphere"인지 확인하고 메쉬를 추가 할 때 BoundingSphere를 bs 배열에 추가합니다. 지금 내가 그 학사를 업데이트하는 방법을 지금 해달라고 ... 내 코드 시도 :BoundingSphere 업데이트
private void buildBoundingSphere()
{
BoundingSphere sphere = new BoundingSphere(Vector3.Zero, 0);
List<BoundingSphere> spheres = new List<BoundingSphere>();
foreach (ModelMesh mesh in Model.Meshes)
{
if (mesh.Name.Contains("BoundingSphere"))
{
BoundingSphere transformed = mesh.BoundingSphere.Transform(modelTransforms[mesh.ParentBone.Index])
spheres.Add(transformed);
sphere = BoundingSphere.CreateMerged(sphere, transformed);
}
}
this.boundingSphere = sphere;
this.spheres = spheres.ToArray();
}
을 지금 BoundingSphere 배열이 얻을/세트 :
public BoundingSphere[] spheres
{
get
{
// No need for rotation, as this is a sphere
List<BoundingSphere> spheres = new List<BoundingSphere>();
foreach (ModelMesh mesh in Model.Meshes)
{
Matrix worldTransform = Matrix.CreateScale(Scale)* Matrix.CreateTranslation(Position);
if (mesh.Name.Contains("BoundingSphere")) {
BoundingSphere transformed = mesh.BoundingSphere.Transform(worldTransform);
spheres.Add(transformed);
}
}
return spheres.ToArray();
}
set{}
}
내가 모델의 2 구를 가지고 있고, 모두 그들도 같은 장소에있다. 힌트를 제공해서 감사합니다.