边界框在错误的位置对象

时间:2014-01-02 12:24:58

标签: c# xna bounding-box

我正在导入.fbx模型(一个简单的长方体),模型本身显示正常(并重复制作墙)但是边界框似乎位于错误的位置。下面是一个屏幕截图:

enter image description here

黄线是灰色长方体的边界框。

地图墙是从地图对象加载的,指定墙应该在哪里

for (int row = 0; row < map.Rows; row++){
    for (int col = 0; col < map.Columns; col++){
        if (map.Get(row, col) == 'w') walls.Add(new Wall(content.Load<Model>("models/wallnew"), new Vector3(col, 0, row)));
    }
}

和一堵墙是:

public class Wall : Entity {
    BoundingBox boundingBox;

    public Wall(Model model, Vector3 position) : base(model){
        this.translation = Matrix.CreateTranslation(position);
        Vector3 from = Vector3.Transform(new Vector3(0f), World);
        Vector3 to = Vector3.Transform(new Vector3(1f), World);
        boundingBox = new BoundingBox(from, to);
    }

    public BoundingBox GetBoundingBox() {
        return boundingBox;
    }

    public override void Draw(bool textured, Matrix view, Matrix proj) {
        foreach (ModelMesh mesh in model.Meshes) {
            foreach (BasicEffect effect in mesh.Effects) {
                effect.World = World * mesh.ParentBone.Transform;
                effect.View = view;
                effect.Projection = proj;
                effect.EnableDefaultLighting();
            }
            mesh.Draw();
        }
    }
}

我不能为我的生活解决为什么边框被添加错误,如果您需要更多信息让我知道!

0 个答案:

没有答案