protected override void LoadContent() { if (asset != null) this.model = Game.Content.Load<Model>("Models/"+asset); Matrix[] transforms = new Matrix[this.model.Bones.Count]; this.model.CopyAbsoluteBoneTransformsTo(transforms); BoundingBox = new BoundingBox(); BoundingSphere = new BoundingSphere(); for (int m = 0; m < this.model.Meshes.Count; m++) { ModelMesh mm = this.model.Meshes[m]; BoundingBox partBox = new BoundingBox(); for (int p = 0; p < mm.MeshParts.Count; p++) { ModelMeshPart part = mm.MeshParts[p]; Vector3[] vertices = part.GetVertexElement(VertexElementUsage.Position); partBox = BoundingBox.CreateFromPoints(vertices); } partBox.Min = Vector3.Transform(partBox.Min, transforms[mm.ParentBone.Index]); partBox.Max = Vector3.Transform(partBox.Max, transforms[mm.ParentBone.Index]); BoundingBox = partBox; BoundingSphere = BoundingSphere.CreateMerged(BoundingSphere, mm.BoundingSphere); } base.LoadContent(); }