XNA调整模型内部的模型

时间:2012-04-21 02:50:00

标签: xna

我创建了一个XNA游戏背景作为模型,但它内部包含更多模型。例如:“地面包含一个球”。现在,我想做的是进入地面并取回球并调整大小。

是否有可能这样做或者我需要单独导入地面和球然后调整大小(我希望这是最后一个选项)?

1 个答案:

答案 0 :(得分:1)

我认为你的意思是你想在模型中缩放特定的ModelMesh。这可以使用Matrix数组来完成,该数组将包含特定于各个网格的变换。像这样:

//In the class for the background, or the game class if there isn't one
Matrix[] specificTransforms;

//Initialize the array however you want, and assign the specific matrix for the ball to its corresponding index

//Loop through the meshes like usual but add this below your code that multiplies the transform matrices:
if (specificTransforms[(put your iterator variable here)] != null)
{
    (put your BasicEffect here).World *= specificTransforms[put your iterator variable here];
}

这会将网格的世界矩阵与您想要应用于球的特定变换相结合。

这不是最好的方法,如果你发布你正在使用的代码,会更容易给你一个例子。除非你这样做,否则无法保证这一点。

相关问题